diff --git a/patches/minecraft/net/minecraft/block/Block.java.patch b/patches/minecraft/net/minecraft/block/Block.java.patch index bfeadbdd96..8aee079695 100644 --- a/patches/minecraft/net/minecraft/block/Block.java.patch +++ b/patches/minecraft/net/minecraft/block/Block.java.patch @@ -221,7 +221,7 @@ public SoundType func_185467_w() { return this.field_149762_H; -@@ -934,6 +952,1314 @@ +@@ -934,6 +952,1331 @@ { } @@ -887,6 +887,23 @@ + } + + /** ++ * Allows a block to override the standard vanilla running particles. ++ * This is called from {@link Entity#spawnRunningParticles} and is called both, ++ * Client and server side, it's up to the implementor to client check / server check. ++ * By default vanilla spawns particles only on the client and the server methods no-op. ++ * ++ * @param state The BlockState the entity is running on. ++ * @param world The world. ++ * @param pos The position at the entities feet. ++ * @param entity The entity running on the block. ++ * @return True to prevent vanilla running particles from spawning. ++ */ ++ public boolean addRunningEffects(IBlockState state, World world, BlockPos pos, Entity entity) ++ { ++ return false; ++ } ++ ++ /** + * Spawn a digging particle effect in the world, this is a wrapper + * around EffectRenderer.addBlockHitEffects to allow the block more + * control over the particles. Useful when you have entirely different @@ -1536,7 +1553,7 @@ public static void func_149671_p() { func_176215_a(0, field_176230_a, (new BlockAir()).func_149663_c("air")); -@@ -1230,31 +2556,6 @@ +@@ -1230,31 +2573,6 @@ block15.field_149783_u = flag; } } diff --git a/patches/minecraft/net/minecraft/entity/Entity.java.patch b/patches/minecraft/net/minecraft/entity/Entity.java.patch index 1ee1d83913..5b336dcdbb 100644 --- a/patches/minecraft/net/minecraft/entity/Entity.java.patch +++ b/patches/minecraft/net/minecraft/entity/Entity.java.patch @@ -55,7 +55,15 @@ if (this.field_70170_p.func_180495_p(p_180429_1_.func_177984_a()).func_177230_c() == Blocks.field_150431_aC) { -@@ -1277,12 +1289,12 @@ +@@ -1259,6 +1271,7 @@ + BlockPos blockpos = new BlockPos(i, j, k); + IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); + ++ if(!iblockstate.func_177230_c().addRunningEffects(iblockstate, field_70170_p, blockpos, this)) + if (iblockstate.func_185901_i() != EnumBlockRenderType.INVISIBLE) + { + this.field_70170_p.func_175688_a(EnumParticleTypes.BLOCK_CRACK, this.field_70165_t + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.field_70130_N, this.func_174813_aQ().field_72338_b + 0.1D, this.field_70161_v + ((double)this.field_70146_Z.nextFloat() - 0.5D) * (double)this.field_70130_N, -this.field_70159_w * 4.0D, 1.5D, -this.field_70179_y * 4.0D, Block.func_176210_f(iblockstate)); +@@ -1277,12 +1290,12 @@ BlockPos blockpos = new BlockPos(this.field_70165_t, d0, this.field_70161_v); IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos); @@ -72,7 +80,7 @@ } else { -@@ -1707,6 +1719,7 @@ +@@ -1707,6 +1720,7 @@ { p_189511_1_.func_74757_a("Glowing", this.field_184238_ar); } @@ -80,7 +88,7 @@ if (!this.field_184236_aF.isEmpty()) { -@@ -1720,6 +1733,9 @@ +@@ -1720,6 +1734,9 @@ p_189511_1_.func_74782_a("Tags", nbttaglist); } @@ -90,7 +98,7 @@ this.func_70014_b(p_189511_1_); if (this.func_184207_aI()) -@@ -1826,7 +1842,11 @@ +@@ -1826,7 +1843,11 @@ this.func_174810_b(p_70020_1_.func_74767_n("Silent")); this.func_189654_d(p_70020_1_.func_74767_n("NoGravity")); this.func_184195_f(p_70020_1_.func_74767_n("Glowing")); @@ -102,7 +110,7 @@ if (p_70020_1_.func_150297_b("Tags", 9)) { this.field_184236_aF.clear(); -@@ -1918,7 +1938,10 @@ +@@ -1918,7 +1939,10 @@ { EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u + (double)p_70099_2_, this.field_70161_v, p_70099_1_); entityitem.func_174869_p(); @@ -114,7 +122,7 @@ return entityitem; } } -@@ -1985,6 +2008,7 @@ +@@ -1985,6 +2009,7 @@ this.field_70159_w = 0.0D; this.field_70181_x = 0.0D; this.field_70179_y = 0.0D; @@ -122,7 +130,7 @@ this.func_70071_h_(); if (this.func_184218_aH()) -@@ -2032,6 +2056,7 @@ +@@ -2032,6 +2057,7 @@ } } @@ -130,7 +138,7 @@ if (p_184205_2_ || this.func_184228_n(p_184205_1_) && p_184205_1_.func_184219_q(this)) { if (this.func_184218_aH()) -@@ -2067,6 +2092,7 @@ +@@ -2067,6 +2093,7 @@ if (this.field_184239_as != null) { Entity entity = this.field_184239_as; @@ -138,7 +146,7 @@ this.field_184239_as = null; entity.func_184225_p(this); } -@@ -2511,6 +2537,7 @@ +@@ -2511,6 +2538,7 @@ { if (!this.field_70170_p.field_72995_K && !this.field_70128_L) { @@ -146,7 +154,7 @@ this.field_70170_p.field_72984_F.func_76320_a("changeDimension"); MinecraftServer minecraftserver = this.func_184102_h(); int i = this.field_71093_bK; -@@ -2535,16 +2562,17 @@ +@@ -2535,16 +2563,17 @@ } else { @@ -168,7 +176,7 @@ { d0 = MathHelper.func_151237_a(d0 * 8.0D, worldserver1.func_175723_af().func_177726_b() + 16.0D, worldserver1.func_175723_af().func_177728_d() - 16.0D); d1 = MathHelper.func_151237_a(d1 * 8.0D, worldserver1.func_175723_af().func_177736_c() + 16.0D, worldserver1.func_175723_af().func_177733_e() - 16.0D); -@@ -2604,7 +2632,7 @@ +@@ -2604,7 +2633,7 @@ public float func_180428_a(Explosion p_180428_1_, World p_180428_2_, BlockPos p_180428_3_, IBlockState p_180428_4_) { diff --git a/src/test/java/net/minecraftforge/debug/BlockParticleEffectsTest.java b/src/test/java/net/minecraftforge/debug/BlockParticleEffectsTest.java new file mode 100644 index 0000000000..f2cf74c8ea --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/BlockParticleEffectsTest.java @@ -0,0 +1,121 @@ +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.particle.ParticleManager; +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.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.client.event.ModelRegistryEvent; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.event.RegistryEvent; +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; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import static net.minecraftforge.debug.BlockParticleEffectsTest.MOD_ID; +import static net.minecraftforge.debug.BlockParticleEffectsTest.MOD_NAME; + +@EventBusSubscriber +@Mod (modid = MOD_ID, name = MOD_NAME, version = "1.0", acceptableRemoteVersions = "*") +public class BlockParticleEffectsTest +{ + + public static final String MOD_ID = "blockparticleeffectstest"; + public static final String MOD_NAME = "Block particle effects test"; + + @ObjectHolder ("particle_block") + public static final Block PARTICLE_BLOCK = null; + + @ObjectHolder ("particle_block") + public static final Item PARTICLE_ITEM = null; + + private static final ResourceLocation particleBlockLocation = new ResourceLocation(MOD_ID, "particle_block"); + + @SubscribeEvent + public static void registerBlocks(RegistryEvent.Register event) + { + Block block = new Block(Material.ROCK) + { + @Override + public boolean addLandingEffects(IBlockState state, WorldServer world, BlockPos blockPosition, IBlockState iblockstate, EntityLivingBase entity, int numberOfParticles) + { + world.spawnParticle(EnumParticleTypes.REDSTONE, entity.posX, entity.posY, entity.posZ, numberOfParticles, 0, 0, 0, 0.1D); + return true; + } + + @Override + public boolean addRunningEffects(IBlockState state, World world, BlockPos pos, Entity entity) + { + world.spawnParticle(EnumParticleTypes.REDSTONE, entity.posX, entity.posY, entity.posZ, 1, 0, 0); + return true; + } + + @Override + @SideOnly (Side.CLIENT) + public boolean addHitEffects(IBlockState state, World world, RayTraceResult target, ParticleManager manager) + { + world.spawnParticle(EnumParticleTypes.REDSTONE, target.hitVec.x, target.hitVec.y, target.hitVec.z, 0, 1, 0); + return true; + } + + @Override + @SideOnly (Side.CLIENT) + public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) + { + world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0, 1); + return true; + } + }; + event.getRegistry().register(block.setCreativeTab(CreativeTabs.BUILDING_BLOCKS).setHardness(20).setRegistryName(particleBlockLocation)); + } + + @SubscribeEvent + public static void registerItems(RegistryEvent.Register event) + { + Item item = new ItemBlock(PARTICLE_BLOCK) { + @Override + public String getItemStackDisplayName(ItemStack stack) + { + return "Particle Tests Block"; + } + }; + event.getRegistry().register(item.setRegistryName(particleBlockLocation)); + } + + @EventBusSubscriber (value = Side.CLIENT, modid = MOD_ID) + public static class ClientEventHandler + { + + @SubscribeEvent + public static void registerModels(ModelRegistryEvent event) + { + ModelResourceLocation normalLoc = new ModelResourceLocation("minecraft:stone", "normal"); + ModelResourceLocation invLoc = new ModelResourceLocation("minecraft:stone", "normal"); + ModelLoader.setCustomStateMapper(PARTICLE_BLOCK, new StateMapperBase() + { + @Override + protected ModelResourceLocation getModelResourceLocation(IBlockState state) + { + return normalLoc; + } + }); + ModelLoader.setCustomModelResourceLocation(PARTICLE_ITEM, 0, invLoc); + } + } +}