Fix issues with PR #1011

See https://github.com/BuildCraft/BuildCraft/issues/1011
This commit is contained in:
CovertJaguar 2013-07-17 11:51:16 -07:00
parent de2f39f4cb
commit e49bddc867
10 changed files with 44 additions and 36 deletions

View file

@ -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;
}

View file

@ -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));
}
}

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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];