New vat model, new fuels and stuff.

This commit is contained in:
cp committed 2014-03-31 21:09:20 +08:00
1 parent 5bd512a219
commit df3c785493
35 files changed
+443 -75

No files matched your search

@@ -54,6 +54,8 @@ import crazypants.enderio.machine.power.CapBankRenderer2;
import crazypants.enderio.machine.power.CapacitorBankRenderer;
import crazypants.enderio.machine.reservoir.ReservoirRenderer;
import crazypants.enderio.machine.reservoir.TileReservoir;
import crazypants.enderio.machine.still.BlockVat;
import crazypants.enderio.machine.still.VatRenderer;
import crazypants.enderio.material.BlockFusedQuartz;
import crazypants.enderio.material.FusedQuartzFrameRenderer;
import crazypants.enderio.material.FusedQuartzRenderer;
@@ -67,12 +69,12 @@ public class ClientProxy extends CommonProxy {
// @formatter:off
public static int[][] sideAndFacingToSpriteOffset = new int[][] {
{ 3, 2, 0, 0, 0, 0 },
{ 2, 3, 1, 1, 1, 1 },
{ 1, 1, 3, 2, 5, 4 },
{ 0, 0, 2, 3, 4, 5 },
{ 4, 5, 4, 5, 3, 2 },
{ 5, 4, 5, 4, 2, 3 } };
{ 3, 2, 0, 0, 0, 0 },
{ 2, 3, 1, 1, 1, 1 },
{ 1, 1, 3, 2, 5, 4 },
{ 0, 0, 2, 3, 4, 5 },
{ 4, 5, 4, 5, 3, 2 },
{ 5, 4, 5, 4, 2, 3 } };
// @formatter:on
static {
@@ -117,12 +119,16 @@ public class ClientProxy extends CommonProxy {
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new FusedQuartzRenderer());
BlockCombustionGenerator.renderId = RenderingRegistry.getNextAvailableRenderId();
CombustionGeneratorRenderer cr = new CombustionGeneratorRenderer();
RenderingRegistry.registerBlockHandler(cr);
ClientRegistry.bindTileEntitySpecialRenderer(TileCombustionGenerator.class, cr);
BlockVat.renderId = RenderingRegistry.getNextAvailableRenderId();
VatRenderer vr = new VatRenderer();
RenderingRegistry.registerBlockHandler(vr);
FusedQuartzFrameRenderer fqfr = new FusedQuartzFrameRenderer();
MinecraftForgeClient.registerItemRenderer(EnderIO.itemFusedQuartzFrame, fqfr);
+29 -11
View File
@@ -107,7 +107,11 @@ public final class Config {
public static float darkSteelPickEffeciencyBoostWhenPowered = 2;
public static int hootchPowerPerCycle = 6;
public static int hootchPowerTotalBurnTime = 25000;
public static int hootchPowerTotalBurnTime = 12000;
public static int rocketFuelPowerPerCycle = 9;
public static int rocketFuelPowerTotalBurnTime = 12000;
public static int fireWaterPowerPerCycle = 12;
public static int fireWaterPowerTotalBurnTime = 12000;
public static void load(FMLPreInitializationEvent event) {
configDirectory = new File(event.getModConfigurationDirectory(), "enderio");
@@ -151,7 +155,7 @@ public final class Config {
conduitScale = config.get("Settings", "conduitScale", DEFAULT_CONDUIT_SCALE,
"Valid values are between 0-1, smallest conduits at 0, largest at 1.\n" +
"In SMP, all clients must be using the same value as the server.").getDouble(DEFAULT_CONDUIT_SCALE);
"In SMP, all clients must be using the same value as the server.").getDouble(DEFAULT_CONDUIT_SCALE);
conduitScale = VecmathUtil.clamp(conduitScale, 0, 1);
fluidConduitExtractRate = config.get("Settings", "fluidConduitExtractRate", fluidConduitExtractRate,
@@ -184,7 +188,7 @@ public final class Config {
"perInterfacePowerTrackingEnabled",
detailedPowerTrackingEnabled,
"Enable per tick sampling on individual power inputs and outputs. This allows slightly more detailed messages from the MJ Reader but has a negative impact on server performance.")
.getBoolean(detailedPowerTrackingEnabled);
.getBoolean(detailedPowerTrackingEnabled);
useSneakMouseWheelYetaWrench = config.get("Settings", "useSneakMouseWheelYetaWrench", useSneakMouseWheelYetaWrench,
"If true, shift-mouse wheel will change the conduit display mode when the YetaWrench is eqipped.")
@@ -240,8 +244,8 @@ public final class Config {
.get("Settings", "travelStaffBlinkThroughClearBlocksEnabled", travelStaffBlinkThroughClearBlocksEnabled,
"If travelStaffBlinkThroughSolidBlocksEnabled is set to false and this is true, the travel " +
"staff can only be used to blink through transparent or partial blocks (e.g. torches). " +
"If both are false, only air blocks may be teleported through.")
.getBoolean(travelStaffBlinkThroughClearBlocksEnabled);
"If both are false, only air blocks may be teleported through.")
.getBoolean(travelStaffBlinkThroughClearBlocksEnabled);
enderIoRange = config.get("Settings", "enderIoRange", enderIoRange,
"Range accessable (in blocks) when using the Ender IO.").getInt(enderIoRange);
@@ -253,7 +257,7 @@ public final class Config {
"When true, correct lighting is recalculated (client side) for conduit bundles when transitioning to"
+ " from being hidden behind a facade. This produces "
+ "better quality rendering but can result in frame stutters when switching to/from a wrench.")
.getBoolean(updateLightingWhenHidingFacades);
.getBoolean(updateLightingWhenHidingFacades);
darkSteelLeggingWalkModifier = config.get("Settings", "darkSteelLeggingWalkModifier", darkSteelLeggingWalkModifier,
"Speed modifier applied when walking in the Dark Steel Boots.").getDouble(darkSteelLeggingWalkModifier);
@@ -278,22 +282,22 @@ public final class Config {
"The base chance a skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble(darkSteelSwordSkullChance);
darkSteelSwordSkullLootingModifier = (float) config.get("Settings", "darkSteelSwordSkullLootingModifier", darkSteelSwordSkullLootingModifier,
"The chance per looting level that a skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble(
darkSteelSwordSkullLootingModifier);
darkSteelSwordSkullLootingModifier);
darkSteelSwordWitherSkullChance = (float) config.get("Settings", "darkSteelSwordWitherSkullChance", darkSteelSwordWitherSkullChance,
"The base chance a wither skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble(
darkSteelSwordWitherSkullChance);
darkSteelSwordWitherSkullChance);
darkSteelSwordWitherSkullLootingModifier = (float) config.get("Settings", "darkSteelSwordWitherSkullLootingModifie",
darkSteelSwordWitherSkullLootingModifier,
"The chance per looting level that a wither skull will be dropped when using a powered dark steel sword (0 = no chance, 1 = 100% chance)").getDouble(
darkSteelSwordWitherSkullLootingModifier);
darkSteelSwordWitherSkullLootingModifier);
vanillaSwordSkullLootingModifier = (float) config.get("Settings", "vanillaSwordSkullLootingModifier", vanillaSwordSkullLootingModifier,
"The chance per looting level that a skull will be dropped when using a non-dark steel sword (0 = no chance, 1 = 100% chance)").getDouble(
vanillaSwordSkullLootingModifier);
vanillaSwordSkullLootingModifier);
darkSteelSwordPowerUsePerHit = config.get("Settings", "darkSteelSwordPowerUsePerHit", darkSteelSwordPowerUsePerHit,
"The amount of power (RF) used per hit.").getInt(darkSteelSwordPowerUsePerHit);
darkSteelSwordEnderPearlDropChance = config.get("Settings", "darkSteelSwordEnderPearlDropChance", darkSteelSwordEnderPearlDropChance,
"The chance that an ender pearl will be dropped when using a dark steel sword (0 = no chance, 1 = 100% chance)").getDouble(
darkSteelSwordEnderPearlDropChance);
darkSteelSwordEnderPearlDropChance);
darkSteelSwordEnderPearlDropChancePerLooting = config.get("Settings", "darkSteelSwordEnderPearlDropChancePerLooting",
darkSteelSwordEnderPearlDropChancePerLooting,
"The chance for each looting level that an additional ender pearl will be dropped when using a dark steel sword (0 = no chance, 1 = 100% chance)")
@@ -314,6 +318,20 @@ public final class Config {
hootchPowerTotalBurnTime = config.get("Settings", "hootchPowerTotalBurnTime", hootchPowerTotalBurnTime,
"The total burn time. Examples: BC Oil = 5000, BC Fuel = 25000").getInt(hootchPowerTotalBurnTime);
rocketFuelPowerPerCycle = config.get("Settings", "rocketFuelPowerPerCycle", rocketFuelPowerPerCycle,
"The amount of power generated per BC engine cycle. Examples: BC Oil = 3, BC Fuel = 6").getInt(rocketFuelPowerPerCycle);
rocketFuelPowerTotalBurnTime = config.get("Settings", "rocketFuelPowerTotalBurnTime", rocketFuelPowerTotalBurnTime,
"The total burn time. Examples: BC Oil = 5000, BC Fuel = 25000").getInt(rocketFuelPowerTotalBurnTime);
fireWaterPowerPerCycle = config.get("Settings", "fireWaterPowerPerCycle", fireWaterPowerPerCycle,
"The amount of power generated per BC engine cycle. Examples: BC Oil = 3, BC Fuel = 6").getInt(fireWaterPowerPerCycle);
fireWaterPowerTotalBurnTime = config.get("Settings", "fireWaterPowerTotalBurnTime", fireWaterPowerTotalBurnTime,
"The total burn time. Examples: BC Oil = 5000, BC Fuel = 25000").getInt(fireWaterPowerTotalBurnTime);
//TODO: Debug
renderCapBankGauge = config.get("Debug", "renderCapBankGauge", renderCapBankGauge, "If not true capacitor banks will not render the level gauge at all.")
.getBoolean(renderCapBankGauge);
+34 -9
View File
@@ -152,6 +152,14 @@ public class EnderIO {
public static BlockFluidEio blocHootch;
public static ItemBucketEio itemBucketHootch;
public static Fluid fluidRocketFuel;
public static BlockFluidEio blockRocketFuel;
public static ItemBucketEio itemBucketRocketFuel;
public static Fluid fluidFireWater;
public static BlockFluidEio blockFireWater;
public static ItemBucketEio itemBucketFireWater;
// Items
public static ItemYetaWrench itemYetaWench;
public static ItemConduitProbe itemConduitProbe;
@@ -163,6 +171,8 @@ public class EnderIO {
public static ItemDarkSteelSword itemDarkSteelSword;
public static ItemDarkSteelPickaxe itemDarkSteelPickaxe;
// public static ITrigger triggerNoEnergy;
// public static ITrigger triggerHasEnergy;
// public static ITrigger triggerFullEnergy;
@@ -204,41 +214,56 @@ public class EnderIO {
blockElectricLight = BlockElectricLight.create();
blockLightNode = BlockLightNode.create();
blockReservoir = BlockReservoir.create();
blockFusedQuartz = BlockFusedQuartz.create();
itemFusedQuartzFrame = ItemFusedQuartzFrame.create();
blockConduitBundle = BlockConduitBundle.create();
blockConduitFacade = BlockConduitFacade.create();
itemConduitFacade = ItemConduitFacade.create();
itemConduitFacade = ItemConduitFacade.create();
itemRedstoneConduit = ItemRedstoneConduit.create();
itemPowerConduit = ItemPowerConduit.create();
itemLiquidConduit = ItemLiquidConduit.create();
itemItemConduit = ItemItemConduit.create();
Fluid f = new Fluid(Fluids.NUTRIENT_DISTILLATION_NAME).setDensity(1500).setViscosity(3000);
FluidRegistry.registerFluid(f);
fluidNutrientDistillation = FluidRegistry.getFluid(f.getName());
blockNutrientDistillation = BlockFluidEio.create(fluidNutrientDistillation, new MaterialLiquid(MapColor.brownColor));
f = new Fluid(Fluids.HOOTCH_NAME).setDensity(900).setViscosity(1000);
FluidRegistry.registerFluid(f);
fluidHootch = FluidRegistry.getFluid(f.getName());
blocHootch = BlockFluidEio.create(fluidHootch, new MaterialLiquid(MapColor.grayColor));
IronEngineFuel.addFuel("hootch", Config.hootchPowerPerCycle, Config.hootchPowerTotalBurnTime);
IronEngineFuel.addFuel(Fluids.HOOTCH_NAME, Config.hootchPowerPerCycle, Config.hootchPowerTotalBurnTime);
f = new Fluid(Fluids.ROCKET_FUEL_NAME).setDensity(900).setViscosity(1000);
FluidRegistry.registerFluid(f);
fluidRocketFuel = FluidRegistry.getFluid(f.getName());
blockRocketFuel = BlockFluidEio.create(fluidRocketFuel, new MaterialLiquid(MapColor.grayColor));
IronEngineFuel.addFuel(Fluids.ROCKET_FUEL_NAME, Config.rocketFuelPowerPerCycle, Config.rocketFuelPowerTotalBurnTime);
f = new Fluid(Fluids.FIRE_WATER_NAME).setDensity(900).setViscosity(1000);
FluidRegistry.registerFluid(f);
fluidFireWater = FluidRegistry.getFluid(f.getName());
blockFireWater = BlockFluidEio.create(fluidFireWater, new MaterialLiquid(MapColor.grayColor));
IronEngineFuel.addFuel(Fluids.FIRE_WATER_NAME, Config.fireWaterPowerPerCycle, Config.fireWaterPowerTotalBurnTime);
itemBasicCapacitor = ItemCapacitor.create();
itemMachinePart = ItemMachinePart.create();
itemMaterial = ItemMaterial.create();
itemAlloy = ItemAlloy.create();
itemPowderIngot = ItemPowderIngot.create();
itemBucketNutrientDistillation = ItemBucketEio.create(fluidNutrientDistillation);
itemBucketHootch = ItemBucketEio.create(fluidHootch);
itemBucketRocketFuel = ItemBucketEio.create(fluidRocketFuel);
itemYetaWench = ItemYetaWrench.create();
itemEnderface = ItemEnderface.create();
itemTravelStaff = ItemTravelStaff.create();
@@ -271,7 +296,7 @@ public class EnderIO {
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(
new WeightedRandomChestContent(new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()), 1, 3, 60));
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST)
.addItem(new WeightedRandomChestContent(new ItemStack(EnderIO.itemYetaWench, 1, 0), 1, 1, 15));
.addItem(new WeightedRandomChestContent(new ItemStack(EnderIO.itemYetaWench, 1, 0), 1, 1, 15));
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(EnderIO.itemConduitProbe, 1, 0), 1, 1, 1));
ItemStack staff = new ItemStack(EnderIO.itemTravelStaff, 1, 0);
@@ -1,24 +1,28 @@
package crazypants.enderio.fluid;
import crazypants.util.Lang;
import net.minecraftforge.fluids.IFluidTank;
import crazypants.util.Lang;
public class Fluids {
public static final String NUTRIENT_DISTILLATION_NAME = "nutrient_distillation";
public static final String HOOTCH_NAME = "hootch";
public static final String ROCKET_FUEL_NAME = "rocket_fuel";
public static final String FIRE_WATER_NAME = "fire_water";
public static String toCapactityString(IFluidTank tank) {
if(tank == null) {
return "0/0 " + MB();
}
return "0/0 " + MB();
}
return tank.getFluidAmount() + "/" + tank.getCapacity() + " " + MB();
}
public static String MB() {
return Lang.localize("fluid.millibucket.abr");
}
}
@@ -2,16 +2,24 @@ package crazypants.enderio.machine.generator;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.util.Util;
public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustionGenerator> {
public static int renderId;
protected IIcon frontOn;
protected IIcon frontOff;
@@ -21,19 +29,53 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
return gen;
}
protected BlockCombustionGenerator() {
super(ModObject.blockCombustionGenerator, TileCombustionGenerator.class);
}
@Override
public void registerBlockIcons(IIconRegister iIconRegister) {
super.registerBlockIcons(iIconRegister);
frontOn = iIconRegister.registerIcon("enderio:combustionGenFrontOn");
frontOff = iIconRegister.registerIcon("enderio:combustionGenFront");
frontOff = iIconRegister.registerIcon("enderio:combustionGenFront");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
TileEntity te = world.getTileEntity(x, y, z);
if(!(te instanceof TileCombustionGenerator)) {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
protected BlockCombustionGenerator() {
super(ModObject.blockCombustionGenerator, TileCombustionGenerator.class);
TileCombustionGenerator gen = (TileCombustionGenerator) te;
ItemStack item = entityPlayer.inventory.getCurrentItem();
if(item == null) {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
//check for filled fluid containers and see if we can empty them into our tanks
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if(fluid == null) {
if(item.getItem() == Items.water_bucket) {
fluid = new FluidStack(FluidRegistry.WATER, 1000);
} else if(item.getItem() == Items.lava_bucket) {
fluid = new FluidStack(FluidRegistry.LAVA, 1000);
}
}
if(fluid != null) {
int filled = gen.fill(ForgeDirection.UP, fluid, false);
if(filled >= fluid.amount) {
gen.fill(ForgeDirection.UP, fluid, true);
if(!entityPlayer.capabilities.isCreativeMode) {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, Util.consumeItem(item));
}
return true;
}
}
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
@Override
@@ -52,22 +94,20 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
}
@Override
public int getRenderType() {
public int getRenderType() {
return renderId;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube() {
return false;
}
public IIcon getBlankSideIcon() {
return iconBuffer[0][3];
}
@@ -80,7 +120,7 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
return frontOff;
}
@Override
public String getTopIconKey(boolean active) {
return super.getTopIconKey(active);
}
@@ -91,10 +131,9 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
}
@Override
public String getMachineFrontIconKey(boolean active) {
return "enderio:blankMachinePanel";
public String getMachineFrontIconKey(boolean active) {
return "enderio:blankMachinePanel";
}
}
@@ -5,7 +5,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
@@ -205,11 +204,6 @@ public class CombustionGeneratorRenderer extends TileEntitySpecialRenderer imple
tes.startDrawingQuads();
renderWorldBlock(null, 0, 0, 0, block, 0, renderer);
tes.draw();
renderer.setRenderBoundsFromBlock(Blocks.stone);
renderer.setOverrideBlockTexture(EnderIO.blockFusedQuartz.getDefaultFrameIcon(0));
renderer.renderBlockAsItem(Blocks.cobblestone, 0, 1);
renderer.setOverrideBlockTexture(null);
}
@Override
@@ -180,7 +180,7 @@ public class RecipeConfigParser extends DefaultHandler {
}
return;
}
// Custom tag handling
// Custom tag handling
if(customHandler != null) {
if(customHandler.endElement(uri, localName, qName)) {
return;
@@ -250,7 +250,7 @@ public class RecipeConfigParser extends DefaultHandler {
return;
}
// Custom tag handling
// Custom tag handling
if(customHandler != null) {
if(customHandler.startElement(uri, localName, qName, attributes)) {
return;
@@ -316,7 +316,7 @@ public class RecipeConfigParser extends DefaultHandler {
//TODO: What a hack!
private boolean isElementRoot(String str) {
return "AlloySmelterRecipes".equals(str) || "SAGMillRecipes".equals(str) || "StillRecipes".equals(str);
return "AlloySmelterRecipes".equals(str) || "SAGMillRecipes".equals(str) || "VatRecipes".equals(str);
}
private void addOutputStack(Attributes attributes) {
@@ -1,9 +1,12 @@
package crazypants.enderio.machine.still;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
@@ -13,21 +16,64 @@ import net.minecraftforge.fluids.FluidStack;
import crazypants.enderio.GuiHandler;
import crazypants.enderio.ModObject;
import crazypants.enderio.machine.AbstractMachineBlock;
import crazypants.util.ItemUtil;
import crazypants.enderio.machine.AbstractMachineEntity;
import crazypants.util.Util;
public class BlockVat extends AbstractMachineBlock<TileVat> {
public static int renderId;
public static BlockVat create() {
BlockVat res = new BlockVat();
res.init();
return res;
}
protected IIcon onIcon;
protected IIcon topIcon;
public BlockVat() {
super(ModObject.blockVat, TileVat.class);
}
@Override
public void registerBlockIcons(IIconRegister iIconRegister) {
blockIcon = iIconRegister.registerIcon("enderio:vatFront");
onIcon = iIconRegister.registerIcon("enderio:vatFrontOn");
topIcon = iIconRegister.registerIcon("enderio:vatTop");
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
// used to render the block in the world
TileEntity te = world.getTileEntity(x, y, z);
boolean on = false;
if(te instanceof AbstractMachineEntity) {
AbstractMachineEntity me = (AbstractMachineEntity) te;
on = me.isActive();
}
if(blockSide == ForgeDirection.UP.ordinal() || blockSide == ForgeDirection.DOWN.ordinal()) {
return topIcon;
}
if(on) {
return onIcon;
} else {
return blockIcon;
}
}
@Override
public IIcon getIcon(int blockSide, int blockMeta) {
if(blockSide == ForgeDirection.UP.ordinal() || blockSide == ForgeDirection.DOWN.ordinal()) {
return topIcon;
}
return blockIcon;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
@@ -86,9 +132,9 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, item);
for (int i = 0; i < entityPlayer.inventory.mainInventory.length; i++) {
if(entityPlayer.inventory.mainInventory[i] == null) {
entityPlayer.inventory.setInventorySlotContents(i, res);
entityPlayer.inventory.setInventorySlotContents(i, res);
return true;
}
}
}
if(!world.isRemote) {
Util.dropItems(world, res, x, y, z, true);
@@ -104,7 +150,24 @@ public class BlockVat extends AbstractMachineBlock<TileVat> {
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
}
@Override
public int getRenderType() {
return renderId;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
@@ -47,12 +47,16 @@ public class TileVat extends AbstractPoweredTaskEntity implements IFluidHandler
@Override
protected boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
return VatRecipeManager.getInstance().isValidInput(new MachineRecipeInput(i, itemstack));
MachineRecipeInput[] inputs = getInputs();
inputs[i] = new MachineRecipeInput(i, itemstack);
//return VatRecipeManager.getInstance().isValidInput(new MachineRecipeInput(i, itemstack));
return VatRecipeManager.getInstance().isValidInput(inputs);
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
if(resource == null || !resource.isFluidEqual(WATER)) {
if(resource == null || !canFill(from, resource.getFluid())) {
return 0;
}
tanksDirty = true;
@@ -115,10 +119,17 @@ public class TileVat extends AbstractPoweredTaskEntity implements IFluidHandler
@Override
public boolean canFill(ForgeDirection from, Fluid fluid) {
if(fluid == null || fluid.getID() != WATER.getFluid().getID()) {
if(fluid == null || (inputTank.getFluid() != null && inputTank.getFluid().getFluid().getID() != fluid.getID())) {
return false;
}
return true;
MachineRecipeInput[] inputs = getInputs();
if(inputTank.getFluidAmount() <= 0) {
inputs[inputs.length - 1] = new MachineRecipeInput(0, new FluidStack(fluid, 1));
}
return VatRecipeManager.getInstance().isValidInput(inputs);
}
@Override
@@ -101,4 +101,25 @@ public class VatRecipeManager {
return false;
}
public boolean isValidInput(MachineRecipeInput[] inputs) {
for (IRecipe recipe : recipes) {
boolean allValid = true;
String name = recipe.getOutputs()[0].getFluidOutput().getFluid().getName();
for(MachineRecipeInput input : inputs) {
if(input.item != null) {
allValid = recipe.isValidInput(input.slotNumber, input.item);
} else if(input.fluid != null) {
allValid = recipe.isValidInput(input.fluid);
}
if(!allValid) {
break;
}
}
if(allValid) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,136 @@
package crazypants.enderio.machine.still;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import crazypants.enderio.EnderIO;
import crazypants.enderio.machine.generator.TileCombustionGenerator;
import crazypants.render.BoundingBox;
import crazypants.render.CubeRenderer;
import crazypants.render.RenderUtil;
import crazypants.render.VertexTransform;
import crazypants.vecmath.Vector3d;
import crazypants.vecmath.Vector3f;
public class VatRenderer implements ISimpleBlockRenderingHandler {
private VertXForm xform = new VertXForm();
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
short facing = 3;
boolean active = false;
if(world != null) {
TileEntity te = world.getTileEntity(x, y, z);
if(te instanceof TileCombustionGenerator) {
TileCombustionGenerator gen = (TileCombustionGenerator) te;
facing = gen.facing;
active = gen.isActive();
}
}
IIcon[] textures = new IIcon[6];
if(world != null) {
textures[0] = EnderIO.blockVat.getIcon(world, x, y, z, ForgeDirection.NORTH.ordinal());
textures[1] = EnderIO.blockVat.getIcon(world, x, y, z, ForgeDirection.NORTH.ordinal());
textures[2] = EnderIO.blockVat.getIcon(world, x, y, z, ForgeDirection.UP.ordinal());
textures[3] = EnderIO.blockVat.getIcon(world, x, y, z, ForgeDirection.DOWN.ordinal());
textures[4] = EnderIO.blockVat.getIcon(world, x, y, z, ForgeDirection.NORTH.ordinal());
textures[5] = EnderIO.blockVat.getIcon(world, x, y, z, ForgeDirection.NORTH.ordinal());
} else {
textures[0] = EnderIO.blockVat.getIcon(3, 0);
textures[1] = EnderIO.blockVat.getIcon(3, 0);
textures[2] = EnderIO.blockVat.getIcon(1, 0);
textures[3] = EnderIO.blockVat.getIcon(0, 0);
textures[4] = EnderIO.blockVat.getIcon(3, 0);
textures[5] = EnderIO.blockVat.getIcon(3, 0);
}
float b = 1;
if(world instanceof World) {
b = RenderUtil.claculateTotalBrightnessForLocation((World) world, x, y, z);
}
float[] cols = new float[6];
for (int i = 0; i < 6; i++) {
float m = RenderUtil.getColorMultiplierForFace(ForgeDirection.values()[i]);
cols[i] = b * m;
}
//-x side
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.333, 1,1);
bb = bb.translate(0.5f - (0.3f/2),0,0);
xform.set(x, y, z);
CubeRenderer.render(bb, textures, xform, cols);
bb = BoundingBox.UNIT_CUBE.scale(0.4, 1,1);
xform.set(x, y, z);
CubeRenderer.render(bb, textures, xform, cols);
bb = BoundingBox.UNIT_CUBE.scale(0.333, 1,1);
bb = bb.translate(-0.5f + (0.3f/2),0,0);
xform.set(x, y, z);
CubeRenderer.render(bb, textures, xform, cols);
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
Tessellator tes = Tessellator.instance;
tes.startDrawingQuads();
renderWorldBlock(null, 0, 0, 0, block, 0, renderer);
tes.draw();
}
@Override
public int getRenderId() {
return BlockVat.renderId;
}
private static class VertXForm implements VertexTransform {
int x;
int y;
int z;
public VertXForm() {
}
void set(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public void apply(Vector3d vec) {
if(vec.x > 0.9 || vec.x < 0.1) {
vec.z -= 0.5;
vec.z *= 0.4;
vec.z += 0.5;
}
vec.add(x, y, z);
}
@Override
public void applyToNormal(Vector3f vec) {
}
}
}