Fixed build, but DSU blocks are not done yet.
This commit is contained in:
parent
e2225b06d4
commit
42bc110cb2
5 changed files with 231 additions and 258 deletions
|
@ -24,21 +24,29 @@
|
|||
|
||||
package techreborn.blocks.storage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import prospector.shootingstar.ShootingStar;
|
||||
import prospector.shootingstar.model.ModelCompound;
|
||||
import reborncore.api.ToolManager;
|
||||
import reborncore.common.BaseTileBlock;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.items.WrenchHelper;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.lesu.TileLSUStorage;
|
||||
|
||||
|
@ -47,18 +55,30 @@ import techreborn.tiles.lesu.TileLSUStorage;
|
|||
*/
|
||||
public class BlockLSUStorage extends BaseTileBlock {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public BlockLSUStorage() {
|
||||
super(Material.IRON);
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
|
||||
*/
|
||||
|
||||
// BaseTileBlock
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
if (world.getTileEntity(pos) instanceof TileLSUStorage) {
|
||||
TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
tile.removeFromNetwork();
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World world, final int meta) {
|
||||
return new TileLSUStorage();
|
||||
}
|
||||
|
||||
// Block
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemstack) {
|
||||
super.onBlockPlacedBy(world, pos, state, player, itemstack);
|
||||
|
@ -70,47 +90,40 @@ public class BlockLSUStorage extends BaseTileBlock {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
|
||||
*/
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||
if (world.getTileEntity(pos) instanceof TileLSUStorage) {
|
||||
TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
tile.removeFromNetwork();
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand,
|
||||
EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = playerIn.getHeldItem(EnumHand.MAIN_HAND);
|
||||
TileEntity tileEntity = worldIn.getTileEntity(pos);
|
||||
|
||||
// We extended BaseTileBlock. Thus we should always have tile entity. I hope.
|
||||
if (tileEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && ToolManager.INSTANCE.canHandleTool(stack)) {
|
||||
if (WrenchHelper.handleWrench(stack, worldIn, pos, playerIn, side)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets a complete list of items dropped from this block.
|
||||
*
|
||||
* @param drops add all items this block drops to this drops list
|
||||
* @param world The current world
|
||||
* @param pos Block position in world
|
||||
* @param state Current state
|
||||
* @param fortune Breakers fortune level
|
||||
*/
|
||||
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
drops.add(new ItemStack(this));
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
NonNullList<ItemStack> items = NonNullList.create();
|
||||
|
||||
if (RebornCoreConfig.wrenchRequired){
|
||||
items.add(new ItemStack(ModBlocks.MACHINE_FRAMES, 1, 0));
|
||||
}
|
||||
else {
|
||||
super.getDrops(items, world, pos, state, fortune);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World world, final int meta) {
|
||||
return new TileLSUStorage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if another block can connect to this block
|
||||
*
|
||||
* @param world The current world
|
||||
* @param pos The position of this block
|
||||
* @param facing The side the connecting block is on
|
||||
* @return True to allow another block to connect to this block
|
||||
*/
|
||||
@Override
|
||||
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
|
||||
{
|
||||
|
|
|
@ -35,17 +35,12 @@ import prospector.shootingstar.ShootingStar;
|
|||
import prospector.shootingstar.model.ModelCompound;
|
||||
import reborncore.api.tile.IMachineGuiHandler;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import techreborn.client.EGui;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileDigitalChest;
|
||||
import techreborn.tiles.TileTechStorageBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockDigitalChest extends BlockMachineBase {
|
||||
|
||||
public BlockDigitalChest() {
|
||||
|
@ -55,46 +50,6 @@ public class BlockDigitalChest extends BlockMachineBase {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier2_machines"));
|
||||
}
|
||||
|
||||
protected void dropChest(final World world, final BlockPos pos) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
return;
|
||||
}
|
||||
final TileTechStorageBase inventory = (TileTechStorageBase) tileEntity;
|
||||
final List<ItemStack> items = new ArrayList<>();
|
||||
items.add(inventory.getDropWithNBT());
|
||||
WorldUtils.dropItems(items, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory(World world, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
} else {
|
||||
final TileTechStorageBase tileEntity1 = (TileTechStorageBase) tileEntity;
|
||||
drops.add(tileEntity1.getDropWithNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if(worldIn.getTileEntity(pos) != null){
|
||||
dropChest(worldIn, pos);
|
||||
}
|
||||
worldIn.removeTileEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World world, final int meta) {
|
||||
return new TileDigitalChest();
|
||||
|
@ -109,4 +64,20 @@ public class BlockDigitalChest extends BlockMachineBase {
|
|||
public boolean isAdvanced() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
/* if (RebornCoreConfig.wrenchRequired){
|
||||
drops.add(isAdvanced() ? advancedFrameStack.copy() : basicFrameStack.copy());
|
||||
}
|
||||
else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}*/
|
||||
|
||||
TileEntity storageTile = world.getTileEntity(pos);
|
||||
if (storageTile != null && storageTile instanceof TileTechStorageBase) {
|
||||
drops.addAll( ( (TileTechStorageBase) storageTile).getContentDrops() );
|
||||
}
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,18 +34,14 @@ import net.minecraft.world.World;
|
|||
import prospector.shootingstar.ShootingStar;
|
||||
import prospector.shootingstar.model.ModelCompound;
|
||||
import reborncore.api.tile.IMachineGuiHandler;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import techreborn.client.EGui;
|
||||
import techreborn.client.TechRebornCreativeTab;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.tiles.TileQuantumChest;
|
||||
import techreborn.tiles.TileTechStorageBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockQuantumChest extends BlockMachineBase {
|
||||
|
||||
public BlockQuantumChest() {
|
||||
|
@ -55,51 +51,6 @@ public class BlockQuantumChest extends BlockMachineBase {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier3_machines"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdvanced() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void dropChest(final World world, final BlockPos pos) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
return;
|
||||
}
|
||||
final TileTechStorageBase inventory = (TileTechStorageBase) tileEntity;
|
||||
final List<ItemStack> items = new ArrayList<>();
|
||||
items.add(inventory.getDropWithNBT());
|
||||
WorldUtils.dropItems(items, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory(World world, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
} else {
|
||||
final TileTechStorageBase tileEntity1 = (TileTechStorageBase) tileEntity;
|
||||
drops.add(tileEntity1.getDropWithNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if(worldIn.getTileEntity(pos) != null){
|
||||
dropChest(worldIn, pos);
|
||||
}
|
||||
worldIn.removeTileEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(final World world, final int meta) {
|
||||
return new TileQuantumChest();
|
||||
|
@ -109,4 +60,25 @@ public class BlockQuantumChest extends BlockMachineBase {
|
|||
public IMachineGuiHandler getGui() {
|
||||
return EGui.QUANTUM_CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdvanced() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
/* if (RebornCoreConfig.wrenchRequired){
|
||||
drops.add(isAdvanced() ? advancedFrameStack.copy() : basicFrameStack.copy());
|
||||
}
|
||||
else {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}*/
|
||||
|
||||
TileEntity storageTile = world.getTileEntity(pos);
|
||||
if (storageTile != null && storageTile instanceof TileTechStorageBase) {
|
||||
drops.addAll(((TileTechStorageBase) storageTile).getContentDrops());
|
||||
}
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue