diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index b6bb5f44f..b34d024e8 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -227,7 +227,7 @@ public SoundType func_185467_w() { return this.field_149762_H; -@@ -936,6 +951,1218 @@ +@@ -936,6 +951,1255 @@ { } @@ -1400,6 +1400,43 @@ + } + + /** ++ * Use this to change the fog color used when the entity is "inside" a material. ++ * Vec3d is used here as "r/g/b" 0 - 1 values. ++ * ++ * @param world The world. ++ * @param pos The position at the entity viewport. ++ * @param state The state at the entity viewport. ++ * @param entity the entity ++ * @param originalColor The current fog color, You are not expected to use this, Return as the default if applicable. ++ * @return The new fog color. ++ */ ++ @SideOnly (Side.CLIENT) ++ public Vec3d getFogColor(World world, BlockPos pos, IBlockState state, Entity entity, Vec3d originalColor, float partialTicks) ++ { ++ if (state.func_185904_a() == Material.field_151586_h) ++ { ++ float f12 = 0.0F; ++ ++ if (entity instanceof net.minecraft.entity.EntityLivingBase) ++ { ++ net.minecraft.entity.EntityLivingBase ent = (net.minecraft.entity.EntityLivingBase)entity; ++ f12 = (float)net.minecraft.enchantment.EnchantmentHelper.func_185292_c(ent) * 0.2F; ++ ++ if (ent.func_70644_a(net.minecraft.init.MobEffects.field_76427_o)) ++ { ++ f12 = f12 * 0.3F + 0.6F; ++ } ++ } ++ return new Vec3d(0.02F + f12, 0.02F + f12, 0.2F + f12); ++ } ++ else if (state.func_185904_a() == Material.field_151587_i) ++ { ++ return new Vec3d(0.6F, 0.1F, 0.0F); ++ } ++ return originalColor; ++ } ++ ++ /** + * Gets the {@link IBlockState} to place + * @param world The world the block is being placed in + * @param pos The position the block is being placed at @@ -1446,7 +1483,7 @@ public static void func_149671_p() { func_176215_a(0, field_176230_a, (new BlockAir()).func_149663_c("air")); -@@ -1247,14 +2474,7 @@ +@@ -1247,14 +2511,7 @@ } else { diff --git a/patches/minecraft/net/minecraft/block/BlockLiquid.java.patch b/patches/minecraft/net/minecraft/block/BlockLiquid.java.patch new file mode 100644 index 000000000..778caf7c4 --- /dev/null +++ b/patches/minecraft/net/minecraft/block/BlockLiquid.java.patch @@ -0,0 +1,32 @@ +--- ../src-base/minecraft/net/minecraft/block/BlockLiquid.java ++++ ../src-work/minecraft/net/minecraft/block/BlockLiquid.java +@@ -452,4 +452,29 @@ + { + return BlockFaceShape.UNDEFINED; + } ++ ++ @Override ++ @SideOnly (Side.CLIENT) ++ public Vec3d getFogColor(World world, BlockPos pos, IBlockState state, Entity entity, Vec3d originalColor, float partialTicks) ++ { ++ Vec3d viewport = net.minecraft.client.renderer.ActiveRenderInfo.func_178806_a(entity, partialTicks); ++ ++ if (state.func_185904_a().func_76224_d()) ++ { ++ float height = 0.0F; ++ if (state.func_177230_c() instanceof BlockLiquid) ++ { ++ height = func_149801_b(state.func_177229_b(field_176367_b)) - 0.11111111F; ++ } ++ float f1 = (float) (pos.func_177956_o() + 1) - height; ++ if (viewport.field_72448_b > (double)f1) ++ { ++ BlockPos upPos = pos.func_177984_a(); ++ IBlockState upState = world.func_180495_p(upPos); ++ return upState.func_177230_c().getFogColor(world, upPos, upState, entity, originalColor, partialTicks); ++ } ++ } ++ ++ return super.getFogColor(world, pos, state, entity, originalColor, partialTicks); ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch index 874491c6b..d5c87821b 100644 --- a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -167,7 +167,47 @@ float f = this.field_78531_r.field_71441_e.func_72867_j(p_78474_1_); if (f > 0.0F) -@@ -1845,6 +1872,13 @@ +@@ -1749,30 +1776,17 @@ + this.field_175082_R = (float)vec3d3.field_72448_b; + this.field_175081_S = (float)vec3d3.field_72449_c; + } +- else if (iblockstate.func_185904_a() == Material.field_151586_h) ++ else + { +- float f12 = 0.0F; +- +- if (entity instanceof EntityLivingBase) +- { +- f12 = (float)EnchantmentHelper.func_185292_c((EntityLivingBase)entity) * 0.2F; +- +- if (((EntityLivingBase)entity).func_70644_a(MobEffects.field_76427_o)) +- { +- f12 = f12 * 0.3F + 0.6F; +- } +- } +- +- this.field_175080_Q = 0.02F + f12; +- this.field_175082_R = 0.02F + f12; +- this.field_175081_S = 0.2F + f12; ++ //Forge Moved to Block. ++ Vec3d viewport = ActiveRenderInfo.func_178806_a(entity, p_78466_1_); ++ BlockPos viewportPos = new BlockPos(viewport); ++ IBlockState viewportState = this.field_78531_r.field_71441_e.func_180495_p(viewportPos); ++ Vec3d inMaterialColor = viewportState.func_177230_c().getFogColor(this.field_78531_r.field_71441_e, viewportPos, viewportState, entity, new Vec3d(field_175080_Q, field_175082_R, field_175081_S), p_78466_1_); ++ this.field_175080_Q = (float)inMaterialColor.field_72450_a; ++ this.field_175082_R = (float)inMaterialColor.field_72448_b; ++ this.field_175081_S = (float)inMaterialColor.field_72449_c; + } +- else if (iblockstate.func_185904_a() == Material.field_151587_i) +- { +- this.field_175080_Q = 0.6F; +- this.field_175082_R = 0.1F; +- this.field_175081_S = 0.0F; +- } + + float f13 = this.field_78535_ad + (this.field_78539_ae - this.field_78535_ad) * p_78466_1_; + this.field_175080_Q *= f13; +@@ -1845,6 +1859,13 @@ this.field_175081_S = f7; } @@ -181,7 +221,7 @@ GlStateManager.func_179082_a(this.field_175080_Q, this.field_175082_R, this.field_175081_S, 0.0F); } -@@ -1855,7 +1889,9 @@ +@@ -1855,7 +1876,9 @@ GlStateManager.func_187432_a(0.0F, -1.0F, 0.0F); GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F); IBlockState iblockstate = ActiveRenderInfo.func_186703_a(this.field_78531_r.field_71441_e, entity, p_78468_2_); @@ -192,7 +232,7 @@ if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).func_70644_a(MobEffects.field_76440_q)) { float f1 = 5.0F; -@@ -1940,6 +1976,7 @@ +@@ -1940,6 +1963,7 @@ GlStateManager.func_179102_b(f * 0.05F); GlStateManager.func_179153_c(Math.min(f, 192.0F) * 0.5F); } diff --git a/src/test/java/net/minecraftforge/debug/FogColorInsideMaterialTest.java b/src/test/java/net/minecraftforge/debug/FogColorInsideMaterialTest.java new file mode 100644 index 000000000..caa4e3af3 --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/FogColorInsideMaterialTest.java @@ -0,0 +1,76 @@ +package net.minecraftforge.debug; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.client.renderer.block.statemap.StateMapperBase; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; + +@EventBusSubscriber +@Mod (modid = FogColorInsideMaterialTest.MOD_ID, name = "FogColor inside material debug.", version = "1.0", acceptableRemoteVersions = "*") +public class FogColorInsideMaterialTest +{ + + public static final String MOD_ID = "fogcolorinsidematerialtest"; + + @ObjectHolder ("test_fluid") + public static final Block FLUID_BLOCK = null; + @ObjectHolder ("test_fluid") + public static final Item FLUID_ITEM = null; + + @SubscribeEvent + public static void registerBlocks(RegistryEvent.Register event) + { + Block fluid = new BlockFluidClassic(FluidRegistry.WATER, Material.WATER) + { + @Override + public Vec3d getFogColor(World world, BlockPos pos, IBlockState state, Entity entity, Vec3d originalColor, float partialTicks) + { + return new Vec3d(0.6F, 0.1F, 0.0F); + } + }; + fluid.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); + fluid.setUnlocalizedName(MOD_ID + ":" + "test_fluid"); + fluid.setRegistryName("test_fluid"); + event.getRegistry().register(fluid); + } + + @SubscribeEvent + public static void registerItems(RegistryEvent.Register event) + { + event.getRegistry().register(new ItemBlock(FLUID_BLOCK).setRegistryName(FLUID_BLOCK.getRegistryName())); + } + + @SubscribeEvent + public static void registerModels(ModelRegistryEvent event) + { + ModelResourceLocation fluidLocation = new ModelResourceLocation(MOD_ID.toLowerCase() + ":test_fluid", "fluid"); + ModelLoader.registerItemVariants(FLUID_ITEM); + ModelLoader.setCustomMeshDefinition(FLUID_ITEM, stack -> fluidLocation); + ModelLoader.setCustomStateMapper(FLUID_BLOCK, new StateMapperBase() + { + @Override + protected ModelResourceLocation getModelResourceLocation(IBlockState state) + { + return fluidLocation; + } + }); + } + +} diff --git a/src/test/resources/assets/fogcolorinsidematerialtest/blockstates/test_fluid.json b/src/test/resources/assets/fogcolorinsidematerialtest/blockstates/test_fluid.json new file mode 100644 index 000000000..c9f4933a0 --- /dev/null +++ b/src/test/resources/assets/fogcolorinsidematerialtest/blockstates/test_fluid.json @@ -0,0 +1,15 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "forge:fluid" + }, + "variants": { + "fluid": [ + { + "custom": { + "fluid": "test_fluid" + } + } + ] + } +}