diff --git a/assets/hbm/lang/de_DE.lang b/assets/hbm/lang/de_DE.lang index 7294d9d24..a50a7a3fd 100644 --- a/assets/hbm/lang/de_DE.lang +++ b/assets/hbm/lang/de_DE.lang @@ -555,9 +555,12 @@ tile.ams_base.name=AMS-Basis [WIP] container.amsBase=AMS-Basis [WIP] tile.dfc_emitter.name=DFC-Emitter +container.dfcEmitter=DFC-Emitter tile.dfc_receiver.name=DFC-Receiver +container.dfcReceiver=DFC-Receiver tile.dfc_injector.name=DFC-Brennstoffinjektor tile.dfc_core.name=Dunkler Fusionskern +container.dfcCore.name=Dunkler Fusionskern item.template_folder.name=Produktionsvorlagen-Zeichenmappe item.fluid_identifier.name=Flüssigkeits-Kennzeichnung diff --git a/assets/hbm/lang/en_US.lang b/assets/hbm/lang/en_US.lang index e7a6f04f2..16b0e6f54 100644 --- a/assets/hbm/lang/en_US.lang +++ b/assets/hbm/lang/en_US.lang @@ -555,9 +555,12 @@ tile.ams_base.name=AMS Base [WIP] container.amsBase=AMS Base [WIP] tile.dfc_emitter.name=DFC Emitter +container.dfcEmitter=DFC Emitter tile.dfc_receiver.name=DFC Receiver +container.dfcReceiver=DFC Receiver tile.dfc_injector.name=DFC Fuel Injector tile.dfc_core.name=Dark Fusion Core +container.dfcCore.name=Dark Fusion Core item.template_folder.name=Machine Template Folder item.fluid_identifier.name=Fluid Identifier diff --git a/assets/hbm/textures/blocks/dfc_core.png b/assets/hbm/textures/blocks/dfc_core.png new file mode 100644 index 000000000..8af6fe16d Binary files /dev/null and b/assets/hbm/textures/blocks/dfc_core.png differ diff --git a/assets/hbm/textures/gui/dfc/gui_injector.png b/assets/hbm/textures/gui/dfc/gui_injector.png new file mode 100644 index 000000000..3c1defca7 Binary files /dev/null and b/assets/hbm/textures/gui/dfc/gui_injector.png differ diff --git a/assets/hbm/textures/items/ammo_20gauge_sleek.png b/assets/hbm/textures/items/ammo_20gauge_sleek.png index 63410fa26..759bf67c9 100644 Binary files a/assets/hbm/textures/items/ammo_20gauge_sleek.png and b/assets/hbm/textures/items/ammo_20gauge_sleek.png differ diff --git a/assets/hbm/textures/items/ammo_22lr.png b/assets/hbm/textures/items/ammo_22lr.png index d6444f096..e2c70d0b2 100644 Binary files a/assets/hbm/textures/items/ammo_22lr.png and b/assets/hbm/textures/items/ammo_22lr.png differ diff --git a/assets/hbm/textures/items/ammo_22lr_ap.png b/assets/hbm/textures/items/ammo_22lr_ap.png index a78f15e46..a919ea35d 100644 Binary files a/assets/hbm/textures/items/ammo_22lr_ap.png and b/assets/hbm/textures/items/ammo_22lr_ap.png differ diff --git a/assets/hbm/textures/items/ammo_50ae.png b/assets/hbm/textures/items/ammo_50ae.png index ec71e1e0b..0a9b47c8b 100644 Binary files a/assets/hbm/textures/items/ammo_50ae.png and b/assets/hbm/textures/items/ammo_50ae.png differ diff --git a/assets/hbm/textures/items/ammo_50ae_ap.png b/assets/hbm/textures/items/ammo_50ae_ap.png index 3b5dfbbcb..5d370b105 100644 Binary files a/assets/hbm/textures/items/ammo_50ae_ap.png and b/assets/hbm/textures/items/ammo_50ae_ap.png differ diff --git a/assets/hbm/textures/items/ammo_50ae_du.png b/assets/hbm/textures/items/ammo_50ae_du.png index c115966ea..ffaacbc63 100644 Binary files a/assets/hbm/textures/items/ammo_50ae_du.png and b/assets/hbm/textures/items/ammo_50ae_du.png differ diff --git a/assets/hbm/textures/items/ammo_50ae_star.png b/assets/hbm/textures/items/ammo_50ae_star.png index 78f6bc437..0553cb5ef 100644 Binary files a/assets/hbm/textures/items/ammo_50ae_star.png and b/assets/hbm/textures/items/ammo_50ae_star.png differ diff --git a/assets/hbm/textures/items/ammo_50bmg.png b/assets/hbm/textures/items/ammo_50bmg.png index cc26b5bab..c0d7f783b 100644 Binary files a/assets/hbm/textures/items/ammo_50bmg.png and b/assets/hbm/textures/items/ammo_50bmg.png differ diff --git a/assets/hbm/textures/items/ammo_50bmg_du.png b/assets/hbm/textures/items/ammo_50bmg_du.png index 2702520cb..38ccdfffb 100644 Binary files a/assets/hbm/textures/items/ammo_50bmg_du.png and b/assets/hbm/textures/items/ammo_50bmg_du.png differ diff --git a/assets/hbm/textures/items/ammo_50bmg_explosive.png b/assets/hbm/textures/items/ammo_50bmg_explosive.png index 0f8481ce5..1dc79f9e0 100644 Binary files a/assets/hbm/textures/items/ammo_50bmg_explosive.png and b/assets/hbm/textures/items/ammo_50bmg_explosive.png differ diff --git a/assets/hbm/textures/items/ammo_50bmg_incendiary.png b/assets/hbm/textures/items/ammo_50bmg_incendiary.png index 51ebe58f5..240346f90 100644 Binary files a/assets/hbm/textures/items/ammo_50bmg_incendiary.png and b/assets/hbm/textures/items/ammo_50bmg_incendiary.png differ diff --git a/assets/hbm/textures/items/ammo_50bmg_star.png b/assets/hbm/textures/items/ammo_50bmg_star.png index c5432573e..6f3248455 100644 Binary files a/assets/hbm/textures/items/ammo_50bmg_star.png and b/assets/hbm/textures/items/ammo_50bmg_star.png differ diff --git a/assets/hbm/textures/items/ammo_5mm.png b/assets/hbm/textures/items/ammo_5mm.png index 1f913655e..c0853664a 100644 Binary files a/assets/hbm/textures/items/ammo_5mm.png and b/assets/hbm/textures/items/ammo_5mm.png differ diff --git a/assets/hbm/textures/items/ammo_5mm_du.png b/assets/hbm/textures/items/ammo_5mm_du.png index dce156448..3e5de3d14 100644 Binary files a/assets/hbm/textures/items/ammo_5mm_du.png and b/assets/hbm/textures/items/ammo_5mm_du.png differ diff --git a/assets/hbm/textures/items/ammo_5mm_explosive.png b/assets/hbm/textures/items/ammo_5mm_explosive.png index f5037f07d..9ee89e1e5 100644 Binary files a/assets/hbm/textures/items/ammo_5mm_explosive.png and b/assets/hbm/textures/items/ammo_5mm_explosive.png differ diff --git a/assets/hbm/textures/items/ammo_5mm_star.png b/assets/hbm/textures/items/ammo_5mm_star.png index b6a78bdf6..6b0002f7f 100644 Binary files a/assets/hbm/textures/items/ammo_5mm_star.png and b/assets/hbm/textures/items/ammo_5mm_star.png differ diff --git a/assets/hbm/textures/items/ammo_9mm.png b/assets/hbm/textures/items/ammo_9mm.png index e09cffa6c..60950815d 100644 Binary files a/assets/hbm/textures/items/ammo_9mm.png and b/assets/hbm/textures/items/ammo_9mm.png differ diff --git a/assets/hbm/textures/items/ammo_9mm_ap.png b/assets/hbm/textures/items/ammo_9mm_ap.png index 6ed83db36..17f2f4df2 100644 Binary files a/assets/hbm/textures/items/ammo_9mm_ap.png and b/assets/hbm/textures/items/ammo_9mm_ap.png differ diff --git a/assets/hbm/textures/items/ammo_9mm_du.png b/assets/hbm/textures/items/ammo_9mm_du.png index 7e91e2076..c388b044e 100644 Binary files a/assets/hbm/textures/items/ammo_9mm_du.png and b/assets/hbm/textures/items/ammo_9mm_du.png differ diff --git a/assets/hbm/textures/items/gun_jack_ammo.png b/assets/hbm/textures/items/gun_jack_ammo.png index 44fdb897e..1a472ef44 100644 Binary files a/assets/hbm/textures/items/gun_jack_ammo.png and b/assets/hbm/textures/items/gun_jack_ammo.png differ diff --git a/assets/hbm/textures/items/gun_revolver_nightmare2_ammo.png b/assets/hbm/textures/items/gun_revolver_nightmare2_ammo.png index aeeb95c93..eb58a2cd7 100644 Binary files a/assets/hbm/textures/items/gun_revolver_nightmare2_ammo.png and b/assets/hbm/textures/items/gun_revolver_nightmare2_ammo.png differ diff --git a/com/hbm/blocks/ModBlocks.java b/com/hbm/blocks/ModBlocks.java index 7ee83ba6b..210ec0cf1 100644 --- a/com/hbm/blocks/ModBlocks.java +++ b/com/hbm/blocks/ModBlocks.java @@ -467,8 +467,11 @@ public class ModBlocks { public static Block dfc_emitter; public static final int guiID_dfc_emitter = 87; public static Block dfc_injector; + public static final int guiID_dfc_injector = 90; public static Block dfc_receiver; + public static final int guiID_dfc_receiver = 88; public static Block dfc_core; + public static final int guiID_dfc_core = 89; public static Block machine_converter_he_rf; public static final int guiID_converter_he_rf = 28; diff --git a/com/hbm/blocks/machine/CoreComponent.java b/com/hbm/blocks/machine/CoreComponent.java index 05eb1493d..ff3e4ebaa 100644 --- a/com/hbm/blocks/machine/CoreComponent.java +++ b/com/hbm/blocks/machine/CoreComponent.java @@ -66,6 +66,12 @@ public class CoreComponent extends BlockContainer { if(this == ModBlocks.dfc_emitter) FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_dfc_emitter, world, x, y, z); + if(this == ModBlocks.dfc_receiver) + FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_dfc_receiver, world, x, y, z); + + if(this == ModBlocks.dfc_injector) + FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_dfc_injector, world, x, y, z); + return true; } else { diff --git a/com/hbm/blocks/machine/CoreCore.java b/com/hbm/blocks/machine/CoreCore.java index be3fba10b..61f5a70ea 100644 --- a/com/hbm/blocks/machine/CoreCore.java +++ b/com/hbm/blocks/machine/CoreCore.java @@ -1,9 +1,13 @@ package com.hbm.blocks.machine; +import com.hbm.blocks.ModBlocks; +import com.hbm.main.MainRegistry; import com.hbm.tileentity.machine.TileEntityCore; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -32,5 +36,20 @@ public class CoreCore extends BlockContainer { public boolean renderAsNormalBlock() { return false; } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + + if(world.isRemote) { + return true; + } else if(!player.isSneaking()) { + + FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_dfc_core, world, x, y, z); + return true; + + } else { + return false; + } + } } diff --git a/com/hbm/handler/GUIHandler.java b/com/hbm/handler/GUIHandler.java index dcd25fbd8..a58364db6 100644 --- a/com/hbm/handler/GUIHandler.java +++ b/com/hbm/handler/GUIHandler.java @@ -786,6 +786,24 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_dfc_receiver: + { + if(entity instanceof TileEntityCoreReceiver) + { + return new ContainerCoreReceiver(player.inventory, (TileEntityCoreReceiver) entity); + } + return null; + } + + case ModBlocks.guiID_dfc_injector: + { + if(entity instanceof TileEntityCoreInjector) + { + return new ContainerCoreInjector(player.inventory, (TileEntityCoreInjector) entity); + } + return null; + } } } else { //NON-TE CONTAINERS @@ -1571,6 +1589,24 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_dfc_receiver: + { + if(entity instanceof TileEntityCoreReceiver) + { + return new GUICoreReceiver(player.inventory, (TileEntityCoreReceiver) entity); + } + return null; + } + + case ModBlocks.guiID_dfc_injector: + { + if(entity instanceof TileEntityCoreInjector) + { + return new GUICoreInjector(player.inventory, (TileEntityCoreInjector) entity); + } + return null; + } } } else { //CLIENTONLY GUIS diff --git a/com/hbm/inventory/container/ContainerCoreInjector.java b/com/hbm/inventory/container/ContainerCoreInjector.java new file mode 100644 index 000000000..59e301183 --- /dev/null +++ b/com/hbm/inventory/container/ContainerCoreInjector.java @@ -0,0 +1,74 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotMachineOutput; +import com.hbm.tileentity.machine.TileEntityCoreInjector; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerCoreInjector extends Container { + + private TileEntityCoreInjector nukeBoy; + + public ContainerCoreInjector(InventoryPlayer invPlayer, TileEntityCoreInjector tedf) { + + nukeBoy = tedf; + + this.addSlotToContainer(new Slot(tedf, 0, 26, 17)); + this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 1, 26, 53)); + this.addSlotToContainer(new Slot(tedf, 2, 134, 17)); + this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 3, 134, 53)); + + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 9; j++) + { + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) + { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) + { + ItemStack var3 = null; + Slot var4 = (Slot) this.inventorySlots.get(par2); + + if (var4 != null && var4.getHasStack()) + { + ItemStack var5 = var4.getStack(); + var3 = var5.copy(); + + if (par2 <= 3) { + if (!this.mergeItemStack(var5, 4, this.inventorySlots.size(), true)) + { + return null; + } + } + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack) null); + } + else + { + var4.onSlotChanged(); + } + } + + return var3; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return nukeBoy.isUseableByPlayer(player); + } +} diff --git a/com/hbm/inventory/container/ContainerCoreReceiver.java b/com/hbm/inventory/container/ContainerCoreReceiver.java new file mode 100644 index 000000000..16953d61e --- /dev/null +++ b/com/hbm/inventory/container/ContainerCoreReceiver.java @@ -0,0 +1,36 @@ +package com.hbm.inventory.container; + +import com.hbm.tileentity.machine.TileEntityCoreReceiver; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; + +public class ContainerCoreReceiver extends Container { + + private TileEntityCoreReceiver te; + + public ContainerCoreReceiver(InventoryPlayer invPlayer, TileEntityCoreReceiver te) { + + this.te = te; + + for(int i = 0; i < 3; i++) + { + for(int j = 0; j < 9; j++) + { + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) + { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return te.isUseableByPlayer(player); + } +} diff --git a/com/hbm/inventory/gui/GUICoreEmitter.java b/com/hbm/inventory/gui/GUICoreEmitter.java index 8ac34de76..38e90334e 100644 --- a/com/hbm/inventory/gui/GUICoreEmitter.java +++ b/com/hbm/inventory/gui/GUICoreEmitter.java @@ -43,14 +43,13 @@ public class GUICoreEmitter extends GuiInfoContainer { this.field.setTextColor(-1); this.field.setDisabledTextColour(-1); this.field.setEnableBackgroundDrawing(false); - this.field.setMaxStringLength(5); + this.field.setMaxStringLength(3); this.field.setText(String.valueOf(emitter.watts)); } @Override public void drawScreen(int mouseX, int mouseY, float f) { super.drawScreen(mouseX, mouseY, f); - this.field.drawTextBox(); emitter.tank.renderTankInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 17, 16, 52); this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 26, guiTop + 17, 16, 52, emitter.power, emitter.maxPower); @@ -102,6 +101,8 @@ public class GUICoreEmitter extends GuiInfoContainer { int i = (int) emitter.getPowerScaled(52); drawTexturedModalRect(guiLeft + 26, guiTop + 69 - i, 176, 52 - i, 16, i); + + this.field.drawTextBox(); Minecraft.getMinecraft().getTextureManager().bindTexture(emitter.tank.getSheet()); emitter.tank.renderTank(this, guiLeft + 8, guiTop + 69, emitter.tank.getTankType().textureX() * FluidTank.x, emitter.tank.getTankType().textureY() * FluidTank.y, 16, 52); diff --git a/com/hbm/inventory/gui/GUICoreInjector.java b/com/hbm/inventory/gui/GUICoreInjector.java new file mode 100644 index 000000000..850e10eb2 --- /dev/null +++ b/com/hbm/inventory/gui/GUICoreInjector.java @@ -0,0 +1,55 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.FluidTank; +import com.hbm.inventory.container.ContainerCoreInjector; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityCoreInjector; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +public class GUICoreInjector extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/dfc/gui_injector.png"); + private TileEntityCoreInjector injector; + + public GUICoreInjector(InventoryPlayer invPlayer, TileEntityCoreInjector tedf) { + super(new ContainerCoreInjector(invPlayer, tedf)); + injector = tedf; + + this.xSize = 176; + this.ySize = 166; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + injector.tanks[0].renderTankInfo(this, mouseX, mouseY, guiLeft + 44, guiTop + 17, 16, 52); + injector.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 116, guiTop + 17, 16, 52); + } + + @Override + protected void drawGuiContainerForegroundLayer( int i, int j) { + + String name = this.injector.hasCustomInventoryName() ? this.injector.getInventoryName() : I18n.format(this.injector.getInventoryName()); + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + Minecraft.getMinecraft().getTextureManager().bindTexture(injector.tanks[0].getSheet()); + injector.tanks[0].renderTank(this, guiLeft + 44, guiTop + 69, injector.tanks[0].getTankType().textureX() * FluidTank.x, injector.tanks[0].getTankType().textureY() * FluidTank.y, 16, 52); + Minecraft.getMinecraft().getTextureManager().bindTexture(injector.tanks[1].getSheet()); + injector.tanks[1].renderTank(this, guiLeft + 116, guiTop + 69, injector.tanks[1].getTankType().textureX() * FluidTank.x, injector.tanks[1].getTankType().textureY() * FluidTank.y, 16, 52); + } +} diff --git a/com/hbm/inventory/gui/GUICoreReceiver.java b/com/hbm/inventory/gui/GUICoreReceiver.java new file mode 100644 index 000000000..c2a0db956 --- /dev/null +++ b/com/hbm/inventory/gui/GUICoreReceiver.java @@ -0,0 +1,57 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.FluidTank; +import com.hbm.inventory.container.ContainerCoreReceiver; +import com.hbm.lib.Library; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityCoreReceiver; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +public class GUICoreReceiver extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/dfc/gui_receiver.png"); + private TileEntityCoreReceiver receiver; + + public GUICoreReceiver(InventoryPlayer invPlayer, TileEntityCoreReceiver tedf) { + super(new ContainerCoreReceiver(invPlayer, tedf)); + receiver = tedf; + + this.xSize = 176; + this.ySize = 166; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + super.drawScreen(mouseX, mouseY, f); + + receiver.tank.renderTankInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 17, 16, 52); + } + + @Override + protected void drawGuiContainerForegroundLayer( int i, int j) { + String name = this.receiver.hasCustomInventoryName() ? this.receiver.getInventoryName() : I18n.format(this.receiver.getInventoryName()); + this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); + + this.fontRendererObj.drawString("Input:", 40, 25, 0xFF7F7F); + this.fontRendererObj.drawString(Library.getShortNumber(receiver.joules) + "Spk", 50, 35, 0xFF7F7F); + this.fontRendererObj.drawString(Library.getShortNumber(receiver.joules * 5000) + "HE", 50, 45, 0xFF7F7F); + + this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + Minecraft.getMinecraft().getTextureManager().bindTexture(receiver.tank.getSheet()); + receiver.tank.renderTank(this, guiLeft + 8, guiTop + 69, receiver.tank.getTankType().textureX() * FluidTank.x, receiver.tank.getTankType().textureY() * FluidTank.y, 16, 52); + } +} diff --git a/com/hbm/items/weapon/ItemAmmo.java b/com/hbm/items/weapon/ItemAmmo.java index 134218181..c8eee5f66 100644 --- a/com/hbm/items/weapon/ItemAmmo.java +++ b/com/hbm/items/weapon/ItemAmmo.java @@ -90,7 +90,7 @@ public class ItemAmmo extends Item { if(this == ModItems.ammo_44_star) { list.add(EnumChatFormatting.BLUE + "+ Highly increased damage"); list.add(EnumChatFormatting.YELLOW + "* Starmetal"); - list.add(EnumChatFormatting.RED + "- Highly decreased damage"); + list.add(EnumChatFormatting.RED + "- Highly increased wear"); } //5mm diff --git a/com/hbm/main/ClientProxy.java b/com/hbm/main/ClientProxy.java index 09ce4431f..9f958b28d 100644 --- a/com/hbm/main/ClientProxy.java +++ b/com/hbm/main/ClientProxy.java @@ -345,6 +345,7 @@ public class ClientProxy extends ServerProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoreEmitter.class, new RenderCoreComponent()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoreReceiver.class, new RenderCoreComponent()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoreInjector.class, new RenderCoreComponent()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCore.class, new RenderCore()); RenderingRegistry.registerEntityRenderingHandler(EntityMissileCustom.class, new RenderMissileCustom()); diff --git a/com/hbm/main/MainRegistry.java b/com/hbm/main/MainRegistry.java index 2e9c6d210..273df4016 100644 --- a/com/hbm/main/MainRegistry.java +++ b/com/hbm/main/MainRegistry.java @@ -521,6 +521,7 @@ public class MainRegistry GameRegistry.registerTileEntity(TileEntityCoreEmitter.class, "tileentity_v0_emitter"); GameRegistry.registerTileEntity(TileEntityCoreReceiver.class, "tileentity_v0_receiver"); GameRegistry.registerTileEntity(TileEntityCoreInjector.class, "tileentity_v0_injector"); + GameRegistry.registerTileEntity(TileEntityCore.class, "tileentity_v0"); GameRegistry.registerTileEntity(TileEntityMachineArcFurnace.class, "tileentity_arc_furnace"); GameRegistry.registerTileEntity(TileEntityMachineAmgen.class, "tileentity_amgen"); GameRegistry.registerTileEntity(TileEntityGeysir.class, "tileentity_geysir"); diff --git a/com/hbm/render/entity/RenderLaser.java b/com/hbm/render/entity/RenderLaser.java index 4d28a913c..4cc75fab4 100644 --- a/com/hbm/render/entity/RenderLaser.java +++ b/com/hbm/render/entity/RenderLaser.java @@ -42,8 +42,8 @@ public class RenderLaser extends Render { int init = (int) -(System.currentTimeMillis() % 360); //BeamPronter.prontHelix(skeleton, 0, 0, 0, EnumWaveType.SPIRAL, EnumBeamType.LINE, 0x0000ff, 0x8080ff, 0, (int)(skeleton.lengthVector() * 5), 0.2F); - BeamPronter.prontHelix(skeleton, EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xff5000, 0xff5000, init, (int) skeleton.lengthVector() + 1, 0.1F, 4, 0.05F); - BeamPronter.prontHelix(skeleton, EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xff3000, 0xff3000, init, 1, 0F, 4, 0.05F); + BeamPronter.prontBeam(skeleton, EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xff5000, 0xff5000, init, (int) skeleton.lengthVector() + 1, 0.1F, 4, 0.05F); + BeamPronter.prontBeam(skeleton, EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xff3000, 0xff3000, init, 1, 0F, 4, 0.05F); } GL11.glPopMatrix(); diff --git a/com/hbm/render/tileentity/RenderCore.java b/com/hbm/render/tileentity/RenderCore.java new file mode 100644 index 000000000..abd740d57 --- /dev/null +++ b/com/hbm/render/tileentity/RenderCore.java @@ -0,0 +1,215 @@ +package com.hbm.render.tileentity; + +import java.nio.FloatBuffer; +import java.util.Random; + +import org.lwjgl.opengl.GL11; + +import com.hbm.main.ResourceManager; +import com.hbm.render.util.RenderSparks; +import com.hbm.tileentity.machine.TileEntityCore; + +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class RenderCore extends TileEntitySpecialRenderer { + + private static final ResourceLocation sky = new ResourceLocation("textures/environment/end_sky.png"); + private static final ResourceLocation portal = new ResourceLocation("textures/entity/end_portal.png"); + private static final Random random = new Random(31100L); + FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16); + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { + + TileEntityCore core = (TileEntityCore)tileEntity; + renderStandby(x, y, z); + } + + public void renderStandby(double x, double y, double z) { + + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_TEXTURE_2D); + + GL11.glScalef(0.25F, 0.25F, 0.25F); + GL11.glColor3f(0.5F, 0.5F, 0.5F); + ResourceManager.sphere_uv.renderAll(); + + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + GL11.glScalef(1.25F, 1.25F, 1.25F); + GL11.glColor3f(0.1F, 0.1F, 0.1F); + ResourceManager.sphere_uv.renderAll(); + GL11.glDisable(GL11.GL_BLEND); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + + if((System.currentTimeMillis() / 100) % 10 == 0) { + for(int i = 0; i < 3; i++) { + RenderSparks.renderSpark((int) System.currentTimeMillis() / 100 + i * 10000, 0, 0, 0, 1.5F, 5, 10, 0xFFFF00, 0xFFFFFF); + RenderSparks.renderSpark((int) System.currentTimeMillis() / 50 + i * 10000, 0, 0, 0, 1.5F, 5, 10, 0xFFFF00, 0xFFFFFF); + } + } + + GL11.glPopMatrix(); + } + + public void renderVoid(TileEntity tile, double x, double y, double z) { + + World world = tile.getWorldObj(); + GL11.glPushMatrix(); + + GL11.glDisable(GL11.GL_LIGHTING); + + random.setSeed(31110L); + + GL11.glDisable(GL11.GL_LIGHTING); + + GL11.glTexGeni(GL11.GL_S, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glTexGeni(GL11.GL_T, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glTexGeni(GL11.GL_R, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glTexGeni(GL11.GL_Q, GL11.GL_TEXTURE_GEN_MODE, GL11.GL_EYE_LINEAR); + GL11.glEnable(GL11.GL_TEXTURE_GEN_S); + GL11.glEnable(GL11.GL_TEXTURE_GEN_T); + GL11.glEnable(GL11.GL_TEXTURE_GEN_R); + GL11.glEnable(GL11.GL_TEXTURE_GEN_Q); + GL11.glMatrixMode(GL11.GL_TEXTURE); + GL11.glPushMatrix(); + GL11.glLoadIdentity(); + float f100 = world.getTotalWorldTime() % 500L / 500F; + GL11.glTranslatef(random.nextFloat(), f100, random.nextFloat()); + + Tessellator tessellator = Tessellator.instance; + + final int end = 10; + for (int i = 0; i < end; ++i) { + float f5 = end - i; + float f7 = 1.0F / (f5 + 1.0F); + + if (i == 0) { + this.bindTexture(sky); + f7 = 0.0F; + f5 = 65.0F; + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + if (i == 1) { + this.bindTexture(portal); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); + } + + GL11.glTranslatef(random.nextFloat() * (1 - f7), random.nextFloat() * (1 - f7), random.nextFloat() * (1 - f7)); + float scale = 0.9F; + GL11.glScalef(scale, scale, scale); + float ang = 360 / end; + GL11.glRotatef(ang * i + ang * random.nextFloat(), 0.0F, 0.0F, 1.0F); + + float f11 = (float) random.nextDouble() * 0.5F + 0.9F; + float f12 = (float) random.nextDouble() * 0.5F + 0.1F; + float f13 = (float) random.nextDouble() * 0.5F + 0.9F; + if (i == 0) { + f13 = 1.0F; + f12 = 1.0F; + f11 = 1.0F; + } + f13 *= f7; + f12 *= f7; + f11 *= f7; + + GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, this.func_147525_a(1, 0, 0, 0)); + GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, this.func_147525_a(0, 0, 1, 0)); + GL11.glTexGen(GL11.GL_R, GL11.GL_EYE_PLANE, this.func_147525_a(0, 0, 0, 1)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.func_147525_a(0, 1, 0, 0)); + + GL11.glRotatef(180, 0, 0, 1); + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(f11, f12, f13); + tessellator.setBrightness(0xF000F0); + tessellator.addVertex(x + 0.0, y + 0.0, z + 1.0); + tessellator.addVertex(x + 0.0, y + 0.0, z + 0.0); + tessellator.addVertex(x + 1.0, y + 0.0, z + 0.0); + tessellator.addVertex(x + 1.0, y + 0.0, z + 1.0); + tessellator.draw(); + + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(f11, f12, f13); + tessellator.setBrightness(0xF000F0); + tessellator.addVertex(x + 1.0, y + 1.0, z + 1.0); + tessellator.addVertex(x + 1.0, y + 1.0, z + 0.0); + tessellator.addVertex(x + 0.0, y + 1.0, z + 0.0); + tessellator.addVertex(x + 0.0, y + 1.0, z + 1.0); + tessellator.draw(); + + GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, this.func_147525_a(0, 1, 0, 0)); + GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, this.func_147525_a(1, 0, 0, 0)); + GL11.glTexGen(GL11.GL_R, GL11.GL_EYE_PLANE, this.func_147525_a(0, 0, 0, 1)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.func_147525_a(0, 0, 1, 0)); + + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(f11, f12, f13); + tessellator.setBrightness(0xF000F0); + tessellator.addVertex(x + 0.0, y + 0.0, z + 0.0); + tessellator.addVertex(x + 0.0, y + 1.0, z + 0.0); + tessellator.addVertex(x + 1.0, y + 1.0, z + 0.0); + tessellator.addVertex(x + 1.0, y + 0.0, z + 0.0); + + tessellator.addVertex(x + 1.0, y + 0.0, z + 1.0); + tessellator.addVertex(x + 1.0, y + 1.0, z + 1.0); + tessellator.addVertex(x + 0.0, y + 1.0, z + 1.0); + tessellator.addVertex(x + 0.0, y + 0.0, z + 1.0); + tessellator.draw(); + + GL11.glTexGen(GL11.GL_S, GL11.GL_EYE_PLANE, this.func_147525_a(0, 1, 0, 0)); + GL11.glTexGen(GL11.GL_T, GL11.GL_EYE_PLANE, this.func_147525_a(0, 0, 1, 0)); + GL11.glTexGen(GL11.GL_R, GL11.GL_EYE_PLANE, this.func_147525_a(0, 0, 0, 1)); + GL11.glTexGen(GL11.GL_Q, GL11.GL_EYE_PLANE, this.func_147525_a(1, 0, 0, 0)); + + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(f11, f12, f13); + tessellator.setBrightness(0xF000F0); + tessellator.addVertex(x + 0.0, y + 0.0, z + 1.0); + tessellator.addVertex(x + 0.0, y + 1.0, z + 1.0); + tessellator.addVertex(x + 0.0, y + 1.0, z + 0.0); + tessellator.addVertex(x + 0.0, y + 0.0, z + 0.0); + tessellator.draw(); + + tessellator.startDrawingQuads(); + tessellator.setColorOpaque_F(f11, f12, f13); + tessellator.setBrightness(0xF000F0); + tessellator.addVertex(x + 1.0, y + 0.0, z + 0.0); + tessellator.addVertex(x + 1.0, y + 1.0, z + 0.0); + tessellator.addVertex(x + 1.0, y + 1.0, z + 1.0); + tessellator.addVertex(x + 1.0, y + 0.0, z + 1.0); + tessellator.draw(); + } + + GL11.glPopMatrix(); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_GEN_S); + GL11.glDisable(GL11.GL_TEXTURE_GEN_T); + GL11.glDisable(GL11.GL_TEXTURE_GEN_R); + GL11.glDisable(GL11.GL_TEXTURE_GEN_Q); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + private FloatBuffer func_147525_a(float x, float y, float z, float w) { + + this.buffer.clear(); + this.buffer.put(x).put(y).put(z).put(w); + this.buffer.flip(); + return this.buffer; + } + +} diff --git a/com/hbm/render/tileentity/RenderCoreComponent.java b/com/hbm/render/tileentity/RenderCoreComponent.java index 810c16541..68bc8f87c 100644 --- a/com/hbm/render/tileentity/RenderCoreComponent.java +++ b/com/hbm/render/tileentity/RenderCoreComponent.java @@ -54,9 +54,9 @@ public class RenderCoreComponent extends TileEntitySpecialRenderer { int range = ((TileEntityCoreEmitter)tileEntity).beam; if(range > 0) { - BeamPronter.prontHelix(Vec3.createVectorHelper(0, 0, range), EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0x404000, 0x404000, 0, 1, 0F, 2, 0.0625F); - BeamPronter.prontHelix(Vec3.createVectorHelper(0, 0, range), EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x401500, 0x401500, (int)tileEntity.getWorldObj().getTotalWorldTime() % 1000, range * 2, 0.125F, 4, 0.0625F); - BeamPronter.prontHelix(Vec3.createVectorHelper(0, 0, range), EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x401500, 0x401500, (int)tileEntity.getWorldObj().getTotalWorldTime() % 1000 + 1, range * 2, 0.125F, 4, 0.0625F); + BeamPronter.prontBeam(Vec3.createVectorHelper(0, 0, range), EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0x404000, 0x404000, 0, 1, 0F, 2, 0.0625F); + BeamPronter.prontBeam(Vec3.createVectorHelper(0, 0, range), EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x401500, 0x401500, (int)tileEntity.getWorldObj().getTotalWorldTime() % 1000, range * 2, 0.125F, 4, 0.0625F); + BeamPronter.prontBeam(Vec3.createVectorHelper(0, 0, range), EnumWaveType.RANDOM, EnumBeamType.SOLID, 0x401500, 0x401500, (int)tileEntity.getWorldObj().getTotalWorldTime() % 1000 + 1, range * 2, 0.125F, 4, 0.0625F); } } @@ -68,6 +68,14 @@ public class RenderCoreComponent extends TileEntitySpecialRenderer { if(tileEntity instanceof TileEntityCoreInjector) { bindTexture(ResourceManager.dfc_injector_tex); ResourceManager.dfc_injector.renderAll(); + + GL11.glTranslated(0, 0.5, 0); + int range = ((TileEntityCoreInjector)tileEntity).beam; + + if(range > 0) { + BeamPronter.prontBeam(Vec3.createVectorHelper(0, 0, range), EnumWaveType.RANDOM, EnumBeamType.LINE, 0x0000ff, 0x8080ff, (int)tileEntity.getWorldObj().getTotalWorldTime() % 1000, range, 0.0625F, 0, 0); + BeamPronter.prontBeam(Vec3.createVectorHelper(0, 0, range), EnumWaveType.RANDOM, EnumBeamType.LINE, 0x0000ff, 0x8080ff, (int)tileEntity.getWorldObj().getTotalWorldTime() % 1000 + 1, range, 0.0625F, 0, 0); + } } GL11.glEnable(GL11.GL_LIGHTING); diff --git a/com/hbm/render/tileentity/RendererObjTester.java b/com/hbm/render/tileentity/RendererObjTester.java index f578345ca..a063d6926 100644 --- a/com/hbm/render/tileentity/RendererObjTester.java +++ b/com/hbm/render/tileentity/RendererObjTester.java @@ -108,8 +108,8 @@ public class RendererObjTester extends TileEntitySpecialRenderer { //SoyuzPronter.prontSoyuz(); //TomPronter.prontTom(); - BeamPronter.prontHelix(Vec3.createVectorHelper(5, 5, 5), EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xff8000, 0xff8000, (int)tileEntity.getWorldObj().getTotalWorldTime() % 360 * 25, 25, 0.1F, 4, 0.05F); - BeamPronter.prontHelix(Vec3.createVectorHelper(5, 5, 5), EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xffff00, 0xffff00, (int)tileEntity.getWorldObj().getTotalWorldTime() % 360 * 25, 1, 0F, 4, 0.05F); + BeamPronter.prontBeam(Vec3.createVectorHelper(5, 5, 5), EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xff8000, 0xff8000, (int)tileEntity.getWorldObj().getTotalWorldTime() % 360 * 25, 25, 0.1F, 4, 0.05F); + BeamPronter.prontBeam(Vec3.createVectorHelper(5, 5, 5), EnumWaveType.SPIRAL, EnumBeamType.SOLID, 0xffff00, 0xffff00, (int)tileEntity.getWorldObj().getTotalWorldTime() % 360 * 25, 1, 0F, 4, 0.05F); //BeamPronter.prontHelix(Vec3.createVectorHelper(0, 5, 0), 0.5, 0.5, 0.5, EnumWaveType.SPIRAL, EnumBeamType.LINE, 0x0000ff, 0xffff00, (int)tileEntity.getWorldObj().getTotalWorldTime() % 360 * 25 + 180, 25, 0.25F); GL11.glPopMatrix(); diff --git a/com/hbm/render/util/BeamPronter.java b/com/hbm/render/util/BeamPronter.java index 3a3a8d96f..660cb1369 100644 --- a/com/hbm/render/util/BeamPronter.java +++ b/com/hbm/render/util/BeamPronter.java @@ -20,7 +20,7 @@ public class BeamPronter { LINE } - public static void prontHelix(Vec3 skeleton, EnumWaveType wave, EnumBeamType beam, int outerColor, int innerColor, int start, int segments, float size, int layers, float thickness) { + public static void prontBeam(Vec3 skeleton, EnumWaveType wave, EnumBeamType beam, int outerColor, int innerColor, int start, int segments, float size, int layers, float thickness) { GL11.glPushMatrix(); diff --git a/com/hbm/render/util/RenderSparks.java b/com/hbm/render/util/RenderSparks.java new file mode 100644 index 000000000..40ecdeff0 --- /dev/null +++ b/com/hbm/render/util/RenderSparks.java @@ -0,0 +1,62 @@ +package com.hbm.render.util; + +import java.util.Random; + +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.Vec3; + +public class RenderSparks { + + public static void renderSpark(int seed, double x, double y, double z, float length, int min, int max, int color1, int color2) { + + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glLineWidth(3F); + Tessellator tessellator = Tessellator.instance; + + Random rand = new Random(seed); + Vec3 vec = Vec3.createVectorHelper(rand.nextDouble() - 0.5, rand.nextDouble() - 0.5, rand.nextDouble() - 0.5); + vec = vec.normalize(); + + double prevX; + double prevY; + double prevZ; + + for(int i = 0; i < min + rand.nextInt(max); i++) { + + prevX = x; + prevY = y; + prevZ = z; + + Vec3 dir = vec.normalize(); + dir.xCoord *= length * rand.nextFloat(); + dir.yCoord *= length * rand.nextFloat(); + dir.zCoord *= length * rand.nextFloat(); + + x = prevX + dir.xCoord; + y = prevY + dir.yCoord; + z = prevZ + dir.zCoord; + + GL11.glLineWidth(5F); + tessellator.startDrawing(3); + tessellator.setColorOpaque_I(color1); + tessellator.addVertex(prevX, prevY, prevZ); + tessellator.addVertex(x, y, z); + tessellator.draw(); + GL11.glLineWidth(2F); + tessellator.startDrawing(3); + tessellator.setColorOpaque_I(color2); + tessellator.addVertex(prevX, prevY, prevZ); + tessellator.addVertex(x, y, z); + tessellator.draw(); + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glPopMatrix(); + } + +} diff --git a/com/hbm/tileentity/machine/TileEntityCore.java b/com/hbm/tileentity/machine/TileEntityCore.java index cac49d0ce..2ecc2e8d7 100644 --- a/com/hbm/tileentity/machine/TileEntityCore.java +++ b/com/hbm/tileentity/machine/TileEntityCore.java @@ -1,11 +1,21 @@ package com.hbm.tileentity.machine; +import com.hbm.handler.FluidTypeHandler.FluidType; +import com.hbm.inventory.FluidTank; import com.hbm.tileentity.TileEntityMachineBase; public class TileEntityCore extends TileEntityMachineBase { + + public int field; + public int heat; + public int color; + public FluidTank[] tanks; public TileEntityCore() { super(3); + tanks = new FluidTank[2]; + tanks[0] = new FluidTank(FluidType.DEUTERIUM, 128000, 0); + tanks[1] = new FluidTank(FluidType.TRITIUM, 128000, 1); } @Override @@ -17,5 +27,39 @@ public class TileEntityCore extends TileEntityMachineBase { public void updateEntity() { } + + public long burn(long joules) { + + return 0; + } + + public float getFuelEfficiency(FluidType type) { + + switch(type) { + + case HYDROGEN: + return 1.0F; + case DEUTERIUM: + return 1.5F; + case TRITIUM: + return 1.7F; + case OXYGEN: + return 1.2F; + case ACID: + return 1.4F; + case XENON: + return 1.5F; + case SAS3: + return 2.0F; + case BALEFIRE: + return 2.5F; + case AMAT: + return 2.2F; + case ASCHRAB: + return 2.7F; + default: + return 0; + } + } } diff --git a/com/hbm/tileentity/machine/TileEntityCoreEmitter.java b/com/hbm/tileentity/machine/TileEntityCoreEmitter.java index 8b11dccfd..7b843ecaf 100644 --- a/com/hbm/tileentity/machine/TileEntityCoreEmitter.java +++ b/com/hbm/tileentity/machine/TileEntityCoreEmitter.java @@ -80,6 +80,9 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements ICon prev = joules; if(joules > 0) { + + long out = joules * 98 / 100; + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); for(int i = 1; i <= range; i++) { @@ -93,10 +96,15 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements ICon if(te instanceof ILaserable) { - ((ILaserable)te).addEnergy(joules * 98 / 100, dir); + ((ILaserable)te).addEnergy(out * 98 / 100, dir); break; } + if(te instanceof TileEntityCore) { + ((TileEntityCore)te).burn(out); + continue; + } + Block b = worldObj.getBlock(x, y, z); if(b != Blocks.air) { @@ -131,6 +139,8 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements ICon joules = 0; prev = 0; } + + this.markDirty(); NBTTagCompound data = new NBTTagCompound(); data.setLong("power", power); @@ -233,5 +243,29 @@ public class TileEntityCoreEmitter extends TileEntityMachineBase implements ICon { return 65536.0D; } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + power = nbt.getLong("power"); + watts = nbt.getInteger("watts"); + joules = nbt.getLong("joules"); + prev = nbt.getLong("prev"); + isOn = nbt.getBoolean("isOn"); + tank.readFromNBT(nbt, "tank"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setLong("power", power); + nbt.setInteger("watts", watts); + nbt.setLong("joules", joules); + nbt.setLong("prev", prev); + nbt.setBoolean("isOn", isOn); + tank.writeToNBT(nbt, "tank"); + } } diff --git a/com/hbm/tileentity/machine/TileEntityCoreInjector.java b/com/hbm/tileentity/machine/TileEntityCoreInjector.java index af86ea190..bb4d51086 100644 --- a/com/hbm/tileentity/machine/TileEntityCoreInjector.java +++ b/com/hbm/tileentity/machine/TileEntityCoreInjector.java @@ -1,7 +1,177 @@ package com.hbm.tileentity.machine; -import net.minecraft.tileentity.TileEntity; +import java.util.ArrayList; +import java.util.List; -public class TileEntityCoreInjector extends TileEntity { +import com.hbm.handler.FluidTypeHandler.FluidType; +import com.hbm.interfaces.IFluidAcceptor; +import com.hbm.inventory.FluidTank; +import com.hbm.tileentity.TileEntityMachineBase; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityCoreInjector extends TileEntityMachineBase implements IFluidAcceptor { + + public FluidTank[] tanks; + public static final int range = 15; + public int beam; + + public TileEntityCoreInjector() { + super(4); + tanks = new FluidTank[2]; + tanks[0] = new FluidTank(FluidType.DEUTERIUM, 128000, 0); + tanks[1] = new FluidTank(FluidType.TRITIUM, 128000, 1); + } + + @Override + public String getName() { + return "container.dfcInjector"; + } + + @Override + public void updateEntity() { + + if(!worldObj.isRemote) { + + tanks[0].setType(0, 1, slots); + tanks[1].setType(2, 3, slots); + + beam = 0; + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); + for(int i = 1; i <= range; i++) { + + int x = xCoord + dir.offsetX * i; + int y = yCoord + dir.offsetY * i; + int z = zCoord + dir.offsetZ * i; + + TileEntity te = worldObj.getTileEntity(x, y, z); + + if(te instanceof TileEntityCore) { + + TileEntityCore core = (TileEntityCore)te; + + for(int t = 0; t < 2; t++) { + + if(core.tanks[t].getTankType() == tanks[t].getTankType()) { + + int f = Math.min(tanks[t].getFill(), core.tanks[t].getMaxFill() - core.tanks[t].getFill()); + + tanks[t].setFill(tanks[t].getFill() - f); + core.tanks[t].setFill(core.tanks[t].getFill() + f); + core.markDirty(); + + } else if(core.tanks[t].getFill() == 0) { + + core.tanks[t].setTankType(tanks[t].getTankType()); + int f = Math.min(tanks[t].getFill(), core.tanks[t].getMaxFill() - core.tanks[t].getFill()); + + tanks[t].setFill(tanks[t].getFill() - f); + core.tanks[t].setFill(core.tanks[t].getFill() + f); + core.markDirty(); + } + } + + beam = i; + break; + } + } + + this.markDirty(); + + tanks[0].updateTank(xCoord, yCoord, zCoord); + tanks[1].updateTank(xCoord, yCoord, zCoord); + + NBTTagCompound data = new NBTTagCompound(); + data.setInteger("beam", beam); + this.networkPack(data, 250); + } + } + + public void networkUnpack(NBTTagCompound data) { + beam = data.getInteger("beam"); + } + + @Override + public int getMaxFluidFill(FluidType type) { + if (type.name().equals(tanks[0].getTankType().name())) + return tanks[0].getMaxFill(); + else if (type.name().equals(tanks[1].getTankType().name())) + return tanks[1].getMaxFill(); + else + return 0; + } + + @Override + public void setFluidFill(int i, FluidType type) { + if (type.name().equals(tanks[0].getTankType().name())) + tanks[0].setFill(i); + else if (type.name().equals(tanks[1].getTankType().name())) + tanks[1].setFill(i); + } + + @Override + public int getFluidFill(FluidType type) { + if (type.name().equals(tanks[0].getTankType().name())) + return tanks[0].getFill(); + else if (type.name().equals(tanks[1].getTankType().name())) + return tanks[1].getFill(); + else + return 0; + } + + @Override + public void setFillstate(int fill, int index) { + if (index < 2 && tanks[index] != null) + tanks[index].setFill(fill); + } + + @Override + public void setType(FluidType type, int index) { + if (index < 2 && tanks[index] != null) + tanks[index].setTankType(type); + } + + @Override + public List getTanks() { + List list = new ArrayList(); + list.add(tanks[0]); + list.add(tanks[1]); + + return list; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return TileEntity.INFINITE_EXTENT_AABB; + } + + @Override + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() + { + return 65536.0D; + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + tanks[0].readFromNBT(nbt, "fuel1"); + tanks[1].readFromNBT(nbt, "fuel2"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + tanks[0].writeToNBT(nbt, "fuel1"); + tanks[1].writeToNBT(nbt, "fuel2"); + } } diff --git a/com/hbm/tileentity/machine/TileEntityCoreReceiver.java b/com/hbm/tileentity/machine/TileEntityCoreReceiver.java index bda7d756c..b8457ec2a 100644 --- a/com/hbm/tileentity/machine/TileEntityCoreReceiver.java +++ b/com/hbm/tileentity/machine/TileEntityCoreReceiver.java @@ -15,6 +15,7 @@ import com.hbm.tileentity.TileEntityMachineBase; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; @@ -55,6 +56,10 @@ public class TileEntityCoreReceiver extends TileEntityMachineBase implements ISo return; } } + + NBTTagCompound data = new NBTTagCompound(); + data.setLong("joules", joules); + this.networkPack(data, 50); joules = 0; @@ -72,6 +77,11 @@ public class TileEntityCoreReceiver extends TileEntityMachineBase implements ISo } } } + + public void networkUnpack(NBTTagCompound data) { + + joules = data.getLong("joules"); + } @Override public void ffgeua(int x, int y, int z, boolean newTact) { @@ -182,4 +192,22 @@ public class TileEntityCoreReceiver extends TileEntityMachineBase implements ISo { return 65536.0D; } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + + power = nbt.getLong("power"); + joules = nbt.getLong("joules"); + tank.readFromNBT(nbt, "tank"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + + nbt.setLong("power", power); + nbt.setLong("joules", joules); + tank.writeToNBT(nbt, "tank"); + } }