Fixed build, but DSU blocks are not done yet.

This commit is contained in:
drcrazy 2018-06-13 17:42:46 +03:00
parent e2225b06d4
commit 42bc110cb2
5 changed files with 231 additions and 258 deletions

View file

@ -24,21 +24,29 @@
package techreborn.blocks.storage; package techreborn.blocks.storage;
import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar; import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound; import prospector.shootingstar.model.ModelCompound;
import reborncore.api.ToolManager;
import reborncore.common.BaseTileBlock; import reborncore.common.BaseTileBlock;
import reborncore.common.RebornCoreConfig;
import reborncore.common.items.WrenchHelper;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.init.ModBlocks;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
import techreborn.tiles.lesu.TileLSUStorage; import techreborn.tiles.lesu.TileLSUStorage;
@ -47,32 +55,13 @@ import techreborn.tiles.lesu.TileLSUStorage;
*/ */
public class BlockLSUStorage extends BaseTileBlock { public class BlockLSUStorage extends BaseTileBlock {
/**
*
*/
public BlockLSUStorage() { public BlockLSUStorage() {
super(Material.IRON); super(Material.IRON);
setCreativeTab(TechRebornCreativeTab.instance); setCreativeTab(TechRebornCreativeTab.instance);
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy")); ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy"));
} }
/** // BaseTileBlock
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemstack) {
super.onBlockPlacedBy(world, pos, state, player, itemstack);
if (world.getTileEntity(pos) instanceof TileLSUStorage) {
TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos);
if (tile != null) {
tile.rebuildNetwork();
}
}
}
/**
* Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
*/
@Override @Override
public void breakBlock(World world, BlockPos pos, IBlockState state) { public void breakBlock(World world, BlockPos pos, IBlockState state) {
if (world.getTileEntity(pos) instanceof TileLSUStorage) { if (world.getTileEntity(pos) instanceof TileLSUStorage) {
@ -84,33 +73,57 @@ public class BlockLSUStorage extends BaseTileBlock {
super.breakBlock(world, pos, state); 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
*/
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
drops.add(new ItemStack(this));
}
@Override @Override
public TileEntity createNewTileEntity(final World world, final int meta) { public TileEntity createNewTileEntity(final World world, final int meta) {
return new TileLSUStorage(); return new TileLSUStorage();
} }
/** // Block
* Determines if another block can connect to this block @Override
* public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemstack) {
* @param world The current world super.onBlockPlacedBy(world, pos, state, player, itemstack);
* @param pos The position of this block if (world.getTileEntity(pos) instanceof TileLSUStorage) {
* @param facing The side the connecting block is on TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos);
* @return True to allow another block to connect to this block if (tile != null) {
*/ tile.rebuildNetwork();
}
}
}
@Override
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;
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, side, hitX, hitY, hitZ);
}
@Override
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 @Override
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
{ {

View file

@ -35,17 +35,12 @@ import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound; import prospector.shootingstar.model.ModelCompound;
import reborncore.api.tile.IMachineGuiHandler; import reborncore.api.tile.IMachineGuiHandler;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.WorldUtils;
import techreborn.client.EGui; import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
import techreborn.tiles.TileDigitalChest; import techreborn.tiles.TileDigitalChest;
import techreborn.tiles.TileTechStorageBase; import techreborn.tiles.TileTechStorageBase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BlockDigitalChest extends BlockMachineBase { public class BlockDigitalChest extends BlockMachineBase {
public BlockDigitalChest() { public BlockDigitalChest() {
@ -55,46 +50,6 @@ public class BlockDigitalChest extends BlockMachineBase {
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier2_machines")); 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 @Override
public TileEntity createNewTileEntity(final World world, final int meta) { public TileEntity createNewTileEntity(final World world, final int meta) {
return new TileDigitalChest(); return new TileDigitalChest();
@ -109,4 +64,20 @@ public class BlockDigitalChest extends BlockMachineBase {
public boolean isAdvanced() { public boolean isAdvanced() {
return true; 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);
}
} }

View file

@ -34,18 +34,14 @@ import net.minecraft.world.World;
import prospector.shootingstar.ShootingStar; import prospector.shootingstar.ShootingStar;
import prospector.shootingstar.model.ModelCompound; import prospector.shootingstar.model.ModelCompound;
import reborncore.api.tile.IMachineGuiHandler; import reborncore.api.tile.IMachineGuiHandler;
import reborncore.common.RebornCoreConfig;
import reborncore.common.blocks.BlockMachineBase; import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.util.WorldUtils;
import techreborn.client.EGui; import techreborn.client.EGui;
import techreborn.client.TechRebornCreativeTab; import techreborn.client.TechRebornCreativeTab;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
import techreborn.tiles.TileQuantumChest; import techreborn.tiles.TileQuantumChest;
import techreborn.tiles.TileTechStorageBase; import techreborn.tiles.TileTechStorageBase;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BlockQuantumChest extends BlockMachineBase { public class BlockQuantumChest extends BlockMachineBase {
public BlockQuantumChest() { public BlockQuantumChest() {
@ -55,51 +51,6 @@ public class BlockQuantumChest extends BlockMachineBase {
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier3_machines")); 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 @Override
public TileEntity createNewTileEntity(final World world, final int meta) { public TileEntity createNewTileEntity(final World world, final int meta) {
return new TileQuantumChest(); return new TileQuantumChest();
@ -109,4 +60,25 @@ public class BlockQuantumChest extends BlockMachineBase {
public IMachineGuiHandler getGui() { public IMachineGuiHandler getGui() {
return EGui.QUANTUM_CHEST; 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);
}
} }

View file

@ -58,6 +58,81 @@ public class TileTechStorageBase extends TileLegacyMachineBase
inventory = new Inventory(3, name, maxCapacity, this); inventory = new Inventory(3, name, maxCapacity, this);
} }
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
storedItem = ItemStack.EMPTY;
if (tagCompound.hasKey("storedStack")) {
this.storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
}
if (!this.storedItem.isEmpty()) {
this.storedItem.setCount(Math.min(tagCompound.getInteger("storedQuantity"), this.maxCapacity));
}
inventory.readFromNBT(tagCompound);
}
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) {
if (!this.storedItem.isEmpty()) {
ItemStack temp = this.storedItem.copy();
if (this.storedItem.getCount() > storedItem.getMaxStackSize()){
temp.setCount(storedItem.getMaxStackSize());
}
tagCompound.setTag("storedStack", temp.writeToNBT(new NBTTagCompound()));
tagCompound.setInteger("storedQuantity", Math.min(this.storedItem.getCount(), this.maxCapacity));
} else {
tagCompound.setInteger("storedQuantity", 0);
}
inventory.writeToNBT(tagCompound);
return tagCompound;
}
public ItemStack getDropWithNBT() {
NBTTagCompound tileEntity = new NBTTagCompound();
ItemStack dropStack = new ItemStack(this.getBlockType(), 1);
writeToNBTWithoutCoords(tileEntity);
dropStack.setTagCompound(new NBTTagCompound());
dropStack.getTagCompound().setTag("tileEntity", tileEntity);
this.storedItem.setCount(0);
setInventorySlotContents(1, ItemStack.EMPTY);
syncWithAll();
return dropStack;
}
public InvWrapper getInvWrapper() {
if (this.invWrapper == null)
this.invWrapper = new InvWrapper(this);
return this.invWrapper;
}
public int getStoredCount() {
return this.storedItem.getCount();
}
public List<ItemStack> getContentDrops() {
ArrayList<ItemStack> stacks = new ArrayList<>();
if (!this.getStoredItemType().isEmpty()) {
if (!this.getStackInSlot(1).isEmpty())
stacks.add(this.getStackInSlot(1));
for (int i = 0; i < this.getStoredCount() / 64; i++) {
ItemStack droped = this.storedItem.copy();
droped.setCount(64);
stacks.add(droped);
}
if (this.getStoredCount() % 64 != 0) {
ItemStack droped = this.storedItem.copy();
droped.setCount(this.getStoredCount() % 64);
stacks.add(droped);
}
}
return stacks;
}
// TileLegacyMachineBase
@Override @Override
public void update() { public void update() {
super.update(); super.update();
@ -132,21 +207,6 @@ public class TileTechStorageBase extends TileLegacyMachineBase
readFromNBTWithoutCoords(tagCompound); readFromNBTWithoutCoords(tagCompound);
} }
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound) {
storedItem = ItemStack.EMPTY;
if (tagCompound.hasKey("storedStack")) {
this.storedItem = new ItemStack((NBTTagCompound) tagCompound.getTag("storedStack"));
}
if (!this.storedItem.isEmpty()) {
this.storedItem.setCount(Math.min(tagCompound.getInteger("storedQuantity"), this.maxCapacity));
}
inventory.readFromNBT(tagCompound);
}
@Override @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
@ -154,59 +214,52 @@ public class TileTechStorageBase extends TileLegacyMachineBase
return tagCompound; return tagCompound;
} }
public NBTTagCompound writeToNBTWithoutCoords(NBTTagCompound tagCompound) { @Override
if (!this.storedItem.isEmpty()) { public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
ItemStack temp = this.storedItem.copy(); if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (this.storedItem.getCount() > storedItem.getMaxStackSize()){ return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getInvWrapper());
temp.setCount(storedItem.getMaxStackSize());
} }
tagCompound.setTag("storedStack", temp.writeToNBT(new NBTTagCompound())); return super.getCapability(capability, facing);
tagCompound.setInteger("storedQuantity", Math.min(this.storedItem.getCount(), this.maxCapacity));
} else {
tagCompound.setInteger("storedQuantity", 0);
}
inventory.writeToNBT(tagCompound);
return tagCompound;
} }
@Override
public boolean hasCapability(final net.minecraftforge.common.capabilities.Capability<?> capability,
@javax.annotation.Nullable
final net.minecraft.util.EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return this.inventory;
}
// IToolDrop
@Override @Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) { public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return getDropWithNBT(); return getDropWithNBT();
} }
public ItemStack getDropWithNBT() { // IListInfoProvider
NBTTagCompound tileEntity = new NBTTagCompound(); @Override
ItemStack dropStack = new ItemStack(this.getBlockType(), 1); public void addInfo(List<String> info, boolean isRealTile) {
writeToNBTWithoutCoords(tileEntity); if (isRealTile) {
dropStack.setTagCompound(new NBTTagCompound()); int size = 0;
dropStack.getTagCompound().setTag("tileEntity", tileEntity); String name = "of nothing";
this.storedItem.setCount(0); if (!storedItem.isEmpty()) {
this.syncWithAll(); name = storedItem.getDisplayName();
size += storedItem.getCount();
return dropStack;
} }
if (getStackInSlot(1) != ItemStack.EMPTY) {
public List<ItemStack> getContentDrops() { name = getStackInSlot(1).getDisplayName();
ArrayList<ItemStack> stacks = new ArrayList<>(); size += getStackInSlot(1).getCount();
if (!this.getStoredItemType().isEmpty()) {
if (!this.getStackInSlot(1).isEmpty())
stacks.add(this.getStackInSlot(1));
for (int i = 0; i < this.getStoredCount() / 64; i++) {
ItemStack droped = this.storedItem.copy();
droped.setCount(64);
stacks.add(droped);
} }
if (this.getStoredCount() % 64 != 0) { info.add(size + " " + name);
ItemStack droped = this.storedItem.copy();
droped.setCount(this.getStoredCount() % 64);
stacks.add(droped);
} }
} }
return stacks; // IDeepStorageUnit
}
@Override @Override
public ItemStack getStoredItemType() { public ItemStack getStoredItemType() {
return this.storedItem.isEmpty() ? this.getStackInSlot(1) : this.storedItem; return this.storedItem.isEmpty() ? this.getStackInSlot(1) : this.storedItem;
@ -229,51 +282,4 @@ public class TileTechStorageBase extends TileLegacyMachineBase
public int getMaxStoredCount() { public int getMaxStoredCount() {
return this.maxCapacity; return this.maxCapacity;
} }
public int getStoredCount() {
return this.storedItem.getCount();
}
@Override
public void addInfo(List<String> info, boolean isRealTile) {
if (isRealTile) {
int size = 0;
String name = "of nothing";
if (!storedItem.isEmpty()) {
name = storedItem.getDisplayName();
size += storedItem.getCount();
}
if (getStackInSlot(1) != ItemStack.EMPTY) {
name = getStackInSlot(1).getDisplayName();
size += getStackInSlot(1).getCount();
}
info.add(size + " " + name);
}
}
@Override
public Inventory getInventory() {
return this.inventory;
}
@Override
public <T> T getCapability(final Capability<T> capability, final EnumFacing facing) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getInvWrapper());
}
return super.getCapability(capability, facing);
}
@Override
public boolean hasCapability(final net.minecraftforge.common.capabilities.Capability<?> capability,
@javax.annotation.Nullable
final net.minecraft.util.EnumFacing facing) {
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
}
public InvWrapper getInvWrapper() {
if (this.invWrapper == null)
this.invWrapper = new InvWrapper(this);
return this.invWrapper;
}
} }

View file

@ -24,38 +24,28 @@
package techreborn.tiles.lesu; package techreborn.tiles.lesu;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import reborncore.api.IToolDrop;
import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.tile.TileLegacyMachineBase;
import techreborn.init.ModBlocks;
public class TileLSUStorage extends TileLegacyMachineBase { public class TileLSUStorage extends TileLegacyMachineBase
implements IToolDrop {
public LesuNetwork network; public LesuNetwork network;
@Override
public void update() {
super.update();
if (network == null) {
findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ());
} else {
if (network.master != null
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
network.master = null;
}
}
}
public final void findAndJoinNetwork(World world, int x, int y, int z) { public final void findAndJoinNetwork(World world, int x, int y, int z) {
network = new LesuNetwork(); network = new LesuNetwork();
network.addElement(this); network.addElement(this);
for (EnumFacing direction : EnumFacing.values()) { for (EnumFacing direction : EnumFacing.values()) {
if (world.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(), if (world.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(),
z + direction.getFrontOffsetZ())) instanceof TileLSUStorage) { z + direction.getFrontOffsetZ())) instanceof TileLSUStorage) {
TileLSUStorage lesu = (TileLSUStorage) world TileLSUStorage lesu = (TileLSUStorage) world.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(),
.getTileEntity(new BlockPos(x + direction.getFrontOffsetX(), y + direction.getFrontOffsetY(), y + direction.getFrontOffsetY(), z + direction.getFrontOffsetZ()));
z + direction.getFrontOffsetZ()));
if (lesu.network != null) { if (lesu.network != null) {
lesu.network.merge(network); lesu.network.merge(network);
} }
@ -86,4 +76,25 @@ public class TileLSUStorage extends TileLegacyMachineBase {
this.resetNetwork(); this.resetNetwork();
this.findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ()); this.findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ());
} }
// TileLegacyMachineBase
@Override
public void update() {
super.update();
if (network == null) {
findAndJoinNetwork(world, getPos().getX(), getPos().getY(), getPos().getZ());
} else {
if (network.master != null
&& network.master.getWorld().getTileEntity(new BlockPos(network.master.getPos().getX(),
network.master.getPos().getY(), network.master.getPos().getZ())) != network.master) {
network.master = null;
}
}
}
// IToolDrop
@Override
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
return new ItemStack(ModBlocks.LSU_STORAGE, 1);
}
} }