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 6d0039d5b..014b9fb8b 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; @@ -158,25 +159,22 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{ @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ ItemStack stack = player.getHeldItem(hand); - TileEntityLaserRelay tile = (TileEntityLaserRelay)world.getTileEntity(pos); - if(tile instanceof TileEntityLaserRelayItem){ - TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile; + TileEntity tile = world.getTileEntity(pos); + if(tile instanceof TileEntityLaserRelay){ + TileEntityLaserRelay relay = (TileEntityLaserRelay)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; } @@ -211,23 +209,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.world != null){ - TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); - if(tile instanceof TileEntityLaserRelayItem){ - TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile; + if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null && StackUtil.isValid(stack)){ + boolean compass = stack.getItem() instanceof ItemCompass; + if(compass || stack.getItem() instanceof ItemLaserWrench){ + TileEntity tile = minecraft.world.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 3947e7154..50ecc32a0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -187,7 +187,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[8] = 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[8] = 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, "page_laser_relay", 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, "pageItemLaserRelayFail", 84), new PagePicture(5, "pageItemLaserRelayTransfer", 78), new PagePicture(6, "pageItemLaserRelayWhitelistChest", 76), new PagePicture(7, "pageItemLaserRelayWhitelistInterface", 75), new PagePicture(8, "pageItemLaserRelaySystem", 75), new PageTextOnly(9), new PageCrafting(10, BlockCrafting.recipeLaserRelayItem).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 PageCrafting(2, BlockCrafting.recipeFluidLaser).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 8ebe5068f..0936413a5 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.apiimpl.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 2d9e05795..9459c9159 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -18,12 +18,17 @@ 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.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; @@ -35,6 +40,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ public static final int CAP = 1000; public final ConcurrentHashMap receiversAround = new ConcurrentHashMap(); + private Mode mode = Mode.BOTH; private final IEnergyStorage[] energyStorages = new IEnergyStorage[6]; @@ -84,7 +90,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ 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.world); if(network != null){ transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate); @@ -147,16 +153,17 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ TileEntity relayTile = this.world.getTileEntity(relay); if(relayTile instanceof TileEntityLaserRelayEnergy){ TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile; + if(theRelay.mode != Mode.INPUT_ONLY){ + int amount = theRelay.receiversAround.size(); + if(theRelay == this && theRelay.receiversAround.containsKey(from)){ + //So that the tile energy was gotten from isn't factored into the amount + amount--; + } - int amount = theRelay.receiversAround.size(); - if(theRelay == this && theRelay.receiversAround.containsKey(from)){ - //So that the tile energy was gotten from isn't factored into the amount - amount--; - } - - if(amount > 0){ - relaysThatWork.add(theRelay); - totalReceiverAmount += amount; + if(amount > 0){ + relaysThatWork.add(theRelay); + totalReceiverAmount += amount; + } } } } @@ -236,4 +243,64 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ 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 e99ea93e5..d2ada896d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java @@ -14,13 +14,19 @@ 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 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.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidTankProperties; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; import java.util.HashMap; @@ -31,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap; public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements ISharingFluidHandler{ public final ConcurrentHashMap receiversAround = new ConcurrentHashMap(); + private Mode mode = Mode.BOTH; private final IFluidHandler[] fluidHandlers = new IFluidHandler[6]; @@ -119,7 +126,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements private int transmitFluid(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.world); if(network != null){ transmitted = this.transferFluidToReceiverInNeed(from, network, stack, doFill); @@ -143,16 +150,17 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements TileEntity relayTile = this.world.getTileEntity(relay); if(relayTile instanceof TileEntityLaserRelayFluids){ TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile; + if(theRelay.mode != Mode.INPUT_ONLY){ + int amount = theRelay.receiversAround.size(); + if(theRelay == this && theRelay.receiversAround.containsKey(from)){ + //So that the tile energy was gotten from isn't factored into the amount + amount--; + } - int amount = theRelay.receiversAround.size(); - if(theRelay == this && theRelay.receiversAround.containsKey(from)){ - //So that the tile energy was gotten from isn't factored into the amount - amount--; - } - - if(amount > 0){ - relaysThatWork.add(theRelay); - totalReceiverAmount += amount; + if(amount > 0){ + relaysThatWork.add(theRelay); + totalReceiverAmount += amount; + } } } } @@ -196,4 +204,42 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements return transmitted; } + + @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 a4e2a37ea..d36cf1e42 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,28 @@ 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 98cb5ccd6..fee6b60dc 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -944,6 +944,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 CF. 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 slight Energy Loss, but nothing to worry about, especially because it's per transfer, so it doesn't matter how many Lasers are inbetween two machines, the loss will always be the same amount.