diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index e3471792e..7af764f55 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.laser.Network; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; +import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench; import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -141,24 +142,21 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile; if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){ - if(player.isSneaking()){ - relay.priority--; - } - else{ - relay.priority++; - } + if(!world.isRemote){ + relay.onCompassAction(player); - Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(relay.getPos(), relay.getWorld()); - if(network != null){ - network.changeAmount++; - } + Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(relay.getPos(), relay.getWorld()); + if(network != null){ + network.changeAmount++; + } - relay.markDirty(); - relay.sendUpdate(); + relay.markDirty(); + relay.sendUpdate(); + } return true; } - else if(relay instanceof TileEntityLaserRelayItemWhitelist && player.isSneaking()){ + else if(relay instanceof TileEntityLaserRelayItemWhitelist){ if(!world.isRemote){ player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ()); } @@ -189,23 +187,26 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ @Override @SideOnly(Side.CLIENT) public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ - if(posHit != null && posHit.getBlockPos() != null && minecraft.theWorld != null){ - TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos()); - if(tile instanceof TileEntityLaserRelayItem){ - TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile; + if(posHit != null && posHit.getBlockPos() != null && minecraft.theWorld != null && StackUtil.isValid(stack)){ + boolean compass = stack.getItem() instanceof ItemCompass; + if(compass || stack.getItem() instanceof ItemLaserWrench){ + TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos()); + if(tile instanceof TileEntityLaserRelay){ + TileEntityLaserRelay relay = (TileEntityLaserRelay)tile; - String strg = "Priority: "+TextFormatting.DARK_RED+relay.getPriority()+TextFormatting.RESET; - minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); + String strg = relay.getExtraDisplayString(); + minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); - String expl; - if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){ - expl = TextFormatting.GREEN+"Right-Click to increase! \nSneak-Right-Click to decrease!"; + String expl; + if(compass){ + expl = relay.getCompassDisplayString(); + } + else{ + expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!"; + } + + StringUtil.drawSplitString(minecraft.fontRendererObj, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true); } - else{ - expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!"; - } - - StringUtil.drawSplitString(minecraft.fontRendererObj, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 3e7e15ec2..eb0d799f9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -161,7 +161,7 @@ public final class InitBooklet{ new BookletChapter("lensMining", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMiningLens), new PageTextOnly(1).addTextReplacement("", LensMining.ENERGY_USE), new PageCrafting(2, ItemCrafting.recipeMiningLens).setNoText()).setImportant(); //Laser Relays - chaptersIntroduction[7] = new BookletChapter("laserIntro", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitItems.itemLaserWrench), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("", TileEntityLaserRelay.MAX_DISTANCE), new PageCrafting(3, ItemCrafting.recipeLaserWrench).setNoText()).setImportant(); + chaptersIntroduction[7] = new BookletChapter("laserIntro", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitItems.itemLaserWrench), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("", TileEntityLaserRelay.MAX_DISTANCE), new PageCrafting(3, ItemCrafting.recipeLaserWrench)).setImportant(); new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("", TileEntityLaserRelayEnergy.CAP).addTextReplacement("", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("", TileEntityLaserRelayEnergyExtreme.CAP), new PagePicture(3, "pageLaserRelay", 0).setNoText(), new PageCrafting(4, BlockCrafting.recipeLaserRelay).setWildcard().setNoText(), new PageCrafting(5, BlockCrafting.recipeLaserRelayAdvanced).setWildcard().setNoText(), new PageCrafting(6, BlockCrafting.recipeLaserRelayExtreme).setWildcard().setNoText()); new BookletChapter("itemStorage", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayItemWhitelist), new PageTextOnly(1), new PageTextOnly(2), new PagePicture(3, "page_item_laser_relay_basic", 78), new PagePicture(4, "page_item_laser_relay_fail", 84), new PagePicture(5, "page_item_laser_relay_transfer", 78), new PagePicture(6, "page_item_laser_relay_whitelist_chest", 76), new PagePicture(7, "page_item_laser_relay_whitelist_interface", 75), new PagePicture(8, "page_item_laser_relay_system", 75), new PageTextOnly(9), new PageReconstructor(10, LensRecipeHandler.recipeItemLaser).setWildcard().setNoText(), new PageCrafting(11, BlockCrafting.recipeLaserRelayItemWhitelist).setWildcard().setNoText(), new PageCrafting(12, BlockCrafting.recipeItemInterface).setNoText()); new BookletChapter("fluidLaser", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayFluids), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeFluidLaser).setWildcard().setNoText()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index 5334abded..dc3dc21d0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -15,9 +15,12 @@ import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.mod.misc.ConnectionPair; import io.netty.util.internal.ConcurrentSet; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Set; @@ -130,4 +133,12 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{ public AxisAlignedBB getRenderBoundingBox(){ return INFINITE_EXTENT_AABB; } + + @SideOnly(Side.CLIENT) + public abstract String getExtraDisplayString(); + + @SideOnly(Side.CLIENT) + public abstract String getCompassDisplayString(); + + public abstract void onCompassAction(EntityPlayer player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java index b427658cb..a5c4b3150 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -19,10 +19,15 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil; import net.darkhax.tesla.api.ITeslaConsumer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; @@ -34,6 +39,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements public static final int CAP = 1000; public final ConcurrentHashMap receiversAround = new ConcurrentHashMap(); + private Mode mode = Mode.BOTH; public TileEntityLaserRelayEnergy(String name){ super(name, LaserType.ENERGY); @@ -60,7 +66,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate){ int transmitted = 0; - if(maxTransmit > 0){ + if(maxTransmit > 0 && this.mode != Mode.OUTPUT_ONLY){ Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj); if(network != null){ transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate); @@ -123,32 +129,34 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements TileEntity relayTile = this.worldObj.getTileEntity(relay); if(relayTile instanceof TileEntityLaserRelayEnergy){ TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile; - boolean workedOnce = false; + if(theRelay.mode != Mode.INPUT_ONLY){ + boolean workedOnce = false; - for(EnumFacing facing : theRelay.receiversAround.keySet()){ - if(theRelay != this || facing != from){ - TileEntity tile = theRelay.receiversAround.get(facing); + for(EnumFacing facing : theRelay.receiversAround.keySet()){ + if(theRelay != this || facing != from){ + TileEntity tile = theRelay.receiversAround.get(facing); - EnumFacing opp = facing.getOpposite(); - if(tile instanceof IEnergyReceiver){ - IEnergyReceiver iReceiver = (IEnergyReceiver)tile; - if(iReceiver.canConnectEnergy(opp) && iReceiver.receiveEnergy(opp, Integer.MAX_VALUE, true) > 0){ - totalReceiverAmount++; - workedOnce = true; + EnumFacing opp = facing.getOpposite(); + if(tile instanceof IEnergyReceiver){ + IEnergyReceiver iReceiver = (IEnergyReceiver)tile; + if(iReceiver.canConnectEnergy(opp) && iReceiver.receiveEnergy(opp, Integer.MAX_VALUE, true) > 0){ + totalReceiverAmount++; + workedOnce = true; + } } - } - else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){ - ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp); - if(cap != null && cap.givePower(maxTransfer, true) > 0){ - totalReceiverAmount++; - workedOnce = true; + else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){ + ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp); + if(cap != null && cap.givePower(maxTransfer, true) > 0){ + totalReceiverAmount++; + workedOnce = true; + } } } } - } - if(workedOnce){ - relaysThatWork.add(theRelay); + if(workedOnce){ + relaysThatWork.add(theRelay); + } } } } @@ -228,4 +236,64 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements public double getLossPercentage(){ return 5; } + + @Override + @SideOnly(Side.CLIENT) + public String getExtraDisplayString(){ + return "Energy Flow: "+TextFormatting.DARK_RED+this.mode.name+TextFormatting.RESET; + } + + @Override + @SideOnly(Side.CLIENT) + public String getCompassDisplayString(){ + return TextFormatting.GREEN+"Right-Click to change!"; + } + + @Override + public void onCompassAction(EntityPlayer player){ + this.mode = this.mode.getNext(); + } + + @Override + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + + if(type != NBTType.SAVE_BLOCK){ + compound.setString("Mode", this.mode.toString()); + } + } + + @Override + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + + if(type != NBTType.SAVE_BLOCK){ + String modeStrg = compound.getString("Mode"); + if(modeStrg != null && !modeStrg.isEmpty()){ + this.mode = Mode.valueOf(modeStrg); + } + } + } + + public enum Mode{ + BOTH("Both Directions"), + OUTPUT_ONLY("Only into adjacent Blocks"), + INPUT_ONLY("Only out of adjacent Blocks"); + + public final String name; + + Mode(String name){ + this.name = name; + } + + public Mode getNext(){ + int ordinal = this.ordinal()+1; + + if(ordinal >= values().length){ + ordinal = 0; + } + + return values()[ordinal]; + } + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java index f32c3c64c..9ed86f469 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java @@ -14,14 +14,21 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy.Mode; +import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; @@ -31,12 +38,26 @@ import java.util.concurrent.ConcurrentHashMap; public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements ISharingFluidHandler{ - public final ConcurrentHashMap receiversAround = new ConcurrentHashMap(); + public final ConcurrentHashMap handlersAround = new ConcurrentHashMap(); + private Mode mode = Mode.BOTH; public TileEntityLaserRelayFluids(){ super("laserRelayFluids", LaserType.FLUID); } + @Override + public void updateEntity(){ + super.updateEntity(); + + if(!this.worldObj.isRemote){ + if(this.mode == Mode.INPUT_ONLY){ + for(EnumFacing side : this.handlersAround.keySet()){ + WorldUtil.doFluidInteraction(this.handlersAround.get(side), this, side.getOpposite(), Integer.MAX_VALUE); + } + } + } + } + @Override public boolean shouldSaveDataOnChangeOrWorldStart(){ return true; @@ -44,16 +65,16 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements @Override public void saveDataOnChangeOrWorldStart(){ - Map old = new HashMap(this.receiversAround); + Map old = new HashMap(this.handlersAround); boolean change = false; - this.receiversAround.clear(); + this.handlersAround.clear(); for(EnumFacing side : EnumFacing.values()){ BlockPos pos = this.getPos().offset(side); TileEntity tile = this.worldObj.getTileEntity(pos); if(tile != null && !(tile instanceof TileEntityLaserRelay)){ if(tile instanceof net.minecraftforge.fluids.IFluidHandler || tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())){ - this.receiversAround.put(side, tile); + this.handlersAround.put(side, tile); TileEntity oldTile = old.get(side); if(oldTile == null || !tile.equals(oldTile)){ @@ -63,7 +84,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements } } - if(change || old.size() != this.receiversAround.size()){ + if(change || old.size() != this.handlersAround.size()){ Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.getPos(), this.getWorld()); if(network != null){ network.changeAmount++; @@ -93,7 +114,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements private int transmitEnergy(EnumFacing from, FluidStack stack, boolean doFill){ int transmitted = 0; - if(stack != null){ + if(stack != null && this.mode != Mode.OUTPUT_ONLY){ Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj); if(network != null){ transmitted = this.transferEnergyToReceiverInNeed(from, network, stack, doFill); @@ -117,32 +138,34 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements TileEntity relayTile = this.worldObj.getTileEntity(relay); if(relayTile instanceof TileEntityLaserRelayFluids){ TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile; - boolean workedOnce = false; + if(theRelay.mode != Mode.INPUT_ONLY){ + boolean workedOnce = false; - for(EnumFacing facing : theRelay.receiversAround.keySet()){ - if(theRelay != this || facing != from){ - TileEntity tile = theRelay.receiversAround.get(facing); + for(EnumFacing facing : theRelay.handlersAround.keySet()){ + if(theRelay != this || facing != from){ + TileEntity tile = theRelay.handlersAround.get(facing); - EnumFacing opp = facing.getOpposite(); - if(tile instanceof net.minecraftforge.fluids.IFluidHandler){ - net.minecraftforge.fluids.IFluidHandler iHandler = (net.minecraftforge.fluids.IFluidHandler)tile; - if(iHandler.canFill(opp, stack.getFluid()) && iHandler.fill(opp, stack, false) > 0){ - totalReceiverAmount++; - workedOnce = true; + EnumFacing opp = facing.getOpposite(); + if(tile instanceof net.minecraftforge.fluids.IFluidHandler){ + net.minecraftforge.fluids.IFluidHandler iHandler = (net.minecraftforge.fluids.IFluidHandler)tile; + if(iHandler.canFill(opp, stack.getFluid()) && iHandler.fill(opp, stack, false) > 0){ + totalReceiverAmount++; + workedOnce = true; + } } - } - else if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){ - IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp); - if(cap != null && cap.fill(stack, false) > 0){ - totalReceiverAmount++; - workedOnce = true; + else if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){ + IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp); + if(cap != null && cap.fill(stack, false) > 0){ + totalReceiverAmount++; + workedOnce = true; + } } } } - } - if(workedOnce){ - relaysThatWork.add(theRelay); + if(workedOnce){ + relaysThatWork.add(theRelay); + } } } } @@ -156,7 +179,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements } for(TileEntityLaserRelayFluids theRelay : relaysThatWork){ - for(Map.Entry receiver : theRelay.receiversAround.entrySet()){ + for(Map.Entry receiver : theRelay.handlersAround.entrySet()){ if(receiver != null){ EnumFacing side = receiver.getKey(); EnumFacing opp = side.getOpposite(); @@ -219,4 +242,42 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements public FluidTankInfo[] getTankInfo(EnumFacing from){ return new FluidTankInfo[0]; } + + @Override + @SideOnly(Side.CLIENT) + public String getExtraDisplayString(){ + return "Fluid Flow: "+TextFormatting.DARK_RED+this.mode.name+TextFormatting.RESET; + } + + @Override + @SideOnly(Side.CLIENT) + public String getCompassDisplayString(){ + return TextFormatting.GREEN+"Right-Click to change!"; + } + + @Override + public void onCompassAction(EntityPlayer player){ + this.mode = this.mode.getNext(); + } + + @Override + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + + if(type != NBTType.SAVE_BLOCK){ + compound.setString("Mode", this.mode.toString()); + } + } + + @Override + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + + if(type != NBTType.SAVE_BLOCK){ + String modeStrg = compound.getString("Mode"); + if(modeStrg != null && !modeStrg.isEmpty()){ + this.mode = Mode.valueOf(modeStrg); + } + } + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index c1e34dccb..23e7a3780 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -16,11 +16,15 @@ import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.Network; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; @@ -124,6 +128,29 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ } } + @Override + @SideOnly(Side.CLIENT) + public String getExtraDisplayString(){ + return "Priority: "+TextFormatting.DARK_RED+this.getPriority()+TextFormatting.RESET; + } + + @Override + @SideOnly(Side.CLIENT) + public String getCompassDisplayString(){ + return TextFormatting.GREEN+"Right-Click to increase! \nSneak-Right-Click to decrease!"; + } + + @Override + public void onCompassAction(EntityPlayer player){ + if(player.isSneaking()){ + this.priority--; + } + else{ + this.priority++; + } + } + + @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(compound, type); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 1e3af653f..a9a3d24a8 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -922,6 +922,7 @@ booklet.actuallyadditions.chapter.hairBalls.text.2=Balls of Fur are an booklet.actuallyadditions.chapter.laserIntro.name=Intro to Laser Relays booklet.actuallyadditions.chapter.laserIntro.text.1=Laser Relays exist in different variants, however, they all have the same basic functionality. A Laser Relay can be connected to one ore more other laser relays using a Laser Wrench. This can be achieved by right-clicking the first relay and then right-clicking the second one. There can be an infinite number of interconnected Laser Relays, making what is called a Network or System. Such a network will have no predefined starting or end point, but instead, booklet.actuallyadditions.chapter.laserIntro.text.2=every Laser Relay has access to interact with all of the other ones in different ways. Connecting two Laser Relays has some restrictions, however. First of all, two connected Laser Relays must be at most blocks apart from each other. Additionally, two Laser Relays of a different type cannot be connected to one another. View the other items in this chapter to find out more about different types of Laser Relays! +booklet.actuallyadditions.chapter.laserIntro.text.3=Hovering over Laser Relays with the Laser Wrench will also bring up useful information like the energy flow configuration or the priority configuration. booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays booklet.actuallyadditions.chapter.laserRelays.text.1=The Energy Laser Relay is a block that can wirelessly transfer RF (or Tesla). When placing a Power Generator or Receiver next to the relay, it can receive Power from any other relay in the network and send power to any other relay as well. During an energy transfer, they have a light Energy Loss, but nothing to worry about. @@ -1048,7 +1049,7 @@ booklet.actuallyadditions.chapter.empowerer.text.3=Because every mod booklet.actuallyadditions.chapter.empowerer.text.4=The Display Stand can also be used for other things! See the Blocks that use RF section for more info about it! booklet.actuallyadditions.chapter.fluidLaser.name=Fluid Laser Relays -booklet.actuallyadditions.chapter.fluidLaser.text.1=The Fluid Laser Relays work much in the same way that normal Laser Relays do, however the thing that makes the Fluid Laser Relay different from the Energy Laser Relay, however, is that it transfers fluids from internal tanks of blocks into other blocks. Fluid Laser Relays can not be connected by Phantomfaces. +booklet.actuallyadditions.chapter.fluidLaser.text.1=The Fluid Laser Relays work much in the same way that normal Laser Relays do, however the thing that makes the Fluid Laser Relay different from the Energy Laser Relay, however, is that it transfers fluids from internal tanks of blocks into other blocks. Fluid Laser Relays can not be connected by Phantomfaces. Note that when they are toggled to Only out of adjacent Blocks mode, they will actively pull fluids out of containers around them. booklet.actuallyadditions.chapter.distributorItem.name=Item Distributor booklet.actuallyadditions.chapter.distributorItem.text.1=The Item Distributor is a simple way to split up items and make them go in different directions. The distributor will pull items into it from the top by itself, and then split them up and put them out into inventories connected to all of the other sides of it. It tries to do split the items equally, however this works best when inputting one item at a time, which its pulling feature does automatically.