Light update network syncs properly now, and some code style cleanup

This commit is contained in:
pahimar 2013-05-12 20:30:23 -04:00
parent 519f390c2f
commit 435cbc9164
18 changed files with 150 additions and 129 deletions

View file

@ -2,7 +2,6 @@ package com.pahimar.ee3.block;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -15,7 +14,6 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import com.pahimar.ee3.EquivalentExchange3; import com.pahimar.ee3.EquivalentExchange3;
import com.pahimar.ee3.lib.GuiIds; import com.pahimar.ee3.lib.GuiIds;
@ -97,6 +95,8 @@ public class BlockGlassBell extends BlockEE {
} }
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); ((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
} }
@Override @Override
@ -106,15 +106,19 @@ public class BlockGlassBell extends BlockEE {
} }
/** /**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world, * Ray traces through the blocks collision from start vector to end vector
* x, y, z, startVec, endVec * returning a ray trace hit. Args: world, x, y, z, startVec, endVec
*/ */
@Override @Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
{ TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
int metaData = world.getBlockMetadata(x, y, z) & 7;
switch (ForgeDirection.getOrientation(metaData)) { if (tileEntity != null) {
if (tileEntity instanceof TileGlassBell) {
TileGlassBell tileGlassBell = (TileGlassBell) tileEntity;
switch (tileGlassBell.getOrientation()) {
case DOWN: { case DOWN: {
this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F); this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F);
break; break;
@ -143,6 +147,8 @@ public class BlockGlassBell extends BlockEE {
break; break;
} }
} }
}
}
return super.collisionRayTrace(world, x, y, z, startVec, endVec); return super.collisionRayTrace(world, x, y, z, startVec, endVec);
} }
@ -150,17 +156,7 @@ public class BlockGlassBell extends BlockEE {
@Override @Override
public int getLightValue(IBlockAccess world, int x, int y, int z) { public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(x, y, z); return world.getBlockMetadata(x, y, z);
if (tileGlassBell != null) {
if (tileGlassBell.getStackInSlot(0) != null) {
if (tileGlassBell.getStackInSlot(0).itemID < 4096) {
return Block.lightValue[tileGlassBell.getStackInSlot(0).itemID];
}
}
}
return 0;
} }
private void dropInventory(World world, int x, int y, int z) { private void dropInventory(World world, int x, int y, int z) {
@ -196,5 +192,4 @@ public class BlockGlassBell extends BlockEE {
} }
} }
} }
} }

View file

@ -49,7 +49,7 @@ public class ModBlocks {
private static void initBlockRecipes() { private static void initBlockRecipes() {
GameRegistry.addRecipe(new ItemStack(glassBell), new Object[] {"iii", "i i", "i i", Character.valueOf('i'), Block.glass }); GameRegistry.addRecipe(new ItemStack(glassBell), new Object[] { "iii", "i i", "i i", Character.valueOf('i'), Block.glass });
GameRegistry.addRecipe(new ItemStack(aludelBase), new Object[] {"iii", "sis", "iii", Character.valueOf('i'), Item.ingotIron, Character.valueOf('s'), Block.stone }); GameRegistry.addRecipe(new ItemStack(aludelBase), new Object[] { "iii", "sis", "iii", Character.valueOf('i'), Item.ingotIron, Character.valueOf('s'), Block.stone });
} }
} }

View file

@ -25,7 +25,8 @@ import cpw.mods.fml.relauncher.SideOnly;
* *
*/ */
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class TileEntityAlchemicalChestRenderer extends TileEntitySpecialRenderer { public class TileEntityAlchemicalChestRenderer extends
TileEntitySpecialRenderer {
private ModelChest modelChest = new ModelChest(); private ModelChest modelChest = new ModelChest();

View file

@ -82,7 +82,7 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
if (tileGlassBell.getStackInSlot(i) != null) { if (tileGlassBell.getStackInSlot(i) != null) {
float scaleFactor = getGhostItemScaleFactor(tileGlassBell.getStackInSlot(i)); float scaleFactor = getGhostItemScaleFactor(tileGlassBell.getStackInSlot(i));
float rotationAngle = (float) (720.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL); float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
EntityItem ghostEntityItem = new EntityItem(tileGlassBell.worldObj); EntityItem ghostEntityItem = new EntityItem(tileGlassBell.worldObj);
ghostEntityItem.hoverStart = 0.0F; ghostEntityItem.hoverStart = 0.0F;
@ -232,21 +232,32 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
if (itemStack != null) { if (itemStack != null) {
if (itemStack.getItem() instanceof ItemBlock) { if (itemStack.getItem() instanceof ItemBlock) {
switch (customRenderItem.getMiniBlockCount(itemStack)) { switch (customRenderItem.getMiniBlockCount(itemStack)) {
case 1: return 0.90F; case 1:
case 2: return 0.90F; return 0.90F;
case 3: return 0.90F; case 2:
case 4: return 0.90F; return 0.90F;
case 5: return 0.80F; case 3:
default: return 0.90F; return 0.90F;
case 4:
return 0.90F;
case 5:
return 0.80F;
default:
return 0.90F;
} }
} }
else { else {
switch (customRenderItem.getMiniItemCount(itemStack)) { switch (customRenderItem.getMiniItemCount(itemStack)) {
case 1: return 0.65F; case 1:
case 2: return 0.65F; return 0.65F;
case 3: return 0.65F; case 2:
case 4: return 0.65F; return 0.65F;
default: return 0.65F; case 3:
return 0.65F;
case 4:
return 0.65F;
default:
return 0.65F;
} }
} }
} }

View file

@ -1,10 +1,12 @@
package com.pahimar.ee3.core.handlers; package com.pahimar.ee3.core.handlers;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.logging.Level;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import com.pahimar.ee3.core.helper.GeneralHelper; import com.pahimar.ee3.core.helper.GeneralHelper;
import com.pahimar.ee3.core.helper.LogHelper;
/** /**
* Equivalent-Exchange-3 * Equivalent-Exchange-3
@ -246,7 +248,7 @@ public class EquivalencyHandler {
int i = 0; int i = 0;
for (ArrayList<ItemStack> list : equivalencyList) { for (ArrayList<ItemStack> list : equivalencyList) {
System.out.println("equivalencyList[" + i + "]: " + list.toString()); LogHelper.log(Level.INFO, "equivalencyList[" + i + "]: " + list.toString());
++i; ++i;
} }
} }

View file

@ -114,13 +114,11 @@ public class VersionHelper implements Runnable {
String[] versionTokens = Reference.VERSION_NUMBER.split(" "); String[] versionTokens = Reference.VERSION_NUMBER.split(" ");
if (versionTokens.length >= 1) { if (versionTokens.length >= 1)
return versionTokens[0]; return versionTokens[0];
} else
else {
return Reference.VERSION_NUMBER; return Reference.VERSION_NUMBER;
} }
}
public static void logResult() { public static void logResult() {

View file

@ -27,6 +27,7 @@ import com.pahimar.ee3.core.helper.TransmutationHelper;
import com.pahimar.ee3.item.IChargeable; import com.pahimar.ee3.item.IChargeable;
import com.pahimar.ee3.lib.ActionTypes; import com.pahimar.ee3.lib.ActionTypes;
import com.pahimar.ee3.lib.BlockIds; import com.pahimar.ee3.lib.BlockIds;
import com.pahimar.ee3.lib.Colours;
import com.pahimar.ee3.lib.RenderIds; import com.pahimar.ee3.lib.RenderIds;
import com.pahimar.ee3.network.PacketTypeHandler; import com.pahimar.ee3.network.PacketTypeHandler;
import com.pahimar.ee3.network.packet.PacketRequestEvent; import com.pahimar.ee3.network.packet.PacketRequestEvent;
@ -134,7 +135,8 @@ public class ClientProxy extends CommonProxy {
@Override @Override
public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) { public void handleTileWithItemPacket(int x, int y, int z, ForgeDirection orientation, byte state, String customName, int itemID, int metaData, int stackSize, int color) {
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getBlockTileEntity(x, y, z); World world = FMLClientHandler.instance().getClient().theWorld;
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
this.handleTileEntityPacket(x, y, z, orientation, state, customName); this.handleTileEntityPacket(x, y, z, orientation, state, customName);
@ -142,9 +144,12 @@ public class ClientProxy extends CommonProxy {
if (tileEntity instanceof TileGlassBell) { if (tileEntity instanceof TileGlassBell) {
ItemStack itemStack = new ItemStack(itemID, stackSize, metaData); ItemStack itemStack = new ItemStack(itemID, stackSize, metaData);
if (color != Integer.parseInt(Colours.PURE_WHITE, 16)) {
ItemHelper.setColor(itemStack, color); ItemHelper.setColor(itemStack, color);
}
((TileGlassBell) tileEntity).setInventorySlotContents(0, itemStack); ((TileGlassBell) tileEntity).setInventorySlotContents(0, itemStack);
world.updateAllLightTypes(x, y, z);
} }
} }
} }

View file

@ -24,7 +24,8 @@ import cpw.mods.fml.relauncher.SideOnly;
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html) * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
* *
*/ */
public class ItemMiniumStone extends ItemEE implements ITransmutationStone, IKeyBound { public class ItemMiniumStone extends ItemEE
implements ITransmutationStone, IKeyBound {
public ItemMiniumStone(int id) { public ItemMiniumStone(int id) {

View file

@ -13,7 +13,6 @@ public class Localizations {
private static final String LANG_RESOURCE_LOCATION = "/mods/ee3/lang/"; private static final String LANG_RESOURCE_LOCATION = "/mods/ee3/lang/";
public static String[] localeFiles = { public static String[] localeFiles = { LANG_RESOURCE_LOCATION + "cs_CZ.xml", LANG_RESOURCE_LOCATION + "cy_GB.xml", LANG_RESOURCE_LOCATION + "da_DK.xml", LANG_RESOURCE_LOCATION + "de_DE.xml", LANG_RESOURCE_LOCATION + "en_US.xml", LANG_RESOURCE_LOCATION + "es_ES.xml", LANG_RESOURCE_LOCATION + "fi_FI.xml", LANG_RESOURCE_LOCATION + "fr_FR.xml", LANG_RESOURCE_LOCATION + "it_IT.xml", LANG_RESOURCE_LOCATION + "ja_JP.xml", LANG_RESOURCE_LOCATION + "la_IT.xml", LANG_RESOURCE_LOCATION + "nl_NL.xml", LANG_RESOURCE_LOCATION + "nb_NO.xml", LANG_RESOURCE_LOCATION + "pl_PL.xml", LANG_RESOURCE_LOCATION + "pt_BR.xml", LANG_RESOURCE_LOCATION + "pt_PT.xml", LANG_RESOURCE_LOCATION + "ru_RU.xml", LANG_RESOURCE_LOCATION + "sk_SK.xml", LANG_RESOURCE_LOCATION + "sr_RS.xml", LANG_RESOURCE_LOCATION + "sv_SE.xml", LANG_RESOURCE_LOCATION + "tr_TR.xml", LANG_RESOURCE_LOCATION + "zh_CN.xml", LANG_RESOURCE_LOCATION + "zh_TW.xml", LANG_RESOURCE_LOCATION + "el_GR.xml" };
LANG_RESOURCE_LOCATION + "cs_CZ.xml", LANG_RESOURCE_LOCATION + "cy_GB.xml", LANG_RESOURCE_LOCATION + "da_DK.xml", LANG_RESOURCE_LOCATION + "de_DE.xml", LANG_RESOURCE_LOCATION + "en_US.xml", LANG_RESOURCE_LOCATION + "es_ES.xml", LANG_RESOURCE_LOCATION + "fi_FI.xml", LANG_RESOURCE_LOCATION + "fr_FR.xml", LANG_RESOURCE_LOCATION + "it_IT.xml", LANG_RESOURCE_LOCATION + "ja_JP.xml", LANG_RESOURCE_LOCATION + "la_IT.xml", LANG_RESOURCE_LOCATION + "nl_NL.xml", LANG_RESOURCE_LOCATION + "nb_NO.xml", LANG_RESOURCE_LOCATION + "pl_PL.xml", LANG_RESOURCE_LOCATION + "pt_BR.xml", LANG_RESOURCE_LOCATION + "pt_PT.xml", LANG_RESOURCE_LOCATION + "ru_RU.xml", LANG_RESOURCE_LOCATION + "sk_SK.xml", LANG_RESOURCE_LOCATION + "sr_RS.xml", LANG_RESOURCE_LOCATION + "sv_SE.xml", LANG_RESOURCE_LOCATION + "tr_TR.xml", LANG_RESOURCE_LOCATION + "zh_CN.xml", LANG_RESOURCE_LOCATION + "zh_TW.xml", LANG_RESOURCE_LOCATION + "el_GR.xml"};
} }

View file

@ -69,7 +69,6 @@ public class PacketTileUpdate extends PacketEE {
@Override @Override
public void execute(INetworkManager manager, Player player) { public void execute(INetworkManager manager, Player player) {
System.out.println("PacketTileUpdate - Execute");
EquivalentExchange3.proxy.handleTileEntityPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName); EquivalentExchange3.proxy.handleTileEntityPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName);
} }

View file

@ -12,7 +12,6 @@ import com.pahimar.ee3.network.PacketTypeHandler;
import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.network.Player;
public class PacketTileWithItemUpdate extends PacketEE { public class PacketTileWithItemUpdate extends PacketEE {
public int x, y, z; public int x, y, z;
@ -74,7 +73,6 @@ public class PacketTileWithItemUpdate extends PacketEE {
@Override @Override
public void execute(INetworkManager manager, Player player) { public void execute(INetworkManager manager, Player player) {
System.out.println("PacketTileWithItemUpdate - Execute");
EquivalentExchange3.proxy.handleTileWithItemPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName, itemID, metaData, stackSize, color); EquivalentExchange3.proxy.handleTileWithItemPacket(x, y, z, ForgeDirection.getOrientation(orientation), state, customName, itemID, metaData, stackSize, color);
} }
} }

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.tileentity; package com.pahimar.ee3.tileentity;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -161,11 +162,22 @@ public class TileGlassBell extends TileEE implements IInventory {
@Override @Override
public Packet getDescriptionPacket() { public Packet getDescriptionPacket() {
if ((inventory[0] != null) && (inventory[0].stackSize > 0)) { if (inventory[0] != null && inventory[0].stackSize > 0)
return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, inventory[0].itemID, inventory[0].getItemDamage(), inventory[0].stackSize, ItemHelper.getColor(inventory[0]))); return PacketTypeHandler.populatePacket(new PacketTileWithItemUpdate(xCoord, yCoord, zCoord, orientation, state, customName, inventory[0].itemID, inventory[0].getItemDamage(), inventory[0].stackSize, ItemHelper.getColor(inventory[0])));
else
return super.getDescriptionPacket();
}
@Override
public void onInventoryChanged() {
if (inventory[0] != null) {
if (inventory[0].itemID < 4096) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, Block.lightValue[inventory[0].itemID], 2);
}
} }
else { else {
return super.getDescriptionPacket(); worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
} }
} }
} }