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 net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
@ -15,7 +14,6 @@ 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;
import com.pahimar.ee3.EquivalentExchange3;
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));
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
}
@Override
@ -106,41 +106,47 @@ public class BlockGlassBell extends BlockEE {
}
/**
* Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,
* x, y, z, startVec, endVec
* Ray traces through the blocks collision from start vector to end vector
* returning a ray trace hit. Args: world, x, y, z, startVec, endVec
*/
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
{
int metaData = world.getBlockMetadata(x, y, z) & 7;
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
switch (ForgeDirection.getOrientation(metaData)) {
case DOWN: {
this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F);
break;
}
case UP: {
this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.66F, 0.875F);
break;
}
case NORTH: {
this.setBlockBounds(0.125F, 0.125F, 0.33F, 0.875F, 0.875F, 1.0F);
break;
}
case SOUTH: {
this.setBlockBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 0.66F);
break;
}
case EAST: {
this.setBlockBounds(0.0F, 0.125F, 0.125F, 0.66F, 0.875F, 0.875F);
break;
}
case WEST: {
this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
break;
}
case UNKNOWN: {
break;
if (tileEntity != null) {
if (tileEntity instanceof TileGlassBell) {
TileGlassBell tileGlassBell = (TileGlassBell) tileEntity;
switch (tileGlassBell.getOrientation()) {
case DOWN: {
this.setBlockBounds(0.125F, 0.33F, 0.125F, 0.875F, 1.0F, 0.875F);
break;
}
case UP: {
this.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.66F, 0.875F);
break;
}
case NORTH: {
this.setBlockBounds(0.125F, 0.125F, 0.33F, 0.875F, 0.875F, 1.0F);
break;
}
case SOUTH: {
this.setBlockBounds(0.125F, 0.125F, 0.0F, 0.875F, 0.875F, 0.66F);
break;
}
case EAST: {
this.setBlockBounds(0.0F, 0.125F, 0.125F, 0.66F, 0.875F, 0.875F);
break;
}
case WEST: {
this.setBlockBounds(0.33F, 0.125F, 0.125F, 1.0F, 0.875F, 0.875F);
break;
}
case UNKNOWN: {
break;
}
}
}
}
@ -150,17 +156,7 @@ public class BlockGlassBell extends BlockEE {
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
TileGlassBell tileGlassBell = (TileGlassBell) world.getBlockTileEntity(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;
return world.getBlockMetadata(x, y, 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() {
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(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 });
}
}

View file

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

View file

@ -82,7 +82,7 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
if (tileGlassBell.getStackInSlot(i) != null) {
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);
ghostEntityItem.hoverStart = 0.0F;
@ -232,21 +232,32 @@ public class TileEntityGlassBellRenderer extends TileEntitySpecialRenderer {
if (itemStack != null) {
if (itemStack.getItem() instanceof ItemBlock) {
switch (customRenderItem.getMiniBlockCount(itemStack)) {
case 1: return 0.90F;
case 2: return 0.90F;
case 3: return 0.90F;
case 4: return 0.90F;
case 5: return 0.80F;
default: return 0.90F;
case 1:
return 0.90F;
case 2:
return 0.90F;
case 3:
return 0.90F;
case 4:
return 0.90F;
case 5:
return 0.80F;
default:
return 0.90F;
}
}
else {
switch (customRenderItem.getMiniItemCount(itemStack)) {
case 1: return 0.65F;
case 2: return 0.65F;
case 3: return 0.65F;
case 4: return 0.65F;
default: return 0.65F;
case 1:
return 0.65F;
case 2:
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;
import java.util.ArrayList;
import java.util.logging.Level;
import net.minecraft.item.ItemStack;
import com.pahimar.ee3.core.helper.GeneralHelper;
import com.pahimar.ee3.core.helper.LogHelper;
/**
* Equivalent-Exchange-3
@ -246,7 +248,7 @@ public class EquivalencyHandler {
int i = 0;
for (ArrayList<ItemStack> list : equivalencyList) {
System.out.println("equivalencyList[" + i + "]: " + list.toString());
LogHelper.log(Level.INFO, "equivalencyList[" + i + "]: " + list.toString());
++i;
}
}

View file

@ -114,12 +114,10 @@ public class VersionHelper implements Runnable {
String[] versionTokens = Reference.VERSION_NUMBER.split(" ");
if (versionTokens.length >= 1) {
if (versionTokens.length >= 1)
return versionTokens[0];
}
else {
else
return Reference.VERSION_NUMBER;
}
}
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.lib.ActionTypes;
import com.pahimar.ee3.lib.BlockIds;
import com.pahimar.ee3.lib.Colours;
import com.pahimar.ee3.lib.RenderIds;
import com.pahimar.ee3.network.PacketTypeHandler;
import com.pahimar.ee3.network.packet.PacketRequestEvent;
@ -134,7 +135,8 @@ public class ClientProxy extends CommonProxy {
@Override
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);
@ -142,9 +144,12 @@ public class ClientProxy extends CommonProxy {
if (tileEntity instanceof TileGlassBell) {
ItemStack itemStack = new ItemStack(itemID, stackSize, metaData);
ItemHelper.setColor(itemStack, color);
if (color != Integer.parseInt(Colours.PURE_WHITE, 16)) {
ItemHelper.setColor(itemStack, color);
}
((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)
*
*/
public class ItemMiniumStone extends ItemEE implements ITransmutationStone, IKeyBound {
public class ItemMiniumStone extends ItemEE
implements ITransmutationStone, IKeyBound {
public ItemMiniumStone(int id) {

View file

@ -11,9 +11,8 @@ package com.pahimar.ee3.lib;
*/
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 = {
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"};
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" };
}

View file

@ -69,7 +69,6 @@ public class PacketTileUpdate extends PacketEE {
@Override
public void execute(INetworkManager manager, Player player) {
System.out.println("PacketTileUpdate - Execute");
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;
public class PacketTileWithItemUpdate extends PacketEE {
public int x, y, z;
@ -74,7 +73,6 @@ public class PacketTileWithItemUpdate extends PacketEE {
@Override
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);
}
}

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3.tileentity;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -161,11 +162,22 @@ public class TileGlassBell extends TileEE implements IInventory {
@Override
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])));
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 {
return super.getDescriptionPacket();
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2);
}
}
}