mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 04:32:18 +00:00
Added zombie head generator.
This commit is contained in:
1 parent
0faf8857f2
commit
2775279854
20 files changed
+1046
-13
No files matched your search
@@ -48,6 +48,8 @@ import crazypants.enderio.machine.generator.combustion.BlockCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.combustion.CombustionGeneratorModelRenderer;
|
||||
import crazypants.enderio.machine.generator.combustion.CombustionGeneratorRenderer;
|
||||
import crazypants.enderio.machine.generator.combustion.TileCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.zombie.TileZombieGenerator;
|
||||
import crazypants.enderio.machine.generator.zombie.ZombieGeneratorRenderer;
|
||||
import crazypants.enderio.machine.hypercube.HyperCubeRenderer;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube;
|
||||
import crazypants.enderio.machine.light.BlockElectricLight;
|
||||
@@ -151,6 +153,10 @@ public class ClientProxy extends CommonProxy {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCombustionGenerator.class, cr);
|
||||
}
|
||||
}
|
||||
|
||||
ZombieGeneratorRenderer zgr = new ZombieGeneratorRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileZombieGenerator.class, zgr);
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockZombieGenerator), zgr);
|
||||
|
||||
BlockVat.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
VatRenderer vr = new VatRenderer();
|
||||
|
||||
@@ -37,11 +37,7 @@ public final class Config {
|
||||
|
||||
public static boolean detailedPowerTrackingEnabled = false;
|
||||
|
||||
public static double maxPhotovoltaicOutput = 1.0;
|
||||
public static double maxPhotovoltaicAdvancedOutput = 4.0;
|
||||
|
||||
public static boolean useSneakMouseWheelYetaWrench = true;
|
||||
|
||||
public static boolean useSneakRightClickYetaWrench = false;
|
||||
|
||||
public static boolean useRfAsDefault = true;
|
||||
@@ -49,11 +45,8 @@ public final class Config {
|
||||
public static boolean itemConduitUsePhyscialDistance = false;
|
||||
|
||||
public static int advancedFluidConduitExtractRate = 100;
|
||||
|
||||
public static int advancedFluidConduitMaxIoRate = 400;
|
||||
|
||||
public static int fluidConduitExtractRate = 50;
|
||||
|
||||
public static int fluidConduitMaxIoRate = 200;
|
||||
|
||||
public static boolean updateLightingWhenHidingFacades = false;
|
||||
@@ -122,6 +115,13 @@ public final class Config {
|
||||
public static int fireWaterPowerTotalBurnTime = 15000;
|
||||
public static float vatPowerUserPerTick = 2;
|
||||
|
||||
public static double maxPhotovoltaicOutput = 1.0;
|
||||
public static double maxPhotovoltaicAdvancedOutput = 4.0;
|
||||
|
||||
public static double zombieGeneratorMjPerTick = 8.0;
|
||||
public static int zombieGeneratorTicksPerMbFuel = 10000;
|
||||
|
||||
|
||||
public static boolean combustionGeneratorUseOpaqueModel = true;
|
||||
|
||||
public static boolean addFuelTooltipsToAllFluidContainers = true;
|
||||
@@ -143,7 +143,9 @@ public final class Config {
|
||||
|
||||
public static boolean useCombustionGenModel = false;
|
||||
|
||||
public static int crafterMjPerCraft = 250;
|
||||
public static int crafterMjPerCraft = 250;
|
||||
|
||||
|
||||
|
||||
public static void load(FMLPreInitializationEvent event) {
|
||||
configDirectory = new File(event.getModConfigurationDirectory(), "enderio");
|
||||
@@ -396,6 +398,11 @@ public final class Config {
|
||||
fireWaterPowerTotalBurnTime = config.get("Settings", "fireWaterPowerTotalBurnTime", fireWaterPowerTotalBurnTime,
|
||||
"The total burn time. Examples: BC Oil = 5000, BC Fuel = 25000").getInt(fireWaterPowerTotalBurnTime);
|
||||
|
||||
zombieGeneratorMjPerTick = config.get("Settings", "zombieGeneratorMjPerTick", zombieGeneratorMjPerTick,
|
||||
"The amount of power generated per tick.").getDouble(zombieGeneratorMjPerTick);
|
||||
zombieGeneratorTicksPerMbFuel = config.get("Settings", "zombieGeneratorTicksPerMbFuel", zombieGeneratorTicksPerMbFuel,
|
||||
"The number of ticks one Mb of fuel lasts.").getInt(zombieGeneratorTicksPerMbFuel);
|
||||
|
||||
addFuelTooltipsToAllFluidContainers = config.get("Settings", "addFuelTooltipsToAllFluidContainers", addFuelTooltipsToAllFluidContainers,
|
||||
"If true, the MJ/t and burn time of the fuel will be displayed in all tooltips for fluid containers with fuel.").getBoolean(
|
||||
addFuelTooltipsToAllFluidContainers);
|
||||
|
||||
@@ -55,6 +55,7 @@ import crazypants.enderio.machine.farm.BlockFarmStation;
|
||||
import crazypants.enderio.machine.farm.FarmersRegistry;
|
||||
import crazypants.enderio.machine.generator.combustion.BlockCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.stirling.BlockStirlingGenerator;
|
||||
import crazypants.enderio.machine.generator.zombie.BlockZombieGenerator;
|
||||
import crazypants.enderio.machine.hypercube.BlockHyperCube;
|
||||
import crazypants.enderio.machine.hypercube.HyperCubeRegister;
|
||||
import crazypants.enderio.machine.light.BlockElectricLight;
|
||||
@@ -141,6 +142,7 @@ public class EnderIO {
|
||||
// Machines
|
||||
public static BlockStirlingGenerator blockStirlingGenerator;
|
||||
public static BlockCombustionGenerator blockCombustionGenerator;
|
||||
public static BlockZombieGenerator blockZombieGenerator;
|
||||
public static BlockSolarPanel blockSolarPanel;
|
||||
public static BlockReservoir blockReservoir;
|
||||
public static BlockAlloySmelter blockAlloySmelter;
|
||||
@@ -208,6 +210,7 @@ public class EnderIO {
|
||||
blockSolarPanel = BlockSolarPanel.create();
|
||||
blockStirlingGenerator = BlockStirlingGenerator.create();
|
||||
blockCombustionGenerator = BlockCombustionGenerator.create();
|
||||
blockZombieGenerator = BlockZombieGenerator.create();
|
||||
|
||||
blockCrusher = BlockCrusher.create();
|
||||
blockAlloySmelter = BlockAlloySmelter.create();
|
||||
|
||||
@@ -37,6 +37,7 @@ public class GuiHandler implements IGuiHandler {
|
||||
public static final int GUI_ID_FARM_STATATION = 22;
|
||||
public static final int GUI_ID_TANK = 86;
|
||||
public static final int GUI_ID_CRAFTER = 87;
|
||||
public static final int GUI_ID_ZOMBIE_GEN = 71;
|
||||
|
||||
protected final Map<Integer, IGuiHandler> guiHandlers = new HashMap<Integer, IGuiHandler>();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ public enum ModObject {
|
||||
// Machines
|
||||
blockStirlingGenerator,
|
||||
blockCombustionGenerator,
|
||||
blockZombieGenerator,
|
||||
blockReservoir,
|
||||
blockAlloySmelter,
|
||||
blockSolarPanel,
|
||||
|
||||
@@ -58,8 +58,8 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
EnderIO.packetPipeline.registerPacket(PacketCurrentTask.class);
|
||||
}
|
||||
|
||||
protected AbstractMachineBlock(ModObject mo, Class<T> teClass) {
|
||||
super(new Material(MapColor.ironColor));
|
||||
protected AbstractMachineBlock(ModObject mo, Class<T> teClass, Material mat) {
|
||||
super(mat);
|
||||
modObject = mo;
|
||||
this.teClass = teClass;
|
||||
setHardness(2.0F);
|
||||
@@ -67,7 +67,10 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
setBlockName(mo.unlocalisedName);
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
random = new Random();
|
||||
|
||||
}
|
||||
|
||||
protected AbstractMachineBlock(ModObject mo, Class<T> teClass) {
|
||||
this(mo, teClass, new Material(MapColor.ironColor));
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.util.FluidUtil;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockZombieGenerator extends AbstractMachineBlock<TileZombieGenerator> {
|
||||
|
||||
public static BlockZombieGenerator create() {
|
||||
|
||||
EnderIO.packetPipeline.registerPacket(PacketTank.class);
|
||||
|
||||
BlockZombieGenerator gen = new BlockZombieGenerator();
|
||||
gen.init();
|
||||
return gen;
|
||||
}
|
||||
|
||||
protected BlockZombieGenerator() {
|
||||
super(ModObject.blockZombieGenerator, TileZombieGenerator.class, Material.water);
|
||||
}
|
||||
|
||||
@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 TileZombieGenerator)) {
|
||||
return super.onBlockActivated(world, x, y, z, entityPlayer, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
TileZombieGenerator gen = (TileZombieGenerator) 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 = FluidUtil.getFluidFromItem(item);
|
||||
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
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerZombieGenerator(player.inventory, (TileZombieGenerator) world.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GuiZombieGenerator(player.inventory, (TileZombieGenerator) world.getTileEntity(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getGuiId() {
|
||||
return GuiHandler.GUI_ID_ZOMBIE_GEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
if(active) {
|
||||
return "enderio:stirlingGenFrontOn";
|
||||
}
|
||||
return "enderio:stirlingGenFrontOff";
|
||||
}
|
||||
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileZombieGenerator && ((TileZombieGenerator)te).isActive()) {
|
||||
//see RenderGlobal.doSpawnParticle
|
||||
for (int i = 0; i < 1; i++) {
|
||||
float xOffset = 0.5f + (world.rand.nextFloat() * 2.0F - 1.0F) * 0.125f;
|
||||
float yOffset = 0.1f;
|
||||
float zOffset = 0.5f + (world.rand.nextFloat() * 2.0F - 1.0F) * 0.125f;
|
||||
world.spawnParticle("bubble", x + xOffset, y + yOffset, z + zOffset, -0.1D, 0.5D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import crazypants.enderio.machine.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerZombieGenerator extends AbstractMachineContainer {
|
||||
|
||||
public ContainerZombieGenerator(InventoryPlayer playerInv, AbstractMachineEntity te) {
|
||||
super(playerInv, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addMachineSlots(InventoryPlayer playerInv) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.fluid.Fluids;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.generator.combustion.ContainerCombustionEngine;
|
||||
import crazypants.enderio.machine.generator.combustion.TileCombustionGenerator;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.gui.GuiToolTip;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.Lang;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class GuiZombieGenerator extends GuiMachineBase {
|
||||
|
||||
private TileZombieGenerator gen;
|
||||
|
||||
|
||||
public GuiZombieGenerator(InventoryPlayer inventory, TileZombieGenerator tileEntity) {
|
||||
super(tileEntity, new ContainerZombieGenerator(inventory, tileEntity));
|
||||
gen = tileEntity;
|
||||
|
||||
addToolTip(new GuiToolTip(new Rectangle(80, 21, 15, 47), "") {
|
||||
|
||||
@Override
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
String heading = Lang.localize("zombieGenerator.fuelTank");
|
||||
text.add(heading);
|
||||
text.add(Fluids.toCapactityString(gen.fuelTank));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showRecipeButton() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderSlotHighlights(IoMode mode) {
|
||||
super.renderSlotHighlights(mode);
|
||||
|
||||
if(mode == IoMode.PULL || mode == IoMode.PUSH_PULL) {
|
||||
int x = 78;
|
||||
int y = 19;
|
||||
int w = 15 + 4;
|
||||
int h = 47 + 4;
|
||||
renderSlotHighlight(PULL_COLOR,x,y,w,h);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/zombieGenerator.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
drawTexturedModalRect(sx, sy, 0, 0, xSize, ySize);
|
||||
int scaled;
|
||||
|
||||
FontRenderer fr = getFontRenderer();
|
||||
double output = 0;
|
||||
if(gen.isActive()) {
|
||||
output = gen.outputPerTick;
|
||||
}
|
||||
String txt = Lang.localize("combustionGenerator.output") + " " + PowerDisplayUtil.formatPower(output) + " " + PowerDisplayUtil.abrevation() + PowerDisplayUtil.perTickStr();
|
||||
int sw = fr.getStringWidth(txt);
|
||||
fr.drawStringWithShadow(txt, guiLeft + xSize / 2 - sw / 2, guiTop + fr.FONT_HEIGHT / 2 + 3, ColorUtil.getRGB(Color.WHITE));
|
||||
|
||||
int x = guiLeft + 80;
|
||||
int y = guiTop + 21;
|
||||
if(gen.fuelTank.getFluidAmount() > 0) {
|
||||
|
||||
RenderUtil.renderGuiTank(gen.fuelTank.getFluid(), gen.fuelTank.getCapacity(), gen.fuelTank.getFluidAmount(), x, y, zLevel, 15, 47);
|
||||
|
||||
if(gen.isActive()) {
|
||||
txt = gen.tickPerMbFuel + " t/Mb";
|
||||
sw = fr.getStringWidth(txt);
|
||||
fr.drawStringWithShadow(txt, x - sw / 2 + 7, y + fr.FONT_HEIGHT / 2 + 46, ColorUtil.getRGB(Color.WHITE));
|
||||
}
|
||||
}
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/zombieGenerator.png");
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerX() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerY() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerHeight() {
|
||||
return 48;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public class ModelZombieJar extends ModelBase {
|
||||
|
||||
ModelRenderer Head;
|
||||
ModelRenderer electrode1;
|
||||
ModelRenderer electrode2;
|
||||
ModelRenderer electrode3;
|
||||
ModelRenderer electrode4;
|
||||
ModelRenderer electrode5;
|
||||
ModelRenderer electrode6;
|
||||
ModelRenderer electrode7;
|
||||
ModelRenderer electrode8;
|
||||
ModelRenderer electrode9;
|
||||
ModelRenderer electrode10;
|
||||
ModelRenderer electrode11;
|
||||
ModelRenderer electrode12;
|
||||
ModelRenderer glass1;
|
||||
ModelRenderer glass2;
|
||||
ModelRenderer glass3;
|
||||
ModelRenderer glass4;
|
||||
ModelRenderer top;
|
||||
ModelRenderer Lid1;
|
||||
ModelRenderer bottom;
|
||||
ModelRenderer Lid2;
|
||||
ModelRenderer Lid3;
|
||||
ModelRenderer Lid4;
|
||||
ModelRenderer Lid5;
|
||||
|
||||
public ModelZombieJar() {
|
||||
this(0.0f);
|
||||
}
|
||||
|
||||
public ModelZombieJar(float par1) {
|
||||
Head = new ModelRenderer(this, 0, 0);
|
||||
Head.setTextureSize(64, 64);
|
||||
Head.addBox(-4F, -4F, -4F, 8, 8, 8);
|
||||
Head.setRotationPoint(0F, -8F, 1F);
|
||||
electrode1 = new ModelRenderer(this, 31, 40);
|
||||
electrode1.setTextureSize(64, 64);
|
||||
electrode1.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode1.setRotationPoint(-2.872653F, -11.50361F, -2.60217F);
|
||||
electrode2 = new ModelRenderer(this, 31, 40);
|
||||
electrode2.setTextureSize(64, 64);
|
||||
electrode2.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode2.setRotationPoint(-0.2268921F, -9.821873F, -3.016515F);
|
||||
electrode3 = new ModelRenderer(this, 31, 40);
|
||||
electrode3.setTextureSize(64, 64);
|
||||
electrode3.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode3.setRotationPoint(2.875378F, -10.08223F, -3.571606F);
|
||||
electrode4 = new ModelRenderer(this, 31, 40);
|
||||
electrode4.setTextureSize(64, 64);
|
||||
electrode4.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode4.setRotationPoint(3.996085F, -9.873959F, -2.810457F);
|
||||
electrode5 = new ModelRenderer(this, 31, 40);
|
||||
electrode5.setTextureSize(64, 64);
|
||||
electrode5.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode5.setRotationPoint(4.288532F, -8.994526F, 0.2129618F);
|
||||
electrode6 = new ModelRenderer(this, 31, 40);
|
||||
electrode6.setTextureSize(64, 64);
|
||||
electrode6.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode6.setRotationPoint(5.037488F, -10.05719F, 3.095634F);
|
||||
electrode7 = new ModelRenderer(this, 31, 40);
|
||||
electrode7.setTextureSize(64, 64);
|
||||
electrode7.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode7.setRotationPoint(-1.494982F, -11.74601F, 5.210991F);
|
||||
electrode8 = new ModelRenderer(this, 31, 40);
|
||||
electrode8.setTextureSize(64, 64);
|
||||
electrode8.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode8.setRotationPoint(1.150779F, -10.06427F, 4.796647F);
|
||||
electrode9 = new ModelRenderer(this, 31, 40);
|
||||
electrode9.setTextureSize(64, 64);
|
||||
electrode9.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode9.setRotationPoint(4.253049F, -10.32463F, 4.241555F);
|
||||
electrode10 = new ModelRenderer(this, 31, 40);
|
||||
electrode10.setTextureSize(64, 64);
|
||||
electrode10.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode10.setRotationPoint(-3.667958F, -11.76913F, -1.517876F);
|
||||
electrode11 = new ModelRenderer(this, 31, 40);
|
||||
electrode11.setTextureSize(64, 64);
|
||||
electrode11.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode11.setRotationPoint(-3.37551F, -10.8897F, 1.505543F);
|
||||
electrode12 = new ModelRenderer(this, 31, 40);
|
||||
electrode12.setTextureSize(64, 64);
|
||||
electrode12.addBox(-0.5F, -0.5F, -0.5F, 1, 1, 1);
|
||||
electrode12.setRotationPoint(-2.626554F, -11.95237F, 4.388215F);
|
||||
glass1 = new ModelRenderer(this, 36, 2);
|
||||
glass1.setTextureSize(64, 64);
|
||||
glass1.addBox(-6F, -7F, 0F, 12, 14, 0);
|
||||
glass1.setRotationPoint(0F, -8F, -5F);
|
||||
glass2 = new ModelRenderer(this, 36, 2);
|
||||
glass2.setTextureSize(64, 64);
|
||||
glass2.addBox(-6F, -7F, 0F, 12, 14, 0);
|
||||
glass2.setRotationPoint(-6F, -8F, 1F);
|
||||
glass3 = new ModelRenderer(this, 36, 2);
|
||||
glass3.setTextureSize(64, 64);
|
||||
glass3.addBox(-6F, -7F, 0F, 12, 14, 0);
|
||||
glass3.setRotationPoint(0F, -8F, 7F);
|
||||
glass4 = new ModelRenderer(this, 36, 2);
|
||||
glass4.setTextureSize(64, 64);
|
||||
glass4.addBox(-6F, -7F, 0F, 12, 14, 0);
|
||||
glass4.setRotationPoint(6F, -8F, 1F);
|
||||
top = new ModelRenderer(this, 1, 17);
|
||||
top.setTextureSize(64, 64);
|
||||
top.addBox(-6F, -0.5F, -6F, 12, 1, 12);
|
||||
top.setRotationPoint(0F, -15.5F, 1F);
|
||||
Lid1 = new ModelRenderer(this, 4, 33);
|
||||
Lid1.setTextureSize(64, 64);
|
||||
Lid1.addBox(-4.5F, -1F, -4.5F, 9, 2, 9);
|
||||
Lid1.setRotationPoint(0F, -17F, 1F);
|
||||
bottom = new ModelRenderer(this, 1, 17);
|
||||
bottom.setTextureSize(64, 64);
|
||||
bottom.addBox(-6F, -0.5F, -6F, 12, 1, 12);
|
||||
bottom.setRotationPoint(0F, -0.5F, 1F);
|
||||
Lid2 = new ModelRenderer(this, 12, 41);
|
||||
Lid2.setTextureSize(64, 64);
|
||||
Lid2.addBox(-4F, -1F, -0.5F, 8, 2, 1);
|
||||
Lid2.setRotationPoint(0F, -17F, -4F);
|
||||
Lid3 = new ModelRenderer(this, 12, 41);
|
||||
Lid3.setTextureSize(64, 64);
|
||||
Lid3.addBox(-4F, -1F, -0.5F, 8, 2, 1);
|
||||
Lid3.setRotationPoint(0F, -17F, 6F);
|
||||
Lid4 = new ModelRenderer(this, 5, 34);
|
||||
Lid4.setTextureSize(64, 64);
|
||||
Lid4.addBox(-0.5F, -1F, -4F, 1, 2, 8);
|
||||
Lid4.setRotationPoint(5F, -17F, 1F);
|
||||
Lid5 = new ModelRenderer(this, 5, 34);
|
||||
Lid5.setTextureSize(64, 64);
|
||||
Lid5.addBox(-0.5F, -1F, -4F, 1, 2, 8);
|
||||
Lid5.setRotationPoint(-5F, -17F, 1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) {
|
||||
|
||||
Head.rotateAngleX = 0.03054326F;
|
||||
Head.rotateAngleY = 0.1745329F;
|
||||
Head.rotateAngleZ = 0.2392846F;
|
||||
Head.renderWithRotation(par7);
|
||||
|
||||
electrode1.rotateAngleX = 0.03054326F;
|
||||
electrode1.rotateAngleY = 0.1745329F;
|
||||
electrode1.rotateAngleZ = 0.2392846F;
|
||||
electrode1.renderWithRotation(par7);
|
||||
|
||||
electrode2.rotateAngleX = 0.03054326F;
|
||||
electrode2.rotateAngleY = 0.1745329F;
|
||||
electrode2.rotateAngleZ = 0.2392846F;
|
||||
electrode2.renderWithRotation(par7);
|
||||
|
||||
electrode3.rotateAngleX = 0.03054326F;
|
||||
electrode3.rotateAngleY = 0.1745329F;
|
||||
electrode3.rotateAngleZ = 0.2392846F;
|
||||
electrode3.renderWithRotation(par7);
|
||||
|
||||
electrode4.rotateAngleX = 0.03054326F;
|
||||
electrode4.rotateAngleY = 0.1745329F;
|
||||
electrode4.rotateAngleZ = 0.2392846F;
|
||||
electrode4.renderWithRotation(par7);
|
||||
|
||||
electrode5.rotateAngleX = 0.03054326F;
|
||||
electrode5.rotateAngleY = 0.1745329F;
|
||||
electrode5.rotateAngleZ = 0.2392846F;
|
||||
electrode5.renderWithRotation(par7);
|
||||
|
||||
electrode6.rotateAngleX = 0.03054326F;
|
||||
electrode6.rotateAngleY = 0.1745329F;
|
||||
electrode6.rotateAngleZ = 0.2392846F;
|
||||
electrode6.renderWithRotation(par7);
|
||||
|
||||
electrode7.rotateAngleX = 0.03054326F;
|
||||
electrode7.rotateAngleY = 0.1745329F;
|
||||
electrode7.rotateAngleZ = 0.2392846F;
|
||||
electrode7.renderWithRotation(par7);
|
||||
|
||||
electrode8.rotateAngleX = 0.03054326F;
|
||||
electrode8.rotateAngleY = 0.1745329F;
|
||||
electrode8.rotateAngleZ = 0.2392846F;
|
||||
electrode8.renderWithRotation(par7);
|
||||
|
||||
electrode9.rotateAngleX = 0.03054326F;
|
||||
electrode9.rotateAngleY = 0.1745329F;
|
||||
electrode9.rotateAngleZ = 0.2392846F;
|
||||
electrode9.renderWithRotation(par7);
|
||||
|
||||
electrode10.rotateAngleX = 0.03054326F;
|
||||
electrode10.rotateAngleY = 0.1745329F;
|
||||
electrode10.rotateAngleZ = 0.2392846F;
|
||||
electrode10.renderWithRotation(par7);
|
||||
|
||||
electrode11.rotateAngleX = 0.03054326F;
|
||||
electrode11.rotateAngleY = 0.1745329F;
|
||||
electrode11.rotateAngleZ = 0.2392846F;
|
||||
electrode11.renderWithRotation(par7);
|
||||
|
||||
electrode12.rotateAngleX = 0.03054326F;
|
||||
electrode12.rotateAngleY = 0.1745329F;
|
||||
electrode12.rotateAngleZ = 0.2392846F;
|
||||
electrode12.renderWithRotation(par7);
|
||||
|
||||
glass1.rotateAngleX = 0F;
|
||||
glass1.rotateAngleY = 0F;
|
||||
glass1.rotateAngleZ = 0F;
|
||||
glass1.renderWithRotation(par7);
|
||||
|
||||
glass2.rotateAngleX = 0F;
|
||||
glass2.rotateAngleY = -1.570796F;
|
||||
glass2.rotateAngleZ = 0F;
|
||||
glass2.renderWithRotation(par7);
|
||||
|
||||
glass3.rotateAngleX = 0F;
|
||||
glass3.rotateAngleY = 0F;
|
||||
glass3.rotateAngleZ = 0F;
|
||||
glass3.renderWithRotation(par7);
|
||||
|
||||
glass4.rotateAngleX = 0F;
|
||||
glass4.rotateAngleY = -1.570796F;
|
||||
glass4.rotateAngleZ = 0F;
|
||||
glass4.renderWithRotation(par7);
|
||||
|
||||
top.rotateAngleX = 0F;
|
||||
top.rotateAngleY = 0F;
|
||||
top.rotateAngleZ = 0F;
|
||||
top.renderWithRotation(par7);
|
||||
|
||||
Lid1.rotateAngleX = 0F;
|
||||
Lid1.rotateAngleY = 0F;
|
||||
Lid1.rotateAngleZ = 0F;
|
||||
Lid1.renderWithRotation(par7);
|
||||
|
||||
bottom.rotateAngleX = 0F;
|
||||
bottom.rotateAngleY = 0F;
|
||||
bottom.rotateAngleZ = 0F;
|
||||
bottom.renderWithRotation(par7);
|
||||
|
||||
Lid2.rotateAngleX = 0F;
|
||||
Lid2.rotateAngleY = 0F;
|
||||
Lid2.rotateAngleZ = 0F;
|
||||
Lid2.renderWithRotation(par7);
|
||||
|
||||
Lid3.rotateAngleX = 0F;
|
||||
Lid3.rotateAngleY = 0F;
|
||||
Lid3.rotateAngleZ = 0F;
|
||||
Lid3.renderWithRotation(par7);
|
||||
|
||||
Lid4.rotateAngleX = 0F;
|
||||
Lid4.rotateAngleY = 0F;
|
||||
Lid4.rotateAngleZ = 0F;
|
||||
Lid4.renderWithRotation(par7);
|
||||
|
||||
Lid5.rotateAngleX = 0F;
|
||||
Lid5.rotateAngleY = 0F;
|
||||
Lid5.rotateAngleZ = 0F;
|
||||
Lid5.renderWithRotation(par7);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public class NutrientTank extends FluidTank {
|
||||
|
||||
public NutrientTank(int capacity) {
|
||||
super(capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(FluidStack resource, boolean doFill) {
|
||||
if(resource == null || resource.getFluid().getID() != EnderIO.fluidNutrientDistillation.getID()) {
|
||||
return 0;
|
||||
}
|
||||
return super.fill(resource, doFill);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.machine.generator.combustion.TileCombustionGenerator;
|
||||
import crazypants.enderio.network.AbstractPacketTileEntity;
|
||||
import crazypants.enderio.network.NetworkUtil;
|
||||
|
||||
public class PacketTank extends AbstractPacketTileEntity<TileZombieGenerator> {
|
||||
|
||||
private NBTTagCompound nbtRoot;
|
||||
|
||||
public PacketTank() {
|
||||
}
|
||||
|
||||
public PacketTank(TileZombieGenerator tile) {
|
||||
super(tile);
|
||||
nbtRoot = new NBTTagCompound();
|
||||
if(tile.fuelTank.getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
tile.fuelTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("tank", tankRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
super.encode(ctx, buf);
|
||||
NetworkUtil.writeNBTTagCompound(nbtRoot, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
super.decode(ctx, buf);
|
||||
nbtRoot = NetworkUtil.readNBTTagCompound(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClientSide(EntityPlayer player, World worldObj, TileZombieGenerator tile) {
|
||||
if(nbtRoot.hasKey("tank")) {
|
||||
NBTTagCompound tankRoot = nbtRoot.getCompoundTag("tank");
|
||||
tile.fuelTank.readFromNBT(tankRoot);
|
||||
} else {
|
||||
tile.fuelTank.setFluid(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.fuels.IronEngineCoolant;
|
||||
import buildcraft.api.fuels.IronEngineFuel;
|
||||
import buildcraft.api.fuels.IronEngineCoolant.Coolant;
|
||||
import buildcraft.api.fuels.IronEngineFuel.Fuel;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import crazypants.enderio.Config;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.IoMode;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.enderio.machine.generator.PowerDistributor;
|
||||
import crazypants.enderio.machine.generator.combustion.PacketTanks;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.FluidUtil;
|
||||
|
||||
public class TileZombieGenerator extends AbstractMachineEntity implements IPowerEmitter, IFluidHandler {
|
||||
|
||||
private static int IO_MB_TICK = 250;
|
||||
|
||||
final NutrientTank fuelTank = new NutrientTank(FluidContainerRegistry.BUCKET_VOLUME * 2);
|
||||
|
||||
float outputPerTick = (float)Config.zombieGeneratorMjPerTick;
|
||||
int tickPerMbFuel = Config.zombieGeneratorTicksPerMbFuel;
|
||||
|
||||
private boolean tanksDirty;
|
||||
private boolean active = false;
|
||||
private PowerDistributor powerDis;
|
||||
|
||||
private int ticksRemaingFuel;
|
||||
private boolean inPause;
|
||||
|
||||
|
||||
public TileZombieGenerator() {
|
||||
super(new SlotDefinition(0, 0, 0));
|
||||
powerHandler.configure(0, 0, 0, capacitorType.capacitor.getMaxEnergyStored());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName() {
|
||||
return ModObject.blockZombieGenerator.unlocalisedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEmitPowerFrom(ForgeDirection side) {
|
||||
return !isSideDisabled(side.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMode(ForgeDirection faceHit, IoMode mode) {
|
||||
return mode != IoMode.PUSH && mode != IoMode.PUSH_PULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doPull(ForgeDirection dir) {
|
||||
boolean res = super.doPull(dir);
|
||||
BlockCoord loc = getLocation().getLocation(dir);
|
||||
IFluidHandler target = FluidUtil.getFluidHandler(worldObj, loc);
|
||||
if(target != null) {
|
||||
FluidTankInfo[] infos = target.getTankInfo(dir.getOpposite());
|
||||
if(infos != null) {
|
||||
for (FluidTankInfo info : infos) {
|
||||
if(info.fluid != null && info.fluid.amount > 0) {
|
||||
if(canFill(dir, info.fluid.getFluid())) {
|
||||
FluidStack canPull = info.fluid.copy();
|
||||
canPull.amount = Math.min(IO_MB_TICK, canPull.amount);
|
||||
FluidStack drained = target.drain(dir.getOpposite(), canPull, false);
|
||||
if(drained != null && drained.amount > 0) {
|
||||
int filled = fill(dir, drained, false);
|
||||
if(filled > 0) {
|
||||
drained = target.drain(dir.getOpposite(), filled, true);
|
||||
fill(dir, drained, true);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getPowerUsePerTick() {
|
||||
return outputPerTick;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isMachineItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProgress() {
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(Block blockId) {
|
||||
super.onNeighborBlockChange(blockId);
|
||||
if(powerDis != null) {
|
||||
powerDis.neighboursChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateStoredEnergyFromPowerHandler() {
|
||||
//no-op as we don't actually need a BC power handler for a generator
|
||||
//Need to clean this up
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return (int) (storedEnergy * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean processTasks(boolean redstoneCheckPassed) {
|
||||
boolean res = false;
|
||||
|
||||
if(!redstoneCheckPassed) {
|
||||
if(active) {
|
||||
active = false;
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
} else {
|
||||
|
||||
boolean isActive = generateEnergy();
|
||||
if(isActive != this.active) {
|
||||
active = isActive;
|
||||
res = true;
|
||||
}
|
||||
|
||||
if(storedEnergy >= capacitorType.capacitor.getMaxEnergyStored()) {
|
||||
inPause = true;
|
||||
}
|
||||
|
||||
transmitEnergy();
|
||||
}
|
||||
|
||||
if(tanksDirty) {
|
||||
EnderIO.packetPipeline.sendToAllAround(new PacketTank(this), this);
|
||||
tanksDirty = false;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private boolean generateEnergy() {
|
||||
|
||||
int generated = 0;
|
||||
|
||||
//once full, don't start again until we have drained 10 seconds worth of power to prevent
|
||||
//flickering on and off constantly when powering a machine that draws less than this produces
|
||||
if(inPause && storedEnergy >= (powerHandler.getMaxEnergyStored() - (outputPerTick * 200))) {
|
||||
return false;
|
||||
}
|
||||
inPause = false;
|
||||
|
||||
boolean res = false;
|
||||
ticksRemaingFuel--;
|
||||
if(ticksRemaingFuel <= 0) {
|
||||
fuelTank.drain(1, true);
|
||||
ticksRemaingFuel = tickPerMbFuel;
|
||||
res = true;
|
||||
tanksDirty = true;
|
||||
}
|
||||
|
||||
float oldVal = storedEnergy;
|
||||
storedEnergy += outputPerTick;
|
||||
storedEnergy = Math.min(storedEnergy, capacitorType.capacitor.getMaxEnergyStored());
|
||||
|
||||
return fuelTank.getFluidAmount() > fuelTank.getCapacity() * 0.9f;
|
||||
}
|
||||
|
||||
private boolean transmitEnergy() {
|
||||
if(storedEnergy <= 0) {
|
||||
return false;
|
||||
}
|
||||
if(powerDis == null) {
|
||||
powerDis = new PowerDistributor(new BlockCoord(this));
|
||||
}
|
||||
float transmitted = powerDis.transmitEnergy(worldObj, Math.min(outputPerTick * 2, storedEnergy));
|
||||
storedEnergy -= transmitted;
|
||||
return transmitted > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
if(resource == null || resource.getFluid() == null || !canFill(from, resource.getFluid())) {
|
||||
return 0;
|
||||
}
|
||||
tanksDirty = true;
|
||||
return fuelTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return fluid != null && fluid.getID() == EnderIO.fluidNutrientDistillation.getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return new FluidTankInfo[] { fuelTank.getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.readCustomNBT(nbtRoot);
|
||||
active = nbtRoot.getBoolean("active");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
|
||||
if(nbtRoot.hasKey("fuelTank")) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("fuelTank");
|
||||
if(tankRoot != null) {
|
||||
fuelTank.readFromNBT(tankRoot);
|
||||
} else {
|
||||
fuelTank.setFluid(null);
|
||||
}
|
||||
} else {
|
||||
fuelTank.setFluid(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
if(fuelTank.getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
fuelTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("fuelTank", tankRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomNBT(NBTTagCompound nbtRoot) {
|
||||
super.writeCustomNBT(nbtRoot);
|
||||
nbtRoot.setBoolean("active", active);
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
package crazypants.enderio.machine.generator.zombie;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.machine.generator.combustion.CombustionGeneratorModel;
|
||||
import crazypants.enderio.machine.generator.combustion.TileCombustionGenerator;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.ForgeDirectionOffsets;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
public class ZombieGeneratorRenderer extends TileEntitySpecialRenderer implements IItemRenderer {
|
||||
|
||||
private static final String TEXTURE = "enderio:models/ZombieJar.png";
|
||||
|
||||
private ModelZombieJar model = new ModelZombieJar();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float tick) {
|
||||
|
||||
World world = te.getWorldObj();
|
||||
TileZombieGenerator gen = (TileZombieGenerator) te;
|
||||
|
||||
float f = world.getBlockLightValue(te.xCoord, te.yCoord, te.zCoord);
|
||||
int l = world.getLightBrightnessForSkyBlocks(te.xCoord, te.yCoord, te.zCoord, 0);
|
||||
int l1 = l % 65536;
|
||||
int l2 = l / 65536;
|
||||
Tessellator.instance.setColorOpaque_F(f, f, f);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) l1, (float) l2);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||
renderModel(gen.facing);
|
||||
renderFluid(gen);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
protected void renderFluid(TileZombieGenerator gen) {
|
||||
FluidTank tank = gen.fuelTank;
|
||||
if(tank.getFluidAmount() <= 0) {
|
||||
return;
|
||||
}
|
||||
IIcon icon = tank.getFluid().getFluid().getStillIcon();
|
||||
if(icon != null) {
|
||||
RenderUtil.bindBlockTexture();
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
|
||||
float fullness = (float) (tank.getFluidAmount()) / (tank.getCapacity());
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.96, 0.85);
|
||||
bb = bb.scale(1, 0.85 * fullness, 1);
|
||||
float ty = -(0.85f - (bb.maxY - bb.minY)) / 2;
|
||||
|
||||
|
||||
Vector3d offset = ForgeDirectionOffsets.offsetScaled(ForgeDirection.values()[gen.facing], -0.075);
|
||||
bb = bb.translate((float)offset.x, ty, (float)offset.z);
|
||||
|
||||
CubeRenderer.render(bb, icon);
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(false);
|
||||
tes.draw();
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void renderModel(int facing) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslatef(0.5F, 0, 0.5F);
|
||||
GL11.glRotatef(180F, 1F, 0F, 0F);
|
||||
GL11.glScalef(1.2f, 0.9f, 1.2f);
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(facing);
|
||||
if(dir == ForgeDirection.SOUTH) {
|
||||
facing = 0;
|
||||
|
||||
} else if(dir == ForgeDirection.WEST) {
|
||||
facing = -1;
|
||||
}
|
||||
GL11.glRotatef(facing * -90F, 0F, 1F, 0F);
|
||||
|
||||
RenderUtil.bindTexture(TEXTURE);
|
||||
model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
|
||||
|
||||
GL11.glTranslatef(-0.5F, 0, -0.5F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
renderItem(0, 0, 0);
|
||||
}
|
||||
|
||||
private void renderItem(float x, float y, float z) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(x, y, z);
|
||||
renderModel(ForgeDirection.NORTH.ordinal());
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user