diff --git a/Xplat/src/main/java/vazkii/botania/common/block/IncensePlateBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/IncensePlateBlock.java index 4b9c262ce9..1f97615d64 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/IncensePlateBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/IncensePlateBlock.java @@ -30,6 +30,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -66,6 +67,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player if (plateStack.isEmpty() && plate.acceptsItem(stack)) { plate.getItemHandler().setItem(0, stack.copy()); + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); stack.shrink(1); did = true; } else if (!plateStack.isEmpty() && !plate.burning) { @@ -75,6 +77,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player } else { player.getInventory().placeItemBackInInventory(plateStack); plate.getItemHandler().setItem(0, ItemStack.EMPTY); + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); } did = true; } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/LuminizerBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/LuminizerBlock.java index bab9310a88..2c4ecc676c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/LuminizerBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/LuminizerBlock.java @@ -28,6 +28,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -73,6 +74,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player if (!world.isClientSide) { stack.shrink(1); relay.setNoParticle(); + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(relay); } return InteractionResult.sidedSuccess(world.isClientSide()); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/PetalApothecaryBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/PetalApothecaryBlock.java index 77632f0187..22db9a3896 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/PetalApothecaryBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/PetalApothecaryBlock.java @@ -30,6 +30,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.BlockHitResult; @@ -139,6 +140,7 @@ public void handlePrecipitation(BlockState state, Level world, BlockPos pos, Bio if (world.random.nextInt(20) == 1) { if (state.getValue(FLUID) == State.EMPTY) { world.setBlockAndUpdate(pos, state.setValue(FLUID, State.WATER)); + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); } } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java index 794836735c..8206d4ccc9 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java @@ -15,6 +15,7 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import vazkii.botania.common.item.CacophoniumItem; @@ -32,6 +33,7 @@ public void annoyDirewolf() { if (!level.isClientSide) { float noteColor = level.random.nextInt(25) / 24.0F; ((ServerLevel) level).sendParticles(ParticleTypes.NOTE, worldPosition.getX() + 0.5, worldPosition.getY() + 1.2, worldPosition.getZ() + 0.5, 0, noteColor, 0, 0, 1); + level.gameEvent(null, GameEvent.NOTE_BLOCK_PLAY, getBlockPos()); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java index 14d0bab90e..83da0b08f9 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java @@ -23,6 +23,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import org.jetbrains.annotations.NotNull; @@ -95,6 +96,7 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st } else { self.getItemHandler().setItem(0, ItemStack.EMPTY); self.burning = false; + level.gameEvent(null, GameEvent.BLOCK_DEACTIVATE, worldPosition); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(self); } } else { @@ -144,6 +146,7 @@ public void ignite() { Brew brew = ((IncenseStickItem) BotaniaItems.incenseStick).getBrew(stack); timeLeft = brew.getPotionEffects(stack).get(0).getDuration() * IncenseStickItem.TIME_MULTIPLIER; level.playSound(null, getBlockPos(), BotaniaSounds.incensePlateIgnite, SoundSource.BLOCKS, 1F, 1F); + level.gameEvent(null, GameEvent.BLOCK_ACTIVATE, getBlockPos()); } @Override diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java index 9e9de9e0fa..3cd1963425 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java @@ -34,6 +34,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -307,10 +308,13 @@ public void tick() { return; } - boolean isItem = getVehicle() instanceof ItemEntity; + boolean isItem = getPassengers().stream().allMatch(ItemEntity.class::isInstance); if (!isItem && tickCount % 30 == 0) { playSound(BotaniaSounds.lightRelay, 0.25F, (float) Math.random() * 0.3F + 0.7F); } + if (!isItem && tickCount % 10 == 0) { + gameEvent(GameEvent.ELYTRA_GLIDE); + } BlockPos pos = blockPosition(); BlockPos exitPos = getExitPos(); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java index db39237222..9cb964dd61 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java @@ -28,6 +28,7 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.AABB; @@ -114,8 +115,9 @@ public boolean collideEntityItem(ItemEntity item) { XplatAbstractions.INSTANCE.itemFlagsComponent(outputItem).apothecarySpawned = true; level.addFreshEntity(outputItem); - setFluid(State.EMPTY); + setFluid(State.EMPTY, false); + level.gameEvent(null, GameEvent.BLOCK_ACTIVATE, getBlockPos()); level.blockEvent(getBlockPos(), getBlockState().getBlock(), CRAFT_EFFECT_EVENT, 0); return true; } @@ -136,6 +138,7 @@ public boolean collideEntityItem(ItemEntity item) { getItemHandler().setItem(i, stack.split(1)); EntityHelper.syncItem(item); level.playSound(null, worldPosition, SoundEvents.GENERIC_SPLASH, SoundSource.BLOCKS, 0.1F, 10F); + level.gameEvent(null, GameEvent.BLOCK_CHANGE, getBlockPos()); clearLastRecipe(); return true; } @@ -177,13 +180,16 @@ public InteractionResult trySetLastRecipe(Player player) { // lastRecipe is not synced. If we're calling this method we already checked that // the apothecary has water and no items, so just optimistically assume // success on the client. - boolean success = player.level().isClientSide - || InventoryHelper.tryToSetLastRecipe(player, getItemHandler(), lastRecipe, SoundEvents.GENERIC_SPLASH); + if (player.level().isClientSide()) { + return InteractionResult.sidedSuccess(true); + } + boolean success = InventoryHelper.tryToSetLastRecipe(player, getItemHandler(), lastRecipe, SoundEvents.GENERIC_SPLASH); if (success) { + level.gameEvent(null, GameEvent.BLOCK_CHANGE, getBlockPos()); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); } return success - ? InteractionResult.sidedSuccess(player.level().isClientSide()) + ? InteractionResult.sidedSuccess(false) : InteractionResult.PASS; } @@ -290,6 +296,13 @@ public int getMaxStackSize() { @Override public void setFluid(State fluid) { + setFluid(fluid, true); + } + + public void setFluid(State fluid, boolean withVibration) { + if (withVibration) { + level.gameEvent(null, fluid == State.EMPTY ? GameEvent.FLUID_PICKUP : GameEvent.FLUID_PLACE, getBlockPos()); + } level.setBlockAndUpdate(getBlockPos(), getBlockState().setValue(PetalApothecaryBlock.FLUID, fluid)); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java index a88c21620e..737b286019 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java @@ -26,6 +26,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -115,6 +116,7 @@ public boolean addItem(@Nullable Player player, ItemStack stack, @Nullable Inter } if (did) { + level.gameEvent(null, GameEvent.BLOCK_CHANGE, getBlockPos()); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); } @@ -238,13 +240,16 @@ private void saveLastRecipe() { public InteractionResult trySetLastRecipe(Player player) { // lastRecipe is not synced. If we're calling this method we already checked that // the altar has no items, so just optimistically assume success on the client. - boolean success = player.level().isClientSide - || InventoryHelper.tryToSetLastRecipe(player, getItemHandler(), lastRecipe, null); + if (player.level().isClientSide()) { + return InteractionResult.sidedSuccess(true); + } + boolean success = InventoryHelper.tryToSetLastRecipe(player, getItemHandler(), lastRecipe, null); if (success) { + level.gameEvent(null, GameEvent.BLOCK_CHANGE, getBlockPos()); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this); } return success - ? InteractionResult.sidedSuccess(player.level().isClientSide()) + ? InteractionResult.sidedSuccess(false) : InteractionResult.PASS; } @@ -283,6 +288,7 @@ public boolean onUsedByWand(@Nullable Player player, ItemStack wand, Direction s XplatAbstractions.INSTANCE.itemFlagsComponent(outputItem).runicAltarSpawned = true; level.addFreshEntity(outputItem); currentRecipe = null; + level.gameEvent(null, GameEvent.BLOCK_ACTIVATE, getBlockPos()); level.blockEvent(getBlockPos(), BotaniaBlocks.runeAltar, SET_COOLDOWN_EVENT, 60); level.blockEvent(getBlockPos(), BotaniaBlocks.runeAltar, CRAFT_EFFECT_EVENT, 0); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java index ada6e04510..1c09973f3c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java @@ -20,6 +20,7 @@ import net.minecraft.world.level.block.entity.FurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; @@ -65,6 +66,9 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st if (self.movePos < max && self.active && self.moving >= 0F) { if (self.moving == 0F) { + if (!level.isClientSide()) { + level.gameEvent(null, GameEvent.BLOCK_ACTIVATE, worldPosition); + } level.playSound(null, worldPosition, BotaniaSounds.bellows, SoundSource.BLOCKS, 1F, 1F); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java index afac47db11..a19035dbf2 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java @@ -25,6 +25,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -197,6 +198,7 @@ public void craftingEffect(boolean playSound) { soundTicks = 6; } + level.gameEvent(null, GameEvent.BLOCK_ACTIVATE, getBlockPos()); level.blockEvent(getBlockPos(), getBlockState().getBlock(), CRAFT_EFFECT_EVENT, 0); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java index d4923b72d2..77361612c7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java @@ -15,6 +15,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.Nullable; @@ -98,6 +99,7 @@ public void tickFlower() { if (BotaniaConfig.common().blockBreakParticles()) { getLevel().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, coords, Block.getId(recipe.getOutputState())); } + getLevel().gameEvent(null, GameEvent.BLOCK_CHANGE, coords); getLevel().blockEvent(getBlockPos(), getBlockState().getBlock(), RECIPE_COMPLETE_EVENT, positionAt); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/ClayconiaBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/ClayconiaBlockEntity.java index 802394b1ee..697e8617d8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/ClayconiaBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/ClayconiaBlockEntity.java @@ -17,6 +17,7 @@ import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import vazkii.botania.api.block_entity.FunctionalFlowerBlockEntity; import vazkii.botania.api.block_entity.RadiusDescriptor; @@ -55,6 +56,7 @@ public void tickFlower() { if (BotaniaConfig.common().blockBreakParticles()) { getLevel().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, coords, stateId); } + getLevel().gameEvent(null, GameEvent.BLOCK_DESTROY, coords); ItemEntity item = new ItemEntity(getLevel(), coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5, new ItemStack(Items.CLAY_BALL)); getLevel().addFreshEntity(item); addMana(-COST); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/JadedAmaranthusBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/JadedAmaranthusBlockEntity.java index aa8abbfe5b..5b40f69734 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/JadedAmaranthusBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/JadedAmaranthusBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import vazkii.botania.api.block_entity.FunctionalFlowerBlockEntity; import vazkii.botania.api.block_entity.RadiusDescriptor; @@ -54,6 +55,7 @@ public void tickFlower() { getLevel().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, up, Block.getId(flower)); } getLevel().setBlockAndUpdate(up, flower); + getLevel().gameEvent(null, GameEvent.BLOCK_PLACE, up); addMana(-COST); sync(); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java index 7dd789142c..59d7e43968 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java @@ -18,6 +18,7 @@ import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; @@ -96,6 +97,7 @@ private void trySetRecipe(BlockPos coords, @Nullable OrechidRecipe recipe) { } playSound(coords); addMana(-getCost()); + getLevel().gameEvent(null, GameEvent.BLOCK_CHANGE, coords); var serverLevel = (ServerLevel) this.level; var server = serverLevel.getServer(); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java index 5a5c465049..b5e5d386f7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java @@ -17,6 +17,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import vazkii.botania.api.block_entity.GeneratingFlowerBlockEntity; @@ -44,7 +45,8 @@ public EndoflameBlockEntity(BlockPos pos, BlockState state) { public void tickFlower() { super.tickFlower(); - if (burnTime > 0) { + boolean wasBurning = burnTime > 0; + if (wasBurning) { burnTime--; } @@ -76,6 +78,7 @@ public void tickFlower() { EntityHelper.shrinkItem(item); getLevel().playSound(null, getEffectivePos(), BotaniaSounds.endoflame, SoundSource.BLOCKS, 1F, 1F); getLevel().blockEvent(getBlockPos(), getBlockState().getBlock(), START_BURN_EVENT, item.getId()); + getLevel().gameEvent(null, GameEvent.BLOCK_ACTIVATE, getBlockPos()); sync(); return; @@ -83,6 +86,9 @@ public void tickFlower() { } } } + if (wasBurning) { + getLevel().gameEvent(null, GameEvent.BLOCK_DEACTIVATE, getBlockPos()); + } } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java index e39cb02f22..8b10575a1f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java @@ -17,6 +17,7 @@ import net.minecraft.world.level.block.BucketPickup; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.FluidState; @@ -92,11 +93,13 @@ public void tickFlower() { } else { getLevel().setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); } + getLevel().gameEvent(null, GameEvent.FLUID_PICKUP, pos); } } if (cooldown == 0) { burnTime += startBurnTime; + getLevel().gameEvent(null, GameEvent.BLOCK_ACTIVATE, getBlockPos()); } else { cooldown = getCooldownTime(false); } @@ -115,6 +118,7 @@ public void tickFlower() { burnTime--; if (burnTime == 0) { cooldown = getCooldownTime(true); + getLevel().gameEvent(null, GameEvent.BLOCK_DEACTIVATE, getBlockPos()); setChanged(); sync(); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java index 61b2e63dd9..79d35489c7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java @@ -20,6 +20,7 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -113,6 +114,7 @@ public void tickFlower() { float burpPitch = (float) Math.pow(2.0, (streakLength == 0 ? -lastFoodCount : streakLength) / 12.0); //Usage of vanilla sound event: Subtitle is just "Burp", at least in English, and not specific to players. getLevel().playSound(null, getEffectivePos(), SoundEvents.PLAYER_BURP, SoundSource.BLOCKS, 1F, burpPitch); + getLevel().gameEvent(null, GameEvent.BLOCK_DEACTIVATE, getEffectivePos()); sync(); } else if (cooldown % munchInterval == 0) { //Usage of vanilla sound event: Subtitle is "Eating", generic sounds are meant to be reused. @@ -138,6 +140,8 @@ public void tickFlower() { cooldown = getCooldown(val); //Usage of vanilla sound event: Subtitle is "Eating", generic sounds are meant to be reused. item.playSound(SoundEvents.GENERIC_EAT, 0.2F, 0.6F); + getLevel().gameEvent(null, GameEvent.EAT, item.position()); + getLevel().gameEvent(null, GameEvent.BLOCK_ACTIVATE, getEffectivePos()); sync(); ((ServerLevel) getLevel()).sendParticles(new ItemParticleOption(ParticleTypes.ITEM, stack), item.getX(), item.getY(), item.getZ(), 20, 0.1D, 0.1D, 0.1D, 0.05D); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/KekimurusBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/KekimurusBlockEntity.java index 58bbbc6a16..3bcf32d724 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/KekimurusBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/KekimurusBlockEntity.java @@ -15,6 +15,7 @@ import net.minecraft.world.level.block.CakeBlock; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import vazkii.botania.api.block_entity.GeneratingFlowerBlockEntity; import vazkii.botania.api.block_entity.RadiusDescriptor; @@ -53,6 +54,7 @@ public void tickFlower() { } getLevel().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(state)); + getLevel().gameEvent(null, GameEvent.EAT, getEffectivePos()); //Usage of vanilla sound event: Subtitle is "Eating", generic sounds are meant to be reused. getLevel().playSound(null, getEffectivePos(), SoundEvents.GENERIC_EAT, SoundSource.BLOCKS, 1F, 0.5F + (float) Math.random() * 0.5F); addMana(mana); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java index dbfb47dbb9..4dd792188c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import vazkii.botania.api.block_entity.GeneratingFlowerBlockEntity; import vazkii.botania.api.block_entity.RadiusDescriptor; @@ -96,6 +97,7 @@ public void tickFlower() { if (BotaniaConfig.common().blockBreakParticles()) { getLevel().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, breakCoords, Block.getId(state)); } + getLevel().gameEvent(null, GameEvent.BLOCK_DESTROY, breakCoords); addMana(manaPerLeaf); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ShulkMeNotBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ShulkMeNotBlockEntity.java index 202e15ec27..e3bc56c487 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ShulkMeNotBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ShulkMeNotBlockEntity.java @@ -19,6 +19,7 @@ import net.minecraft.world.entity.monster.Shulker; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -66,6 +67,7 @@ public void tickFlower() { particles(world, pos, target); particles(world, pos, shulker); + world.gameEvent(null, GameEvent.BLOCK_ACTIVATE, pos); addMana(generate); sync(); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java index 220e8daad0..11edc501da 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java @@ -26,6 +26,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; @@ -117,6 +118,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player prism.getItemHandler().setItem(0, toInsert); world.playSound(player, pos, BotaniaSounds.prismAddLens, SoundSource.BLOCKS, 1F, 1F); + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); return InteractionResult.sidedSuccess(world.isClientSide()); } if (!lens.isEmpty() && (mainHandEmpty || lensIsSame)) { @@ -124,7 +126,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player prism.getItemHandler().setItem(0, ItemStack.EMPTY); world.playSound(player, pos, BotaniaSounds.prismRemoveLens, SoundSource.BLOCKS, 1F, 1F); - + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); return InteractionResult.sidedSuccess(world.isClientSide()); } return InteractionResult.PASS; diff --git a/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java b/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java index e06fbff095..ac8209bacc 100644 --- a/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java +++ b/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java @@ -22,6 +22,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.HopperBlockEntity; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -107,6 +108,7 @@ public static void withdrawFromInventory(SimpleInventoryBlockEntity inv, Player ItemStack copy = stackAt.copy(); player.getInventory().placeItemBackInInventory(copy); inv.getItemHandler().setItem(i, ItemStack.EMPTY); + inv.getLevel().gameEvent(null, GameEvent.BLOCK_CHANGE, inv.getBlockPos()); break; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/CacophoniumItem.java b/Xplat/src/main/java/vazkii/botania/common/item/CacophoniumItem.java index 14c224c60f..66051509a8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/CacophoniumItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/CacophoniumItem.java @@ -32,6 +32,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.NoteBlock; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -130,6 +131,7 @@ public InteractionResultHolder use(Level world, Player player, @NotNu public void onUseTick(Level world, @NotNull LivingEntity living, @NotNull ItemStack stack, int count) { if (!world.isClientSide && count % (isDOIT(stack) ? 20 : 6) == 0) { playSound(living.level(), stack, living.getX(), living.getY(), living.getZ(), living.getSoundSource(), 0.9F); + living.gameEvent(GameEvent.INSTRUMENT_PLAY); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java b/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java index 630243e2a9..2bd8e880d3 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/HornItem.java @@ -23,6 +23,7 @@ import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,6 +65,7 @@ public InteractionResultHolder use(Level world, Player player, @NotNu public void onUseTick(Level world, @NotNull LivingEntity living, @NotNull ItemStack stack, int time) { if (!world.isClientSide) { if (time != getUseDuration(stack) && time % 5 == 0) { + living.gameEvent(GameEvent.INSTRUMENT_PLAY); breakGrass(world, stack, living.blockPosition(), living); } world.playSound(null, living.getX(), living.getY(), living.getZ(), BotaniaSounds.hornDoot, SoundSource.BLOCKS, 1F, 1F); diff --git a/Xplat/src/main/java/vazkii/botania/common/item/LaputaShardItem.java b/Xplat/src/main/java/vazkii/botania/common/item/LaputaShardItem.java index 44dc60f5f5..1c07d96b4f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/LaputaShardItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/LaputaShardItem.java @@ -32,6 +32,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.HitResult; @@ -99,6 +100,7 @@ public InteractionResult useOn(UseOnContext ctx) { BlockPos pos = ctx.getClickedPos(); if (pos.getY() < world.getMaxBuildHeight() - BASE_OFFSET && !world.dimensionType().hasCeiling()) { if (!world.isClientSide) { + world.gameEvent(ctx.getPlayer(), GameEvent.ENTITY_PLACE, pos); world.playSound(null, pos, BotaniaSounds.laputaStart, SoundSource.BLOCKS, 1.0F + world.random.nextFloat(), world.random.nextFloat() * 0.7F + 1.3F); ItemStack stack = ctx.getItemInHand(); spawnFirstBurst(world, pos, stack); @@ -196,6 +198,7 @@ private void spawnNextBurst(Level world, BlockPos pos, ItemStack shard, boolean } world.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos_, Block.getId(state)); + world.gameEvent(null, GameEvent.BLOCK_DESTROY, pos_); ItemStack copyLens = new ItemStack(this); copyLens.getOrCreateTag().putInt(TAG_LEVEL, getShardLevel(shard)); @@ -315,6 +318,7 @@ public void updateBurst(ManaBurst burst, ItemStack stack) { } entity.level().setBlockAndUpdate(pos, placeState); entity.level().levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(placeState)); + entity.level().gameEvent(null, GameEvent.BLOCK_PLACE, pos); if (tile != null) { entity.level().setBlockEntity(tile); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/OvergrowthSeedItem.java b/Xplat/src/main/java/vazkii/botania/common/item/OvergrowthSeedItem.java index 4faaaf6b3f..0a284b227b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/OvergrowthSeedItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/OvergrowthSeedItem.java @@ -17,6 +17,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; @@ -38,6 +39,7 @@ public InteractionResult useOn(UseOnContext ctx) { if (state.is(Blocks.GRASS_BLOCK)) { if (!world.isClientSide) { world.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, pos, Block.getId(state)); + world.gameEvent(null, GameEvent.BLOCK_CHANGE, pos); world.setBlockAndUpdate(pos, BotaniaBlocks.enchantedSoil.defaultBlockState()); ctx.getItemInHand().shrink(1); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/WorldSeedItem.java b/Xplat/src/main/java/vazkii/botania/common/item/WorldSeedItem.java index 9d7f3b9276..543b53c7f2 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/WorldSeedItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/WorldSeedItem.java @@ -18,6 +18,8 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; @@ -39,6 +41,7 @@ public InteractionResultHolder use(Level world, Player player, @NotNu boolean inRange = coords.distToCenterSqr(player.getX(), player.getY(), player.getZ()) <= 24 * 24; if (world.dimension() == Level.OVERWORLD && !inRange) { if (!world.isClientSide) { + Vec3 sourcePos = player.position(); player.setXRot(0F); player.setYRot(0F); player.teleportTo(coords.getX() + 0.5, coords.getY() + 0.5, coords.getZ() + 0.5); @@ -51,6 +54,8 @@ public InteractionResultHolder use(Level world, Player player, @NotNu SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.25F, 1F, 0.25F, 10); ((ServerLevel) world).sendParticles(data, player.getX(), player.getY() + player.getBbHeight() / 2, player.getZ(), 50, player.getBbWidth() / 8, player.getBbHeight() / 4, player.getBbWidth() / 8, 0); stack.shrink(1); + + world.gameEvent(player, GameEvent.TELEPORT, sourcePos); } return InteractionResultHolder.sidedSuccess(stack, world.isClientSide()); diff --git a/Xplat/src/main/java/vazkii/botania/common/item/lens/BoreLens.java b/Xplat/src/main/java/vazkii/botania/common/item/lens/BoreLens.java index 5119179e6b..c0220ffebf 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/lens/BoreLens.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/lens/BoreLens.java @@ -22,6 +22,7 @@ import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; @@ -75,6 +76,7 @@ && canHarvest(harvestLevel, state) List items = Block.getDrops(state, (ServerLevel) world, collidePos, tile); world.removeBlock(collidePos, false); + world.gameEvent(entity, GameEvent.BLOCK_DESTROY, collidePos); if (BotaniaConfig.common().blockBreakParticles()) { world.levelEvent(LevelEvent.PARTICLES_DESTROY_BLOCK, collidePos, Block.getId(state)); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/relic/EyeOfTheFlugelItem.java b/Xplat/src/main/java/vazkii/botania/common/item/relic/EyeOfTheFlugelItem.java index 5145f6b05e..4e47bc7e7c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/relic/EyeOfTheFlugelItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/relic/EyeOfTheFlugelItem.java @@ -26,6 +26,8 @@ import net.minecraft.world.item.UseAnim; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -122,7 +124,9 @@ public ItemStack finishUsingItem(@NotNull ItemStack stack, Level world, LivingEn if (!(living instanceof Player player) || ManaItemHandler.instance().requestManaExact(stack, player, cost, true)) { moveParticlesAndSound(living); + Vec3 sourcePos = living.position(); living.teleportTo(x + 0.5, y + 1.5, z + 0.5); + world.gameEvent(living, GameEvent.TELEPORT, sourcePos); moveParticlesAndSound(living); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/relic/FruitOfGrisaiaItem.java b/Xplat/src/main/java/vazkii/botania/common/item/relic/FruitOfGrisaiaItem.java index 830860819c..77438805be 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/relic/FruitOfGrisaiaItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/relic/FruitOfGrisaiaItem.java @@ -16,6 +16,7 @@ import net.minecraft.world.item.ItemUtils; import net.minecraft.world.item.UseAnim; import net.minecraft.world.level.Level; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; @@ -63,6 +64,7 @@ public void onUseTick(@NotNull Level world, @NotNull LivingEntity living, @NotNu } if (ManaItemHandler.instance().requestManaExact(stack, player, 500, true)) { if (count % 5 == 0) { + player.gameEvent(GameEvent.EAT); player.getFoodData().eat(2, 2.4F); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java b/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java index 4e403e07e6..d14258a5bd 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -107,6 +108,7 @@ public InteractionResultHolder use(Level world, Player player, @NotNu if (placedAny) { world.playSound(null, player.getX(), player.getY(), player.getZ(), BotaniaSounds.bifrostRod, SoundSource.PLAYERS, 1F, 1F); + player.gameEvent(GameEvent.ITEM_INTERACT_FINISH); ManaItemHandler.instance().requestManaExactForTool(stack, player, MANA_COST, false); player.getCooldowns().addCooldown(this, player.isCreative() ? 10 : TIME); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/rod/HellsRodItem.java b/Xplat/src/main/java/vazkii/botania/common/item/rod/HellsRodItem.java index fde934886a..e7b2e9a09b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/rod/HellsRodItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/rod/HellsRodItem.java @@ -18,6 +18,7 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; @@ -61,6 +62,7 @@ public InteractionResult useOn(UseOnContext ctx) { } ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, true); + world.gameEvent(player, GameEvent.PROJECTILE_SHOOT, pos); ctx.getLevel().playSound(null, pos.getX(), pos.getY(), pos.getZ(), BotaniaSounds.fireRod, SoundSource.PLAYERS, 1F, 1F); } } @@ -73,13 +75,15 @@ public static class AvatarBehavior implements AvatarWieldable { public void onAvatarUpdate(Avatar tile) { BlockEntity te = (BlockEntity) tile; Level world = te.getLevel(); - ManaReceiver receiver = XplatAbstractions.INSTANCE.findManaReceiver(world, te.getBlockPos(), te.getBlockState(), te, null); + BlockPos pos = te.getBlockPos(); + ManaReceiver receiver = XplatAbstractions.INSTANCE.findManaReceiver(world, pos, te.getBlockState(), te, null); if (!world.isClientSide && receiver.getCurrentMana() >= COST && tile.getElapsedFunctionalTicks() % 300 == 0 && tile.isEnabled()) { FlameRingEntity entity = BotaniaEntities.FLAME_RING.create(world); - entity.setPos(te.getBlockPos().getX() + 0.5, te.getBlockPos().getY(), te.getBlockPos().getZ() + 0.5); + entity.setPos(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); world.addFreshEntity(entity); receiver.receiveMana(-COST); + world.gameEvent(null, GameEvent.PROJECTILE_SHOOT, pos); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/rod/PlentifulMantleRodItem.java b/Xplat/src/main/java/vazkii/botania/common/item/rod/PlentifulMantleRodItem.java index b21e005598..adec0c9655 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/rod/PlentifulMantleRodItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/rod/PlentifulMantleRodItem.java @@ -21,6 +21,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; import org.jetbrains.annotations.NotNull; @@ -56,6 +57,7 @@ public InteractionResultHolder use(Level world, Player p, @NotNull In doHighlight(world, p.blockPosition(), range, seedxor); } else { world.playSound(null, p.getX(), p.getY(), p.getZ(), BotaniaSounds.divinationRod, SoundSource.PLAYERS, 1F, 1F); + p.gameEvent(GameEvent.ITEM_INTERACT_FINISH); } return InteractionResultHolder.sidedSuccess(stack, world.isClientSide); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/rod/SkiesRodItem.java b/Xplat/src/main/java/vazkii/botania/common/item/rod/SkiesRodItem.java index e418a68332..f74c58ac66 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/rod/SkiesRodItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/rod/SkiesRodItem.java @@ -20,6 +20,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -85,6 +86,9 @@ public void inventoryTick(ItemStack stack, Level world, Entity ent, int slot, bo } player.playSound(BotaniaSounds.airRod, 1F, 1F); + if (getFlyCounter(stack) % 3 == 0) { + player.gameEvent(GameEvent.FLAP); + } for (int i = 0; i < 5; i++) { WispParticleData data = WispParticleData.wisp(0.35F + (float) Math.random() * 0.1F, 0.25F, 0.25F, 0.25F); world.addParticle(data, player.getX(), player.getY(), player.getZ(), @@ -131,6 +135,7 @@ public InteractionResultHolder use(Level world, Player player, @NotNu if (fly == 0 && ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, false)) { ManaItemHandler.instance().requestManaExactForTool(stack, player, COST, true); setFlying(stack, true); + player.gameEvent(GameEvent.ITEM_INTERACT_FINISH); return InteractionResultHolder.sidedSuccess(stack, world.isClientSide()); } @@ -228,6 +233,7 @@ public static void doAvatarJump(Player p, Level world) { private static void doAvatarMiscEffects(Player p, ManaReceiver tile) { p.level().playSound(null, p.getX(), p.getY(), p.getZ(), BotaniaSounds.dash, SoundSource.PLAYERS, 1F, 1F); + p.gameEvent(GameEvent.FLAP); p.addEffect(new MobEffectInstance(BotaniaMobEffects.featherfeet, 100, 0)); tile.receiveMana(-COST); }