Updated IC2 Reactor laser textures by Saphyrion

This commit is contained in:
LemADEC 2015-12-12 15:57:58 +01:00
parent eabd0bd903
commit 678edd0906
7 changed files with 92 additions and 15 deletions

View file

@ -1,27 +1,22 @@
package cr0s.warpdrive.block.energy; package cr0s.warpdrive.block.energy;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockAbstractContainer;
public class BlockIC2reactorLaserMonitor extends BlockAbstractContainer {// TODO BlockAbstractContainer
static IIcon[] iconBuffer = new IIcon[3];
public class BlockIC2reactorLaserMonitor extends BlockContainer {
public BlockIC2reactorLaserMonitor() { public BlockIC2reactorLaserMonitor() {
super(Material.rock); super(Material.iron);
setHardness(0.5F); setBlockName("warpdrive.energy.IC2ReactorLaserMonitor");
setStepSound(Block.soundTypeMetal);
setCreativeTab(WarpDrive.creativeTabWarpDrive);
this.setBlockName("warpdrive.energy.IC2ReactorLaserMonitor");
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
blockIcon = par1IconRegister.registerIcon("warpdrive:energy/IC2reactorLaserMonitor");
} }
@Override @Override
@ -29,6 +24,37 @@ public class BlockIC2reactorLaserMonitor extends BlockContainer {
return new TileEntityIC2reactorLaserMonitor(); return new TileEntityIC2reactorLaserMonitor();
} }
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconBuffer[0] = par1IconRegister.registerIcon("warpdrive:energy/IC2reactorLaserMonitorNotConnected");
iconBuffer[1] = par1IconRegister.registerIcon("warpdrive:energy/IC2reactorLaserMonitorConnectedNotPowered");
iconBuffer[2] = par1IconRegister.registerIcon("warpdrive:energy/IC2reactorLaserMonitorConnectedPowered");
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
int meta = world.getBlockMetadata(x, y, z);
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity == null || !(tileEntity instanceof TileEntityIC2reactorLaserMonitor)) {
return iconBuffer[0];
}
if (((TileEntityIC2reactorLaserMonitor)tileEntity).isSideActive(side)) {
if ((meta & 8) == 0) {
return iconBuffer[1];
} else {
return iconBuffer[2];
}
}
return iconBuffer[0];
}
@Override
public IIcon getIcon(int side, int metadata) {
return iconBuffer[1];
}
/** /**
* Called upon block activation (right click on the block.) * Called upon block activation (right click on the block.)
*/ */

View file

@ -8,6 +8,9 @@ import java.util.Set;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ChunkCoordinates;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@ -21,6 +24,8 @@ import cr0s.warpdrive.network.PacketHandler;
public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy { public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
private int ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS; private int ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS;
private byte activeSides = 0;
private boolean updateFlag = false;
public TileEntityIC2reactorLaserMonitor() { public TileEntityIC2reactorLaserMonitor() {
super(); super();
@ -31,12 +36,26 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
private static int[] deltaX = {-2, 2, 0, 0, 0, 0}; private static int[] deltaX = {-2, 2, 0, 0, 0, 0};
private static int[] deltaY = { 0, 0,-2, 2, 0, 0}; private static int[] deltaY = { 0, 0,-2, 2, 0, 0};
private static int[] deltaZ = { 0, 0, 0, 0,-2, 2}; private static int[] deltaZ = { 0, 0, 0, 0,-2, 2};
private static byte[] deltaSides = { 1, 2, 4, 8, 16, 32 };
protected boolean isSideActive(int side) {
switch (side) {
case 4: return (deltaSides[0] & activeSides) != 0;
case 5: return (deltaSides[1] & activeSides) != 0;
case 0: return (deltaSides[2] & activeSides) != 0;
case 1: return (deltaSides[3] & activeSides) != 0;
case 2: return (deltaSides[4] & activeSides) != 0;
case 3: return (deltaSides[5] & activeSides) != 0;
default: return false;
}
}
// returns IReactor tile entities // returns IReactor tile entities
@Optional.Method(modid = "IC2") @Optional.Method(modid = "IC2")
private Set<IReactor> findReactors() { private Set<IReactor> findReactors() {
Set<IReactor> output = new HashSet<IReactor>(); Set<IReactor> output = new HashSet<IReactor>();
byte newActiveSides = 0;
for(int i = 0; i < deltaX.length; i++) { for(int i = 0; i < deltaX.length; i++) {
TileEntity tileEntity = worldObj.getTileEntity(xCoord + deltaX[i], yCoord + deltaY[i], zCoord + deltaZ[i]); TileEntity tileEntity = worldObj.getTileEntity(xCoord + deltaX[i], yCoord + deltaY[i], zCoord + deltaZ[i]);
if (tileEntity == null) { if (tileEntity == null) {
@ -44,6 +63,7 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
} }
if (tileEntity instanceof IReactor) { if (tileEntity instanceof IReactor) {
newActiveSides |= deltaSides[i];
output.add((IReactor)tileEntity); output.add((IReactor)tileEntity);
} else if (tileEntity instanceof IReactorChamber) { } else if (tileEntity instanceof IReactorChamber) {
@ -60,9 +80,14 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
continue; continue;
} }
newActiveSides |= deltaSides[i];
output.add(reactor); output.add(reactor);
} }
} }
if (activeSides != newActiveSides) {
updateFlag = !updateFlag;
activeSides = newActiveSides;
}
return output; return output;
} }
@ -103,6 +128,7 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS; ticks = WarpDriveConfig.IC2_REACTOR_COOLING_INTERVAL_TICKS;
Vector3 myPos = new Vector3(this).translate(0.5); Vector3 myPos = new Vector3(this).translate(0.5);
Set<IReactor> reactors = findReactors(); Set<IReactor> reactors = findReactors();
setMetadata();
if (reactors.size() == 0) { if (reactors.size() == 0) {
return; return;
} }
@ -115,14 +141,39 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
} }
} }
private void setMetadata() {
int metadata = (updateFlag ? 0 : 1) | (activeSides != 0 ? 2 : 0);
if (getEnergyStored() >= WarpDriveConfig.IC2_REACTOR_ENERGY_PER_HEAT) {
metadata |= 8;
}
if (getBlockMetadata() != metadata) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metadata, 3);
}
}
@Override @Override
public void writeToNBT(NBTTagCompound tag) { public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag); super.writeToNBT(tag);
tag.setByte("activeSides", activeSides);
} }
@Override @Override
public void readFromNBT(NBTTagCompound tag) { public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag); super.readFromNBT(tag);
activeSides = tag.getByte("activeSides");
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound tagCompound = new NBTTagCompound();
writeToNBT(tagCompound);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound);
}
@Override
public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) {
NBTTagCompound tag = packet.func_148857_g();
readFromNBT(tag);
} }
@Override @Override
@ -130,8 +181,8 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
public String getStatus() { public String getStatus() {
Set<IReactor> reactors = findReactors(); Set<IReactor> reactors = findReactors();
return getBlockType().getLocalizedName() return getBlockType().getLocalizedName()
+ String.format(" energy level is %.0f/%.0f EU.", convertInternalToEU(getEnergyStored()), convertInternalToEU(getMaxEnergyStored())) + String.format("\nEnergy level is %.0f/%.0f EU.", convertInternalToEU(getEnergyStored()), convertInternalToEU(getMaxEnergyStored()))
+ ((reactors == null || reactors.size() == 0) ? " No reactor found!" : " " + reactors.size() + " reactor(s) connected."); + "\n" + ((reactors == null || reactors.size() == 0) ? "No reactor found!" : reactors.size() + " reactor(s) connected.");
} }
@Override @Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
wiki/IC2reactorLaser.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB