mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-27 01:08:34 +01:00
Add laser relay sidedness config and fluid laser outputting
This commit is contained in:
parent
1310bdc2c4
commit
ac13e6c243
7 changed files with 244 additions and 75 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;
|
||||||
|
@ -141,24 +142,21 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile;
|
TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)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){
|
||||||
network.changeAmount++;
|
network.changeAmount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
relay.markDirty();
|
relay.markDirty();
|
||||||
relay.sendUpdate();
|
relay.sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(relay instanceof TileEntityLaserRelayItemWhitelist && player.isSneaking()){
|
else if(relay instanceof TileEntityLaserRelayItemWhitelist){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
@ -189,23 +187,26 @@ 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.theWorld != null){
|
if(posHit != null && posHit.getBlockPos() != null && minecraft.theWorld != null && StackUtil.isValid(stack)){
|
||||||
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.getBlockPos());
|
boolean compass = stack.getItem() instanceof ItemCompass;
|
||||||
if(tile instanceof TileEntityLaserRelayItem){
|
if(compass || stack.getItem() instanceof ItemLaserWrench){
|
||||||
TileEntityLaserRelayItem relay = (TileEntityLaserRelayItem)tile;
|
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;
|
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{
|
||||||
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,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[7] = 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[7] = 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, "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("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, "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("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());
|
new BookletChapter("fluidLaser", ActuallyAdditionsAPI.entryLaserRelays, new ItemStack(InitBlocks.blockLaserRelayFluids), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeFluidLaser).setWildcard().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.ConnectionPair;
|
import de.ellpeck.actuallyadditions.mod.misc.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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,15 @@ 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.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;
|
||||||
|
@ -34,6 +39,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
public TileEntityLaserRelayEnergy(String name){
|
public TileEntityLaserRelayEnergy(String name){
|
||||||
super(name, LaserType.ENERGY);
|
super(name, LaserType.ENERGY);
|
||||||
|
@ -60,7 +66,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
||||||
|
|
||||||
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.worldObj);
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate);
|
transmitted = this.transferEnergyToReceiverInNeed(from, network, maxTransmit, simulate);
|
||||||
|
@ -123,32 +129,34 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
||||||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||||
if(relayTile instanceof TileEntityLaserRelayEnergy){
|
if(relayTile instanceof TileEntityLaserRelayEnergy){
|
||||||
TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile;
|
TileEntityLaserRelayEnergy theRelay = (TileEntityLaserRelayEnergy)relayTile;
|
||||||
boolean workedOnce = false;
|
if(theRelay.mode != Mode.INPUT_ONLY){
|
||||||
|
boolean workedOnce = false;
|
||||||
|
|
||||||
for(EnumFacing facing : theRelay.receiversAround.keySet()){
|
for(EnumFacing facing : theRelay.receiversAround.keySet()){
|
||||||
if(theRelay != this || facing != from){
|
if(theRelay != this || facing != from){
|
||||||
TileEntity tile = theRelay.receiversAround.get(facing);
|
TileEntity tile = theRelay.receiversAround.get(facing);
|
||||||
|
|
||||||
EnumFacing opp = facing.getOpposite();
|
EnumFacing opp = facing.getOpposite();
|
||||||
if(tile instanceof IEnergyReceiver){
|
if(tile instanceof IEnergyReceiver){
|
||||||
IEnergyReceiver iReceiver = (IEnergyReceiver)tile;
|
IEnergyReceiver iReceiver = (IEnergyReceiver)tile;
|
||||||
if(iReceiver.canConnectEnergy(opp) && iReceiver.receiveEnergy(opp, Integer.MAX_VALUE, true) > 0){
|
if(iReceiver.canConnectEnergy(opp) && iReceiver.receiveEnergy(opp, Integer.MAX_VALUE, true) > 0){
|
||||||
totalReceiverAmount++;
|
totalReceiverAmount++;
|
||||||
workedOnce = true;
|
workedOnce = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
|
||||||
else if(ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaConsumer, opp)){
|
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
|
||||||
ITeslaConsumer cap = tile.getCapability(TeslaUtil.teslaConsumer, opp);
|
if(cap != null && cap.givePower(maxTransfer, true) > 0){
|
||||||
if(cap != null && cap.givePower(maxTransfer, true) > 0){
|
totalReceiverAmount++;
|
||||||
totalReceiverAmount++;
|
workedOnce = true;
|
||||||
workedOnce = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(workedOnce){
|
if(workedOnce){
|
||||||
relaysThatWork.add(theRelay);
|
relaysThatWork.add(theRelay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,4 +236,64 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay implements
|
||||||
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,14 +14,21 @@ 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 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.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.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
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.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,12 +38,26 @@ 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> handlersAround = new ConcurrentHashMap<EnumFacing, TileEntity>();
|
||||||
|
private Mode mode = Mode.BOTH;
|
||||||
|
|
||||||
public TileEntityLaserRelayFluids(){
|
public TileEntityLaserRelayFluids(){
|
||||||
super("laserRelayFluids", LaserType.FLUID);
|
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
|
@Override
|
||||||
public boolean shouldSaveDataOnChangeOrWorldStart(){
|
public boolean shouldSaveDataOnChangeOrWorldStart(){
|
||||||
return true;
|
return true;
|
||||||
|
@ -44,16 +65,16 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDataOnChangeOrWorldStart(){
|
public void saveDataOnChangeOrWorldStart(){
|
||||||
Map<EnumFacing, TileEntity> old = new HashMap<EnumFacing, TileEntity>(this.receiversAround);
|
Map<EnumFacing, TileEntity> old = new HashMap<EnumFacing, TileEntity>(this.handlersAround);
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
|
|
||||||
this.receiversAround.clear();
|
this.handlersAround.clear();
|
||||||
for(EnumFacing side : EnumFacing.values()){
|
for(EnumFacing side : EnumFacing.values()){
|
||||||
BlockPos pos = this.getPos().offset(side);
|
BlockPos pos = this.getPos().offset(side);
|
||||||
TileEntity tile = this.worldObj.getTileEntity(pos);
|
TileEntity tile = this.worldObj.getTileEntity(pos);
|
||||||
if(tile != null && !(tile instanceof TileEntityLaserRelay)){
|
if(tile != null && !(tile instanceof TileEntityLaserRelay)){
|
||||||
if(tile instanceof net.minecraftforge.fluids.IFluidHandler || tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())){
|
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);
|
TileEntity oldTile = old.get(side);
|
||||||
if(oldTile == null || !tile.equals(oldTile)){
|
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());
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.getPos(), this.getWorld());
|
||||||
if(network != null){
|
if(network != null){
|
||||||
network.changeAmount++;
|
network.changeAmount++;
|
||||||
|
@ -93,7 +114,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
|
|
||||||
private int transmitEnergy(EnumFacing from, FluidStack stack, boolean doFill){
|
private int transmitEnergy(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.worldObj);
|
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
|
||||||
if(network != null){
|
if(network != null){
|
||||||
transmitted = this.transferEnergyToReceiverInNeed(from, network, stack, doFill);
|
transmitted = this.transferEnergyToReceiverInNeed(from, network, stack, doFill);
|
||||||
|
@ -117,32 +138,34 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
TileEntity relayTile = this.worldObj.getTileEntity(relay);
|
||||||
if(relayTile instanceof TileEntityLaserRelayFluids){
|
if(relayTile instanceof TileEntityLaserRelayFluids){
|
||||||
TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile;
|
TileEntityLaserRelayFluids theRelay = (TileEntityLaserRelayFluids)relayTile;
|
||||||
boolean workedOnce = false;
|
if(theRelay.mode != Mode.INPUT_ONLY){
|
||||||
|
boolean workedOnce = false;
|
||||||
|
|
||||||
for(EnumFacing facing : theRelay.receiversAround.keySet()){
|
for(EnumFacing facing : theRelay.handlersAround.keySet()){
|
||||||
if(theRelay != this || facing != from){
|
if(theRelay != this || facing != from){
|
||||||
TileEntity tile = theRelay.receiversAround.get(facing);
|
TileEntity tile = theRelay.handlersAround.get(facing);
|
||||||
|
|
||||||
EnumFacing opp = facing.getOpposite();
|
EnumFacing opp = facing.getOpposite();
|
||||||
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
net.minecraftforge.fluids.IFluidHandler iHandler = (net.minecraftforge.fluids.IFluidHandler)tile;
|
net.minecraftforge.fluids.IFluidHandler iHandler = (net.minecraftforge.fluids.IFluidHandler)tile;
|
||||||
if(iHandler.canFill(opp, stack.getFluid()) && iHandler.fill(opp, stack, false) > 0){
|
if(iHandler.canFill(opp, stack.getFluid()) && iHandler.fill(opp, stack, false) > 0){
|
||||||
totalReceiverAmount++;
|
totalReceiverAmount++;
|
||||||
workedOnce = true;
|
workedOnce = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){
|
||||||
else if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)){
|
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp);
|
||||||
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp);
|
if(cap != null && cap.fill(stack, false) > 0){
|
||||||
if(cap != null && cap.fill(stack, false) > 0){
|
totalReceiverAmount++;
|
||||||
totalReceiverAmount++;
|
workedOnce = true;
|
||||||
workedOnce = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(workedOnce){
|
if(workedOnce){
|
||||||
relaysThatWork.add(theRelay);
|
relaysThatWork.add(theRelay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +179,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
}
|
}
|
||||||
|
|
||||||
for(TileEntityLaserRelayFluids theRelay : relaysThatWork){
|
for(TileEntityLaserRelayFluids theRelay : relaysThatWork){
|
||||||
for(Map.Entry<EnumFacing, TileEntity> receiver : theRelay.receiversAround.entrySet()){
|
for(Map.Entry<EnumFacing, TileEntity> receiver : theRelay.handlersAround.entrySet()){
|
||||||
if(receiver != null){
|
if(receiver != null){
|
||||||
EnumFacing side = receiver.getKey();
|
EnumFacing side = receiver.getKey();
|
||||||
EnumFacing opp = side.getOpposite();
|
EnumFacing opp = side.getOpposite();
|
||||||
|
@ -219,4 +242,42 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay implements
|
||||||
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
||||||
return new FluidTankInfo[0];
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,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
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||||
super.readSyncableNBT(compound, type);
|
super.readSyncableNBT(compound, type);
|
||||||
|
|
|
@ -922,6 +922,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 RF (or Tesla)<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 light <imp>Energy Loss<r>, but nothing to worry about.
|
booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Energy Laser Relay<r> is a block that can <imp>wirelessly transfer RF (or Tesla)<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 light <imp>Energy Loss<r>, but nothing to worry about.
|
||||||
|
@ -1048,7 +1049,7 @@ booklet.actuallyadditions.chapter.empowerer.text.3=<n><n><n><i>Because every mod
|
||||||
booklet.actuallyadditions.chapter.empowerer.text.4=The <item>Display Stand<r> can also be used for other things! See the <imp>Blocks that use RF<r> section for more info about it!
|
booklet.actuallyadditions.chapter.empowerer.text.4=The <item>Display Stand<r> can also be used for other things! See the <imp>Blocks that use RF<r> section for more info about it!
|
||||||
|
|
||||||
booklet.actuallyadditions.chapter.fluidLaser.name=Fluid Laser Relays
|
booklet.actuallyadditions.chapter.fluidLaser.name=Fluid Laser Relays
|
||||||
booklet.actuallyadditions.chapter.fluidLaser.text.1=The <item>Fluid Laser Relays<r> work much in the same way that normal <item>Laser Relays<r> do, however the thing that makes the <item>Fluid Laser Relay<r> different from the <item>Energy Laser Relay<r>, however, is that it transfers <imp>fluids<r> from internal tanks of blocks into other blocks. <n><n><item>Fluid Laser Relays<r> can not be connected by Phantomfaces.
|
booklet.actuallyadditions.chapter.fluidLaser.text.1=The <item>Fluid Laser Relays<r> work much in the same way that normal <item>Laser Relays<r> do, however the thing that makes the <item>Fluid Laser Relay<r> different from the <item>Energy Laser Relay<r>, however, is that it transfers <imp>fluids<r> from internal tanks of blocks into other blocks. <n><n><item>Fluid Laser Relays<r> can not be connected by Phantomfaces. <n><n>Note that when they are toggled to <imp>Only out of adjacent Blocks<r> mode, they will <imp>actively pull<r> fluids out of containers around them.
|
||||||
|
|
||||||
booklet.actuallyadditions.chapter.distributorItem.name=Item Distributor
|
booklet.actuallyadditions.chapter.distributorItem.name=Item Distributor
|
||||||
booklet.actuallyadditions.chapter.distributorItem.text.1=The <item>Item Distributor<r> is a simple way to split up items and make them go <imp>in different directions<r>. <n><n>The distributor will <imp>pull items into it from the top<r> by itself, and then split them up and <imp>put them<r> out into inventories connected to all of the <imp>other sides<r> of it. <n>It tries to do split the items <imp>equally<r>, however this works best when inputting <imp>one item at a time<r>, which its pulling feature does automatically.
|
booklet.actuallyadditions.chapter.distributorItem.text.1=The <item>Item Distributor<r> is a simple way to split up items and make them go <imp>in different directions<r>. <n><n>The distributor will <imp>pull items into it from the top<r> by itself, and then split them up and <imp>put them<r> out into inventories connected to all of the <imp>other sides<r> of it. <n>It tries to do split the items <imp>equally<r>, however this works best when inputting <imp>one item at a time<r>, which its pulling feature does automatically.
|
||||||
|
|
Loading…
Reference in a new issue