Fix holding position, fix chat sending on server, drop sap if broken

This commit is contained in:
Justin Vitale 2020-07-08 19:15:23 +10:00
parent 80716876b2
commit e6e9b8bcfe
5 changed files with 39 additions and 9 deletions

View file

@ -28,13 +28,17 @@ 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;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.util.WorldUtils;
import techreborn.blocks.machine.tier1.ResinBasinBlock;
import techreborn.blocks.misc.BlockRubberLog;
import techreborn.config.TechRebornConfig;
@ -102,8 +106,7 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
if ((readyToHarvest || world.getTime() % 20 == 0) && !validPlacement()) {
// Not placed on log, drop on ground
world.setBlockState(pos, Blocks.AIR.getDefaultState());
ItemEntity itemEntity = new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(TRContent.Machine.RESIN_BASIN));
world.spawnEntity(itemEntity);
WorldUtils.dropItem(TRContent.Machine.RESIN_BASIN.asItem(), world, pos);
return;
}
@ -128,6 +131,16 @@ public class ResinBasinBlockEntity extends MachineBaseBlockEntity {
}
}
@Override
public void onBreak(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState) {
super.onBreak(world, playerEntity, blockPos, blockState);
// Drop a sap if full
if(this.isFull){
WorldUtils.dropItem(TRContent.Parts.SAP.asItem(), world, pos);
}
}
@Override
public CompoundTag toTag(CompoundTag tagCompound) {
super.toTag(tagCompound);

View file

@ -4,6 +4,7 @@ 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;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
@ -18,8 +19,11 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import reborncore.common.BaseBlockEntityProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.util.WorldUtils;
import techreborn.init.TRContent;
import java.util.UUID;
import java.util.function.Supplier;
public class ResinBasinBlock extends BaseBlockEntityProvider {
@ -70,9 +74,8 @@ 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());
ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(this.asBlock()));
worldIn.spawnEntity(itemEntity);
placer.sendSystemMessage(new LiteralText(new TranslatableText(this.getTranslationKey()).getString() + new TranslatableText("techreborn.tooltip.invalid_basin_placement").getString()), null);
WorldUtils.dropItem(this.asItem(), worldIn,pos);
placer.sendSystemMessage(new TranslatableText("techreborn.tooltip.invalid_basin_placement"), UUID.randomUUID());
}
}
@ -83,4 +86,14 @@ public class ResinBasinBlock extends BaseBlockEntityProvider {
}
return blockEntityClass.get();
}
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if(blockEntity instanceof MachineBaseBlockEntity){
((MachineBaseBlockEntity) blockEntity).onBreak(world, player, pos, state);
}
super.onBreak(world, pos, state, player);
}
}

View file

@ -11,6 +11,10 @@
"facing=north,pouring=false,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full" },
"facing=south,pouring=false,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 180 },
"facing=west,pouring=false,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 270 },
"facing=east,pouring=false,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 90 }
"facing=east,pouring=false,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 90 },
"facing=north,pouring=true,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full" },
"facing=south,pouring=true,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 180 },
"facing=west,pouring=true,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 270 },
"facing=east,pouring=true,full=true": { "model": "techreborn:block/machines/tier0_machines/resin_basin_full", "y": 90 }
}
}

View file

@ -719,7 +719,7 @@
"techreborn.tooltip.inventory": "Inventory",
"techreborn.tooltip.upgrades": "Upgrades",
"techreborn.tooltip.alarm": "Shift right-click to change sound",
"techreborn.tooltip.invalid_basin_placement": " must be placed on a valid rubber tree.",
"techreborn.tooltip.invalid_basin_placement": "Resin basin must be placed on a valid rubber tree.",
"techreborn.tooltip.generationRate.day": "Generation Rate Day",
"techreborn.tooltip.generationRate.night": "Generation Rate Night",
"techreborn.tooltip.greenhouse.upgrade_available": "Can be upgraded with powered lamps\nCheck multiblock hologram for details",

View file

@ -140,8 +140,8 @@
],
"display": {
"thirdperson_righthand": {
"rotation": [48.75, 0, 0],
"translation": [0.5, -1.25, -1],
"rotation": [48.75, -180, 0],
"translation": [0, 3.25, 0.75],
"scale": [0.5, 0.5, 0.5]
},
"thirdperson_lefthand": {