More update work

Fluids are mostly converted, including rendering and registration. Added
Fuel Block.
This commit is contained in:
CovertJaguar 2013-07-12 16:38:03 -07:00
parent 1d11beaa6b
commit a3e30d57cc
25 changed files with 434 additions and 340 deletions

View file

@ -13,18 +13,18 @@ import buildcraft.api.recipes.RefineryRecipe;
import buildcraft.core.BlockIndex;
import buildcraft.core.BlockSpring;
import buildcraft.core.DefaultProps;
import buildcraft.core.ItemBuildCraft;
import buildcraft.core.Version;
import buildcraft.core.network.PacketHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.triggers.BCTrigger;
import buildcraft.energy.BlockBuildcraftFluid;
import buildcraft.energy.BlockEngine;
import buildcraft.energy.BptBlockEngine;
import buildcraft.energy.EnergyProxy;
import buildcraft.energy.GuiHandler;
import buildcraft.energy.ItemBucketOil;
import buildcraft.energy.ItemBucketBuildcraft;
import buildcraft.energy.ItemEngine;
import buildcraft.energy.OilBucketHandler;
import buildcraft.energy.BucketHandler;
import buildcraft.energy.TileEngine.EnergyStage;
import buildcraft.energy.TriggerEngineHeat;
import buildcraft.energy.worldgen.BiomeGenOilDesert;
@ -56,10 +56,8 @@ import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.Property;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
import net.minecraftforge.fluids.FluidRegistry;
@Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE)
@ -72,10 +70,12 @@ public class BuildCraftEnergy {
public static BiomeGenOilDesert biomeOilDesert;
public static BiomeGenOilOcean biomeOilOcean;
public static BlockEngine engineBlock;
private static Fluid buildcraftFluidOil;
private static Fluid buildcraftFluidFuel;
public static Fluid fluidOil;
public static Fluid fluidFuel;
public static Block oilMoving;
public static Block blockOil;
public static Block blockFuel;
public static Item bucketOil;
public static Item bucketFuel;
public static Item fuel;
@ -91,13 +91,20 @@ public class BuildCraftEnergy {
@EventHandler
public void preInit(FMLPreInitializationEvent evt) {
Property engineId = BuildCraftCore.mainConfiguration.getBlock("engine.id", DefaultProps.ENGINE_ID);
Property oilStillId = BuildCraftCore.mainConfiguration.getBlock("oilStill.id", DefaultProps.OIL_STILL_ID);
Property oilMovingId = BuildCraftCore.mainConfiguration.getBlock("oilMoving.id", DefaultProps.OIL_MOVING_ID);
Property bucketOilId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bucketOil.id", DefaultProps.BUCKET_OIL_ID);
Property bucketFuelId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "bucketFuel.id", DefaultProps.BUCKET_FUEL_ID);
Property itemFuelId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "fuel.id", DefaultProps.FUEL_ID);
Property oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilDesert", 160);
Property oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", 161);
// Update oil tag
int defaultOilId = DefaultProps.OIL_ID;
if (BuildCraftCore.mainConfiguration.hasKey(Configuration.CATEGORY_BLOCK, "oilStill.id")) {
defaultOilId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_BLOCK, "oilStill.id", defaultOilId).getInt(defaultOilId);
BuildCraftCore.mainConfiguration.getCategory(Configuration.CATEGORY_BLOCK).remove("oilStill.id");
}
int blockOilId = BuildCraftCore.mainConfiguration.getBlock("oil.id", defaultOilId).getInt(defaultOilId);
int blockFuelId = BuildCraftCore.mainConfiguration.getBlock("fuel.id", DefaultProps.FUEL_ID).getInt(DefaultProps.FUEL_ID);
int bucketOilId = BuildCraftCore.mainConfiguration.getItem("bucketOil.id", DefaultProps.BUCKET_OIL_ID).getInt(DefaultProps.BUCKET_OIL_ID);
int bucketFuelId = BuildCraftCore.mainConfiguration.getItem("bucketFuel.id", DefaultProps.BUCKET_FUEL_ID).getInt(DefaultProps.BUCKET_FUEL_ID);
int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT);
int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN);
canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true);
BuildCraftCore.mainConfiguration.save();
@ -108,20 +115,18 @@ public class BuildCraftEnergy {
}
}
int oilDesertId = oilDesertBiomeId.getInt();
if (oilDesertId > 0) {
if (BiomeGenBase.biomeList[oilDesertId] != null) {
throw new BiomeIdException("oilDesert", oilDesertId);
if (oilDesertBiomeId > 0) {
if (BiomeGenBase.biomeList[oilDesertBiomeId] != null) {
throw new BiomeIdException("oilDesert", oilDesertBiomeId);
}
biomeOilDesert = BiomeGenOilDesert.makeBiome(oilDesertId);
biomeOilDesert = BiomeGenOilDesert.makeBiome(oilDesertBiomeId);
}
int oilOceanId = oilOceanBiomeId.getInt();
if (oilOceanId > 0) {
if (BiomeGenBase.biomeList[oilOceanId] != null) {
throw new BiomeIdException("oilOcean", oilOceanId);
if (oilOceanBiomeId > 0) {
if (BiomeGenBase.biomeList[oilOceanBiomeId] != null) {
throw new BiomeIdException("oilOcean", oilOceanBiomeId);
}
biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanId);
biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanBiomeId);
}
@ -134,37 +139,61 @@ public class BuildCraftEnergy {
// Oil and fuel
FluidRegistry.registerFluid(new Fluid("oil"));
buildcraftFluidOil = new Fluid("oil");
FluidRegistry.registerFluid(buildcraftFluidOil);
fluidOil = FluidRegistry.getFluid("oil");
FluidRegistry.registerFluid(new Fluid("fuel"));
buildcraftFluidFuel = new Fluid("fuel");
FluidRegistry.registerFluid(buildcraftFluidFuel);
fluidFuel = FluidRegistry.getFluid("fuel");
if (fluidOil.getBlockID() == -1) {
blockOil = new BlockFluidClassic(oilStillId.getInt(DefaultProps.OIL_STILL_ID), fluidOil, Material.water);
fluidOil.setBlockID(blockOil);
if (blockOilId > 0) {
blockOil = new BlockBuildcraftFluid(blockOilId, fluidOil, Material.water);
blockOil.setUnlocalizedName("blockOil");
CoreProxy.proxy.addName(blockOil, "Oil");
CoreProxy.proxy.registerBlock(blockOil);
Property oilSpringsProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilSprings", true);
spawnOilSprings = oilSpringsProp.getBoolean(true);
BlockSpring.EnumSpring.OIL.canGen = spawnOilSprings;
BlockSpring.EnumSpring.OIL.liquidBlock = blockOil;
fluidOil.setBlockID(blockOil);
}
} else {
blockOil = Block.blocksList[fluidOil.getBlockID()];
}
// TODO 1.6: Add Fuel Block
fuel = new ItemBuildCraft(itemFuelId.getInt(DefaultProps.FUEL_ID)).setUnlocalizedName("fuel");
LanguageRegistry.addName(fuel, "Fuel");
if (blockOil != null) {
Property oilSpringsProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilSprings", true);
spawnOilSprings = oilSpringsProp.getBoolean(true);
BlockSpring.EnumSpring.OIL.canGen = spawnOilSprings;
BlockSpring.EnumSpring.OIL.liquidBlock = blockOil;
}
MinecraftForge.EVENT_BUS.register(new OilBucketHandler());
if (fluidFuel.getBlockID() == -1) {
if (blockFuelId > 0) {
blockFuel = new BlockBuildcraftFluid(blockFuelId, fluidFuel, Material.water);
blockFuel.setUnlocalizedName("blockFuel");
CoreProxy.proxy.addName(blockFuel, "Fuel");
CoreProxy.proxy.registerBlock(blockFuel);
fluidFuel.setBlockID(blockFuel);
}
} else {
blockFuel = Block.blocksList[fluidOil.getBlockID()];
}
bucketOil = (new ItemBucketOil(bucketOilId.getInt(DefaultProps.BUCKET_OIL_ID))).setUnlocalizedName("bucketOil").setContainerItem(Item.bucketEmpty);
// Buckets
MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);
if (blockOil != null && bucketOilId > 0) {
bucketOil = new ItemBucketBuildcraft(bucketOilId, blockOil.blockID);
bucketOil.setUnlocalizedName("bucketOil").setContainerItem(Item.bucketEmpty);
LanguageRegistry.addName(bucketOil, "Oil Bucket");
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Item.bucketEmpty));
}
bucketFuel = new ItemBuildCraft(bucketFuelId.getInt()).setUnlocalizedName("bucketFuel").setContainerItem(Item.bucketEmpty);
bucketFuel.setMaxStackSize(1);
if (blockFuel != null && bucketFuelId > 0) {
bucketFuel = new ItemBucketBuildcraft(bucketFuelId, blockFuel.blockID);
bucketFuel.setUnlocalizedName("bucketFuel").setContainerItem(Item.bucketEmpty);
LanguageRegistry.addName(bucketFuel, "Fuel Bucket");
FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty));
}
RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(FluidRegistry.getFluid("oil"), null, FluidRegistry.getFluid("fuel"), 12, 1));
@ -177,9 +206,6 @@ public class BuildCraftEnergy {
IronEngineCoolant.addCoolant(FluidRegistry.getFluid("water"), 0.0023F);
IronEngineCoolant.addCoolant(Block.ice.blockID, 0, FluidRegistry.getFluidStack("water", FluidContainerRegistry.BUCKET_VOLUME * 2));
FluidContainerRegistry.registerFluidContainer(new FluidContainerData(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Item.bucketEmpty)));
FluidContainerRegistry.registerFluidContainer(new FluidContainerData(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty)));
MinecraftForge.EVENT_BUS.register(this);
}
@ -208,8 +234,8 @@ public class BuildCraftEnergy {
@SideOnly(Side.CLIENT)
public void textureHook(TextureStitchEvent.Post event) {
if (event.map.textureType == 0) {
FluidRegistry.getFluid("fuel").setIcons(fuel.getIconFromDamage(0));
FluidRegistry.getFluid("oil").setIcons(blockOil.getBlockTextureFromSide(1));
buildcraftFluidOil.setIcons(blockOil.getBlockTextureFromSide(1));
buildcraftFluidFuel.setIcons(blockFuel.getBlockTextureFromSide(1));
}
}

View file

@ -220,7 +220,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP
EntityPowerLaser laser = new EntityPowerLaser(worldObj, new Position(previous.i + 0.5, previous.j + 0.5, previous.k + 0.5), new Position(
b.i + 0.5, b.j + 0.5, b.k + 0.5));
laser.setTexture(DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png");
laser.setTexture(0);
laser.show();
worldObj.spawnEntityInWorld(laser);
pathLasers.add(laser);

View file

@ -62,7 +62,7 @@ public class TilePathMarker extends TileMarker {
pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5));
laser.show();
laser.setTexture(DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png");
laser.setTexture(0);
worldObj.spawnEntityInWorld(laser);
connect(pathMarker, laser);

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.gui;
import buildcraft.BuildCraftBuilders;
@ -21,17 +19,16 @@ import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtils;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiBlueprintLibrary extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/template_gui.png");
EntityPlayer player;
TileBlueprintLibrary library;
ContainerBlueprintLibrary container;
boolean computeInput;
BptPlayerIndex index;
public GuiBlueprintLibrary(EntityPlayer player, TileBlueprintLibrary library) {
@ -45,7 +42,6 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
index = BuildCraftBuilders.getPlayerIndex(player.username);
}
private GuiButton nextPageButton;
private GuiButton prevPageButton;
private GuiButton lockButton;
@ -109,7 +105,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/library_rw.png");
mc.renderEngine.func_110577_a(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
@ -162,7 +158,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft {
if (ySlot >= 0 && ySlot <= 11) {
if (ySlot < library.currentNames.length) {
PacketPayload payload = new PacketPayload();
payload.intPayload = new int[] { ySlot };
payload.intPayload = new int[]{ySlot};
PacketLibraryAction packet = new PacketLibraryAction(PacketIds.LIBRARY_SELECT, library.xCoord, library.yCoord, library.zCoord);
packet.actionId = ySlot;
CoreProxy.proxy.sendToServer(packet.getPacket());

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.gui;
import buildcraft.builders.TileBuilder;
@ -16,10 +14,13 @@ import buildcraft.core.utils.StringUtils;
import java.util.Collection;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiBuilder extends GuiAdvancedInterface {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/builder.png");
private static final ResourceLocation BLUEPRINT_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/builder_blueprint.png");
IInventory playerInventory;
TileBuilder builder;
@ -63,10 +64,10 @@ public class GuiBuilder extends GuiAdvancedInterface {
int realXSize = 0;
if (builder.isBuildingBlueprint()) {
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/builder_blueprint.png");
mc.renderEngine.func_110577_a(BLUEPRINT_TEXTURE);
realXSize = 256;
} else {
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/builder.png");
mc.renderEngine.func_110577_a(TEXTURE);
realXSize = 176;
}
@ -93,6 +94,5 @@ public class GuiBuilder extends GuiAdvancedInterface {
drawBackgroundSlots();
}
int inventoryRows = 6;
}

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.gui;
import buildcraft.builders.TileFiller;
@ -14,10 +12,13 @@ import buildcraft.core.DefaultProps;
import buildcraft.core.gui.GuiBuildCraft;
import buildcraft.core.utils.StringUtils;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiFiller extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filler.png");
private static final ResourceLocation BLOCK_TEXTURE = new ResourceLocation("/terrain.png");
IInventory playerInventory;
TileFiller filler;
@ -45,12 +46,12 @@ public class GuiFiller extends GuiBuildCraft {
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/filler.png");
mc.renderEngine.func_110577_a(TEXTURE);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if (filler.currentPattern != null) {
mc.renderEngine.bindTexture("/terrain.png");
mc.renderEngine.func_110577_a(BLOCK_TEXTURE);
drawTexturedModelRectFromIcon(guiLeft + patternSymbolX, guiTop + patternSymbolY, filler.currentPattern.getTexture(), 16, 16);
}
@ -85,10 +86,8 @@ public class GuiFiller extends GuiBuildCraft {
lastX = i;
lastY = j;
}
private int lastX = 0;
private int lastY = 0;
public final int patternSymbolX = 125;
public final int patternSymbolY = 34;
}

View file

@ -1,12 +1,10 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.builders.gui;
import buildcraft.builders.TileArchitect;
@ -19,13 +17,14 @@ import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtils;
import java.util.Date;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiTemplate extends GuiBuildCraft {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/template_gui.png");
IInventory playerInventory;
TileArchitect template;
boolean editMode = false;
public GuiTemplate(IInventory playerInventory, TileArchitect template) {
@ -52,7 +51,7 @@ public class GuiTemplate extends GuiBuildCraft {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/template_gui.png");
mc.renderEngine.func_110577_a(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
@ -85,7 +84,7 @@ public class GuiTemplate extends GuiBuildCraft {
return;
}
PacketPayload payload = new PacketPayload();
payload.intPayload = new int[] { c };
payload.intPayload = new int[]{c};
PacketUpdate packet = new PacketUpdate(PacketIds.ARCHITECT_NAME, template.xCoord, template.yCoord, template.zCoord, payload);
CoreProxy.proxy.sendToServer(packet.getPacket());
} else {

View file

@ -37,7 +37,6 @@ public class DefaultProps {
public static int TEMPLATE_ITEM_ID = 19105;
public static int WRENCH_ID = 19106;
public static int BUCKET_OIL_ID = 19107;
public static int FUEL_ID = 19108;
public static int PIPE_WATERPROOF_ID = 19109;
public static int BUCKET_FUEL_ID = 19110;
public static int GATE_ID = 19111;
@ -108,11 +107,12 @@ public class DefaultProps {
public static int ASSEMBLY_TABLE_ID = 1517;
public static int PATH_MARKER_ID = 1518;
public static int HOPPER_ID = 1519;
public static int OIL_MOVING_ID = 1520;
public static int OIL_STILL_ID = 1521;
public static int SPRING_ID = 1522;
public static int FILTERED_BUFFER = 1523;
public static int OIL_ID = 1530;
public static int FUEL_ID = 1531;
public static boolean CURRENT_CONTINUOUS = false;
public static double PIPES_DURABILITY = 0.25D;
public static boolean FILLER_DESTROY = false;
@ -165,4 +165,6 @@ public class DefaultProps {
public static int ACTION_ENERGY_PULSER = 9;
public static int ACTION_SINGLE_ENERGY_PULSE = 10;
public static int BIOME_OIL_OCEAN = 160;
public static int BIOME_OIL_DESERT = 161;
}

View file

@ -1,22 +1,21 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core;
import buildcraft.api.core.Position;
import static buildcraft.core.EntityLaser.LASER_TEXTURES;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityEnergyLaser extends EntityLaser {
public static final short POWER_AVERAGING = 100;
public int displayStage = 0;
private final float power[] = new float[POWER_AVERAGING];
private int powerIndex = 0;
private float powerAverage = 0;
@ -46,16 +45,15 @@ public class EntityEnergyLaser extends EntityLaser {
}
@Override
public String getTexture() {
public ResourceLocation getTexture() {
if (getPowerAverage() <= 1.0)
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png";
return LASER_TEXTURES[0];
else if (getPowerAverage() <= 2.0)
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_2.png";
return LASER_TEXTURES[1];
else if (getPowerAverage() <= 3.0)
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_3.png";
return LASER_TEXTURES[2];
else
return DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_4.png";
return LASER_TEXTURES[3];
}
@Override

View file

@ -11,10 +11,16 @@ import buildcraft.api.core.Position;
import buildcraft.core.proxy.CoreProxy;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public abstract class EntityLaser extends Entity {
public static final ResourceLocation[] LASER_TEXTURES = new ResourceLocation[]{
new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png"),
new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_2.png"),
new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_3.png"),
new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_4.png")};
protected Position head, tail;
public double renderSize = 0;
public double angleY = 0;
@ -142,7 +148,7 @@ public abstract class EntityLaser extends Entity {
return this.isVisible;
}
public abstract String getTexture();
public abstract ResourceLocation getTexture();
protected int encodeDouble(double d) {
return (int) (d * 8192);

View file

@ -1,10 +1,12 @@
package buildcraft.core;
import buildcraft.api.core.Position;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityPowerLaser extends EntityLaser {
private String texture;
private byte texture;
public EntityPowerLaser(World world) {
super(world);
@ -17,23 +19,23 @@ public class EntityPowerLaser extends EntityLaser {
@Override
protected void entityInit() {
super.entityInit();
dataWatcher.addObject(15, "");
dataWatcher.addObject(15, (byte) 0);
}
@Override
public String getTexture() {
return texture;
public ResourceLocation getTexture() {
return LASER_TEXTURES[texture];
}
public void setTexture(String texture) {
this.texture = texture;
public void setTexture(int texture) {
this.texture = (byte) texture;
needsUpdate = true;
}
@Override
protected void updateDataClient() {
super.updateDataClient();
texture = dataWatcher.getWatchableObjectString(15);
texture = dataWatcher.getWatchableObjectByte(15);
}
@Override

View file

@ -12,11 +12,10 @@ import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
@ -27,110 +26,74 @@ import org.lwjgl.opengl.GL11;
*/
public class FluidRenderer {
private static Map<FluidStack, int[]> flowingRenderCache = new HashMap<FluidStack, int[]>();
private static Map<FluidStack, int[]> stillRenderCache = new HashMap<FluidStack, int[]>();
private static final ResourceLocation BLOCK_TEXTURE = new ResourceLocation("/terrain.png");
private static Map<Fluid, int[]> flowingRenderCache = new HashMap<Fluid, int[]>();
private static Map<Fluid, int[]> stillRenderCache = new HashMap<Fluid, int[]>();
public static final int DISPLAY_STAGES = 100;
private static final BlockInterface liquidBlock = new BlockInterface();
public static class FluidTextureException extends RuntimeException {
public static class MissingFluidTextureException extends RuntimeException {
private final FluidStack liquid;
private final FluidStack fluidStack;
public FluidTextureException(FluidStack liquid) {
public MissingFluidTextureException(FluidStack fluidStack) {
super();
this.liquid = liquid;
this.fluidStack = fluidStack;
}
@Override
public String getMessage() {
String liquidName = FluidRegistry.getFluidName(liquid);
if (liquidName == null) {
liquidName = String.format("ID: %d Meta: %d", liquid.itemID, liquid.itemMeta);
}
return String.format("Fluid %s has no icon. Please contact the author of the mod the liquid came from.", liquidName);
String fluidName = FluidRegistry.getFluidName(fluidStack);
return String.format("Fluid %s has no icon. Please contact the author of the mod the fluid came from.", fluidName);
}
}
public static class FluidCanonException extends RuntimeException {
private final FluidStack liquid;
public FluidCanonException(FluidStack liquid) {
super();
this.liquid = liquid;
}
@Override
public String getMessage() {
String liquidName = FluidRegistry.getFluidName(liquid);
if (liquidName == null) {
liquidName = String.format("ID: %d Meta: %d", liquid.itemID, liquid.itemMeta);
}
return String.format("Fluid %s is not registered with the Fluid Dictionary. Please contact the author of the mod the liquid came from.", liquidName);
}
}
public static Icon getFluidTexture(FluidStack liquid) {
if (liquid == null || liquid.itemID <= 0) {
public static Icon getFluidTexture(FluidStack fluidStack, boolean flowing) {
if (fluidStack == null) {
return null;
}
FluidStack canon = liquid.canonical();
if (canon == null) {
throw new FluidCanonException(liquid);
}
Icon icon = canon.getRenderingIcon();
Fluid fluid = fluidStack.getFluid();
Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
if (icon == null) {
throw new FluidTextureException(liquid);
throw new MissingFluidTextureException(fluidStack);
}
return icon;
}
public static ResourceLocation getFluidSheet(FluidStack liquid) {
if (liquid == null || liquid.itemID <= 0) {
return "/terrain.png";
}
FluidStack canon = liquid.canonical();
if (canon == null) {
throw new FluidCanonException(liquid);
}
return canon.getTextureSheet();
return BLOCK_TEXTURE;
}
public static int[] getFluidDisplayLists(FluidStack liquid, World world, boolean flowing) {
if (liquid == null) {
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
if (fluidStack == null) {
return null;
}
liquid = liquid.canonical();
if(liquid == null){
throw new FluidCanonException(liquid);
Fluid fluid = fluidStack.getFluid();
if (fluid == null) {
return null;
}
Map<FluidStack, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
int[] diplayLists = cache.get(liquid);
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
int[] diplayLists = cache.get(fluid);
if (diplayLists != null) {
return diplayLists;
}
diplayLists = new int[DISPLAY_STAGES];
if (liquid.itemID < Block.blocksList.length && Block.blocksList[liquid.itemID] != null) {
liquidBlock.baseBlock = Block.blocksList[liquid.itemID];
if (!flowing) {
liquidBlock.texture = getFluidTexture(liquid);
}
} else if (Item.itemsList[liquid.itemID] != null) {
liquidBlock.baseBlock = Block.waterStill;
liquidBlock.texture = getFluidTexture(liquid);
if (fluid.getBlockID() > 0) {
liquidBlock.baseBlock = Block.blocksList[fluid.getBlockID()];
liquidBlock.texture = getFluidTexture(fluidStack, flowing);
} else {
return null;
liquidBlock.baseBlock = Block.waterStill;
liquidBlock.texture = getFluidTexture(fluidStack, flowing);
}
cache.put(liquid, diplayLists);
cache.put(fluid, diplayLists);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_CULL_FACE);
ItemStack stack = liquid.asItemStack();
int color = stack.getItem().getColorFromItemStack(stack, 0);
int color = fluid.getColor(fluidStack);
float c1 = (float) (color >> 16 & 255) / 255.0F;
float c2 = (float) (color >> 8 & 255) / 255.0F;
float c3 = (float) (color & 255) / 255.0F;
@ -147,7 +110,7 @@ public class FluidRenderer {
liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
liquidBlock.maxZ = 0.99f;
RenderEntityBlock.renderBlock(liquidBlock, world, 0, 0, 0, false, true);
RenderEntityBlock.INSTANCE.renderBlock(liquidBlock, world, 0, 0, 0, false, true);
GL11.glEndList();
}

View file

@ -6,6 +6,7 @@ import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class RenderLaser extends Render {
@ -45,7 +46,7 @@ public class RenderLaser extends Render {
GL11.glRotatef((float) laser.angleZ, 0, 1, 0);
GL11.glRotatef((float) laser.angleY, 0, 0, 1);
renderManager.renderEngine.bindTexture(laser.getTexture());
renderManager.renderEngine.func_110577_a(laser.getTexture());
float factor = (float) (1.0 / 16.0);
@ -70,11 +71,14 @@ public class RenderLaser extends Render {
}
protected void iterate(EntityLaser laser) {
}
protected ModelRenderer getBox(EntityLaser laser) {
return box;
}
@Override
protected ResourceLocation func_110775_a(Entity entity) {
return ((EntityLaser) entity).getTexture();
}
}

View file

@ -9,10 +9,14 @@ import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
private static final ResourceLocation BLOCK_TEXTURE = new ResourceLocation("/terrain.png");
public static class EntityRenderIndex {
public EntityRenderIndex(Block block, int damage) {
@ -34,11 +38,9 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
return i.block == block && i.damage == damage;
}
Block block;
int damage;
}
public static HashMap<EntityRenderIndex, IInventoryRenderer> blockByEntityRenders = new HashMap<EntityRenderIndex, IInventoryRenderer>();
@Override
@ -92,9 +94,8 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {
// renderblocks.renderStandardBlock(block, i, j, k);
} else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
Minecraft.getMinecraft().renderEngine.bindTexture("/terrain.png");
Minecraft.getMinecraft().renderEngine.func_110577_a(BLOCK_TEXTURE);
legacyPipeRender(renderer, world, x, y, z, block, modelId);
}
@ -159,5 +160,4 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}

View file

@ -78,7 +78,7 @@ public class BlockUtil {
if (block.getBlockHardness(world, x, y, z) < 0)
return false;
if (blockID == BuildCraftEnergy.oilMoving.blockID || blockID == BuildCraftEnergy.blockOil.blockID)
if (blockID == BuildCraftEnergy.blockOil.blockID)
return false;
if (blockID == Block.lavaStill.blockID || blockID == Block.lavaMoving.blockID)

View file

@ -45,6 +45,10 @@ import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
public class Utils {
@ -230,23 +234,23 @@ public class Utils {
TileEntityChest adjacent = null;
if (chest.adjacentChestXNeg != null){
if (chest.adjacentChestXNeg != null) {
adjacent = chest.adjacentChestXNeg;
}
if (chest.adjacentChestXPos != null){
if (chest.adjacentChestXPos != null) {
adjacent = chest.adjacentChestXPos;
}
if (chest.adjacentChestZNeg != null){
if (chest.adjacentChestZNeg != null) {
adjacent = chest.adjacentChestZNeg;
}
if (chest.adjacentChestZPosition != null){
if (chest.adjacentChestZPosition != null) {
adjacent = chest.adjacentChestZPosition;
}
if (adjacent != null){
if (adjacent != null) {
return new InventoryLargeChest("", inv, adjacent);
}
return inv;
@ -376,6 +380,26 @@ public class Utils {
}
}
public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) {
int blockId = world.getBlockId(x, y, z);
if (Block.blocksList[blockId] instanceof IFluidBlock) {
IFluidBlock fluidBlock = (IFluidBlock) Block.blocksList[blockId];
if (fluidBlock.canDrain(world, x, y, z))
return fluidBlock.drain(world, x, y, z, doDrain);
} else if (blockId == Block.waterStill.blockID || blockId == Block.waterMoving.blockID) {
if (doDrain) {
world.setBlockToAir(x, y, z);
}
return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME);
} else if (blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID) {
if (doDrain) {
world.setBlockToAir(x, y, z);
}
return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME);
}
return null;
}
public static void preDestroyBlock(World world, int i, int j, int k) {
TileEntity tile = world.getBlockTileEntity(i, j, k);

View file

@ -0,0 +1,76 @@
/*
* Copyright (c) SpaceToad, 2011-2012
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
/**
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class BlockBuildcraftFluid extends BlockFluidClassic {
public BlockBuildcraftFluid(int id, Fluid fluid, Material material) {
super(id, fluid, material);
}
@SideOnly(Side.CLIENT)
protected Icon[] theIcon;
protected boolean flammable;
protected int flammability = 0;
@Override
public Icon getIcon(int side, int meta) {
return side != 0 && side != 1 ? this.theIcon[1] : this.theIcon[0];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
this.theIcon = new Icon[]{iconRegister.registerIcon("buildcraft:" + fluidName), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow")};
}
public BlockBuildcraftFluid setFlammable(boolean flammable) {
this.flammable = flammable;
return this;
}
public BlockBuildcraftFluid setFlammability(int flammability) {
this.flammability = flammability;
return this;
}
@Override
public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) {
return flammable ? 300 : 0;
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) {
return flammability;
}
@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) {
return flammable;
}
@Override
public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side) {
return flammable && flammability == 0;
}
}

View file

@ -1,15 +1,17 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import buildcraft.BuildCraftEnergy;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
@ -17,7 +19,13 @@ import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;
public class OilBucketHandler {
public class BucketHandler {
public static BucketHandler INSTANCE = new BucketHandler();
public Map<Block, Item> buckets = new HashMap<Block, Item>();
private BucketHandler() {
}
@ForgeSubscribe
public void onBucketFill(FillBucketEvent event) {
@ -31,19 +39,16 @@ public class OilBucketHandler {
event.setResult(Result.ALLOW);
}
public ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {
int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);
if ((blockID == BuildCraftEnergy.blockOil.blockID || blockID == BuildCraftEnergy.oilMoving.blockID)
&& world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {
Item bucket = buckets.get(Block.blocksList[blockID]);
if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
return new ItemStack(BuildCraftEnergy.bucketOil);
return new ItemStack(bucket);
} else
return null;
}
}

View file

@ -3,7 +3,7 @@ package buildcraft.energy;
import buildcraft.core.GuiIds;
import buildcraft.energy.gui.ContainerEngine;
import buildcraft.energy.gui.GuiCombustionEngine;
import buildcraft.energy.gui.GuiSteamEngine;
import buildcraft.energy.gui.GuiStoneEngine;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
@ -29,7 +29,7 @@ public class GuiHandler implements IGuiHandler {
return new GuiCombustionEngine(player.inventory, engine);
case GuiIds.ENGINE_STONE:
return new GuiSteamEngine(player.inventory, engine);
return new GuiStoneEngine(player.inventory, engine);
default:
return null;

View file

@ -1,27 +1,27 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy;
import buildcraft.BuildCraftEnergy;
import buildcraft.core.CreativeTabBuildCraft;
import buildcraft.core.utils.StringUtils;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBucket;
import net.minecraft.item.ItemStack;
public class ItemBucketOil extends ItemBucket {
public class ItemBucketBuildcraft extends ItemBucket {
public ItemBucketOil(int i) {
super(i, BuildCraftEnergy.oilMoving.blockID);
private String iconName;
public ItemBucketBuildcraft(int i, int blockId) {
super(i, blockId);
setCreativeTab(CreativeTabBuildCraft.tabBuildCraft);
}
@ -30,10 +30,15 @@ public class ItemBucketOil extends ItemBucket {
return StringUtils.localize(getUnlocalizedName(itemstack));
}
@Override
public Item setUnlocalizedName(String par1Str) {
iconName = par1Str;
return super.setUnlocalizedName(par1Str);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon("buildcraft:oil_bucket");
public void registerIcons(IconRegister par1IconRegister) {
this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName);
}
}

View file

@ -1,27 +1,28 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy.gui;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngine;
import buildcraft.energy.TileEngineIron;
import net.minecraft.block.Block;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
public class GuiCombustionEngine extends GuiEngine {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png");
private static final ResourceLocation BLOCK_TEXTURE = new ResourceLocation("/terrain.png");
public GuiCombustionEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
}
@ -37,7 +38,7 @@ public class GuiCombustionEngine extends GuiEngine {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png");
mc.renderEngine.func_110577_a(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
@ -54,30 +55,21 @@ public class GuiCombustionEngine extends GuiEngine {
}
private void displayGauge(int j, int k, int line, int col, int squaled, FluidStack liquid) {
if (liquid == null)
{
if (liquid == null) {
return;
}
int start = 0;
Icon liquidIcon;
String textureSheet;
if(liquid.canonical() != null && liquid.canonical().getRenderingIcon() != null) {
textureSheet = liquid.canonical().getTextureSheet();
liquidIcon = liquid.canonical().getRenderingIcon();
} else {
if (liquid.itemID < Block.blocksList.length && Block.blocksList[liquid.itemID].blockID > 0) {
liquidIcon = Block.blocksList[liquid.itemID].getBlockTextureFromSide(0);
textureSheet = "/terrain.png";
} else {
liquidIcon = Item.itemsList[liquid.itemID].getIconFromDamage(liquid.itemMeta);
textureSheet = "/gui/items.png";
Icon liquidIcon = null;
Fluid fluid = liquid.getFluid();
if (fluid != null && fluid.getStillIcon() != null) {
liquidIcon = fluid.getStillIcon();
}
}
mc.renderEngine.bindTexture(textureSheet);
mc.renderEngine.func_110577_a(BLOCK_TEXTURE);
if (liquidIcon != null) {
while (true) {
int x = 0;
int x;
if (squaled > 16) {
x = 16;
@ -94,9 +86,9 @@ public class GuiCombustionEngine extends GuiEngine {
break;
}
}
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png");
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}
mc.renderEngine.func_110577_a(TEXTURE);
drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}
}

View file

@ -8,9 +8,12 @@ import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngine;
import net.minecraft.client.Minecraft;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
public abstract class GuiEngine extends GuiBuildCraft {
private static final ResourceLocation ITEM_TEXTURE = new ResourceLocation("/gui/items.png");
protected class EngineLedger extends Ledger {
TileEngine engine;
@ -31,7 +34,7 @@ public abstract class GuiEngine extends GuiBuildCraft {
drawBackground(x, y);
// Draw icon
Minecraft.getMinecraft().renderEngine.bindTexture("/gui/items.png");
Minecraft.getMinecraft().renderEngine.func_110577_a(ITEM_TEXTURE);
drawIcon(BuildCraftCore.iconProvider.getIcon(CoreIconProvider.ENERGY), x + 3, y + 4);
if (!isFullyOpened())

View file

@ -1,23 +1,24 @@
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
* 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.energy.gui;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtils;
import buildcraft.energy.TileEngine;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiSteamEngine extends GuiEngine {
public class GuiStoneEngine extends GuiEngine {
public GuiSteamEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png");
public GuiStoneEngine(InventoryPlayer inventoryplayer, TileEngine tileEngine) {
super(new ContainerEngine(inventoryplayer, tileEngine), tileEngine);
}
@ -32,7 +33,7 @@ public class GuiSteamEngine extends GuiEngine {
@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/steam_engine_gui.png");
mc.renderEngine.func_110577_a(TEXTURE);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);

View file

@ -31,6 +31,8 @@ import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.minecraftforge.fluids.BlockFluidBase;
import net.minecraftforge.fluids.IFluidBlock;
public class OilPopulate {
@ -251,18 +253,15 @@ public class OilPopulate {
}
}
/**
* TODO: This might need adjustment when more liquids have blocks
*/
private boolean isOilOrWater(World world, int x, int y, int z) {
private boolean isReplaceableFluid(World world, int x, int y, int z) {
int blockId = world.getBlockId(x, y, z);
Block block = Block.blocksList[blockId];
return block instanceof BlockFluid && block.blockMaterial != Material.lava;
return (block instanceof BlockFluid || block instanceof IFluidBlock) && block.blockMaterial != Material.lava;
}
private boolean isOil(World world, int x, int y, int z) {
int blockId = world.getBlockId(x, y, z);
return (blockId == BuildCraftEnergy.blockOil.blockID || blockId == BuildCraftEnergy.oilMoving.blockID);
return (blockId == BuildCraftEnergy.blockOil.blockID);
}
private boolean isReplaceableForLake(World world, BiomeGenBase biome, int x, int y, int z) {
@ -316,7 +315,7 @@ public class OilPopulate {
if (!world.isAirBlock(x, y + 2, z)) {
return;
}
if (isOilOrWater(world, x, y, z) || world.isBlockSolidOnSide(x, y - 1, z, ForgeDirection.UP)) {
if (isReplaceableFluid(world, x, y, z) || world.isBlockSolidOnSide(x, y - 1, z, ForgeDirection.UP)) {
world.setBlock(x, y, z, BuildCraftEnergy.blockOil.blockID, 0, update);
} else {
return;
@ -326,7 +325,7 @@ public class OilPopulate {
}
for (int d = 1; d <= depth - 1; d++) {
if (isOilOrWater(world, x, y - d, z) || !world.isBlockSolidOnSide(x, y - d - 1, z, ForgeDirection.UP)) {
if (isReplaceableFluid(world, x, y - d, z) || !world.isBlockSolidOnSide(x, y - d - 1, z, ForgeDirection.UP)) {
return;
}
world.setBlock(x, y - d, z, BuildCraftEnergy.blockOil.blockID, 0, 2);
@ -350,6 +349,9 @@ public class OilPopulate {
if (block instanceof BlockFluid) {
return y;
}
if (block instanceof IFluidBlock) {
return y;
}
if (!block.blockMaterial.blocksMovement()) {
continue;
}

View file

@ -28,19 +28,20 @@ import java.util.LinkedList;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor, ITankContainer {
public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor, IFluidHandler {
public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME;
public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 16;
EntityBlock tube;
private TreeMap<Integer, LinkedList<BlockIndex>> blocksToPump = new TreeMap<Integer, LinkedList<BlockIndex>>();
FluidTank tank;
@ -84,15 +85,15 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
BlockIndex index = getNextIndexToPump(false);
if (isPumpableFluid(index)) {
FluidStack liquidToPump = Utils.liquidFromBlockId(worldObj.getBlockId(index.i, index.j, index.k));
FluidStack liquidToPump = Utils.drainBlock(worldObj, index.i, index.j, index.k, false);
if (tank.fill(liquidToPump, false) == liquidToPump.amount) {
if (powerHandler.useEnergy(10, 10, true) == 10) {
index = getNextIndexToPump(true);
if (liquidToPump.itemID != Block.waterStill.blockID || BuildCraftCore.consumeWaterSources) {
worldObj.setBlock(index.i, index.j, index.k, 0);
if (liquidToPump.getFluid() != FluidRegistry.WATER || BuildCraftCore.consumeWaterSources) {
Utils.drainBlock(worldObj, index.i, index.j, index.k, true);
}
tank.fill(liquidToPump, true);
@ -131,8 +132,8 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
TileEntity tile = worldObj.getBlockTileEntity((int) p.x, (int) p.y, (int) p.z);
if (tile instanceof ITankContainer) {
int moved = ((ITankContainer) tile).fill(p.orientation.getOpposite(), liquid, true);
if (tile instanceof IFluidHandler) {
int moved = ((IFluidHandler) tile).fill(p.orientation.getOpposite(), liquid, true);
tank.drain(moved, true);
if (liquid.amount <= 0) {
break;
@ -267,7 +268,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
if (index == null)
return false;
FluidStack liquid = Utils.liquidFromBlockId(worldObj.getBlockId(index.i, index.j, index.k));
FluidStack liquid = Utils.drainBlock(worldObj, index.i, index.j, index.k, false);
if (liquid == null)
return false;
@ -275,38 +276,31 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
public void readFromNBT(NBTTagCompound data) {
super.readFromNBT(data);
if (nbttagcompound.hasKey("internalFluid")) {
tank.setFluid(new FluidStack(nbttagcompound.getInteger("liquidId"), nbttagcompound.getInteger("internalFluid")));
} else if (nbttagcompound.hasKey("tank")) {
tank.setFluid(FluidStack.loadFluidStackFromNBT(nbttagcompound.getCompoundTag("tank")));
}
aimY = nbttagcompound.getInteger("aimY");
powerHandler.readFromNBT(data);
tank.readFromNBT(data);
tubeY = nbttagcompound.getFloat("tubeY");
aimY = data.getInteger("aimY");
tubeY = data.getFloat("tubeY");
powerHandler.readFromNBT(nbttagcompound);
initPowerProvider();
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
public void writeToNBT(NBTTagCompound data) {
super.writeToNBT(data);
powerHandler.writeToNBT(nbttagcompound);
powerHandler.writeToNBT(data);
tank.writeToNBT(data);
if (tank.getFluid() != null) {
nbttagcompound.setTag("tank", tank.getFluid().writeToNBT(new NBTTagCompound()));
}
nbttagcompound.setInteger("aimY", aimY);
data.setInteger("aimY", aimY);
if (tube != null) {
nbttagcompound.setFloat("tubeY", (float) tube.posY);
data.setFloat("tubeY", (float) tube.posY);
} else {
nbttagcompound.setFloat("tubeY", yCoord);
data.setFloat("tubeY", yCoord);
}
}
@ -326,31 +320,25 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
@Override
public PacketPayload getPacketPayload() {
PacketPayload payload = new PacketPayload(4, 1, 0);
PacketPayload payload = new PacketPayload(3, 1, 0);
if (tank.getFluid() != null) {
payload.intPayload[0] = tank.getFluid().itemID;
payload.intPayload[1] = tank.getFluid().itemMeta;
payload.intPayload[2] = tank.getFluid().amount;
payload.intPayload[0] = tank.getFluid().getFluid().getID();
payload.intPayload[1] = tank.getFluid().amount;
} else {
payload.intPayload[0] = 0;
payload.intPayload[1] = 0;
payload.intPayload[2] = 0;
}
payload.intPayload[3] = aimY;
payload.intPayload[2] = aimY;
payload.floatPayload[0] = (float) tubeY;
return payload;
}
@Override
public void handleDescriptionPacket(PacketUpdate packet) {
handleUpdatePacket(packet);
}
@Override
public void handleUpdatePacket(PacketUpdate packet) {
if (packet.payload.intPayload[0] > 0) {
tank.setFluid(new FluidStack(packet.payload.intPayload[0], packet.payload.intPayload[2], packet.payload.intPayload[1]));
FluidStack liquid = new FluidStack(FluidRegistry.getFluid(packet.payload.intPayload[0]), packet.payload.intPayload[2]);
tank.setFluid(liquid);
} else {
tank.setFluid(null);
}
@ -361,6 +349,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
setTubePosition();
}
@Override
public void handleDescriptionPacket(PacketUpdate packet) {
handleUpdatePacket(packet);
}
private void setTubePosition() {
if (tube != null) {
tube.iSize = Utils.pipeMaxPos - Utils.pipeMinPos;
@ -403,39 +396,37 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor
return false;
}
// ITankContainer implementation.
// IFluidHandler implementation.
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
// not acceptable
return 0;
}
@Override
public int fill(int tankIndex, FluidStack resource, boolean doFill) {
// not acceptable
return 0;
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
return drain(0, maxDrain, doDrain);
}
@Override
public FluidStack drain(int tankIndex, int maxDrain, boolean doDrain) {
if (tankIndex == 0)
return tank.drain(maxDrain, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
if (resource != null && !resource.isFluidEqual(tank.getFluid()))
return null;
return drain(from, resource.amount, doDrain);
}
@Override
public IFluidTank[] getTanks(ForgeDirection direction) {
return new IFluidTank[]{tank};
public boolean canFill(ForgeDirection from, Fluid fluid) {
return false;
}
@Override
public IFluidTank getTank(ForgeDirection direction, FluidStack type) {
return tank;
public boolean canDrain(ForgeDirection from, Fluid fluid) {
return true;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
return new FluidTankInfo[]{tank.getInfo()};
}
}