Item Phantom Networks, part 1

This commit is contained in:
Ellpeck 2016-05-08 21:09:58 +02:00
parent 9c40296db0
commit b4fde39a33
16 changed files with 1240 additions and 91 deletions

View file

@ -0,0 +1,31 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class BlockItemViewer extends BlockContainerBase{
public BlockItemViewer(String name){
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F);
this.setResistance(10.0F);
this.setSoundType(SoundType.STONE);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
return new TileEntityItemViewer();
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE;
}
}

View file

@ -27,13 +27,16 @@ import net.minecraft.world.World;
public class BlockLaserRelay extends BlockContainerBase{ public class BlockLaserRelay extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5); private static final PropertyInteger META = PropertyInteger.create("meta", 0, 5);
private boolean isItem;
public BlockLaserRelay(String name){ public BlockLaserRelay(String name, boolean isItem){
super(Material.ROCK, name); super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0); this.setHarvestLevel("pickaxe", 0);
this.setHardness(1.5F); this.setHardness(1.5F);
this.setResistance(10.0F); this.setResistance(10.0F);
this.setSoundType(SoundType.STONE); this.setSoundType(SoundType.STONE);
this.isItem = isItem;
} }
@Override @Override
@ -63,6 +66,6 @@ public class BlockLaserRelay extends BlockContainerBase{
@Override @Override
public TileEntity createNewTileEntity(World world, int i){ public TileEntity createNewTileEntity(World world, int i){
return new TileEntityLaserRelay(); return this.isItem ? new TileEntityLaserRelay.TileEntityLaserRelayItem() : new TileEntityLaserRelay.TileEntityLaserRelayEnergy();
} }
} }

View file

@ -92,6 +92,8 @@ public class InitBlocks{
public static Block blockRangedCollector; public static Block blockRangedCollector;
public static Block blockLaserRelay; public static Block blockLaserRelay;
public static Block blockLaserRelayItem;
public static Block blockItemViewer;
public static Block blockBlackLotus; public static Block blockBlackLotus;
public static Block blockCrystal; public static Block blockCrystal;
@ -114,12 +116,14 @@ public class InitBlocks{
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Blocks..."); ModUtil.LOGGER.info("Initializing Blocks...");
blockItemViewer = new BlockItemViewer("blockItemViewer");
blockFireworkBox = new BlockFireworkBox("blockFireworkBox"); blockFireworkBox = new BlockFireworkBox("blockFireworkBox");
blockMiner = new BlockMiner("blockMiner"); blockMiner = new BlockMiner("blockMiner");
blockAtomicReconstructor = new BlockAtomicReconstructor("blockAtomicReconstructor"); blockAtomicReconstructor = new BlockAtomicReconstructor("blockAtomicReconstructor");
blockCrystal = new BlockCrystal("blockCrystal"); blockCrystal = new BlockCrystal("blockCrystal");
blockBlackLotus = new BlockBlackLotus("blockBlackLotus"); blockBlackLotus = new BlockBlackLotus("blockBlackLotus");
blockLaserRelay = new BlockLaserRelay("blockLaserRelay"); blockLaserRelay = new BlockLaserRelay("blockLaserRelay", false);
blockLaserRelayItem = new BlockLaserRelay("blockLaserRelayItem", true);
blockRangedCollector = new BlockRangedCollector("blockRangedCollector"); blockRangedCollector = new BlockRangedCollector("blockRangedCollector");
blockDirectionalBreaker = new BlockDirectionalBreaker("blockDirectionalBreaker"); blockDirectionalBreaker = new BlockDirectionalBreaker("blockDirectionalBreaker");
blockLeafGenerator = new BlockLeafGenerator("blockLeafGenerator"); blockLeafGenerator = new BlockLeafGenerator("blockLeafGenerator");

View file

@ -55,6 +55,8 @@ public class CreativeTab extends CreativeTabs{
this.add(InitBlocks.blockFireworkBox); this.add(InitBlocks.blockFireworkBox);
this.add(InitBlocks.blockLaserRelay); this.add(InitBlocks.blockLaserRelay);
this.add(InitBlocks.blockLaserRelayItem);
this.add(InitBlocks.blockItemViewer);
this.add(InitBlocks.blockAtomicReconstructor); this.add(InitBlocks.blockAtomicReconstructor);
this.add(InitBlocks.blockPhantomface); this.add(InitBlocks.blockPhantomface);
this.add(InitBlocks.blockPhantomEnergyface); this.add(InitBlocks.blockPhantomEnergyface);

View file

@ -244,7 +244,7 @@ public class ContainerDrill extends Container{
} }
else{ else{
stackAt = this.slots[i].splitStack(j); stackAt = this.slots[i].splitStack(j);
if(this.slots[i].stackSize == 0){ if(this.slots[i].stackSize <= 0){
this.slots[i] = null; this.slots[i] = null;
} }
this.markDirty(); this.markDirty();

View file

@ -50,7 +50,8 @@ public class ItemLaserWrench extends ItemBase{
} }
else{ else{
BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack); BlockPos savedPos = ItemPhantomConnector.getStoredPosition(stack);
if(ItemPhantomConnector.getStoredWorld(stack) == world && world.getTileEntity(savedPos) instanceof TileEntityLaserRelay && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, pos)){ TileEntity savedTile = world.getTileEntity(savedPos);
if(ItemPhantomConnector.getStoredWorld(stack) == world && savedTile instanceof TileEntityLaserRelay && ((TileEntityLaserRelay)savedTile).isItem == ((TileEntityLaserRelay)tile).isItem && LaserRelayConnectionHandler.getInstance().addConnection(savedPos, pos)){
ItemPhantomConnector.clearStorage(stack); ItemPhantomConnector.clearStorage(stack);
((TileEntityLaserRelay)world.getTileEntity(savedPos)).sendUpdate(); ((TileEntityLaserRelay)world.getTileEntity(savedPos)).sendUpdate();

View file

@ -161,46 +161,6 @@ public class LaserRelayConnectionHandler{
//System.out.println("Merged Two Networks!"); //System.out.println("Merged Two Networks!");
} }
public int transferEnergyToReceiverInNeed(World world, BlockPos energyGottenFrom, Network network, int maxTransfer, boolean simulate){
int transmitted = 0;
//Go through all of the connections in the network
for(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){
//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 = world.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;
}
public static class ConnectionPair{ public static class ConnectionPair{
public BlockPos firstRelay; public BlockPos firstRelay;

View file

@ -78,11 +78,13 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{
GameRegistry.registerTileEntity(TileEntityLeafGenerator.class, ModUtil.MOD_ID+":tileEntityLeafGenerator"); GameRegistry.registerTileEntity(TileEntityLeafGenerator.class, ModUtil.MOD_ID+":tileEntityLeafGenerator");
GameRegistry.registerTileEntity(TileEntityDirectionalBreaker.class, ModUtil.MOD_ID+":tileEntityDirectionalBreaker"); GameRegistry.registerTileEntity(TileEntityDirectionalBreaker.class, ModUtil.MOD_ID+":tileEntityDirectionalBreaker");
GameRegistry.registerTileEntity(TileEntityRangedCollector.class, ModUtil.MOD_ID+":tileEntityRangedCollector"); GameRegistry.registerTileEntity(TileEntityRangedCollector.class, ModUtil.MOD_ID+":tileEntityRangedCollector");
GameRegistry.registerTileEntity(TileEntityLaserRelay.class, ModUtil.MOD_ID+":tileEntityLaserRelay");
GameRegistry.registerTileEntity(TileEntityAtomicReconstructor.class, ModUtil.MOD_ID+":tileEntityAtomicReconstructor"); GameRegistry.registerTileEntity(TileEntityAtomicReconstructor.class, ModUtil.MOD_ID+":tileEntityAtomicReconstructor");
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(TileEntityLaserRelay.TileEntityLaserRelayEnergy.class, ModUtil.MOD_ID+":tileEntityLaserRelay");
GameRegistry.registerTileEntity(TileEntityItemViewer.class, ModUtil.MOD_ID+":tileItemViewer");
} }
@Override @Override

View file

@ -33,10 +33,12 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
this.initializeSlots(slots); this.initializeSlots(slots);
if(this.hasInvWrapperCapabilities()){
for(int i = 0; i < this.invWrappers.length; i++){ for(int i = 0; i < this.invWrappers.length; i++){
this.invWrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]); this.invWrappers[i] = new SidedInvWrapper(this, EnumFacing.values()[i]);
} }
} }
}
public void initializeSlots(int itemAmount){ public void initializeSlots(int itemAmount){
this.slots = new ItemStack[itemAmount]; this.slots = new ItemStack[itemAmount];
@ -82,15 +84,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
} }
} }
@Override
public void updateEntity(){
super.updateEntity();
}
@Override @Override
public int[] getSlotsForFace(EnumFacing side){ public int[] getSlotsForFace(EnumFacing side){
if(this.slots.length > 0){ int invSize = this.getSizeInventory();
int[] theInt = new int[this.slots.length]; if(invSize > 0){
int[] theInt = new int[invSize];
for(int i = 0; i < theInt.length; i++){ for(int i = 0; i < theInt.length; i++){
theInt[i] = i; theInt[i] = i;
} }
@ -177,7 +175,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
} }
else{ else{
stackAt = this.slots[i].splitStack(j); stackAt = this.slots[i].splitStack(j);
if(this.slots[i].stackSize == 0){ if(this.slots[i].stackSize <= 0){
this.slots[i] = null; this.slots[i] = null;
} }
this.markDirty(); this.markDirty();

View file

@ -0,0 +1,163 @@
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.IItemHandler;
import org.apache.commons.lang3.tuple.Pair;
import java.util.List;
public class TileEntityItemViewer extends TileEntityInventoryBase{
public TileEntityItemViewer(){
super(0, "itemViewer");
}
private List<IItemHandler> getItemHandlers(){
TileEntityLaserRelay.TileEntityLaserRelayItem relay = this.getConnectedRelay();
if(relay != null){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(relay.getPos());
if(network != null){
return relay.getItemHandlersInNetwork(network);
}
}
return null;
}
private Pair<IItemHandler, Integer> getSwitchedIndexHandler(int i){
List<IItemHandler> handlers = this.getItemHandlers();
int currentI = 0;
if(handlers != null && !handlers.isEmpty()){
for(IItemHandler handler : handlers){
int slotAmount = handler.getSlots();
if(currentI+slotAmount > i){
return Pair.of(handler, i-currentI);
}
else{
currentI += slotAmount;
}
}
}
return null;
}
private TileEntityLaserRelay.TileEntityLaserRelayItem getConnectedRelay(){
TileEntityLaserRelay.TileEntityLaserRelayItem tileFound = null;
if(this.worldObj != null){ //Why is that even possible..?
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 instanceof TileEntityLaserRelay.TileEntityLaserRelayItem){
if(tileFound != null){
return null;
}
else{
tileFound = (TileEntityLaserRelay.TileEntityLaserRelayItem)tile;
}
}
}
}
return tileFound;
}
@Override
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction){
return this.isItemValidForSlot(index, stack);
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){
Pair<IItemHandler, Integer> handler = this.getSwitchedIndexHandler(index);
if(handler != null){
if(ItemStack.areItemsEqual(handler.getKey().getStackInSlot(handler.getValue()), stack)){
ItemStack gaveBack = handler.getKey().extractItem(handler.getValue(), stack.stackSize, true);
return gaveBack != null;
}
}
return false;
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
Pair<IItemHandler, Integer> handler = this.getSwitchedIndexHandler(index);
if(handler != null){
ItemStack gaveBack = handler.getKey().insertItem(handler.getValue(), stack, true);
return !ItemStack.areItemStacksEqual(gaveBack, stack);
}
return false;
}
@Override
public void clear(){
for(int i = 0; i < this.getSizeInventory(); i++){
this.removeStackFromSlot(i);
}
}
@Override
public void setInventorySlotContents(int i, ItemStack stack){
if(stack != null){
Pair<IItemHandler, Integer> handler = this.getSwitchedIndexHandler(i);
if(handler != null){
ItemStack toInsert = stack.copy();
ItemStack inSlot = handler.getKey().getStackInSlot(handler.getValue());
if(inSlot != null){
toInsert.stackSize -= inSlot.stackSize;
}
handler.getKey().insertItem(handler.getValue(), toInsert, false);
}
}
else{
this.removeStackFromSlot(i);
}
}
@Override
public int getSizeInventory(){
int size = 0;
List<IItemHandler> handlers = this.getItemHandlers();
if(handlers != null){
for(IItemHandler handler : handlers){
size += handler.getSlots();
}
}
return size;
}
@Override
public ItemStack getStackInSlot(int i){
Pair<IItemHandler, Integer> handler = this.getSwitchedIndexHandler(i);
if(handler != null){
return handler.getKey().getStackInSlot(handler.getValue());
}
return null;
}
@Override
public ItemStack decrStackSize(int i, int j){
Pair<IItemHandler, Integer> handler = this.getSwitchedIndexHandler(i);
if(handler != null){
return handler.getKey().extractItem(handler.getValue(), j, false);
}
return null;
}
@Override
public ItemStack removeStackFromSlot(int index){
Pair<IItemHandler, Integer> handler = this.getSwitchedIndexHandler(index);
if(handler != null){
ItemStack stackInSlot = handler.getKey().getStackInSlot(handler.getValue());
if(stackInSlot != null){
handler.getKey().extractItem(handler.getValue(), stackInSlot.stackSize, false);
}
return stackInSlot;
}
return null;
}
}

View file

@ -21,18 +21,28 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import io.netty.util.internal.ConcurrentSet; import io.netty.util.internal.ConcurrentSet;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
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;
public class TileEntityLaserRelay extends TileEntityBase implements IEnergyReceiver{ import java.util.ArrayList;
import java.util.List;
public abstract class TileEntityLaserRelay extends TileEntityBase{
public static final int MAX_DISTANCE = 15; public static final int MAX_DISTANCE = 15;
private static final float[] COLOR = new float[]{1F, 0F, 0F}; private static final float[] COLOR = new float[]{1F, 0F, 0F};
private static final float[] COLOR_ITEM = new float[]{139F/255F, 94F/255F, 1F};
public TileEntityLaserRelay(){ public boolean isItem;
super("laserRelay");
public TileEntityLaserRelay(String name, boolean isItem){
super(name);
this.isItem = isItem;
} }
@Override @Override
@ -86,7 +96,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
if(network != null){ if(network != null){
for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){ for(LaserRelayConnectionHandler.ConnectionPair aPair : network.connections){
if(aPair.contains(thisPos) && PosUtil.areSamePos(thisPos, aPair.firstRelay)){ if(aPair.contains(thisPos) && PosUtil.areSamePos(thisPos, aPair.firstRelay)){
PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigValues.lessParticles ? 2 : Util.RANDOM.nextInt(6)+1, 0.6F, COLOR, 1F); PacketParticle.renderParticlesFromAToB(aPair.firstRelay.getX(), aPair.firstRelay.getY(), aPair.firstRelay.getZ(), aPair.secondRelay.getX(), aPair.secondRelay.getY(), aPair.secondRelay.getZ(), ConfigValues.lessParticles ? 2 : Util.RANDOM.nextInt(6)+1, 0.6F, this.isItem ? COLOR_ITEM : COLOR, 1F);
} }
} }
} }
@ -99,6 +109,42 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos); LaserRelayConnectionHandler.getInstance().removeRelayFromNetwork(this.pos);
} }
public static class TileEntityLaserRelayItem extends TileEntityLaserRelay{
public TileEntityLaserRelayItem(){
super("laserRelayItem", true);
}
public List<IItemHandler> getItemHandlersInNetwork(LaserRelayConnectionHandler.Network network){
List<IItemHandler> handlers = new ArrayList<IItemHandler>();
for(LaserRelayConnectionHandler.ConnectionPair pair : network.connections){
BlockPos[] relays = new BlockPos[]{pair.firstRelay, pair.secondRelay};
for(BlockPos relay : relays){
if(relay != null){
for(int i = 0; i <= 5; i++){
EnumFacing side = WorldUtil.getDirectionBySidesInOrder(i);
BlockPos pos = WorldUtil.getCoordsFromSide(side, relay, 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.contains(handler)){
handlers.add(handler);
}
}
}
}
}
}
return handlers;
}
}
public static class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements IEnergyReceiver{
public TileEntityLaserRelayEnergy(){
super("laserRelay", false);
}
@Override @Override
public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){ public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate){
return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, this.pos, 0), maxReceive, simulate); return this.transmitEnergy(WorldUtil.getCoordsFromSide(from, this.pos, 0), maxReceive, simulate);
@ -119,7 +165,7 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
if(maxTransmit > 0){ if(maxTransmit > 0){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(this.pos); LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getInstance().getNetworkFor(this.pos);
if(network != null){ if(network != null){
transmitted = LaserRelayConnectionHandler.getInstance().transferEnergyToReceiverInNeed(this.worldObj, blockFrom, network, Math.min(ConfigIntValues.LASER_RELAY_MAX_TRANSFER.getValue(), maxTransmit), simulate); transmitted = this.transferEnergyToReceiverInNeed(blockFrom, network, Math.min(ConfigIntValues.LASER_RELAY_MAX_TRANSFER.getValue(), maxTransmit), simulate);
} }
} }
return transmitted; return transmitted;
@ -129,4 +175,47 @@ public class TileEntityLaserRelay extends TileEntityBase implements IEnergyRecei
public boolean canConnectEnergy(EnumFacing from){ public boolean canConnectEnergy(EnumFacing from){
return true; 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

@ -85,11 +85,6 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
return null; return null;
} }
@Override
public String getName(){
return this.name;
}
public ISidedInventory getSided(){ public ISidedInventory getSided(){
return this.getInventory() instanceof ISidedInventory ? (ISidedInventory)this.getInventory() : null; return this.getInventory() instanceof ISidedInventory ? (ISidedInventory)this.getInventory() : null;
} }

View file

@ -0,0 +1,19 @@
{
"forge_marker": 1,
"defaults": {
"model": "actuallyadditions:blockLaserRelayItem",
"transform": "forge:default-block"
},
"variants": {
"normal": [{}],
"inventory": [{}],
"meta": {
"0": { "x": 180 },
"1": {},
"2": { "x": 90 },
"3": { "x": 270 },
"4": { "x": 90, "y": 270 },
"5": { "x": 270, "y": 270 }
}
}
}

View file

@ -134,6 +134,8 @@ tile.actuallyadditions.blockChiseledQuartzSlab.name=Chiseled Black Quartz Slab
tile.actuallyadditions.blockPillarQuartzWall.name=Black Quartz Pillar Wall tile.actuallyadditions.blockPillarQuartzWall.name=Black Quartz Pillar Wall
tile.actuallyadditions.blockPillarQuartzStair.name=Black Quartz Pillar Stairs tile.actuallyadditions.blockPillarQuartzStair.name=Black Quartz Pillar Stairs
tile.actuallyadditions.blockPillarQuartzSlab.name=Black Quartz Pillar Slab tile.actuallyadditions.blockPillarQuartzSlab.name=Black Quartz Pillar Slab
tile.actuallyadditions.blockLaserRelayItem.name=Item Laser Relay
tile.actuallyadditions.blockItemViewer.name=Item Interface
#ESD #ESD
tile.actuallyadditions.blockInputter.name=ESD tile.actuallyadditions.blockInputter.name=ESD
@ -440,7 +442,7 @@ tooltip.actuallyadditions.extraInfo.desc=Advanced Info
tooltip.actuallyadditions.blockPhantomRange.desc=Range tooltip.actuallyadditions.blockPhantomRange.desc=Range
tooltip.actuallyadditions.laser.stored.desc=<Laser stored!> tooltip.actuallyadditions.laser.stored.desc=<Laser stored!>
tooltip.actuallyadditions.laser.connected.desc=<Laser connected!> tooltip.actuallyadditions.laser.connected.desc=<Laser connected!>
tooltip.actuallyadditions.laser.cantConnect.desc=Can't connect: The relays are either part of the same network, the stored relay doesn't exist anymore or it is too far away! tooltip.actuallyadditions.laser.cantConnect.desc=Can't connect: The relays are either part of the same network, the stored relay isn't the same type or doesn't exist anymore or it is too far away!
tooltip.actuallyadditions.itemBooklet.desc=Or "Booklet", if you will tooltip.actuallyadditions.itemBooklet.desc=Or "Booklet", if you will
#Gui Information #Gui Information

View file

@ -0,0 +1,880 @@
{
"__createdBy": "canitzp",
"ambientocclusion": false,
"textures": {
"particle": "actuallyadditions:blocks/models/modelLaserRelayItem",
"laserRelay": "actuallyadditions:blocks/models/modelLaserRelayItem"
},
"elements": [
{
"from": [4,0,4],
"to": [12,1,12],
"faces": {
"up": {
"uv": [0,0,8,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
}
}
},
{
"from": [4,1,3],
"to": [12,4,4],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
}
}
},
{
"from": [4,1,12],
"to": [12,4,13],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
}
}
},
{
"from": [4,11,12],
"to": [12,14,13],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
}
}
},
{
"from": [4,11,3],
"to": [12,14,4],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
}
}
},
{
"from": [4,4,2],
"to": [12,5,3],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
}
}
},
{
"from": [4,10,2],
"to": [12,11,3],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
}
}
},
{
"from": [4,10,13],
"to": [12,11,14],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
}
}
},
{
"from": [4,4,13],
"to": [12,5,14],
"faces": {
"up": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
}
}
},
{
"from": [5.5,1,5.5],
"to": [10.5,3,10.5],
"faces": {
"up": {
"uv": [13.5,13.5,16,16],
"texture": "#laserRelay"
},
"down": {
"uv": [0.0,0.0,5.0,5.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,5,2],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,5,2],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,5,2],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,5,2],
"texture": "#laserRelay"
}
}
},
{
"from": [7,3,7],
"to": [9,14,9],
"faces": {
"up": {
"uv": [0.0,0.0,2.0,2.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,2.0,2.0],
"texture": "missingtexture"
},
"west": {
"uv": [14,2,16,7.5],
"texture": "#laserRelay"
},
"east": {
"uv": [14,2,16,7.5],
"texture": "#laserRelay"
},
"north": {
"uv": [14,2,16,7.5],
"texture": "#laserRelay"
},
"south": {
"uv": [14,2,16,7.5],
"texture": "#laserRelay"
}
}
},
{
"from": [4,14,4],
"to": [12,15,12],
"faces": {
"up": {
"uv": [1,12,5,15],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,8,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
}
}
},
{
"from": [6.5,6.5,6.5],
"to": [9.5,9.5,9.5],
"faces": {
"up": {
"uv": [14,0,16,2],
"texture": "#laserRelay"
},
"down": {
"uv": [14,0,16,2],
"texture": "#laserRelay"
},
"west": {
"uv": [14,0,16,2],
"texture": "#laserRelay"
},
"east": {
"uv": [14,0,16,2],
"texture": "#laserRelay"
},
"north": {
"uv": [14,0,16,2],
"texture": "#laserRelay"
},
"south": {
"uv": [14,0,16,2],
"texture": "#laserRelay"
}
}
},
{
"from": [4,5,2],
"to": [5,10,3],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [11,5,2],
"to": [12,10,3],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [11,5,13],
"to": [12,10,14],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [4,5,13],
"to": [5,10,14],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [3,1,4],
"to": [4,4,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
}
}
},
{
"from": [12,1,4],
"to": [13,4,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
}
}
},
{
"from": [12,11,4],
"to": [13,14,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
}
}
},
{
"from": [3,11,4],
"to": [4,14,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,3],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,3],
"texture": "#laserRelay"
}
}
},
{
"from": [2,4,4],
"to": [3,5,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
}
}
},
{
"from": [2,10,4],
"to": [3,11,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
}
}
},
{
"from": [13,10,4],
"to": [14,11,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
}
}
},
{
"from": [13,4,4],
"to": [14,5,12],
"faces": {
"up": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"down": {
"uv": [0,0,1,8],
"texture": "#laserRelay"
},
"west": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,8,1],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,1],
"texture": "#laserRelay"
}
}
},
{
"from": [2,5,4],
"to": [3,10,5],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [2,5,11],
"to": [3,10,12],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [13,5,11],
"to": [14,10,12],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
},
{
"from": [13,5,4],
"to": [14,10,5],
"faces": {
"up": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"down": {
"uv": [0.0,0.0,1.0,1.0],
"texture": "missingtexture"
},
"west": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"east": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"north": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
},
"south": {
"uv": [0,0,1,5],
"texture": "#laserRelay"
}
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B