From 4344bdf61854eb8f5c11cbbf568f87d367514dd7 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Fri, 17 Jul 2020 23:09:30 -0500 Subject: [PATCH] Add visual and auditory feedback for tigerseye --- .../subtile/functional/SubTileTigerseye.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java index 0a0161b07..2168b24c8 100644 --- a/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java +++ b/src/main/java/vazkii/botania/common/block/subtile/functional/SubTileTigerseye.java @@ -8,15 +8,18 @@ */ package vazkii.botania.common.block.subtile.functional; +import net.minecraft.entity.Entity; import net.minecraft.entity.ai.goal.AvoidEntityGoal; import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal; import net.minecraft.entity.ai.goal.PrioritizedGoal; import net.minecraft.entity.monster.CreeperEntity; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.SoundEvents; import net.minecraft.util.math.AxisAlignedBB; import vazkii.botania.api.subtile.RadiusDescriptor; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; +import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.block.ModSubtiles; import java.util.ArrayList; @@ -25,6 +28,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower { private static final int RANGE = 10; private static final int RANGE_Y = 4; private static final int COST = 70; + private static final int SUCCESS_EVENT = 0; public SubTileTigerseye() { super(ModSubtiles.TIGERSEYE); @@ -62,6 +66,8 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower { } if (did) { + entity.playSound(SoundEvents.ENTITY_CREEPER_HURT, 1.0F, (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F + 1.0F); + world.addBlockEvent(getPos(), getBlockState().getBlock(), SUCCESS_EVENT, entity.getEntityId()); addMana(-COST); sync(); } @@ -69,6 +75,30 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower { } } + @Override + public boolean receiveClientEvent(int id, int payload) { + if (id == SUCCESS_EVENT) { + if (world.isRemote) { + Entity e = world.getEntityByID(payload); + if (e != null) { + float r = (getColor() >> 16 & 0xFF) / 255F; + float g = (getColor() >> 8 & 0xFF) / 255F; + float b = (getColor() & 0xFF) / 255F; + SparkleParticleData data = SparkleParticleData.sparkle(world.rand.nextFloat(), r, g, b, 10); + + for (int i = 0; i < 50; i++) { + double x = e.getPosX() + world.rand.nextDouble() - 0.5; + double y = e.getPosY() + e.getHeight() * world.rand.nextDouble(); + double z = e.getPosZ() + world.rand.nextDouble() - 0.5; + world.addParticle(data, x, y, z, 0, 0, 0); + } + } + } + return true; + } + return super.receiveClientEvent(id, payload); + } + @Override public RadiusDescriptor getRadius() { return new RadiusDescriptor.Square(getEffectivePos(), RANGE);