Skip to content

Commit

Permalink
sa
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Sep 23, 2024
1 parent c4b52be commit 2dc10da
Showing 1 changed file with 8 additions and 47 deletions.
55 changes: 8 additions & 47 deletions src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package tectech.thing.metaTileEntity.pipe;


import static gregtech.api.enums.Dyes.MACHINE_METAL;
import static net.minecraft.util.StatCollector.translateToLocal;


import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
Expand All @@ -15,7 +12,6 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;


import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.GTMod;
Expand All @@ -38,34 +34,27 @@
import tectech.mechanics.pipe.PipeActivityMessage;
import tectech.util.CommonValues;


public class MTEPipeEnergy extends MetaPipeEntity implements IConnectsToEnergyTunnel, IActivePipe {


static Textures.BlockIcons.CustomIcon EMcandy, EMCandyActive;
private static Textures.BlockIcons.CustomIcon EMpipe;
public byte connectionCount = 0;


private boolean active;


public MTEPipeEnergy(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, 0);
}


public MTEPipeEnergy(String aName) {
super(aName, 0);
}


@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) {
return new MTEPipeEnergy(mName);
}


@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister aBlockIconRegister) {
Expand All @@ -75,49 +64,42 @@ public void registerIcons(IIconRegister aBlockIconRegister) {
super.registerIcons(aBlockIconRegister);
}


@Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections,
int colorIndex, boolean aConnected, boolean aRedstone) {
int colorIndex, boolean aConnected, boolean aRedstone) {
return new ITexture[] { new GTRenderedTexture(EMpipe),
new GTRenderedTexture(
getActive() ? EMCandyActive : EMcandy,
Dyes.getModulation(colorIndex, MACHINE_METAL.getRGBA())) };
}


@Override
public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side,
ItemStack itemStack) {
ItemStack itemStack) {
return false;
}


@Override
public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side,
ItemStack itemStack) {
ItemStack itemStack) {
return false;
}


@Override
public void onBlockDestroyed() {
this.updateNetwork();
super.onBlockDestroyed();
}


@Override
public void onServerStart() {
this.updateNetwork();
super.onServerStart();
}


public void updateNetwork() {
IGregTechTileEntity aBaseMetaTileEntity = this.getBaseMetaTileEntity();


if (active) {
active = false;
}
Expand All @@ -129,7 +111,6 @@ public void updateNetwork() {
for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
final ForgeDirection oppositeSide = side.getOpposite();


TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side);
if (tTileEntity instanceof IColoredTileEntity) {
byte tColor = ((IColoredTileEntity) tTileEntity).getColorization();
Expand All @@ -138,7 +119,6 @@ public void updateNetwork() {
}
}


if (tTileEntity instanceof PowerLogicHost) {
PowerLogic logic = ((PowerLogicHost) tTileEntity).getPowerLogic(oppositeSide);
if (logic != null && logic.canUseLaser()) {
Expand All @@ -148,47 +128,41 @@ public void updateNetwork() {
}
}


if (tTileEntity instanceof IConnectsToEnergyTunnel
&& ((IConnectsToEnergyTunnel) tTileEntity).canConnect(oppositeSide)) {
mConnections |= 1 << side.ordinal();
connectionCount++;
} else if (tTileEntity instanceof IGregTechTileEntity
&& ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IConnectsToEnergyTunnel) {
if (((IConnectsToEnergyTunnel) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())
.canConnect(oppositeSide)) {
mConnections |= 1 << side.ordinal();
connectionCount++;
if (((IConnectsToEnergyTunnel) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())
.canConnect(oppositeSide)) {
mConnections |= 1 << side.ordinal();
connectionCount++;
}
}
}
}
}


@Override
public void loadNBTData(NBTTagCompound nbtTagCompound) {
active = nbtTagCompound.getBoolean("eActive");
}


@Override
public void saveNBTData(NBTTagCompound nbtTagCompound) {
nbtTagCompound.setBoolean("eActive", active);
}


@Override
public boolean renderInside(ForgeDirection side) {
return false;
}


@Override
public byte getTileEntityBaseType() {
return 4;
}


@Override
public String[] getDescription() {
return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.pipe.energystream.desc.0"), // Laser
Expand All @@ -204,13 +178,11 @@ public String[] getDescription() {
};
}


@Override
public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
this.updateNetwork();
}


@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (aBaseMetaTileEntity.isServerSide()) {
Expand All @@ -230,14 +202,12 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
}
}


@Override
public void onColorChangeServer(byte aColor) {
this.updateNetwork();
super.onColorChangeServer(aColor);
}


@Override
public void setActive(boolean state) {
if (state != active) {
Expand All @@ -246,25 +216,21 @@ public void setActive(boolean state) {
}
}


@Override
public boolean getActive() {
return active;
}


@Override
public void markUsed() {
this.active = true;
}


@Override
public boolean canConnect(ForgeDirection side) {
return true;
}


@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
float tSpace = (1f - 0.5f) / 2;
Expand All @@ -275,7 +241,6 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int a
float tSide4 = tSpace;
float tSide5 = 1f - tSpace;


if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) {
tSide0 = tSide2 = tSide4 = 0;
tSide3 = tSide5 = 1;
Expand All @@ -301,7 +266,6 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int a
tSide1 = tSide3 = tSide5 = 1;
}


byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections;
if ((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) {
tSide0 = 0f;
Expand All @@ -322,12 +286,10 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int a
tSide5 = 1f;
}


return AxisAlignedBB
.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3);
}


@Override
public float getThickNess() {
if (GTMod.instance.isClientSide() && GTClient.hideValue == 1) {
Expand All @@ -336,5 +298,4 @@ public float getThickNess() {
return 0.5f;
}


}

0 comments on commit 2dc10da

Please sign in to comment.