Fixing a sided error, but also discovering a dust stack colour bug in SMP

This commit is contained in:
pahimar 2014-01-12 13:52:52 -05:00
parent 58bd0a1dca
commit d81d5594e2
4 changed files with 39 additions and 16 deletions

View file

@ -1,11 +1,7 @@
package com.pahimar.ee3.client.helper; package com.pahimar.ee3.client.helper;
import java.util.regex.Pattern;
public class ColourUtils public class ColourUtils
{ {
private static final Pattern HEX_COLOUR_PATTERN = Pattern.compile("[0-9a-fA-F]{6}");
public static byte[] convertIntColourToByteArray(int intColour) public static byte[] convertIntColourToByteArray(int intColour)
{ {
byte[] colourByteArray = new byte[3]; byte[] colourByteArray = new byte[3];
@ -21,9 +17,9 @@ public class ColourUtils
{ {
float[] colourFloatArray = new float[3]; float[] colourFloatArray = new float[3];
colourFloatArray[0] = (float) (intColour >> 16 & 255) / 255F; colourFloatArray[0] = ((intColour >> 16 & 0xFF) / 255F);
colourFloatArray[1] = (float) (intColour >> 8 & 255) / 255F; colourFloatArray[1] = ((intColour >> 8 & 0xFF) / 255F);
colourFloatArray[2] = (float) (intColour & 255) / 255F; colourFloatArray[2] = ((intColour & 0xFF) / 255F);
return colourFloatArray; return colourFloatArray;
} }

View file

@ -66,6 +66,7 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
GL11.glRotatef(-45F, 0F, 1F, 0F); GL11.glRotatef(-45F, 0F, 1F, 0F);
float[] dustColour = getBlendedDustColour(tileCalcinator.leftStackSize, tileCalcinator.leftStackColour, tileCalcinator.rightStackSize, tileCalcinator.rightStackColour); float[] dustColour = getBlendedDustColour(tileCalcinator.leftStackSize, tileCalcinator.leftStackColour, tileCalcinator.rightStackSize, tileCalcinator.rightStackColour);
GL11.glColor4f(dustColour[0], dustColour[1], dustColour[2], 1F); GL11.glColor4f(dustColour[0], dustColour[1], dustColour[2], 1F);
if (dustStackSize <= 32) if (dustStackSize <= 32)
@ -103,8 +104,15 @@ public class TileEntityCalcinatorRenderer extends TileEntitySpecialRenderer
float[][] blendedColours = ColourUtils.getFloatBlendedColours(leftStackColour, rightStackColour, 2 * stackSizeStepRange - 1); float[][] blendedColours = ColourUtils.getFloatBlendedColours(leftStackColour, rightStackColour, 2 * stackSizeStepRange - 1);
if (blendedColours != null)
{
return blendedColours[stackSizeStepRange + (factoredLeftStackSize - factoredRightStackSize)]; return blendedColours[stackSizeStepRange + (factoredLeftStackSize - factoredRightStackSize)];
} }
else
{
return new float[]{1F, 1F, 1F};
}
}
else if (leftStackSize > 0) else if (leftStackSize > 0)
{ {
return ColourUtils.convertIntColourToFloatArray(leftStackColour); return ColourUtils.convertIntColourToFloatArray(leftStackColour);

View file

@ -16,6 +16,7 @@ public class Colours
public static final String DUST_VERDANT = "45CC39"; public static final String DUST_VERDANT = "45CC39";
public static final String DUST_AZURE = "35A6DE"; public static final String DUST_AZURE = "35A6DE";
public static final String DUST_MINIUM = "FF4545"; public static final String DUST_MINIUM = "FF4545";
public static final String[] DUST_COLOURS = new String[]{DUST_ASH, DUST_VERDANT, DUST_AZURE, DUST_MINIUM};
// Infused Planks // Infused Planks
public static final String INFUSED_PLANKS_VERDANT = "3D822A"; public static final String INFUSED_PLANKS_VERDANT = "3D822A";

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.tileentity; package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.item.ItemAlchemicalDust;
import com.pahimar.ee3.lib.Colours; import com.pahimar.ee3.lib.Colours;
import com.pahimar.ee3.lib.Strings; import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.network.PacketTypeHandler; import com.pahimar.ee3.network.PacketTypeHandler;
@ -13,6 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.MathHelper;
/** /**
* Equivalent-Exchange-3 * Equivalent-Exchange-3
@ -61,6 +63,7 @@ public class TileCalcinator extends TileEE implements IInventory
@Override @Override
public ItemStack getStackInSlot(int slotIndex) public ItemStack getStackInSlot(int slotIndex)
{ {
sendDustPileData();
return inventory[slotIndex]; return inventory[slotIndex];
} }
@ -289,10 +292,7 @@ public class TileCalcinator extends TileEE implements IInventory
this.onInventoryChanged(); this.onInventoryChanged();
this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0; this.state = this.deviceCookTime > 0 ? (byte) 1 : (byte) 0;
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 1, this.state); this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 1, this.state);
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 2, getLeftStackSize()); sendDustPileData();
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 3, getLeftStackColour());
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 4, getRightStackSize());
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 5, getRightStackColour());
this.worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID); this.worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID);
} }
} }
@ -420,10 +420,15 @@ public class TileCalcinator extends TileEE implements IInventory
{ {
if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null) if (this.inventory[OUTPUT_LEFT_INVENTORY_INDEX] != null)
{ {
return this.inventory[OUTPUT_LEFT_INVENTORY_INDEX].getItem().getColorFromItemStack(this.inventory[OUTPUT_LEFT_INVENTORY_INDEX], 1); ItemStack itemStack = this.inventory[OUTPUT_LEFT_INVENTORY_INDEX];
if (itemStack.getItem() instanceof ItemAlchemicalDust)
{
return Integer.parseInt(Colours.DUST_COLOURS[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Colours.DUST_COLOURS.length - 1)], 16);
}
} }
return Integer.parseInt(Colours.PURE_WHITE, 16); return 16777215;
} }
private int getRightStackSize() private int getRightStackSize()
@ -440,9 +445,22 @@ public class TileCalcinator extends TileEE implements IInventory
{ {
if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null) if (this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX] != null)
{ {
return this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX].getItem().getColorFromItemStack(this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX], 1); ItemStack itemStack = this.inventory[OUTPUT_RIGHT_INVENTORY_INDEX];
if (itemStack.getItem() instanceof ItemAlchemicalDust)
{
return Integer.parseInt(Colours.DUST_COLOURS[MathHelper.clamp_int(itemStack.getItemDamage(), 0, Colours.DUST_COLOURS.length - 1)], 16);
}
} }
return Integer.parseInt(Colours.PURE_WHITE, 16); return 16777215;
}
private void sendDustPileData()
{
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 2, getLeftStackSize());
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 3, getLeftStackColour());
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 4, getRightStackSize());
this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType().blockID, 5, getRightStackColour());
} }
} }