mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Added Laser Relay in/out config
This commit is contained in:
parent
1de62f5dc7
commit
5776ac2fa0
7 changed files with 202 additions and 50 deletions
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
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.items.ItemLaserWrench;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
|
@ -158,17 +159,13 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
|
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);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
TileEntityLaserRelay tile = (TileEntityLaserRelay)world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityLaserRelayItem){
|
if(tile instanceof TileEntityLaserRelay){
|
||||||
TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile;
|
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||||
|
|
||||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){
|
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){
|
||||||
if(player.isSneaking()){
|
if(!world.isRemote){
|
||||||
relay.priority--;
|
relay.onCompassAction(player);
|
||||||
}
|
|
||||||
else{
|
|
||||||
relay.priority++;
|
|
||||||
}
|
|
||||||
|
|
||||||
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(relay.getPos(), relay.getWorld());
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(relay.getPos(), relay.getWorld());
|
||||||
if(network != null){
|
if(network != null){
|
||||||
|
@ -177,6 +174,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
|
|
||||||
relay.markDirty();
|
relay.markDirty();
|
||||||
relay.sendUpdate();
|
relay.sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -211,17 +209,19 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
||||||
if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null){
|
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());
|
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||||
if(tile instanceof TileEntityLaserRelayItem){
|
if(tile instanceof TileEntityLaserRelay){
|
||||||
TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile;
|
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||||
|
|
||||||
String strg = "Priority: "+TextFormatting.DARK_RED+relay.getPriority()+TextFormatting.RESET;
|
String strg = relay.getExtraDisplayString();
|
||||||
minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
|
minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
|
|
||||||
String expl;
|
String expl;
|
||||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){
|
if(compass){
|
||||||
expl = TextFormatting.GREEN+"Right-Click to increase! \nSneak-Right-Click to decrease!";
|
expl = relay.getCompassDisplayString();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!";
|
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!";
|
||||||
|
@ -231,6 +231,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public enum Type{
|
public enum Type{
|
||||||
ENERGY_BASIC,
|
ENERGY_BASIC,
|
||||||
|
|
|
@ -187,7 +187,7 @@ public final class InitBooklet{
|
||||||
new BookletChapter("lensMining", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMiningLens), new PageTextOnly(1).addTextReplacement("<energy>", LensMining.ENERGY_USE), new PageCrafting(2, ItemCrafting.recipeMiningLens).setNoText()).setImportant();
|
new BookletChapter("lensMining", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMiningLens), new PageTextOnly(1).addTextReplacement("<energy>", LensMining.ENERGY_USE), new PageCrafting(2, ItemCrafting.recipeMiningLens).setNoText()).setImportant();
|
||||||
|
|
||||||
//Laser Relays
|
//Laser Relays
|
||||||
chaptersIntroduction[8] = new BookletChapter("laserIntro", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitItems.itemLaserWrench), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("<range>", 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("<range>", 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("<cap1>", TileEntityLaserRelayEnergy.CAP).addTextReplacement("<cap2>", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("<cap3>", 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("laserRelays", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1), new PageTextOnly(2).addTextReplacement("<cap1>", TileEntityLaserRelayEnergy.CAP).addTextReplacement("<cap2>", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("<cap3>", 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("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());
|
new BookletChapter("fluidLaser", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayFluids), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFluidLaser).setNoText());
|
||||||
|
|
|
@ -15,9 +15,12 @@ import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.ConnectionPair;
|
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.ConnectionPair;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -130,4 +133,12 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||||
public AxisAlignedBB getRenderBoundingBox(){
|
public AxisAlignedBB getRenderBoundingBox(){
|
||||||
return INFINITE_EXTENT_AABB;
|
return INFINITE_EXTENT_AABB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public abstract String getExtraDisplayString();
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public abstract String getCompassDisplayString();
|
||||||
|
|
||||||
|
public abstract void onCompassAction(EntityPlayer player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,17 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
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.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.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -35,6 +40,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
|
||||||
|
|
||||||
public static final int CAP = 1000;
|
public static final int CAP = 1000;
|
||||||
public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
||||||
|
private Mode mode = Mode.BOTH;
|
||||||
|
|
||||||
private final IEnergyStorage[] energyStorages = new IEnergyStorage[6];
|
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){
|
private int transmitEnergy(EnumFacing from, int maxTransmit, boolean simulate){
|
||||||
int transmitted = 0;
|
int transmitted = 0;
|
||||||
if(maxTransmit > 0){
|
if(maxTransmit > 0 && this.mode != Mode.OUTPUT_ONLY){
|
||||||
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.world);
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.world);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate);
|
transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate);
|
||||||
|
@ -147,7 +153,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
|
||||||
TileEntity relayTile = this.world.getTileEntity(relay);
|
TileEntity relayTile = this.world.getTileEntity(relay);
|
||||||
if(relayTile instanceof TileEntityLaserRelayEnergy){
|
if(relayTile instanceof TileEntityLaserRelayEnergy){
|
||||||
TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile;
|
TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile;
|
||||||
|
if(theRelay.mode != Mode.INPUT_ONLY){
|
||||||
int amount = theRelay.receiversAround.size();
|
int amount = theRelay.receiversAround.size();
|
||||||
if(theRelay == this && theRelay.receiversAround.containsKey(from)){
|
if(theRelay == this && theRelay.receiversAround.containsKey(from)){
|
||||||
//So that the tile energy was gotten from isn't factored into the amount
|
//So that the tile energy was gotten from isn't factored into the amount
|
||||||
|
@ -162,6 +168,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
|
if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
|
||||||
int amountPer = maxTransfer/totalReceiverAmount;
|
int amountPer = maxTransfer/totalReceiverAmount;
|
||||||
|
@ -236,4 +243,64 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
|
||||||
public double getLossPercentage(){
|
public double getLossPercentage(){
|
||||||
return 5;
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,13 +14,19 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
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.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.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -31,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements ISharingFluidHandler{
|
public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements ISharingFluidHandler{
|
||||||
|
|
||||||
public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
public final ConcurrentHashMap<EnumFacing, TileEntity> receiversAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
||||||
|
private Mode mode = Mode.BOTH;
|
||||||
|
|
||||||
private final IFluidHandler[] fluidHandlers = new IFluidHandler[6];
|
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){
|
private int transmitFluid(EnumFacing from, FluidStack stack, boolean doFill){
|
||||||
int transmitted = 0;
|
int transmitted = 0;
|
||||||
if(stack != null){
|
if(stack != null && this.mode != Mode.OUTPUT_ONLY){
|
||||||
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.world);
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.world);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
transmitted = this.transferFluidToReceiverInNeed(from, network, stack, doFill);
|
transmitted = this.transferFluidToReceiverInNeed(from, network, stack, doFill);
|
||||||
|
@ -143,7 +150,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
TileEntity relayTile = this.world.getTileEntity(relay);
|
TileEntity relayTile = this.world.getTileEntity(relay);
|
||||||
if(relayTile instanceof TileEntityLaserRelayFluids){
|
if(relayTile instanceof TileEntityLaserRelayFluids){
|
||||||
TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile;
|
TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile;
|
||||||
|
if(theRelay.mode != Mode.INPUT_ONLY){
|
||||||
int amount = theRelay.receiversAround.size();
|
int amount = theRelay.receiversAround.size();
|
||||||
if(theRelay == this && theRelay.receiversAround.containsKey(from)){
|
if(theRelay == this && theRelay.receiversAround.containsKey(from)){
|
||||||
//So that the tile energy was gotten from isn't factored into the amount
|
//So that the tile energy was gotten from isn't factored into the amount
|
||||||
|
@ -158,6 +165,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
|
if(totalReceiverAmount > 0 && !relaysThatWork.isEmpty()){
|
||||||
int amountPer = stack.amount/totalReceiverAmount;
|
int amountPer = stack.amount/totalReceiverAmount;
|
||||||
|
@ -196,4 +204,42 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
|
|
||||||
return transmitted;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,15 @@ import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||||
import de.ellpeck.actuallyadditions.api.laser.Network;
|
import de.ellpeck.actuallyadditions.api.laser.Network;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewer.GenericItemHandlerInfo;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
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.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.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
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
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||||
super.readSyncableNBT(compound, type);
|
super.readSyncableNBT(compound, type);
|
||||||
|
|
|
@ -944,6 +944,7 @@ booklet.actuallyadditions.chapter.hairBalls.text.2=<item>Balls of Fur<r> are an
|
||||||
booklet.actuallyadditions.chapter.laserIntro.name=Intro to Laser Relays
|
booklet.actuallyadditions.chapter.laserIntro.name=Intro to Laser Relays
|
||||||
booklet.actuallyadditions.chapter.laserIntro.text.1=<item>Laser Relays<r> exist in <imp>different variants<r>, however, they all have the same basic functionality. <n>A <item>Laser Relay<r> can be connected to one ore more other laser relays using a <item>Laser Wrench<r>. This can be achieved by <imp>right-clicking<r> the first relay and then right-clicking the second one. There can be an <imp>infinite number<r> of interconnected Laser Relays, making what is called a <item>Network<r> or <item>System<r>. Such a network will have no predefined starting or end point, but instead,
|
booklet.actuallyadditions.chapter.laserIntro.text.1=<item>Laser Relays<r> exist in <imp>different variants<r>, however, they all have the same basic functionality. <n>A <item>Laser Relay<r> can be connected to one ore more other laser relays using a <item>Laser Wrench<r>. This can be achieved by <imp>right-clicking<r> the first relay and then right-clicking the second one. There can be an <imp>infinite number<r> of interconnected Laser Relays, making what is called a <item>Network<r> or <item>System<r>. Such a network will have no predefined starting or end point, but instead,
|
||||||
booklet.actuallyadditions.chapter.laserIntro.text.2=every <item>Laser Relay<r> has <imp>access to interact with all of the other ones<r> in different ways. <n>Connecting two <item>Laser Relays<r> has some restrictions, however. First of all, two connected <item>Laser Relays<r> must be <imp>at most <range> blocks apart<r> from each other. <n>Additionally, two <item>Laser Relays<r> of a <imp>different type<r> cannot be connected to one another. <n><n><i>View the other items in this chapter to find out more about different types of Laser Relays!
|
booklet.actuallyadditions.chapter.laserIntro.text.2=every <item>Laser Relay<r> has <imp>access to interact with all of the other ones<r> in different ways. <n>Connecting two <item>Laser Relays<r> has some restrictions, however. First of all, two connected <item>Laser Relays<r> must be <imp>at most <range> blocks apart<r> from each other. <n>Additionally, two <item>Laser Relays<r> of a <imp>different type<r> cannot be connected to one another. <n><n><i>View the other items in this chapter to find out more about different types of Laser Relays!
|
||||||
|
booklet.actuallyadditions.chapter.laserIntro.text.3=<imp>Hovering over<r> Laser Relays with the <item>Laser Wrench<r> will also bring up useful information like the <imp>energy flow configuration<r> or the <imp>priority configuration<r>.
|
||||||
|
|
||||||
booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays
|
booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays
|
||||||
booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Energy Laser Relay<r> is a block that can <imp>wirelessly transfer CF<r>. <n>When placing a Power Generator or Receiver next to the relay, it can receive Power <imp>from any other relay<r> in the network and send power <imp>to any other relay<r> as well. <n>During an energy transfer, they have a slight <imp>Energy Loss<r>, but nothing to worry about, especially because it's <imp>per transfer<r>, so it doesn't matter how many Lasers are inbetween two machines, the loss will <imp>always be the same amount<r>.
|
booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Energy Laser Relay<r> is a block that can <imp>wirelessly transfer CF<r>. <n>When placing a Power Generator or Receiver next to the relay, it can receive Power <imp>from any other relay<r> in the network and send power <imp>to any other relay<r> as well. <n>During an energy transfer, they have a slight <imp>Energy Loss<r>, but nothing to worry about, especially because it's <imp>per transfer<r>, so it doesn't matter how many Lasers are inbetween two machines, the loss will <imp>always be the same amount<r>.
|
||||||
|
|
Loading…
Reference in a new issue