From 666e9754c6f58142177d37532d13db6febcd1782 Mon Sep 17 00:00:00 2001 From: ACGaming <4818419+ACGaming@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:17:04 +0200 Subject: [PATCH] Implement returning Experiment 115 cake bites --- build.gradle | 2 +- .../block/BlockTFExperiment115.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1299dde4c6..de071b3ece 100644 --- a/build.gradle +++ b/build.gradle @@ -145,7 +145,7 @@ dependencies { deobfCompile "thaumcraft:Thaumcraft:${minecraft_version}:${thaumcraft_version}" // curse - deobfCompile "curse.maven:llibrary-243298:3116493" + compileOnly "curse.maven:llibrary-243298:3116493" deobfCompile "curse.maven:mowzies-mobs-250498:3048685" } diff --git a/src/main/java/twilightforest/block/BlockTFExperiment115.java b/src/main/java/twilightforest/block/BlockTFExperiment115.java index d17a0856b8..344e0d897d 100644 --- a/src/main/java/twilightforest/block/BlockTFExperiment115.java +++ b/src/main/java/twilightforest/block/BlockTFExperiment115.java @@ -15,11 +15,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; +import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -105,6 +107,19 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, if (player instanceof EntityPlayerMP) CriteriaTriggers.PLACED_BLOCK.trigger((EntityPlayerMP) player, pos, stack); return true; } + } else { + if (bitesTaken < 7) worldIn.setBlockState(pos, state.withProperty(NOMS, bitesTaken + 1)); + else worldIn.setBlockToAir(pos); + if (!player.isCreative()) { + ItemStack cakeBite = new ItemStack(TFItems.experiment_115); + if (player.inventory.addItemStackToInventory(cakeBite)) { + player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.getRNG().nextFloat() - player.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F); + player.inventoryContainer.detectAndSendChanges(); + } else { + player.dropItem(cakeBite, false); + } + } + return true; } return this.eatCake(worldIn, pos, state, player) || stack.isEmpty();