Have chance to yield two sap closes #2014

This commit is contained in:
Justin Vitale 2020-07-08 19:43:19 +10:00
parent 9ca7b491b0
commit 48bf8ae0f2
2 changed files with 7 additions and 10 deletions

View file

@ -27,10 +27,8 @@ package techreborn.blockentity.machine.tier1;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sound.SoundCategory;
@ -85,11 +83,11 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
// Try and deposit
if (isFull) {
// Find a rubber log
// Get inventory
Inventory invBelow = getInventoryBelow();
if (invBelow != null) {
ItemStack out = new ItemStack(TRContent.Parts.SAP, 1);
ItemStack out = new ItemStack(TRContent.Parts.SAP, (Math.random() <= 0.5) ? 1 : 2);
out = HopperBlockEntity.transfer(null, invBelow, out, Direction.UP);
if (out.isEmpty()) {
@ -136,8 +134,9 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
super.onBreak(world, playerEntity, blockPos, blockState);
// Drop a sap if full
if(this.isFull){
WorldUtils.dropItem(TRContent.Parts.SAP.asItem(), world, pos);
if (this.isFull) {
ItemStack out = new ItemStack(TRContent.Parts.SAP, (Math.random() <= 0.6) ? 1 : 2);
WorldUtils.dropItem(out, world, pos);
}
}

View file

@ -2,7 +2,6 @@ package techreborn.blocks.machine.tier1;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@ -10,7 +9,6 @@ import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@ -74,7 +72,7 @@ public class ResinBasinBlock extends BaseBlockEntityProvider {
// Drop item if not next to log and yell at user
if (worldIn.getBlockState(pos.offset(facing.getOpposite())).getBlock() != TRContent.RUBBER_LOG) {
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
WorldUtils.dropItem(this.asItem(), worldIn,pos);
WorldUtils.dropItem(this.asItem(), worldIn, pos);
placer.sendSystemMessage(new TranslatableText("techreborn.tooltip.invalid_basin_placement"), UUID.randomUUID());
}
}
@ -90,7 +88,7 @@ public class ResinBasinBlock extends BaseBlockEntityProvider {
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if(blockEntity instanceof MachineBaseBlockEntity){
if (blockEntity instanceof MachineBaseBlockEntity) {
((MachineBaseBlockEntity) blockEntity).onBreak(world, player, pos, state);
}