Skip to content

Commit

Permalink
Implement returning Experiment 115 cake bites
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Apr 28, 2024
1 parent 1853dce commit 666e975
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/twilightforest/block/BlockTFExperiment115.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 666e975

Please sign in to comment.