Added Light P2P Tunnel
This commit is contained in:
@@ -42,7 +42,7 @@ public enum AEFeature
|
|||||||
DenseEnergyCells("HigherCapacity"), DenseCables("HigherCapacity"),
|
DenseEnergyCells("HigherCapacity"), DenseCables("HigherCapacity"),
|
||||||
|
|
||||||
P2PTunnelRF("P2PTunnels"), P2PTunnelME("P2PTunnels"), P2PTunnelItems("P2PTunnels"), P2PTunnelRedstone("P2PTunnels"), P2PTunnelEU("P2PTunnels"), P2PTunnelMJ(
|
P2PTunnelRF("P2PTunnels"), P2PTunnelME("P2PTunnels"), P2PTunnelItems("P2PTunnels"), P2PTunnelRedstone("P2PTunnels"), P2PTunnelEU("P2PTunnels"), P2PTunnelMJ(
|
||||||
"P2PTunnels"), P2PTunnelLiquids("P2PTunnels"),
|
"P2PTunnels"), P2PTunnelLiquids("P2PTunnels"), P2PTunnelLight("P2PTunnels"),
|
||||||
|
|
||||||
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
|
MassCannonBlockDamage("BlockFeatures"), TinyTNTBlockDamage("BlockFeatures"), Facades("Facades"),
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry
|
|||||||
|
|
||||||
public void configure()
|
public void configure()
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* light!
|
||||||
|
*/
|
||||||
|
addNewAttunement( new ItemStack( Blocks.torch ), TunnelType.LIGHT );
|
||||||
|
addNewAttunement( new ItemStack( Blocks.glowstone ), TunnelType.LIGHT );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* attune based on most redstone base items.
|
* attune based on most redstone base items.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public enum GuiText
|
|||||||
|
|
||||||
OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting,
|
OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting,
|
||||||
|
|
||||||
Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs;
|
Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs, LightTunnel;
|
||||||
|
|
||||||
String root;
|
String root;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ public enum TickRates
|
|||||||
|
|
||||||
StorageBus(5, 60),
|
StorageBus(5, 60),
|
||||||
|
|
||||||
ItemTunnel(5, 60);
|
ItemTunnel(5, 60),
|
||||||
|
|
||||||
|
LightTunnel(5, 120);
|
||||||
|
|
||||||
public int min;
|
public int min;
|
||||||
public int max;
|
public int max;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import appeng.parts.networking.PartQuartzFiber;
|
|||||||
import appeng.parts.p2p.PartP2PBCPower;
|
import appeng.parts.p2p.PartP2PBCPower;
|
||||||
import appeng.parts.p2p.PartP2PIC2Power;
|
import appeng.parts.p2p.PartP2PIC2Power;
|
||||||
import appeng.parts.p2p.PartP2PItems;
|
import appeng.parts.p2p.PartP2PItems;
|
||||||
|
import appeng.parts.p2p.PartP2PLight;
|
||||||
import appeng.parts.p2p.PartP2PLiquids;
|
import appeng.parts.p2p.PartP2PLiquids;
|
||||||
import appeng.parts.p2p.PartP2PRFPower;
|
import appeng.parts.p2p.PartP2PRFPower;
|
||||||
import appeng.parts.p2p.PartP2PRedstone;
|
import appeng.parts.p2p.PartP2PRedstone;
|
||||||
@@ -104,6 +105,8 @@ public enum PartType
|
|||||||
|
|
||||||
P2PTunnelRF(466, AEFeature.P2PTunnelRF, PartP2PRFPower.class, GuiText.RFTunnel),
|
P2PTunnelRF(466, AEFeature.P2PTunnelRF, PartP2PRFPower.class, GuiText.RFTunnel),
|
||||||
|
|
||||||
|
P2PTunnelLight(467, AEFeature.P2PTunnelLight, PartP2PLight.class, GuiText.LightTunnel),
|
||||||
|
|
||||||
InterfaceTerminal(480, AEFeature.InterfaceTerminal, PartInterfaceTerminal.class);
|
InterfaceTerminal(480, AEFeature.InterfaceTerminal, PartInterfaceTerminal.class);
|
||||||
|
|
||||||
private final EnumSet<AEFeature> features;
|
private final EnumSet<AEFeature> features;
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
package appeng.parts.p2p;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import appeng.api.config.TunnelType;
|
||||||
|
import appeng.api.networking.IGridNode;
|
||||||
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||||
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||||
|
import appeng.api.networking.ticking.IGridTickable;
|
||||||
|
import appeng.api.networking.ticking.TickRateModulation;
|
||||||
|
import appeng.api.networking.ticking.TickingRequest;
|
||||||
|
import appeng.core.settings.TickRates;
|
||||||
|
import appeng.me.GridAccessException;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTickable
|
||||||
|
{
|
||||||
|
|
||||||
|
public PartP2PLight(ItemStack is) {
|
||||||
|
super( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
public TunnelType getTunnelType()
|
||||||
|
{
|
||||||
|
return TunnelType.LIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lastValue = 0;
|
||||||
|
|
||||||
|
public void setLightLevel(int out)
|
||||||
|
{
|
||||||
|
lastValue = out;
|
||||||
|
getHost().markForUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightLevel()
|
||||||
|
{
|
||||||
|
if ( output && isPowered() )
|
||||||
|
return blockLight( lastValue );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int blockLight(int emit)
|
||||||
|
{
|
||||||
|
TileEntity te = this.getTile();
|
||||||
|
float opacity = 255 - te.getWorldObj().getBlockLightOpacity( te.xCoord + side.offsetX, te.yCoord + side.offsetY, te.zCoord + side.offsetZ );
|
||||||
|
return (int) (emit * (opacity / 255.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void chanRender(MENetworkChannelsChanged c)
|
||||||
|
{
|
||||||
|
onTunnelNetworkChange();
|
||||||
|
super.chanRender( c );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void powerRender(MENetworkPowerStatusChange c)
|
||||||
|
{
|
||||||
|
onTunnelNetworkChange();
|
||||||
|
super.powerRender( c );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTunnelNetworkChange()
|
||||||
|
{
|
||||||
|
if ( output )
|
||||||
|
{
|
||||||
|
PartP2PLight src = getInput();
|
||||||
|
if ( src != null && src.proxy.isActive() )
|
||||||
|
setLightLevel( src.lastValue );
|
||||||
|
else
|
||||||
|
getHost().markForUpdate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
doWork();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTunnelConfigChange()
|
||||||
|
{
|
||||||
|
onTunnelNetworkChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNeighborChanged()
|
||||||
|
{
|
||||||
|
doWork();
|
||||||
|
if ( output )
|
||||||
|
getHost().markForUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
super.writeToNBT( tag );
|
||||||
|
tag.setInteger( "lastValue", lastValue );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tag)
|
||||||
|
{
|
||||||
|
super.readFromNBT( tag );
|
||||||
|
lastValue = tag.getInteger( "lastValue" );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean readFromStream(ByteBuf data) throws IOException
|
||||||
|
{
|
||||||
|
super.readFromStream( data );
|
||||||
|
lastValue = data.readInt();
|
||||||
|
output = lastValue > 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToStream(ByteBuf data) throws IOException
|
||||||
|
{
|
||||||
|
super.writeToStream( data );
|
||||||
|
data.writeInt( output ? lastValue : 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public IIcon getTypeTexture()
|
||||||
|
{
|
||||||
|
return Blocks.quartz_block.getBlockTextureFromSide( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TickingRequest getTickingRequest(IGridNode node)
|
||||||
|
{
|
||||||
|
return new TickingRequest( TickRates.LightTunnel.min, TickRates.LightTunnel.max, false, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean doWork()
|
||||||
|
{
|
||||||
|
if ( output )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TileEntity te = getTile();
|
||||||
|
World w = te.getWorldObj();
|
||||||
|
|
||||||
|
int newLevel = w.getBlockLightValue( te.xCoord + side.offsetX, te.yCoord + side.offsetY, te.zCoord + side.offsetZ );
|
||||||
|
|
||||||
|
if ( lastValue != newLevel && proxy.isActive() )
|
||||||
|
{
|
||||||
|
lastValue = newLevel;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (PartP2PLight out : getOutputs())
|
||||||
|
out.setLightLevel( lastValue );
|
||||||
|
}
|
||||||
|
catch (GridAccessException e)
|
||||||
|
{
|
||||||
|
// :P
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
|
||||||
|
{
|
||||||
|
return doWork() ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -121,6 +121,9 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
|||||||
|
|
||||||
switch (tt)
|
switch (tt)
|
||||||
{
|
{
|
||||||
|
case LIGHT:
|
||||||
|
newType = AEApi.instance().parts().partP2PTunnelLight.stack( 1 );
|
||||||
|
break;
|
||||||
|
|
||||||
case RF_POWER:
|
case RF_POWER:
|
||||||
newType = AEApi.instance().parts().partP2PTunnelRF.stack( 1 );
|
newType = AEApi.instance().parts().partP2PTunnelRF.stack( 1 );
|
||||||
|
|||||||
Reference in New Issue
Block a user