Moved inner tileentity classes to own file

This commit is contained in:
Ellpeck 2016-05-14 17:50:10 +02:00
parent f34ed513fa
commit 09ecb708aa
24 changed files with 476 additions and 426 deletions

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer;
import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -47,7 +48,7 @@ public class BlockBreaker extends BlockContainerBase{
@Override @Override
public TileEntity createNewTileEntity(World world, int par2){ public TileEntity createNewTileEntity(World world, int par2){
return this.isPlacer ? new TileEntityBreaker.TileEntityPlacer() : new TileEntityBreaker(); return this.isPlacer ? new TileEntityPlacer() : new TileEntityBreaker();
} }
@Override @Override

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer;
import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.BlockPistonBase; import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -48,7 +49,7 @@ public class BlockFluidCollector extends BlockContainerBase{
@Override @Override
public TileEntity createNewTileEntity(World world, int par2){ public TileEntity createNewTileEntity(World world, int par2){
return this.isPlacer ? new TileEntityFluidCollector.TileEntityFluidPlacer() : new TileEntityFluidCollector(); return this.isPlacer ? new TileEntityFluidPlacer() : new TileEntityFluidCollector();
} }
@Override @Override

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy; import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinderDouble;
import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -52,7 +53,7 @@ public class BlockGrinder extends BlockContainerBase{
@Override @Override
public TileEntity createNewTileEntity(World world, int par2){ public TileEntity createNewTileEntity(World world, int par2){
return this.isDouble ? new TileEntityGrinder.TileEntityGrinderDouble() : new TileEntityGrinder(); return this.isDouble ? new TileEntityGrinderDouble() : new TileEntityGrinder();
} }
@Override @Override

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter; import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputter;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInputterAdvanced;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -51,7 +52,7 @@ public class BlockInputter extends BlockContainerBase{
@Override @Override
public TileEntity createNewTileEntity(World world, int par2){ public TileEntity createNewTileEntity(World world, int par2){
return this.isAdvanced ? new TileEntityInputter.TileEntityInputterAdvanced() : new TileEntityInputter(); return this.isAdvanced ? new TileEntityInputterAdvanced() : new TileEntityInputter();
} }
@Override @Override

View file

@ -14,6 +14,9 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.properties.PropertyInteger;
@ -72,7 +75,7 @@ public class BlockLaserRelay extends BlockContainerBase{
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(player.isSneaking()){ if(player.isSneaking()){
TileEntityLaserRelay relay = (TileEntityLaserRelay)world.getTileEntity(pos); TileEntityLaserRelay relay = (TileEntityLaserRelay)world.getTileEntity(pos);
if(relay instanceof TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist){ if(relay instanceof TileEntityLaserRelayItemWhitelist){
if(!world.isRemote){ if(!world.isRemote){
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
} }
@ -86,11 +89,11 @@ public class BlockLaserRelay extends BlockContainerBase{
public TileEntity createNewTileEntity(World world, int i){ public TileEntity createNewTileEntity(World world, int i){
switch(this.type){ switch(this.type){
case ITEM: case ITEM:
return new TileEntityLaserRelay.TileEntityLaserRelayItem(); return new TileEntityLaserRelayItem();
case ITEM_WHITELIST: case ITEM_WHITELIST:
return new TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist(); return new TileEntityLaserRelayItemWhitelist();
default: default:
return new TileEntityLaserRelay.TileEntityLaserRelayEnergy(); return new TileEntityLaserRelayEnergy();
} }
} }

View file

@ -93,7 +93,7 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{
case PLACER: case PLACER:
return new TileEntityPhantomPlacer(); return new TileEntityPhantomPlacer();
case BREAKER: case BREAKER:
return new TileEntityPhantomPlacer.TileEntityPhantomBreaker(); return new TileEntityPhantomBreaker();
case LIQUIFACE: case LIQUIFACE:
return new TileEntityPhantomLiquiface(); return new TileEntityPhantomLiquiface();
case ENERGYFACE: case ENERGYFACE:

View file

@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;

View file

@ -15,7 +15,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter.SmallerButton;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler; import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton; import de.ellpeck.actuallyadditions.mod.network.gui.PacketGuiButton;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -31,7 +31,6 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)

View file

@ -54,9 +54,9 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
GameRegistry.registerTileEntity(TileEntityGreenhouseGlass.class, ModUtil.MOD_ID+":tileEntityGreenhouseGlass"); GameRegistry.registerTileEntity(TileEntityGreenhouseGlass.class, ModUtil.MOD_ID+":tileEntityGreenhouseGlass");
GameRegistry.registerTileEntity(TileEntityBreaker.class, ModUtil.MOD_ID+":tileEntityBreaker"); GameRegistry.registerTileEntity(TileEntityBreaker.class, ModUtil.MOD_ID+":tileEntityBreaker");
GameRegistry.registerTileEntity(TileEntityDropper.class, ModUtil.MOD_ID+":tileEntityDropper"); GameRegistry.registerTileEntity(TileEntityDropper.class, ModUtil.MOD_ID+":tileEntityDropper");
GameRegistry.registerTileEntity(TileEntityInputter.TileEntityInputterAdvanced.class, ModUtil.MOD_ID+":tileEntityInputterAdvanced"); GameRegistry.registerTileEntity(TileEntityInputterAdvanced.class, ModUtil.MOD_ID+":tileEntityInputterAdvanced");
GameRegistry.registerTileEntity(TileEntityBreaker.TileEntityPlacer.class, ModUtil.MOD_ID+":tileEntityPlacer"); GameRegistry.registerTileEntity(TileEntityPlacer.class, ModUtil.MOD_ID+":tileEntityPlacer");
GameRegistry.registerTileEntity(TileEntityGrinder.TileEntityGrinderDouble.class, ModUtil.MOD_ID+":tileEntityGrinderDouble"); GameRegistry.registerTileEntity(TileEntityGrinderDouble.class, ModUtil.MOD_ID+":tileEntityGrinderDouble");
GameRegistry.registerTileEntity(TileEntityCanolaPress.class, ModUtil.MOD_ID+":tileEntityCanolaPress"); GameRegistry.registerTileEntity(TileEntityCanolaPress.class, ModUtil.MOD_ID+":tileEntityCanolaPress");
GameRegistry.registerTileEntity(TileEntityFermentingBarrel.class, ModUtil.MOD_ID+":tileEntityFermentingBarrel"); GameRegistry.registerTileEntity(TileEntityFermentingBarrel.class, ModUtil.MOD_ID+":tileEntityFermentingBarrel");
GameRegistry.registerTileEntity(TileEntityOilGenerator.class, ModUtil.MOD_ID+":tileEntityOilGenerator"); GameRegistry.registerTileEntity(TileEntityOilGenerator.class, ModUtil.MOD_ID+":tileEntityOilGenerator");
@ -65,9 +65,9 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
GameRegistry.registerTileEntity(TileEntityPhantomLiquiface.class, ModUtil.MOD_ID+":tileEntityPhantomLiquiface"); GameRegistry.registerTileEntity(TileEntityPhantomLiquiface.class, ModUtil.MOD_ID+":tileEntityPhantomLiquiface");
GameRegistry.registerTileEntity(TileEntityPhantomEnergyface.class, ModUtil.MOD_ID+":tileEntityPhantomEnergyface"); GameRegistry.registerTileEntity(TileEntityPhantomEnergyface.class, ModUtil.MOD_ID+":tileEntityPhantomEnergyface");
GameRegistry.registerTileEntity(TileEntityPhantomPlacer.class, ModUtil.MOD_ID+":tileEntityPhantomPlacer"); GameRegistry.registerTileEntity(TileEntityPhantomPlacer.class, ModUtil.MOD_ID+":tileEntityPhantomPlacer");
GameRegistry.registerTileEntity(TileEntityPhantomPlacer.TileEntityPhantomBreaker.class, ModUtil.MOD_ID+":tileEntityPhantomBreaker"); GameRegistry.registerTileEntity(TileEntityPhantomBreaker.class, ModUtil.MOD_ID+":tileEntityPhantomBreaker");
GameRegistry.registerTileEntity(TileEntityFluidCollector.class, ModUtil.MOD_ID+":tileEntityFluidCollector"); GameRegistry.registerTileEntity(TileEntityFluidCollector.class, ModUtil.MOD_ID+":tileEntityFluidCollector");
GameRegistry.registerTileEntity(TileEntityFluidCollector.TileEntityFluidPlacer.class, ModUtil.MOD_ID+":tileEntityFluidPlacer"); GameRegistry.registerTileEntity(TileEntityFluidPlacer.class, ModUtil.MOD_ID+":tileEntityFluidPlacer");
GameRegistry.registerTileEntity(TileEntityLavaFactoryController.class, ModUtil.MOD_ID+":tileEntityLavaFactoryController"); GameRegistry.registerTileEntity(TileEntityLavaFactoryController.class, ModUtil.MOD_ID+":tileEntityLavaFactoryController");
GameRegistry.registerTileEntity(TileEntityCoffeeMachine.class, ModUtil.MOD_ID+":tileEntityCoffeeMachine"); GameRegistry.registerTileEntity(TileEntityCoffeeMachine.class, ModUtil.MOD_ID+":tileEntityCoffeeMachine");
GameRegistry.registerTileEntity(TileEntityPhantomBooster.class, ModUtil.MOD_ID+":tileEntityPhantomBooster"); GameRegistry.registerTileEntity(TileEntityPhantomBooster.class, ModUtil.MOD_ID+":tileEntityPhantomBooster");
@ -82,9 +82,9 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
GameRegistry.registerTileEntity(TileEntityMiner.class, ModUtil.MOD_ID+":tileEntityMiner"); GameRegistry.registerTileEntity(TileEntityMiner.class, ModUtil.MOD_ID+":tileEntityMiner");
GameRegistry.registerTileEntity(TileEntityFireworkBox.class, ModUtil.MOD_ID+":tileEntityFireworkBox"); GameRegistry.registerTileEntity(TileEntityFireworkBox.class, ModUtil.MOD_ID+":tileEntityFireworkBox");
GameRegistry.registerTileEntity(TileEntityPhantomRedstoneface.class, ModUtil.MOD_ID+":tileEntityPhantomRedstoneface"); GameRegistry.registerTileEntity(TileEntityPhantomRedstoneface.class, ModUtil.MOD_ID+":tileEntityPhantomRedstoneface");
GameRegistry.registerTileEntity(TileEntityLaserRelay.TileEntityLaserRelayItem.class, ModUtil.MOD_ID+":tileEntityLaserRelayItem"); GameRegistry.registerTileEntity(TileEntityLaserRelayItem.class, ModUtil.MOD_ID+":tileEntityLaserRelayItem");
GameRegistry.registerTileEntity(TileEntityLaserRelay.TileEntityLaserRelayEnergy.class, ModUtil.MOD_ID+":tileEntityLaserRelay"); GameRegistry.registerTileEntity(TileEntityLaserRelayEnergy.class, ModUtil.MOD_ID+":tileEntityLaserRelay");
GameRegistry.registerTileEntity(TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist.class, ModUtil.MOD_ID+":tileEntityLaserRelayItemWhitelist"); GameRegistry.registerTileEntity(TileEntityLaserRelayItemWhitelist.class, ModUtil.MOD_ID+":tileEntityLaserRelayItemWhitelist");
GameRegistry.registerTileEntity(TileEntityItemViewer.class, ModUtil.MOD_ID+":tileItemViewer"); GameRegistry.registerTileEntity(TileEntityItemViewer.class, ModUtil.MOD_ID+":tileItemViewer");
} }

View file

@ -134,13 +134,4 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst
this.doWork(); this.doWork();
} }
public static class TileEntityPlacer extends TileEntityBreaker{
public TileEntityPlacer(){
super(9, "placer");
this.isPlacer = true;
}
}
} }

View file

@ -200,13 +200,4 @@ public class TileEntityFluidCollector extends TileEntityBase implements IFluidHa
this.tank.setFluid(fluids[0]); this.tank.setFluid(fluids[0]);
} }
public static class TileEntityFluidPlacer extends TileEntityFluidCollector{
public TileEntityFluidPlacer(){
super("fluidPlacer");
this.isPlacer = true;
}
}
} }

View file

@ -0,0 +1,10 @@
package de.ellpeck.actuallyadditions.mod.tile;
public class TileEntityFluidPlacer extends TileEntityFluidCollector{
public TileEntityFluidPlacer(){
super("fluidPlacer");
this.isPlacer = true;
}
}

View file

@ -274,12 +274,4 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg
this.storage.setEnergyStored(energy); this.storage.setEnergyStored(energy);
} }
public static class TileEntityGrinderDouble extends TileEntityGrinder{
public TileEntityGrinderDouble(){
super(6, "grinderDouble");
this.isDouble = true;
}
}
} }

View file

@ -0,0 +1,10 @@
package de.ellpeck.actuallyadditions.mod.tile;
public class TileEntityGrinderDouble extends TileEntityGrinder{
public TileEntityGrinderDouble(){
super(6, "grinderDouble");
this.isDouble = true;
}
}

View file

@ -438,13 +438,4 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){ public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){
return slot == 0; return slot == 0;
} }
public static class TileEntityInputterAdvanced extends TileEntityInputter{
public TileEntityInputterAdvanced(){
super(25, "inputterAdvanced");
this.isAdvanced = true;
}
}
} }

View file

@ -0,0 +1,10 @@
package de.ellpeck.actuallyadditions.mod.tile;
public class TileEntityInputterAdvanced extends TileEntityInputter{
public TileEntityInputterAdvanced(){
super(25, "inputterAdvanced");
this.isAdvanced = true;
}
}

View file

@ -1,8 +1,6 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay.TileEntityLaserRelayItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;

View file

@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketParticle; import de.ellpeck.actuallyadditions.mod.network.PacketParticle;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo;
import de.ellpeck.actuallyadditions.mod.util.*; import de.ellpeck.actuallyadditions.mod.util.*;
import io.netty.util.internal.ConcurrentSet; import io.netty.util.internal.ConcurrentSet;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -31,7 +30,6 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList; import java.util.ArrayList;
@ -115,363 +113,4 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos); LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos);
} }
public static class TileEntityLaserRelayItem extends TileEntityLaserRelay{
public TileEntityLaserRelayItem(String name){
super(name, true);
}
public TileEntityLaserRelayItem(){
this("laserRelayItem");
}
public boolean isWhitelisted(ItemStack stack){
return true;
}
public List<IItemHandler> getAllHandlersAround(){
List<IItemHandler> handlers = new ArrayList<IItemHandler>();
for(int i = 0; i <= 5; i++){
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
BlockPos pos = WorldUtil.getCoordsFromSide(side, this.getPos(), 0);
TileEntity tile = this.worldObj.getTileEntity(pos);
if(tile != null && !(tile instanceof TileEntityItemViewer)){
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite());
if(handler != null){
handlers.add(handler);
}
}
}
return handlers;
}
public List<GenericItemHandlerInfo> getItemHandlersInNetwork(LaserRelayConnectionHandler.Network network){
List<GenericItemHandlerInfo> handlers = new ArrayList<GenericItemHandlerInfo>();
for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){
BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay};
for(BlockPos relay : relays){
if(relay != null){
TileEntity aRelayTile = this.worldObj.getTileEntity(relay);
if(aRelayTile instanceof TileEntityLaserRelayItem){
TileEntityLaserRelayItem relayTile = (TileEntityLaserRelayItem)aRelayTile;
if(!GenericItemHandlerInfo.containsTile(handlers, relayTile)){
GenericItemHandlerInfo info = new GenericItemHandlerInfo(relayTile);
List<IItemHandler> handlersAroundTile = relayTile.getAllHandlersAround();
for(IItemHandler handler : handlersAroundTile){
if(!GenericItemHandlerInfo.containsHandler(handlers, handler)){
info.handlers.add(handler);
}
}
handlers.add(info);
}
}
}
}
}
return handlers;
}
}
public static class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor{
public IInventory filterInventory;
public boolean isLeftWhitelist;
public boolean isRightWhitelist;
private ItemStack[] slots = new ItemStack[24];
private boolean lastLeftWhitelist;
private boolean lastRightWhitelist;
public TileEntityLaserRelayItemWhitelist(){
super("laserRelayItemWhitelist");
this.filterInventory = new IInventory(){
private TileEntityLaserRelayItemWhitelist tile;
private IInventory setTile(TileEntityLaserRelayItemWhitelist tile){
this.tile = tile;
return this;
}
@Override
public String getName(){
return this.tile.name;
}
@Override
public int getInventoryStackLimit(){
return 64;
}
@Override
public void markDirty(){
}
@Override
public boolean isUseableByPlayer(EntityPlayer player){
return this.tile.canPlayerUse(player);
}
@Override
public void openInventory(EntityPlayer player){
}
@Override
public void closeInventory(EntityPlayer player){
}
@Override
public int getField(int id){
return 0;
}
@Override
public void setField(int id, int value){
}
@Override
public int getFieldCount(){
return 0;
}
@Override
public void clear(){
int length = this.tile.slots.length;
this.tile.slots = new ItemStack[length];
}
@Override
public void setInventorySlotContents(int i, ItemStack stack){
this.tile.slots[i] = stack;
this.markDirty();
}
@Override
public int getSizeInventory(){
return this.tile.slots.length;
}
@Override
public ItemStack getStackInSlot(int i){
if(i < this.getSizeInventory()){
return this.tile.slots[i];
}
return null;
}
@Override
public ItemStack decrStackSize(int i, int j){
if(this.tile.slots[i] != null){
ItemStack stackAt;
if(this.tile.slots[i].stackSize <= j){
stackAt = this.tile.slots[i];
this.tile.slots[i] = null;
this.markDirty();
return stackAt;
}
else{
stackAt = this.tile.slots[i].splitStack(j);
if(this.tile.slots[i].stackSize <= 0){
this.tile.slots[i] = null;
}
this.markDirty();
return stackAt;
}
}
return null;
}
@Override
public ItemStack removeStackFromSlot(int index){
ItemStack stack = this.tile.slots[index];
this.tile.slots[index] = null;
return stack;
}
@Override
public boolean hasCustomName(){
return false;
}
@Override
public ITextComponent getDisplayName(){
return new TextComponentString(StringUtil.localize(this.getName()));
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return false;
}
}.setTile(this);
}
@Override
public boolean isWhitelisted(ItemStack stack){
return this.checkFilter(stack, true, this.isLeftWhitelist) || this.checkFilter(stack, false, this.isRightWhitelist);
}
private boolean checkFilter(ItemStack stack, boolean left, boolean isWhitelist){
int slotStart = left ? 0 : 12;
int slotStop = slotStart+12;
for(int i = slotStart; i < slotStop; i++){
if(this.slots[i] != null && this.slots[i].isItemEqual(stack)){
return isWhitelist;
}
}
return !isWhitelist;
}
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync);
if(!isForSync){
TileEntityInventoryBase.saveSlots(this.slots, compound);
}
compound.setBoolean("LeftWhitelist", this.isLeftWhitelist);
compound.setBoolean("RightWhitelist", this.isRightWhitelist);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.readSyncableNBT(compound, isForSync);
if(!isForSync){
TileEntityInventoryBase.loadSlots(this.slots, compound);
}
this.isLeftWhitelist = compound.getBoolean("LeftWhitelist");
this.isRightWhitelist = compound.getBoolean("RightWhitelist");
}
@Override
public void onButtonPressed(int buttonID, EntityPlayer player){
if(buttonID == 0){
this.isLeftWhitelist = !this.isLeftWhitelist;
}
else if(buttonID == 1){
this.isRightWhitelist = !this.isRightWhitelist;
}
else if(buttonID == 2){
this.addWhitelistSmart();
}
}
private void addWhitelistSmart(){
List<IItemHandler> handlers = this.getAllHandlersAround();
for(IItemHandler handler : handlers){
for(int i = 0; i < handler.getSlots(); i++){
ItemStack stack = handler.getStackInSlot(i);
if(stack != null){
if(!ItemUtil.contains(this.slots, stack, false)){
for(int j = 0; j < this.slots.length; j++){
if(this.slots[j] == null || this.slots[j].stackSize <= 0){
ItemStack whitelistStack = stack.copy();
whitelistStack.stackSize = 1;
this.slots[j] = whitelistStack;
break;
}
}
}
}
}
}
}
@Override
public void updateEntity(){
super.updateEntity();
if(!this.worldObj.isRemote){
if((this.isLeftWhitelist != this.lastLeftWhitelist || this.isRightWhitelist != this.lastRightWhitelist) && this.sendUpdateWithInterval()){
this.lastLeftWhitelist = this.isLeftWhitelist;
this.lastRightWhitelist = this.isRightWhitelist;
}
}
}
}
public static class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements IEnergyReceiver{
public TileEntityLaserRelayEnergy(){
super("laserRelay", false);
}
@Override
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, this.pos, 0), maxReceive, simulate);
}
@Override
public int getEnergyStored(EnumFacing from){
return 0;
}
@Override
public int getMaxEnergyStored(EnumFacing from){
return 0;
}
public int transmitEnergy(BlockPos blockFrom, int maxTransmit, boolean simulate){
int transmitted = 0;
if(maxTransmit > 0){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(this.pos);
if(network != null){
transmitted = this.transferEnergyToReceiverInNeed(blockFrom, network, Math.min(ConfigIntValues.LASER_RELAY_MAX_TRANSFER.getValue(), maxTransmit), simulate);
}
}
return transmitted;
}
@Override
public boolean canConnectEnergy(EnumFacing from){
return true;
}
private int transferEnergyToReceiverInNeed(BlockPos energyGottenFrom, LaserRelayConnectionHandler.Network network, int maxTransfer, boolean simulate){
int transmitted = 0;
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();
//Go through all of the connections in the network
for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){
BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay};
//Go through both relays in the connection
for(BlockPos relay : relays){
if(relay != null && !alreadyChecked.contains(relay)){
alreadyChecked.add(relay);
//Get every side of the relay
for(int i = 0; i <= 5; i++){
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
//Get the Position at the side
BlockPos pos = WorldUtil.getCoordsFromSide(side, relay, 0);
if(!PosUtil.areSamePos(pos, energyGottenFrom)){
TileEntity tile = this.worldObj.getTileEntity(pos);
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
IEnergyReceiver receiver = (IEnergyReceiver)tile;
if(receiver.canConnectEnergy(side.getOpposite())){
//Transfer the energy (with the energy loss!)
int theoreticalReceived = ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), maxTransfer-transmitted, true);
//The amount of energy lost during a transfer
int deduct = (int)(theoreticalReceived*((double)ConfigIntValues.LASER_RELAY_LOSS.getValue()/100));
transmitted += ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), theoreticalReceived-deduct, simulate);
transmitted += deduct;
//If everything that could be transmitted was transmitted
if(transmitted >= maxTransfer){
return transmitted;
}
}
}
}
}
}
}
}
return transmitted;
}
}
} }

View file

@ -0,0 +1,93 @@
package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.IEnergyReceiver;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.List;
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements IEnergyReceiver{
public TileEntityLaserRelayEnergy(){
super("laserRelay", false);
}
@Override
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, this.pos, 0), maxReceive, simulate);
}
@Override
public int getEnergyStored(EnumFacing from){
return 0;
}
@Override
public int getMaxEnergyStored(EnumFacing from){
return 0;
}
public int transmitEnergy(BlockPos blockFrom, int maxTransmit, boolean simulate){
int transmitted = 0;
if(maxTransmit > 0){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(this.pos);
if(network != null){
transmitted = this.transferEnergyToReceiverInNeed(blockFrom, network, Math.min(ConfigIntValues.LASER_RELAY_MAX_TRANSFER.getValue(), maxTransmit), simulate);
}
}
return transmitted;
}
@Override
public boolean canConnectEnergy(EnumFacing from){
return true;
}
private int transferEnergyToReceiverInNeed(BlockPos energyGottenFrom, LaserRelayConnectionHandler.Network network, int maxTransfer, boolean simulate){
int transmitted = 0;
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>();
//Go through all of the connections in the network
for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){
BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay};
//Go through both relays in the connection
for(BlockPos relay : relays){
if(relay != null && !alreadyChecked.contains(relay)){
alreadyChecked.add(relay);
//Get every side of the relay
for(int i = 0; i <= 5; i++){
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
//Get the Position at the side
BlockPos pos = WorldUtil.getCoordsFromSide(side, relay, 0);
if(!PosUtil.areSamePos(pos, energyGottenFrom)){
TileEntity tile = this.worldObj.getTileEntity(pos);
if(tile instanceof IEnergyReceiver && !(tile instanceof TileEntityLaserRelay)){
IEnergyReceiver receiver = (IEnergyReceiver)tile;
if(receiver.canConnectEnergy(side.getOpposite())){
//Transfer the energy (with the energy loss!)
int theoreticalReceived = ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), maxTransfer-transmitted, true);
//The amount of energy lost during a transfer
int deduct = (int)(theoreticalReceived*((double)ConfigIntValues.LASER_RELAY_LOSS.getValue()/100));
transmitted += ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), theoreticalReceived-deduct, simulate);
transmitted += deduct;
//If everything that could be transmitted was transmitted
if(transmitted >= maxTransfer){
return transmitted;
}
}
}
}
}
}
}
}
return transmitted;
}
}

View file

@ -0,0 +1,72 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.util.ArrayList;
import java.util.List;
public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
public TileEntityLaserRelayItem(String name){
super(name, true);
}
public TileEntityLaserRelayItem(){
this("laserRelayItem");
}
public boolean isWhitelisted(ItemStack stack){
return true;
}
public List<IItemHandler> getAllHandlersAround(){
List<IItemHandler> handlers = new ArrayList<IItemHandler>();
for(int i = 0; i <= 5; i++){
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
BlockPos pos = WorldUtil.getCoordsFromSide(side, this.getPos(), 0);
TileEntity tile = this.worldObj.getTileEntity(pos);
if(tile != null && !(tile instanceof TileEntityItemViewer)){
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite());
if(handler != null){
handlers.add(handler);
}
}
}
return handlers;
}
public List<TileEntityItemViewer.GenericItemHandlerInfo> getItemHandlersInNetwork(LaserRelayConnectionHandler.Network network){
List<TileEntityItemViewer.GenericItemHandlerInfo> handlers = new ArrayList<TileEntityItemViewer.GenericItemHandlerInfo>();
for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){
BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay};
for(BlockPos relay : relays){
if(relay != null){
TileEntity aRelayTile = this.worldObj.getTileEntity(relay);
if(aRelayTile instanceof de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem){
de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem relayTile = (de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem)aRelayTile;
if(!TileEntityItemViewer.GenericItemHandlerInfo.containsTile(handlers, relayTile)){
TileEntityItemViewer.GenericItemHandlerInfo info = new TileEntityItemViewer.GenericItemHandlerInfo(relayTile);
List<IItemHandler> handlersAroundTile = relayTile.getAllHandlersAround();
for(IItemHandler handler : handlersAroundTile){
if(!TileEntityItemViewer.GenericItemHandlerInfo.containsHandler(handlers, handler)){
info.handlers.add(handler);
}
}
handlers.add(info);
}
}
}
}
}
return handlers;
}
}

View file

@ -0,0 +1,235 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.items.IItemHandler;
import java.util.List;
public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor{
public IInventory filterInventory;
public boolean isLeftWhitelist;
public boolean isRightWhitelist;
private ItemStack[] slots = new ItemStack[24];
private boolean lastLeftWhitelist;
private boolean lastRightWhitelist;
public TileEntityLaserRelayItemWhitelist(){
super("laserRelayItemWhitelist");
this.filterInventory = new IInventory(){
private de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist tile;
private IInventory setTile(de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemWhitelist tile){
this.tile = tile;
return this;
}
@Override
public String getName(){
return this.tile.name;
}
@Override
public int getInventoryStackLimit(){
return 64;
}
@Override
public void markDirty(){
}
@Override
public boolean isUseableByPlayer(EntityPlayer player){
return this.tile.canPlayerUse(player);
}
@Override
public void openInventory(EntityPlayer player){
}
@Override
public void closeInventory(EntityPlayer player){
}
@Override
public int getField(int id){
return 0;
}
@Override
public void setField(int id, int value){
}
@Override
public int getFieldCount(){
return 0;
}
@Override
public void clear(){
int length = this.tile.slots.length;
this.tile.slots = new ItemStack[length];
}
@Override
public void setInventorySlotContents(int i, ItemStack stack){
this.tile.slots[i] = stack;
this.markDirty();
}
@Override
public int getSizeInventory(){
return this.tile.slots.length;
}
@Override
public ItemStack getStackInSlot(int i){
if(i < this.getSizeInventory()){
return this.tile.slots[i];
}
return null;
}
@Override
public ItemStack decrStackSize(int i, int j){
if(this.tile.slots[i] != null){
ItemStack stackAt;
if(this.tile.slots[i].stackSize <= j){
stackAt = this.tile.slots[i];
this.tile.slots[i] = null;
this.markDirty();
return stackAt;
}
else{
stackAt = this.tile.slots[i].splitStack(j);
if(this.tile.slots[i].stackSize <= 0){
this.tile.slots[i] = null;
}
this.markDirty();
return stackAt;
}
}
return null;
}
@Override
public ItemStack removeStackFromSlot(int index){
ItemStack stack = this.tile.slots[index];
this.tile.slots[index] = null;
return stack;
}
@Override
public boolean hasCustomName(){
return false;
}
@Override
public ITextComponent getDisplayName(){
return new TextComponentString(StringUtil.localize(this.getName()));
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return false;
}
}.setTile(this);
}
@Override
public boolean isWhitelisted(ItemStack stack){
return this.checkFilter(stack, true, this.isLeftWhitelist) || this.checkFilter(stack, false, this.isRightWhitelist);
}
private boolean checkFilter(ItemStack stack, boolean left, boolean isWhitelist){
int slotStart = left ? 0 : 12;
int slotStop = slotStart+12;
for(int i = slotStart; i < slotStop; i++){
if(this.slots[i] != null && this.slots[i].isItemEqual(stack)){
return isWhitelist;
}
}
return !isWhitelist;
}
@Override
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.writeSyncableNBT(compound, isForSync);
if(!isForSync){
TileEntityInventoryBase.saveSlots(this.slots, compound);
}
compound.setBoolean("LeftWhitelist", this.isLeftWhitelist);
compound.setBoolean("RightWhitelist", this.isRightWhitelist);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
super.readSyncableNBT(compound, isForSync);
if(!isForSync){
TileEntityInventoryBase.loadSlots(this.slots, compound);
}
this.isLeftWhitelist = compound.getBoolean("LeftWhitelist");
this.isRightWhitelist = compound.getBoolean("RightWhitelist");
}
@Override
public void onButtonPressed(int buttonID, EntityPlayer player){
if(buttonID == 0){
this.isLeftWhitelist = !this.isLeftWhitelist;
}
else if(buttonID == 1){
this.isRightWhitelist = !this.isRightWhitelist;
}
else if(buttonID == 2){
this.addWhitelistSmart();
}
}
private void addWhitelistSmart(){
List<IItemHandler> handlers = this.getAllHandlersAround();
for(IItemHandler handler : handlers){
for(int i = 0; i < handler.getSlots(); i++){
ItemStack stack = handler.getStackInSlot(i);
if(stack != null){
if(!ItemUtil.contains(this.slots, stack, false)){
for(int j = 0; j < this.slots.length; j++){
if(this.slots[j] == null || this.slots[j].stackSize <= 0){
ItemStack whitelistStack = stack.copy();
whitelistStack.stackSize = 1;
this.slots[j] = whitelistStack;
break;
}
}
}
}
}
}
}
@Override
public void updateEntity(){
super.updateEntity();
if(!this.worldObj.isRemote){
if((this.isLeftWhitelist != this.lastLeftWhitelist || this.isRightWhitelist != this.lastRightWhitelist) && this.sendUpdateWithInterval()){
this.lastLeftWhitelist = this.isLeftWhitelist;
this.lastRightWhitelist = this.isRightWhitelist;
}
}
}
}

View file

@ -0,0 +1,10 @@
package de.ellpeck.actuallyadditions.mod.tile;
public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer{
public TileEntityPhantomBreaker(){
super(9, "phantomBreaker");
this.isBreaker = true;
}
}

View file

@ -221,12 +221,4 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
this.doWork(); this.doWork();
} }
public static class TileEntityPhantomBreaker extends TileEntityPhantomPlacer{
public TileEntityPhantomBreaker(){
super(9, "phantomBreaker");
this.isBreaker = true;
}
}
} }

View file

@ -0,0 +1,10 @@
package de.ellpeck.actuallyadditions.mod.tile;
public class TileEntityPlacer extends TileEntityBreaker{
public TileEntityPlacer(){
super(9, "placer");
this.isPlacer = true;
}
}