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

View file

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

View file

@ -16,6 +16,7 @@ public class Colours
public static final String DUST_VERDANT = "45CC39";
public static final String DUST_AZURE = "35A6DE";
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
public static final String INFUSED_PLANKS_VERDANT = "3D822A";

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.tileentity;
import com.pahimar.ee3.item.ItemAlchemicalDust;
import com.pahimar.ee3.lib.Colours;
import com.pahimar.ee3.lib.Strings;
import com.pahimar.ee3.network.PacketTypeHandler;
@ -13,6 +14,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.packet.Packet;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.MathHelper;
/**
* Equivalent-Exchange-3
@ -61,6 +63,7 @@ public class TileCalcinator extends TileEE implements IInventory
@Override
public ItemStack getStackInSlot(int slotIndex)
{
sendDustPileData();
return inventory[slotIndex];
}
@ -289,10 +292,7 @@ public class TileCalcinator extends TileEE implements IInventory
this.onInventoryChanged();
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, 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());
sendDustPileData();
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)
{
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()
@ -440,9 +445,22 @@ public class TileCalcinator extends TileEE implements IInventory
{
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());
}
}