Getting somewhere with electric lights.

This commit is contained in:
brad-c committed 2013-08-20 01:46:04 +08:00
1 parent 75fadea823
commit 68b6c2e81e
10 files changed
+528 -66

No files matched your search

+6 -2
View File
@@ -37,6 +37,7 @@ import crazypants.enderio.machine.MachineRecipes;
import crazypants.enderio.machine.alloy.BlockAlloySmelter;
import crazypants.enderio.machine.generator.BlockStirlingGenerator;
import crazypants.enderio.machine.light.BlockElectricLight;
import crazypants.enderio.machine.light.BlockLightNode;
import crazypants.enderio.machine.painter.BlockCustomFence;
import crazypants.enderio.machine.painter.BlockCustomFenceGate;
import crazypants.enderio.machine.painter.BlockCustomStair;
@@ -92,10 +93,12 @@ public class EnderIO {
// Machines
public static BlockStirlingGenerator blockStirlingGenerator;
public static BlockSolarPanel blockSolarPanel;
public static BlockElectricLight blockElectricLight;
public static BlockSolarPanel blockSolarPanel;
public static BlockReservoir blockReservoir;
public static BlockAlloySmelter blockAlloySmelter;
public static BlockElectricLight blockElectricLight;
public static BlockLightNode blockLightNode;
public static ItemYetaWrench itemYetaWench;
@@ -142,6 +145,7 @@ public class EnderIO {
itemLiquidConduit = ItemLiquidConduit.create();
blockElectricLight = BlockElectricLight.create();
blockLightNode = BlockLightNode.create();
itemYetaWench = ItemYetaWrench.create();
}
+1
View File
@@ -44,6 +44,7 @@ public enum ModObject {
blockSolarPanel(++Config.BID, CATEGORY_BLOCK, "Photovoltaic Panel"),
blockElectricLight(++Config.BID, CATEGORY_BLOCK, "Electric Light"),
blockLightNode(++Config.BID, CATEGORY_BLOCK, "Light Node (Internal Only)"),
itemYetaWrench(++Config.IID, CATEGORY_ITEM, "Yeta Wrench");
@@ -53,7 +53,11 @@ public class BlockConduitFacade extends Block {
if (id <= 0 || id == blockID) {
return blockIcon;
}
return Block.blocksList[id].getIcon(side, meta);
Block block = Block.blocksList[id];
if(block != null) {
return block.getIcon(side, meta);
}
return blockIcon;
}
@@ -29,7 +29,7 @@ import crazypants.enderio.ModObject;
import crazypants.render.IconUtil;
public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> extends BlockContainer implements IGuiHandler {
public static final Icon[] REDSTONE_CONTROL_ICONS = new Icon[RedstoneControlMode.values().length];
@SideOnly(Side.CLIENT)
@@ -44,7 +44,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
}
@Override
public int getTextureType() {
public int getTextureType() {
return 0;
}
@@ -52,8 +52,6 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
}
@SideOnly(Side.CLIENT)
public static Icon getRedstoneControlIcon(RedstoneControlMode mode) {
return REDSTONE_CONTROL_ICONS[mode.ordinal()];
@@ -156,16 +154,21 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
@SuppressWarnings("unchecked")
T te = (T) world.getBlockTileEntity(x, y, z);
if (te != null) {
dropContent(0, te, world, te.xCoord, te.yCoord, te.zCoord);
TileEntity ent = world.getBlockTileEntity(x, y, z);
if (ent != null) {
if (teClass.isAssignableFrom(ent.getClass())) {
@SuppressWarnings("unchecked")
T te = (T) world.getBlockTileEntity(x, y, z);
if (te != null) {
dropContent(0, te, world, te.xCoord, te.yCoord, te.zCoord);
}
}
}
super.breakBlock(world, x, y, z, par5, par6);
}
public void dropContent(int newSize, T inventory, World world, int xCoord, int yCoord, int zCoord) {
for (int i = newSize; i < inventory.getSizeInventory(); i++) {
for (int i = newSize; i < inventory.getSizeInventory(); i++) {
ItemStack itemstack = inventory.getStackInSlot(i);
if (itemstack == null) {
continue;
@@ -219,8 +222,11 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) {
AbstractMachineEntity te = (AbstractMachineEntity) world.getBlockTileEntity(x, y, z);
te.onNeighborBlockChange(blockId);
TileEntity ent = world.getBlockTileEntity(x, y, z);
if (ent instanceof AbstractMachineEntity) {
AbstractMachineEntity te = (AbstractMachineEntity) ent;
te.onNeighborBlockChange(blockId);
}
}
@Override
@@ -48,7 +48,7 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
setUnlocalizedName(ModObject.blockElectricLight.unlocalisedName);
setCreativeTab(EnderIOTab.tabEnderIO);
setLightOpacity(0);
setLightValue(1);
setLightValue(0);
setBlockBounds(BLOCK_EDGE_MIN, 0.0F, BLOCK_EDGE_MIN, BLOCK_EDGE_MAX, BLOCK_HEIGHT, BLOCK_EDGE_MAX);
}
@@ -99,10 +99,12 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
return renderId;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
Block block = blocksList[world.getBlockId(x, y, z)];
if (block != null && block != this) {
return block.getLightValue(world, x, y, z);
}
return world.getBlockMetadata(x, y, z) > 0 ? 15 : 0;
}
@@ -182,14 +184,27 @@ public class BlockElectricLight extends Block implements ITileEntityProvider {
((TileElectricLight) te).onNeighborBlockChange(blockID);
}
}
@Override
public boolean canPlaceBlockOnSide(World par1World, int x, int y, int z, int side) {
ForgeDirection dir = ForgeDirection.getOrientation(side);
ForgeDirection op = dir.getOpposite();
return par1World.isBlockSolidOnSide(x + op.offsetX, y + op.offsetY, z + op.offsetZ, dir);
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
System.out.println("BlockLightNode.breakBlock: ");
TileElectricLight te = (TileElectricLight) world.getBlockTileEntity(x, y, z);
if (te != null) {
System.out.println("BlockElectricLight.breakBlock: Got tile entity");
te.onBlockRemoved();
} else {
System.out.println("BlockElectricLight.breakBlock: No tile entity");
}
world.removeBlockTileEntity(x, y, z);
}
// @Override
// public boolean canPlaceBlockOnSide(World par1World, int x, int y, int z, int side) {
// ForgeDirection dir = ForgeDirection.getOrientation(side);
// ForgeDirection op = dir.getOpposite();
// return par1World.isBlockSolidOnSide(x + op.offsetX, y + op.offsetY, z + op.offsetZ, dir);
// }
@Override
public TileEntity createNewTileEntity(World world) {
return new TileElectricLight();
@@ -0,0 +1,171 @@
package crazypants.enderio.machine.light;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIOTab;
import crazypants.enderio.ModObject;
import crazypants.enderio.conduit.IConduitBundle;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class BlockLightNode extends Block implements ITileEntityProvider {
public static BlockLightNode create() {
BlockLightNode result = new BlockLightNode();
result.init();
return result;
}
public BlockLightNode() {
super(ModObject.blockLightNode.id, Material.rock);
setHardness(2.0F);
setStepSound(soundGlassFootstep);
setUnlocalizedName(ModObject.blockLightNode.unlocalisedName);
setLightOpacity(0);
setLightValue(0);
//setBlockBounds(0.45f, 0.45F, 0.45f, 0.55f, 0.55f, 0.55f);
setBlockBounds(0,0,0,0,0,0);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) {
setBlockBounds(0,0,0,0,0,0);
}
@Override
public void setBlockBoundsForItemRender() {
setBlockBounds(0,0,0,0,0,0);
}
@Override
public boolean isBlockSolid(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return false;
}
@Override
public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) {
return false;
}
@Override
public boolean isBlockReplaceable(World world, int x, int y, int z) {
return true;
}
// @Override
// public MovingObjectPosition collisionRayTrace(World world, int x, int y,
// int z, Vec3 origin, Vec3 direction) {
// return null;
// }
// @Override
// public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int
// y, int z) {
// return null;
// }
public boolean canCollideCheck(int par1, boolean par2) {
return false;
}
public boolean isCollidable() {
return false;
}
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z,
AxisAlignedBB axisalignedbb, @SuppressWarnings("rawtypes") List arraylist,
Entity par7Entity) {
setBlockBounds(0,0,0,0,0,0);
super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist,
par7Entity);
setBlockBounds(0,0,0,0,0,0);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y ,z , x, y , z);
}
@Override
@SideOnly(Side.CLIENT)
public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public boolean addBlockDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) {
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
TileLightNode te = (TileLightNode) world.getBlockTileEntity(x, y, z);
if (te != null) {
te.onBlockRemoved();
}
world.removeBlockTileEntity(x, y, z);
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
Block block = blocksList[world.getBlockId(x, y, z)];
if (block != null && block != this) {
return block.getLightValue(world, x, y, z);
}
return world.getBlockMetadata(x, y, z) > 0 ? 15 : 0;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int par5) {
TileLightNode te = (TileLightNode) world.getBlockTileEntity(x, y, z);
if (te != null) {
te.onNeighbourChanged();
}
}
protected void init() {
LanguageRegistry.addName(this, ModObject.blockLightNode.name);
GameRegistry.registerBlock(this, ModObject.blockLightNode.unlocalisedName);
GameRegistry.registerTileEntity(TileLightNode.class, ModObject.blockLightNode.unlocalisedName + "TileEntity");
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void registerIcons(IconRegister iconRegister) {
blockIcon = iconRegister.registerIcon("enderio:blockElectricLightFace");
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileLightNode();
}
}
@@ -1,13 +1,19 @@
package crazypants.enderio.machine.light;
import java.util.ArrayList;
import java.util.List;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import crazypants.enderio.ModObject;
import crazypants.enderio.PacketHandler;
import crazypants.enderio.power.BasicCapacitor;
import crazypants.enderio.power.Capacitors;
import crazypants.enderio.power.IInternalPowerReceptor;
import crazypants.enderio.power.PowerHandlerUtil;
import crazypants.util.ForgeDirectionOffsets;
import crazypants.vecmath.Vector3d;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntity;
@@ -17,19 +23,42 @@ import net.minecraftforge.common.ForgeDirection;
public class TileElectricLight extends TileEntity implements IInternalPowerReceptor {
private ForgeDirection face = ForgeDirection.DOWN;
public static final float MJ_USE_PER_TICK = 0.2f;
protected PowerHandler powerHandler;
private boolean init = true;
private List<TileLightNode> lightNodes;
private int[] lightNodeCoords;
private boolean updatingLightNodes = false;
public TileElectricLight() {
powerHandler = PowerHandlerUtil.createHandler(new BasicCapacitor(1,6), this, Type.MACHINE);
powerHandler = PowerHandlerUtil.createHandler(new BasicCapacitor(1, 6), this, Type.MACHINE);
}
public void onNeighborBlockChange(int blockID) {
public void onNeighborBlockChange(int blockID) {
//if (!updatingLightNodes) {
// updateLightNodes();
//}
init = true;
}
public void nodeNeighbourChanged(TileLightNode tileLightNode) {
//if (!updatingLightNodes) {
// updateLightNodes();
//}
init = true;
}
public void nodeRemoved(TileLightNode tileLightNode) {
if (!updatingLightNodes) {
//updateLightNodes();
init = true;
}
}
public ForgeDirection getFace() {
@@ -43,49 +72,203 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
public boolean isOn() {
return blockMetadata > 0;
}
@Override
public void updateEntity() {
if(worldObj.isRemote) {
if (worldObj.isRemote) {
return;
}
boolean hasRedstone = worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord) > 0;
powerHandler.update();
if(hasRedstone) {
powerHandler.setEnergy(Math.max(0,powerHandler.getEnergyStored() - MJ_USE_PER_TICK));
}
boolean hasRedstone = hasRedstoneSignal();
powerHandler.update();
if (hasRedstone) {
powerHandler.setEnergy(Math.max(0, powerHandler.getEnergyStored() - MJ_USE_PER_TICK));
}
boolean isActivated = hasPower() && hasRedstone;
if(isActivated && !isOn() || !isActivated && isOn() || init) {
if (init) {
lightNodes = new ArrayList<TileLightNode>();
updateLightNodes();
}
if (isActivated && !isOn() || !isActivated && isOn() || init) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, isActivated ? 1 : 0, 2);
for (TileLightNode ln : lightNodes) {
if (ln != null) {
worldObj.setBlockMetadataWithNotify(ln.xCoord, ln.yCoord, ln.zCoord, isActivated ? 1 : 0, 2);
}
}
init = false;
}
}
}
public void onBlockRemoved() {
updatingLightNodes = true;
try {
clearLightNodes();
} finally {
updatingLightNodes = false;
}
}
private void updateLightNodes() {
updatingLightNodes = true;
try {
if (lightNodeCoords != null) {
clearLightNodes();
// just loaded
lightNodes = new ArrayList<TileLightNode>();
for (int i = 0; i < lightNodeCoords.length; i += 3) {
TileEntity te = worldObj.getBlockTileEntity(lightNodeCoords[i], lightNodeCoords[i + 1], lightNodeCoords[i + 2]);
if (te instanceof TileLightNode) {
lightNodes.add((TileLightNode) te);
}
}
lightNodeCoords = null;
} else if (lightNodes == null) { // just created
lightNodes = new ArrayList<TileLightNode>();
} else { // updating existing so kill all out current ones
clearLightNodes();
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (dir != face && dir != face.getOpposite()) { // don't project behind us
Vector3d offset = ForgeDirectionOffsets.forDirCopy(dir);
addNodeInDirection(new Vector3d(offset));
addNodeInDirection(offset.add(ForgeDirectionOffsets.forDirCopy(face.getOpposite())));
}
}
addNodeInDirection(ForgeDirectionOffsets.forDirCopy(face.getOpposite()));
Vector3d[] diags = new Vector3d[2];
if(face.offsetX != 0) {
diags[0] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.UP);
diags[1] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.SOUTH);
} else if(face.offsetY != 0) {
diags[0] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.EAST);
diags[1] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.SOUTH);
} else {
diags[0] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.UP);
diags[1] = ForgeDirectionOffsets.forDirCopy(ForgeDirection.EAST);
}
addDiaganals(diags, new Vector3d());
addDiaganals(diags,ForgeDirectionOffsets.forDirCopy(face.getOpposite()));
} finally {
updatingLightNodes = false;
}
}
private void addDiaganals(Vector3d[] diags, Vector3d trans) {
Vector3d offset = new Vector3d();
offset.set(diags[0]);
offset.add(diags[1]);
addNodeInDirection(offset.add(trans));
offset.set(diags[0]);
offset.sub(diags[1]);
addNodeInDirection(offset.add(trans));
offset.set(new Vector3d(diags[0]).negate());
offset.add(diags[1]);
addNodeInDirection(offset.add(trans));
offset.set(new Vector3d(diags[0]).negate());
offset.sub(diags[1]);
addNodeInDirection(offset.add(trans));
}
private void addNodeInDirection(Vector3d offset) {
boolean isAir = isAir(offset);
boolean isTransp = isTranparent(offset);
if (isAir || isTransp) {
offset.scale(2);
if (isAir(offset)) {
addLightNode(offset);
} else if (isAir) {
offset.scale(0.5);
addLightNode(offset);
}
}
}
private void clearLightNodes() {
if (lightNodes != null) {
for (TileLightNode ln : lightNodes) {
worldObj.setBlockToAir(ln.xCoord, ln.yCoord, ln.zCoord);
}
lightNodes.clear();
}
}
private void addLightNode(Vector3d offset) {
worldObj.setBlock(xCoord + (int) offset.x, yCoord + (int) offset.y, zCoord + (int) offset.z, ModObject.blockLightNode.actualId);
TileLightNode ln = (TileLightNode)worldObj.getBlockTileEntity(xCoord + (int) offset.x, yCoord + (int) offset.y, zCoord + (int) offset.z);
ln.parentX = xCoord;
ln.parentY = yCoord;
ln.parentZ = zCoord;
boolean isActivated = hasPower() && hasRedstoneSignal();
worldObj.setBlockMetadataWithNotify(ln.xCoord, ln.yCoord, ln.zCoord, isActivated ? 1 : 0, 2);
lightNodes.add(ln);
}
private boolean isTranparent(Vector3d offset) {
return worldObj.getBlockLightOpacity(xCoord + (int) offset.x, yCoord + (int) offset.y, zCoord + (int) offset.z) == 0;
}
private boolean isAir(Vector3d offset) {
return worldObj.isAirBlock(xCoord + (int) offset.x, yCoord + (int) offset.y, zCoord + (int) offset.z) ||
worldObj.getBlockId(xCoord + (int) offset.x, yCoord + (int) offset.y, zCoord + (int) offset.z) == ModObject.blockLightNode.actualId;
}
@Override
public void readFromNBT(NBTTagCompound root) {
super.readFromNBT(root);
face = ForgeDirection.values()[root.getShort("face")];
face = ForgeDirection.values()[root.getShort("face")];
float storedEnergy = root.getFloat("storedEnergy");
powerHandler.setEnergy(storedEnergy);
lightNodeCoords = root.getIntArray("lightNodes");
}
@Override
public void writeToNBT(NBTTagCompound root) {
super.writeToNBT(root);
root.setShort("face", (short)face.ordinal());
root.setShort("face", (short) face.ordinal());
root.setFloat("storedEnergy", powerHandler.getEnergyStored());
if (lightNodes != null) {
int[] lnLoc = new int[lightNodes.size() * 3];
int index = 0;
for (TileLightNode ln : lightNodes) {
lnLoc[index++] = ln.xCoord;
lnLoc[index++] = ln.yCoord;
lnLoc[index++] = ln.zCoord;
}
root.setIntArray("lightNodes", lnLoc);
}
}
public boolean hasPower() {
boolean hasPower = powerHandler.getEnergyStored() > MJ_USE_PER_TICK;
return hasPower;
return powerHandler.getEnergyStored() > MJ_USE_PER_TICK;
}
private boolean hasRedstoneSignal() {
return worldObj.getStrongestIndirectPower(xCoord, yCoord, zCoord) > 0;
}
@Override
public Packet getDescriptionPacket() {
return PacketHandler.getPacket(this);
@@ -97,7 +280,7 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
}
@Override
public void doWork(PowerHandler workProvider) {
public void doWork(PowerHandler workProvider) {
}
@Override
@@ -111,8 +294,7 @@ public class TileElectricLight extends TileEntity implements IInternalPowerRecep
}
@Override
public void applyPerdition() {
public void applyPerdition() {
}
}
@@ -0,0 +1,74 @@
package crazypants.enderio.machine.light;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crazypants.enderio.EnderIO;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
public class TileLightNode extends TileEntity {
int parentX;
int parentY;
int parentZ;
public TileElectricLight getParent() {
TileEntity te = worldObj.getBlockTileEntity(parentX, parentY, parentZ);
if(te instanceof TileElectricLight) {
return (TileElectricLight)te;
}
return null;
}
// public int getLightValue() {
// TileElectricLight p = getParent();
// if(p == null) {
// return 0;
// }
// return EnderIO.blockElectricLight.getLightValue(worldObj, parentX, parentY, parentZ);
// }
public void onNeighbourChanged() {
TileElectricLight p = getParent();
if(p != null) {
p.nodeNeighbourChanged(this);
}
}
public void onBlockRemoved() {
TileElectricLight p = getParent();
if(p != null) {
p.nodeRemoved(this);
}
}
@Override
public void readFromNBT(NBTTagCompound root) {
super.readFromNBT(root);
parentX = root.getInteger("parentX");
parentY = root.getInteger("parentY");
parentZ = root.getInteger("parentZ");
}
@Override
public void writeToNBT(NBTTagCompound root) {
super.writeToNBT(root);
root.setInteger("parentX", parentX);
root.setInteger("parentY", parentY);
root.setInteger("parentZ", parentZ);
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
return null;
}
}
@@ -9,15 +9,15 @@ import net.minecraft.util.StringTranslate;
public final class PainterUtil {
private PainterUtil() {
private PainterUtil() {
}
public static boolean isMetadataEquivelent(ItemStack one, ItemStack two) {
if(one == null || two == null) {
if (one == null || two == null) {
return false;
}
return PainterUtil.getSourceBlockId(one) == PainterUtil.getSourceBlockId(two) && PainterUtil.getSourceBlockMetadata(one) == PainterUtil.getSourceBlockMetadata(two);
return PainterUtil.getSourceBlockId(one) == PainterUtil.getSourceBlockId(two)
&& PainterUtil.getSourceBlockMetadata(one) == PainterUtil.getSourceBlockMetadata(two);
}
public static Block getSourceBlock(ItemStack item) {
@@ -58,20 +58,23 @@ public final class PainterUtil {
}
tag.setInteger(BlockPainter.KEY_SOURCE_BLOCK_ID, sourceId);
tag.setInteger(BlockPainter.KEY_SOURCE_BLOCK_META, meta);
String sourceName = "";
if (sourceId > 0) {
sourceName = Item.itemsList[sourceId].getUnlocalizedName(new ItemStack(sourceId, 1, meta));
sourceName = StatCollector.translateToLocal(sourceName + ".name");
if (sourceId > 0) {
Item i = Item.itemsList[sourceId];
if (i != null) {
sourceName = i.getUnlocalizedName(new ItemStack(sourceId, 1, meta));
sourceName = StatCollector.translateToLocal(sourceName + ".name");
}
}
String typeName;
typeName = Item.itemsList[item.itemID].getUnlocalizedName(item);
typeName = StatCollector.translateToLocal(typeName + ".name");
NBTTagCompound displayTags = new NBTTagCompound();
displayTags.setString("Name", "Painted " + sourceName + " " + typeName);
tag.setCompoundTag("display", displayTags);
}
}
+4 -2
View File
@@ -34,10 +34,11 @@ public class Vector3d {
z = vec.z;
}
public void add(Vector3d vec) {
public Vector3d add(Vector3d vec) {
x += vec.x;
y += vec.y;
z += vec.z;
return this;
}
public void sub(Vector3d vec) {
@@ -46,10 +47,11 @@ public class Vector3d {
z -= vec.z;
}
public void negate() {
public Vector3d negate() {
x = -x;
y = -y;
z = -z;
return this;
}
public void scale(double s) {