diff --git a/common/buildcraft/core/network/PacketPayload.java b/common/buildcraft/core/network/PacketPayload.java index 0700e0db..5f1074ef 100644 --- a/common/buildcraft/core/network/PacketPayload.java +++ b/common/buildcraft/core/network/PacketPayload.java @@ -17,7 +17,7 @@ public abstract class PacketPayload { if (type == Type.ARRAY.ordinal()) return new PacketPayloadArrays(); if (type == Type.STREAM.ordinal()) - return null; + return new PacketPayloadStream(); return null; } diff --git a/common/buildcraft/energy/EnergyProxyClient.java b/common/buildcraft/energy/EnergyProxyClient.java index b69a7691..447dcc9b 100644 --- a/common/buildcraft/energy/EnergyProxyClient.java +++ b/common/buildcraft/energy/EnergyProxyClient.java @@ -1,13 +1,13 @@ package buildcraft.energy; import buildcraft.BuildCraftEnergy; -import buildcraft.core.DefaultProps; import buildcraft.core.render.RenderingEntityBlocks; import buildcraft.core.render.RenderingEntityBlocks.EntityRenderIndex; import buildcraft.energy.render.RenderEngine; import cpw.mods.fml.client.registry.ClientRegistry; public class EnergyProxyClient extends EnergyProxy { + @Override public void registerTileEntities() { super.registerTileEntities(); @@ -16,11 +16,8 @@ public class EnergyProxyClient extends EnergyProxy { @Override public void registerBlockRenderers() { - RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 0), new RenderEngine( - DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png")); - RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 1), new RenderEngine( - DefaultProps.TEXTURE_PATH_BLOCKS + "/base_stone.png")); - RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 2), new RenderEngine( - DefaultProps.TEXTURE_PATH_BLOCKS + "/base_iron.png")); + RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 0), new RenderEngine(TileEngine.WOOD_TEXTURE)); + RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 1), new RenderEngine(TileEngine.STONE_TEXTURE)); + RenderingEntityBlocks.blockByEntityRenders.put(new EntityRenderIndex(BuildCraftEnergy.engineBlock, 2), new RenderEngine(TileEngine.IRON_TEXTURE)); } } diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index e68c55b0..e83c2769 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -17,6 +17,7 @@ import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.transport.IPipeConnection; +import buildcraft.core.DefaultProps; import buildcraft.core.TileBuffer; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.SimpleInventory; @@ -33,10 +34,15 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagFloat; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; public abstract class TileEngine extends TileBuildCraft implements IPowerReceptor, IPowerEmitter, IInventory, IOverrideDefaultTriggers, IPipeConnection { + public static final ResourceLocation WOOD_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"); + public static final ResourceLocation STONE_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_stone.png"); + public static final ResourceLocation IRON_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_iron.png"); + public enum EnergyStage { BLUE, GREEN, YELLOW, RED, OVERHEAT @@ -78,7 +84,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } } - public abstract String getTextureFile(); + public abstract ResourceLocation getTextureFile(); public boolean onBlockActivated(EntityPlayer player, ForgeDirection side) { return false; diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 085ca1f0..b5309fcc 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -27,6 +27,7 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -54,8 +55,8 @@ public class TileEngineIron extends TileEngine implements IFluidHandler { } @Override - public String getTextureFile() { - return DefaultProps.TEXTURE_PATH_BLOCKS + "/base_iron.png"; + public ResourceLocation getTextureFile() { + return IRON_TEXTURE; } @Override diff --git a/common/buildcraft/energy/TileEngineLegacy.java b/common/buildcraft/energy/TileEngineLegacy.java index 7882e768..c33dfa4b 100644 --- a/common/buildcraft/energy/TileEngineLegacy.java +++ b/common/buildcraft/energy/TileEngineLegacy.java @@ -10,6 +10,7 @@ package buildcraft.energy; import buildcraft.core.DefaultProps; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; /** * This class is just intended to update pre 4.0 engines to the design. @@ -46,8 +47,8 @@ public class TileEngineLegacy extends TileEngine { } @Override - public String getTextureFile() { - return DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"; + public ResourceLocation getTextureFile() { + return WOOD_TEXTURE; } @Override diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java index f2a574e9..31340777 100644 --- a/common/buildcraft/energy/TileEngineStone.java +++ b/common/buildcraft/energy/TileEngineStone.java @@ -21,6 +21,7 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; public class TileEngineStone extends TileEngine { @@ -48,8 +49,8 @@ public class TileEngineStone extends TileEngine { } @Override - public String getTextureFile() { - return DefaultProps.TEXTURE_PATH_BLOCKS + "/base_stone.png"; + public ResourceLocation getTextureFile() { + return STONE_TEXTURE; } @Override diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java index 6638aee9..b13d116d 100644 --- a/common/buildcraft/energy/TileEngineWood.java +++ b/common/buildcraft/energy/TileEngineWood.java @@ -7,8 +7,8 @@ */ package buildcraft.energy; -import buildcraft.core.DefaultProps; import buildcraft.core.proxy.CoreProxy; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ForgeDirection; public class TileEngineWood extends TileEngine { @@ -20,8 +20,8 @@ public class TileEngineWood extends TileEngine { } @Override - public String getTextureFile() { - return DefaultProps.TEXTURE_PATH_BLOCKS + "/base_wood.png"; + public ResourceLocation getTextureFile() { + return WOOD_TEXTURE; } @Override diff --git a/common/buildcraft/energy/render/RenderEngine.java b/common/buildcraft/energy/render/RenderEngine.java index 36eed1c4..65290f5c 100644 --- a/common/buildcraft/energy/render/RenderEngine.java +++ b/common/buildcraft/energy/render/RenderEngine.java @@ -30,13 +30,18 @@ import org.lwjgl.opengl.GL11; public class RenderEngine extends TileEntitySpecialRenderer implements IInventoryRenderer { + private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/chamber.png"); + private static final ResourceLocation TRUNK_BLUE_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_blue.png"); + private static final ResourceLocation TRUNK_GREEN_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_green.png"); + private static final ResourceLocation TRUNK_YELLOW_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_yellow.png"); + private static final ResourceLocation TRUNK_RED_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_red.png"); private ModelBase model = new ModelBase() { }; private ModelRenderer box; private ModelRenderer trunk; private ModelRenderer movingBox; private ModelRenderer chamber; - private String baseTexture; + private ResourceLocation baseTexture; private static final float[] angleMap = new float[6]; static { @@ -76,7 +81,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor chamber.rotationPointZ = 8F; } - public RenderEngine(String baseTexture) { + public RenderEngine(ResourceLocation baseTexture) { this(); this.baseTexture = baseTexture; setTileEntityRenderer(TileEntityRenderer.instance); @@ -97,7 +102,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor } } - private void render(EnergyStage energy, float progress, ForgeDirection orientation, String baseTexture, double x, double y, double z) { + private void render(EnergyStage energy, float progress, ForgeDirection orientation, ResourceLocation baseTexture, double x, double y, double z) { if (BuildCraftCore.render == RenderMode.NoDynamic) { return; @@ -155,7 +160,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor float factor = (float) (1.0 / 16.0); - func_110628_a(new ResourceLocation(baseTexture)); + func_110628_a(baseTexture); box.render(factor); @@ -163,7 +168,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor movingBox.render(factor); GL11.glTranslatef(-translate[0] * translatefact, -translate[1] * translatefact, -translate[2] * translatefact); - func_110628_a(new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/chamber.png")); + func_110628_a(CHAMBER_TEXTURE); float chamberf = 2F / 16F; @@ -176,24 +181,24 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor GL11.glTranslatef(-translate[0] * chamberf, -translate[1] * chamberf, -translate[2] * chamberf); } - String texture = ""; + ResourceLocation texture; switch (energy) { case BLUE: - texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_blue.png"; + texture = TRUNK_BLUE_TEXTURE; break; case GREEN: - texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_green.png"; + texture = TRUNK_GREEN_TEXTURE; break; case YELLOW: - texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_yellow.png"; + texture = TRUNK_YELLOW_TEXTURE; break; default: - texture = DefaultProps.TEXTURE_PATH_BLOCKS + "/trunk_red.png"; + texture = TRUNK_RED_TEXTURE; break; } - func_110628_a(new ResourceLocation(texture)); + func_110628_a(texture); trunk.render(factor); diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index cebe6326..15682e19 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -378,7 +378,6 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe @Override public PacketPayload getPacketPayload() { PacketPayload payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { - @Override public void writeData(DataOutputStream data) throws IOException { data.writeFloat(animationSpeed); @@ -390,11 +389,9 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe @Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { - if (packet.payload != null) { - DataInputStream stream = ((PacketPayloadStream) packet.payload).stream; - animationSpeed = stream.readFloat(); - tankManager.readData(stream); - } + DataInputStream stream = ((PacketPayloadStream) packet.payload).stream; + animationSpeed = stream.readFloat(); + tankManager.readData(stream); } @Override diff --git a/common/buildcraft/factory/render/RenderRefinery.java b/common/buildcraft/factory/render/RenderRefinery.java index a2d0fe25..53148d19 100644 --- a/common/buildcraft/factory/render/RenderRefinery.java +++ b/common/buildcraft/factory/render/RenderRefinery.java @@ -22,7 +22,7 @@ import org.lwjgl.opengl.GL11; public class RenderRefinery extends TileEntitySpecialRenderer implements IInventoryRenderer { - private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft:textures/blocks/refinery.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/refinery.png"); private static final float pixel = (float) (1.0 / 16.0); private final ModelRenderer tank; private final ModelRenderer magnet[] = new ModelRenderer[4];