diff --git a/changelog b/changelog index dd831e3fd..ce5ce5c44 100644 --- a/changelog +++ b/changelog @@ -4,7 +4,14 @@ * Overdrive upgrades now use fullerite instead of lithium crystals * Machines now only send their sync packets once a second instead of once per tick if the values haven't changed, reducing network traffic by a considerable amount * Tom's explosion no longer causes any block updates on the millions of blocks it deletes which hopefully fixes a majority of the lag caused by the crater +* Overdrive upgrades now increase power usage in pyrolysis ovens (equivalent to 2 speed upgrades per level) +* Due to the increased maximum demand with overdrives + speed upgrades, the energy buffer for the pyrolysis oven has been increased tenfold +* Updated basalt textures +* Scaffold blocks can now be placed horizontally +* Updated the shredder's textures ## Fixed * The conveyor grabber should no longer skip over items when used in long lines -* Fixed a potential crash regarding crucibles \ No newline at end of file +* Fixed a potential crash regarding crucibles +* Fixed compatibility with EndlessIDs, biome changes should no longer crash the game +* Fixed GL state leak caused by fluid tanks, causing some tile entities to be rendered without face culling \ No newline at end of file diff --git a/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java b/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java index 2160a0451..523bc10b7 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java +++ b/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java @@ -8,6 +8,7 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class MachineRotaryFurnace extends BlockDummyable { @@ -29,11 +30,31 @@ public class MachineRotaryFurnace extends BlockDummyable { @Override public int[] getDimensions() { - return new int[] {3, 0, 1, 1, 2, 2}; + return new int[] {4, 0, 1, 1, 2, 2}; } @Override public int getOffset() { return 1; } + + @Override + protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { + super.fillSpace(world, x, y, z, dir, o); + x += dir.offsetX * o; + z += dir.offsetZ * o; + + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + //back + for(int i = -2; i <= 2; i++) { + this.makeExtra(world, x - dir.offsetX + rot.offsetX * i, y, z - dir.offsetZ + rot.offsetZ * i); + } + //side fluid + this.makeExtra(world, x + dir.offsetX - rot.offsetX * 2, y, z + dir.offsetZ - rot.offsetZ * 2); + //exhaust + this.makeExtra(world, x + rot.offsetX, y + 4, z + rot.offsetZ); + //solid fuel + this.makeExtra(world, x + dir.offsetX + rot.offsetX, y, z + dir.offsetZ + rot.offsetZ); + } } diff --git a/src/main/java/com/hbm/inventory/container/ContainerMachineRotaryFurnace.java b/src/main/java/com/hbm/inventory/container/ContainerMachineRotaryFurnace.java new file mode 100644 index 000000000..219f1f0e6 --- /dev/null +++ b/src/main/java/com/hbm/inventory/container/ContainerMachineRotaryFurnace.java @@ -0,0 +1,75 @@ +package com.hbm.inventory.container; + +import com.hbm.items.machine.IItemFluidIdentifier; +import com.hbm.tileentity.machine.TileEntityMachineRotaryFurnace; + +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; +import net.minecraft.tileentity.TileEntityFurnace; + +public class ContainerMachineRotaryFurnace extends Container { + + private TileEntityMachineRotaryFurnace furnace; + + public ContainerMachineRotaryFurnace(InventoryPlayer invPlayer, TileEntityMachineRotaryFurnace tile) { + furnace = tile; + + //Inputs + this.addSlotToContainer(new Slot(tile, 0, 8, 18)); + this.addSlotToContainer(new Slot(tile, 1, 26, 18)); + this.addSlotToContainer(new Slot(tile, 2, 44, 18)); + //Fluid ID + this.addSlotToContainer(new Slot(tile, 3, 8, 54)); + //Solid fuel + this.addSlotToContainer(new Slot(tile, 4, 44, 54)); + + 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, 104 + i * 18)); + } + } + + for(int i = 0; i < 9; i++) { + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 162)); + } + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int index) { + ItemStack rStack = null; + Slot slot = (Slot) this.inventorySlots.get(index); + + if(slot != null && slot.getHasStack()) { + ItemStack stack = slot.getStack(); + rStack = stack.copy(); + + if(index <= 4) { + if(!this.mergeItemStack(stack, 5, this.inventorySlots.size(), true)) return null; + } else { + if(TileEntityFurnace.isItemFuel(rStack)) { + if(!this.mergeItemStack(stack, 4, 5, false)) return null; + } else if(rStack.getItem() instanceof IItemFluidIdentifier) { + if(!this.mergeItemStack(stack, 3, 4, false)) return null; + } else { + if(!this.mergeItemStack(stack, 0, 3, false)) return null; + } + } + + if(stack.stackSize == 0) { + slot.putStack((ItemStack) null); + } else { + slot.onSlotChanged(); + } + } + + return rStack; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return furnace.isUseableByPlayer(player); + } +} diff --git a/src/main/java/com/hbm/inventory/container/ContainerMachineShredder.java b/src/main/java/com/hbm/inventory/container/ContainerMachineShredder.java index c10e47ae7..983129533 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerMachineShredder.java +++ b/src/main/java/com/hbm/inventory/container/ContainerMachineShredder.java @@ -55,12 +55,12 @@ public class ContainerMachineShredder extends Container { 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 + 56)); + this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 67)); } } for(int i = 0; i < 9; i++) { - this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 56)); + this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 67)); } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineRotaryFurnace.java b/src/main/java/com/hbm/inventory/gui/GUIMachineRotaryFurnace.java new file mode 100644 index 000000000..873694184 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineRotaryFurnace.java @@ -0,0 +1,93 @@ +package com.hbm.inventory.gui; + +import java.awt.Color; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.container.ContainerMachineRotaryFurnace; +import com.hbm.inventory.material.Mats; +import com.hbm.lib.RefStrings; +import com.hbm.tileentity.machine.TileEntityMachineRotaryFurnace; +import com.hbm.util.I18nUtil; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; + +public class GUIMachineRotaryFurnace extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_rotary_furnace.png"); + private TileEntityMachineRotaryFurnace furnace; + + public GUIMachineRotaryFurnace(InventoryPlayer playerInv, TileEntityMachineRotaryFurnace tile) { + super(new ContainerMachineRotaryFurnace(playerInv, tile)); + + this.furnace = tile; + this.xSize = 176; + this.ySize = 186; + } + + @Override + public void drawScreen(int x, int y, float interp) { + super.drawScreen(x, y, interp); + + furnace.tanks[0].renderTankInfo(this, x, y, guiLeft + 8, guiTop + 36, 52, 16); + furnace.tanks[1].renderTankInfo(this, x, y, guiLeft + 134, guiTop + 18, 16, 52); + furnace.tanks[2].renderTankInfo(this, x, y, guiLeft + 152, guiTop + 18, 16, 52); + + if(furnace.output == null) { + this.drawCustomInfoStat(x, y, guiLeft + 98, guiTop + 18, 16, 52, x, y, EnumChatFormatting.RED + "Empty"); + } else { + this.drawCustomInfoStat(x, y, guiLeft + 98, guiTop + 18, 16, 52, x, y,EnumChatFormatting.YELLOW + + I18nUtil.resolveKey(furnace.output.material.getUnlocalizedName()) + ": " + Mats.formatAmount(furnace.output.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int i, int j) { + String name = this.furnace.hasCustomInventoryName() ? this.furnace.getInventoryName() : I18n.format(this.furnace.getInventoryName()); + this.fontRendererObj.drawString(name, (this.xSize - 54) / 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 interp, int x, int y) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + int p = (int) (furnace.progress * 33); + drawTexturedModalRect(guiLeft + 63, guiTop + 30, 176, 0, p, 10); + + if(furnace.maxBurnTime > 0) { + int b = furnace.burnTime * 14 / furnace.maxBurnTime; + drawTexturedModalRect(guiLeft + 26, guiTop + 69 - b, 176, 24 - b, 14, b); + } + + if(furnace.output != null) { + + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + + int hex = furnace.output.material.moltenColor; + int amount = furnace.output.amount * 52 / furnace.maxOutput; + Color color = new Color(hex); + GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); + drawTexturedModalRect(guiLeft + 98, guiTop + 70 - amount, 176, 76 - amount, 16, amount); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1F, 1F, 1F, 0.3F); + drawTexturedModalRect(guiLeft + 98, guiTop + 70 - amount, 176, 76 - amount, 16, amount); + GL11.glDisable(GL11.GL_BLEND); + + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor3f(255, 255, 255); + } + + furnace.tanks[0].renderTank(guiLeft + 8, guiTop + 52, this.zLevel, 52, 16, 1); + furnace.tanks[1].renderTank(guiLeft + 134, guiTop + 70, this.zLevel, 16, 52); + furnace.tanks[2].renderTank(guiLeft + 152, guiTop + 70, this.zLevel, 16, 52); + } +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineShredder.java b/src/main/java/com/hbm/inventory/gui/GUIMachineShredder.java index 255b789ba..ef433374e 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineShredder.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineShredder.java @@ -21,7 +21,7 @@ public class GUIMachineShredder extends GuiInfoContainer { diFurnace = tedf; this.xSize = 176; - this.ySize = 222; + this.ySize = 233; } @Override diff --git a/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java b/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java new file mode 100644 index 000000000..713474b35 --- /dev/null +++ b/src/main/java/com/hbm/inventory/recipes/RotaryFurnaceRecipes.java @@ -0,0 +1,176 @@ +package com.hbm.inventory.recipes; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import static com.hbm.inventory.OreDictManager.*; +import static com.hbm.inventory.material.Mats.*; +import static com.hbm.inventory.material.MaterialShapes.*; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.stream.JsonWriter; +import com.hbm.inventory.FluidStack; +import com.hbm.inventory.RecipesCommon.AStack; +import com.hbm.inventory.RecipesCommon.OreDictStack; +import com.hbm.inventory.material.Mats; +import com.hbm.inventory.material.Mats.MaterialStack; +import com.hbm.inventory.recipes.loader.SerializableRecipe; +import com.hbm.items.machine.ItemFluidIcon; +import com.hbm.items.machine.ItemScraps; + +import net.minecraft.item.ItemStack; + +public class RotaryFurnaceRecipes extends SerializableRecipe { + + public static List recipes = new ArrayList(); + + @Override + public void registerDefaults() { + + recipes.add(new RotaryFurnaceRecipe(new MaterialStack(MAT_STEEL, INGOT.q(1)), 200, 100, + new OreDictStack(IRON.ingot()), new OreDictStack(ANY_COKE.gem()) + )); + } + + public static HashMap getRecipes() { + + HashMap recipes = new HashMap(); + + for(RotaryFurnaceRecipe recipe : RotaryFurnaceRecipes.recipes) { + + int size = recipe.ingredients.length + (recipe.fluid != null ? 1 : 0); + Object[] array = new Object[size]; + + for(int i = 0; i < recipe.ingredients.length; i++) { + array[i] = recipe.ingredients[i]; + } + + if(recipe.fluid != null) array[size - 1] = ItemFluidIcon.make(recipe.fluid); + + recipes.put(array, ItemScraps.create(recipe.output, true)); + } + + return recipes; + } + + public static RotaryFurnaceRecipe getRecipe(ItemStack... inputs) { + + outer: + for(RotaryFurnaceRecipe recipe : recipes) { + + List recipeList = new ArrayList(); + for(AStack ingredient : recipe.ingredients) recipeList.add(ingredient); + + for(int i = 0; i < inputs.length; i++) { + + ItemStack inputStack = inputs[i]; + + if(inputStack != null) { + + boolean hasMatch = false; + Iterator iterator = recipeList.iterator(); + + while(iterator.hasNext()) { + AStack recipeStack = iterator.next(); + + if(recipeStack.matchesRecipe(inputStack, true) && inputStack.stackSize >= recipeStack.stacksize) { + hasMatch = true; + recipeList.remove(recipeStack); + break; + } + } + + if(!hasMatch) { + continue outer; + } + } + } + + if(recipeList.isEmpty()) return recipe; + } + + return null; + } + + @Override + public String getFileName() { + return "hbmRotaryFurnace.json"; + } + + @Override + public Object getRecipeObject() { + return recipes; + } + + @Override + public void deleteRecipes() { + recipes.clear(); + } + + @Override + public void readRecipe(JsonElement recipe) { + JsonObject obj = (JsonObject) recipe; + + AStack[] inputs = this.readAStackArray(obj.get("inputs").getAsJsonArray()); + FluidStack fluid = obj.has("fluid") ? this.readFluidStack(obj.get("fluid").getAsJsonArray()) : null; + + JsonArray array = obj.get("output").getAsJsonArray(); + MaterialStack stack = new MaterialStack(Mats.matByName.get(array.get(0).getAsString()), array.get(1).getAsInt()); + + int duration = obj.get("duration").getAsInt(); + int steam = obj.get("steam").getAsInt(); + + recipes.add(new RotaryFurnaceRecipe(stack, duration, steam, fluid, inputs)); + } + + @Override + public void writeRecipe(Object obj, JsonWriter writer) throws IOException { + RotaryFurnaceRecipe recipe = (RotaryFurnaceRecipe) obj; + + writer.name("inputs").beginArray(); + for(AStack aStack : recipe.ingredients) { + this.writeAStack(aStack, writer); + } + writer.endArray(); + + if(recipe.fluid != null) { + writer.name("fluid"); + this.writeFluidStack(recipe.fluid, writer); + } + + writer.name("output").beginArray(); + writer.setIndent(""); + writer.value(recipe.output.material.names[0]).value(recipe.output.amount); + writer.endArray(); + writer.setIndent(" "); + + writer.name("duration").value(recipe.duration); + writer.name("steam").value(recipe.steam); + } + + public static class RotaryFurnaceRecipe { + + public AStack[] ingredients; + public FluidStack fluid; + public MaterialStack output; + public int duration; + public int steam; + + public RotaryFurnaceRecipe(MaterialStack output, int duration, int steam, FluidStack fluid, AStack... ingredients) { + this.ingredients = ingredients; + this.fluid = fluid; + this.output = output; + this.duration = duration; + this.steam = steam; + } + + public RotaryFurnaceRecipe(MaterialStack output, int duration, int steam, AStack... ingredients) { + this(output, duration, steam, null, ingredients); + } + } +} diff --git a/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java b/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java index bbcbceb5a..3652216d0 100644 --- a/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java @@ -71,6 +71,7 @@ public abstract class SerializableRecipe { recipeHandlers.add(new ElectrolyserFluidRecipes()); recipeHandlers.add(new ElectrolyserMetalRecipes()); recipeHandlers.add(new ArcWelderRecipes()); + recipeHandlers.add(new RotaryFurnaceRecipes()); recipeHandlers.add(new ExposureChamberRecipes()); recipeHandlers.add(new AssemblerRecipes()); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java index d44feaa28..30e1c9c74 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java @@ -35,7 +35,7 @@ public class GunFactory { /// GUNS /// ModItems.gun_debug = new ItemGunBaseNT(new GunConfig() - .dura(600F).draw(15).jam(23).inspect(23).crosshair(Crosshair.L_CLASSIC).hud(Lego.HUD_COMPONENT_DURABILITY, Lego.HUD_COMPONENT_AMMO).smoke(true).orchestra(Orchestras.DEBUG_ORCHESTRA) + .dura(600F).draw(15).jam(23).inspect(23).crosshair(Crosshair.L_CLASSIC).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO).smoke(true).orchestra(Orchestras.DEBUG_ORCHESTRA) .rec(new Receiver(0) .dmg(10F).delay(14).reload(46).sound("hbm:weapon.44Shoot", 1.0F, 1.0F) .mag(new MagazineFullReload(0, 12).addConfigs(ammo_debug, ammo_debug_buckshot)) diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java index fd6444561..55226db8a 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Lego.java @@ -11,8 +11,6 @@ import com.hbm.items.weapon.sedna.ItemGunBaseNT; import com.hbm.items.weapon.sedna.ItemGunBaseNT.GunState; import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext; import com.hbm.items.weapon.sedna.Receiver; -import com.hbm.items.weapon.sedna.hud.HUDComponentAmmoCounter; -import com.hbm.items.weapon.sedna.hud.HUDComponentDurabilityBar; import com.hbm.items.weapon.sedna.mags.IMagazine; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationSequence; @@ -29,9 +27,6 @@ import net.minecraft.item.ItemStack; public class Lego { public static final Random ANIM_RAND = new Random(); - - public static HUDComponentDurabilityBar HUD_COMPONENT_DURABILITY = new HUDComponentDurabilityBar(); - public static HUDComponentAmmoCounter HUD_COMPONENT_AMMO = new HUDComponentAmmoCounter(0); /** * If IDLE and the mag of receiver 0 can be loaded, set state to RELOADING. Used by keybinds. */ diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java b/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java new file mode 100644 index 000000000..bed03eb38 --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/LegoClient.java @@ -0,0 +1,10 @@ +package com.hbm.items.weapon.sedna.factory; + +import com.hbm.items.weapon.sedna.hud.HUDComponentAmmoCounter; +import com.hbm.items.weapon.sedna.hud.HUDComponentDurabilityBar; + +public class LegoClient { + + public static HUDComponentDurabilityBar HUD_COMPONENT_DURABILITY = new HUDComponentDurabilityBar(); + public static HUDComponentAmmoCounter HUD_COMPONENT_AMMO = new HUDComponentAmmoCounter(0); +} diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java index b541be616..1f39386a4 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryBlackPowder.java @@ -28,7 +28,7 @@ public class XFactoryBlackPowder { BulletConfig shot = new BulletConfig().setItem(EnumAmmo.STONE_SHOT).setSpread(0.1F).setRicochetAngle(45).setProjectiles(6, 6).setDamage(0.5F); ModItems.gun_pepperbox = new ItemGunBaseNT(new GunConfig() - .dura(300).draw(4).inspect(23).crosshair(Crosshair.CIRCLE).hud(Lego.HUD_COMPONENT_DURABILITY, Lego.HUD_COMPONENT_AMMO).smoke(true).orchestra(Orchestras.ORCHESTRA_PEPPERBOX) + .dura(300).draw(4).inspect(23).crosshair(Crosshair.CIRCLE).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO).smoke(true).orchestra(Orchestras.ORCHESTRA_PEPPERBOX) .rec(new Receiver(0) .dmg(5F).delay(27).reload(67).sound("hbm:weapon.fire.blackPowder", 1.0F, 1.0F) .mag(new MagazineFullReload(0, 6).addConfigs(stone, flint, iron, shot)) diff --git a/src/main/java/com/hbm/render/tileentity/RenderRotaryFurnace.java b/src/main/java/com/hbm/render/tileentity/RenderRotaryFurnace.java index 57b5ee037..d7ff261ae 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderRotaryFurnace.java +++ b/src/main/java/com/hbm/render/tileentity/RenderRotaryFurnace.java @@ -6,6 +6,7 @@ import com.hbm.blocks.BlockDummyable; import com.hbm.blocks.ModBlocks; import com.hbm.main.ResourceManager; import com.hbm.render.item.ItemRenderBase; +import com.hbm.util.BobMathUtil; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.Item; @@ -31,7 +32,11 @@ public class RenderRotaryFurnace extends TileEntitySpecialRenderer implements II GL11.glShadeModel(GL11.GL_SMOOTH); bindTexture(ResourceManager.rotary_furnace_tex); - ResourceManager.rotary_furnace.renderAll(); + ResourceManager.rotary_furnace.renderPart("Furnace"); + GL11.glPushMatrix(); + GL11.glTranslated(0, BobMathUtil.sps((tile.getWorldObj().getTotalWorldTime() + f) * 0.125) * 0.5 - 0.5, 0); + ResourceManager.rotary_furnace.renderPart("Piston"); + GL11.glPopMatrix(); GL11.glShadeModel(GL11.GL_FLAT); GL11.glPopMatrix(); diff --git a/src/main/java/com/hbm/tileentity/IConditionalInvAccess.java b/src/main/java/com/hbm/tileentity/IConditionalInvAccess.java index 9416eb837..d66553efa 100644 --- a/src/main/java/com/hbm/tileentity/IConditionalInvAccess.java +++ b/src/main/java/com/hbm/tileentity/IConditionalInvAccess.java @@ -11,7 +11,7 @@ import net.minecraft.item.ItemStack; public interface IConditionalInvAccess { public boolean isItemValidForSlot(int x, int y, int z, int slot, ItemStack stack); - public boolean canInsertItem(int x, int y, int z, int slot, ItemStack stack, int side); + public default boolean canInsertItem(int x, int y, int z, int slot, ItemStack stack, int side) { return isItemValidForSlot(x, y, z, slot, stack); } public boolean canExtractItem(int x, int y, int z, int slot, ItemStack stack, int side); public int[] getAccessibleSlotsFromSide(int x, int y, int z, int side); } diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRotaryFurnace.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRotaryFurnace.java index af03860dc..85e8fb5db 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRotaryFurnace.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineRotaryFurnace.java @@ -1,37 +1,337 @@ package com.hbm.tileentity.machine; -import com.hbm.inventory.fluid.FluidType; -import com.hbm.inventory.fluid.tank.FluidTank; -import com.hbm.tileentity.TileEntityMachinePolluting; +import java.util.Random; -public class TileEntityMachineRotaryFurnace extends TileEntityMachinePolluting { +import com.hbm.handler.pollution.PollutionHandler; +import com.hbm.handler.pollution.PollutionHandler.PollutionType; +import com.hbm.inventory.RecipesCommon.AStack; +import com.hbm.inventory.container.ContainerMachineRotaryFurnace; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.inventory.fluid.tank.FluidTank; +import com.hbm.inventory.gui.GUIMachineRotaryFurnace; +import com.hbm.inventory.material.MaterialShapes; +import com.hbm.inventory.material.Mats; +import com.hbm.inventory.material.Mats.MaterialStack; +import com.hbm.inventory.recipes.RotaryFurnaceRecipes; +import com.hbm.inventory.recipes.RotaryFurnaceRecipes.RotaryFurnaceRecipe; +import com.hbm.lib.Library; +import com.hbm.main.MainRegistry; +import com.hbm.packet.PacketDispatcher; +import com.hbm.packet.toclient.AuxParticlePacketNT; +import com.hbm.tileentity.IConditionalInvAccess; +import com.hbm.tileentity.IFluidCopiable; +import com.hbm.tileentity.IGUIProvider; +import com.hbm.tileentity.TileEntityMachinePolluting; +import com.hbm.util.CrucibleUtil; +import com.hbm.util.fauxpointtwelve.BlockPos; +import com.hbm.util.fauxpointtwelve.DirPos; + +import api.hbm.fluid.IFluidStandardTransceiver; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityMachineRotaryFurnace extends TileEntityMachinePolluting implements IFluidStandardTransceiver, IGUIProvider, IFluidCopiable, IConditionalInvAccess { + + public FluidTank[] tanks; + public boolean isProgressing; + public float progress; + public int burnTime; + public int maxBurnTime; + public boolean isVenting; + public MaterialStack output; + public static final int maxOutput = MaterialShapes.BLOCK.q(16); public TileEntityMachineRotaryFurnace() { - super(0, 50); + super(5, 50); + tanks = new FluidTank[3]; + tanks[0] = new FluidTank(Fluids.NONE, 16_000); + tanks[1] = new FluidTank(Fluids.STEAM, 4_000); + tanks[2] = new FluidTank(Fluids.SPENTSTEAM, 40); } @Override public String getName() { - return null; + return "container.machineRotaryFurnace"; } @Override public void updateEntity() { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + if(!worldObj.isRemote) { + + tanks[0].setType(3, slots); + + for(DirPos pos : getSteamPos()) { + this.trySubscribe(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + } + if(tanks[0].getTankType() != Fluids.NONE) for(DirPos pos : getFluidPos()) { + this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + } + + if(smoke.getFill() > 0) this.sendFluid(smoke, worldObj, xCoord + rot.offsetX, yCoord + 5, zCoord + rot.offsetZ, Library.POS_Y); + + if(this.output != null) { + + Vec3 impact = Vec3.createVectorHelper(0, 0, 0); + MaterialStack leftover = CrucibleUtil.pourSingleStack(worldObj, xCoord + 0.5D + rot.offsetX * 2.875D, yCoord + 1.25D, zCoord + 0.5D + rot.offsetZ * 2.875D, 6, true, this.output, MaterialShapes.INGOT.q(1), impact); + + if(leftover.amount != this.output.amount) { + this.output = leftover; + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "foundry"); + data.setInteger("color", leftover.material.moltenColor); + data.setByte("dir", (byte) rot.ordinal()); + data.setFloat("off", 0.625F); + data.setFloat("base", 0.625F); + data.setFloat("len", Math.max(1F, yCoord + 1 - (float) (Math.ceil(impact.yCoord) - 1.125))); + PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + rot.offsetX * 2.875D, yCoord + 0.75, zCoord + 0.5D + rot.offsetZ * 2.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50)); + } + + if(output.amount <= 0) this.output = null; + } + + RotaryFurnaceRecipe recipe = RotaryFurnaceRecipes.getRecipe(slots[0], slots[1], slots[2]); + + if(recipe != null) { + + if(this.burnTime <= 0 && slots[4] != null && TileEntityFurnace.isItemFuel(slots[4])) { + this.maxBurnTime = this.burnTime = TileEntityFurnace.getItemBurnTime(slots[4]) / 2; + this.decrStackSize(4, 1); + this.markChanged(); + } + + if(this.canProcess(recipe)) { + this.progress += 1F / recipe.duration; + tanks[1].setFill(tanks[1].getFill() - recipe.steam); + tanks[2].setFill(tanks[2].getFill() + recipe.steam / 100); + + if(this.progress >= 1F) { + this.progress -= 1F; + this.consumeItems(recipe); + + if(this.output == null) { + this.output = recipe.output.copy(); + } else { + this.output.amount += recipe.output.amount; + } + this.markDirty(); + } + + } else { + this.progress = 0; + } + } else { + this.progress = 0; + } + + this.isVenting = false; + if(this.burnTime > 0) { + this.pollute(PollutionType.SOOT, PollutionHandler.SOOT_PER_SECOND / 10F); + this.burnTime--; + } + + this.networkPackNT(50); + + } else { + + if(this.burnTime > 0 && MainRegistry.proxy.me().getDistance(xCoord, yCoord, zCoord) < 25) { + Random rand = worldObj.rand; + worldObj.spawnParticle("flame", xCoord + 0.5 + dir.offsetX * 0.5 + rot.offsetX + rand.nextGaussian() * 0.25, yCoord + 0.375, zCoord + 0.5 + dir.offsetZ * 0.5 + rot.offsetZ + rand.nextGaussian() * 0.25, 0, 0, 0); + } + + if(isVenting && worldObj.getTotalWorldTime() % 2 == 0) { + + NBTTagCompound fx = new NBTTagCompound(); + fx.setString("type", "tower"); + fx.setFloat("lift", 10F); + fx.setFloat("base", 0.25F); + fx.setFloat("max", 2.5F); + fx.setInteger("life", 100 + worldObj.rand.nextInt(20)); + fx.setInteger("color",0x202020); + fx.setDouble("posX", xCoord + 0.5 + rot.offsetX); + fx.setDouble("posY", yCoord + 5); + fx.setDouble("posZ", zCoord + 0.5 + rot.offsetZ); + MainRegistry.proxy.effectNT(fx); + } + } } + @Override public void serialize(ByteBuf buf) { + super.serialize(buf); + tanks[0].serialize(buf); + tanks[1].serialize(buf); + tanks[2].serialize(buf); + buf.writeBoolean(isVenting); + buf.writeBoolean(isProgressing); + buf.writeFloat(progress); + buf.writeInt(burnTime); + buf.writeInt(maxBurnTime); + + if(this.output != null) { + buf.writeBoolean(true); + buf.writeInt(this.output.material.id); + buf.writeInt(this.output.amount); + } else { + buf.writeBoolean(false); + } + } + + @Override public void deserialize(ByteBuf buf) { + super.deserialize(buf); + tanks[0].deserialize(buf); + tanks[1].deserialize(buf); + tanks[2].deserialize(buf); + isVenting = buf.readBoolean(); + isProgressing = buf.readBoolean(); + progress = buf.readFloat(); + burnTime = buf.readInt(); + maxBurnTime = buf.readInt(); + + if(buf.readBoolean()) { + this.output = new MaterialStack(Mats.matById.get(buf.readInt()), buf.readInt()); + } else { + this.output = null; + } + } + @Override - public FluidTank[] getAllTanks() { - return null; + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + this.tanks[0].readFromNBT(nbt, "t0"); + this.tanks[1].readFromNBT(nbt, "t1"); + this.tanks[2].readFromNBT(nbt, "t2"); + this.progress = nbt.getFloat("prog"); + this.burnTime = nbt.getInteger("burn"); + this.maxBurnTime = nbt.getInteger("maxBurn"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + this.tanks[0].writeToNBT(nbt, "t0"); + this.tanks[1].writeToNBT(nbt, "t1"); + this.tanks[2].writeToNBT(nbt, "t2"); + nbt.setFloat("prog", progress); + nbt.setInteger("burn", burnTime); + nbt.setInteger("maxBurn", maxBurnTime); + } + + public DirPos[] getSteamPos() { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + return new DirPos[] { + new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX * 2, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ * 2, dir.getOpposite()), + new DirPos(xCoord - dir.offsetX * 2 - rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 - rot.offsetZ, dir.getOpposite()) + }; + } + + public DirPos[] getFluidPos() { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + return new DirPos[] { + new DirPos(xCoord + dir.offsetX + rot.offsetX * 3, yCoord, zCoord + dir.offsetZ + rot.offsetZ * 3, rot), + new DirPos(xCoord - dir.offsetX + rot.offsetX * 3, yCoord, zCoord - dir.offsetZ + rot.offsetZ * 3, rot) + }; + } + + public boolean canProcess(RotaryFurnaceRecipe recipe) { + + if(this.burnTime <= 0) return false; + + if(recipe.fluid != null) { + if(this.tanks[0].getTankType() != recipe.fluid.type) return false; + if(this.tanks[0].getFill() < recipe.fluid.fill) return false; + } + + if(tanks[1].getFill() < recipe.steam) return false; + if(tanks[2].getMaxFill() - tanks[2].getFill() < recipe.steam / 100) return false; + + if(this.output != null) { + if(this.output.material != recipe.output.material) return false; + if(this.output.amount + recipe.output.amount > this.maxOutput) return false; + } + + return true; + } + + public void consumeItems(RotaryFurnaceRecipe recipe) { + + for(AStack aStack : recipe.ingredients) { + + for(int i = 0; i < 3; i++) { + ItemStack stack = slots[i]; + if(aStack.matchesRecipe(stack, true) && stack.stackSize >= aStack.stacksize) { + this.decrStackSize(i, aStack.stacksize); + break; + } + } + } + + if(recipe.fluid != null) { + this.tanks[0].setFill(tanks[0].getFill() - recipe.fluid.fill); + } + } + + @Override + public void pollute(PollutionType type, float amount) { + FluidTank tank = type == PollutionType.SOOT ? smoke : type == PollutionType.HEAVYMETAL ? smoke_leaded : smoke_poison; + + int fluidAmount = (int) Math.ceil(amount * 100); + tank.setFill(tank.getFill() + fluidAmount); + + if(tank.getFill() > tank.getMaxFill()) { + int overflow = tank.getFill() - tank.getMaxFill(); + tank.setFill(tank.getMaxFill()); + PollutionHandler.incrementPollution(worldObj, xCoord, yCoord, zCoord, type, overflow / 100F); + this.isVenting = true; + } } - @Override - public long transferFluid(FluidType type, int pressure, long fluid) { - return 0; - } + @Override public int[] getAccessibleSlotsFromSide(int side) { return new int[0]; } + @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return slot < 3 || slot == 4; } + @Override public boolean canExtractItem(int slot, ItemStack stack, int side) { return false; } + + @Override public boolean isItemValidForSlot(int x, int y, int z, int slot, ItemStack stack) { return slot < 3 || slot == 4; } + @Override public boolean canExtractItem(int x, int y, int z, int slot, ItemStack stack, int side) { return false; } @Override - public long getDemand(FluidType type, int pressure) { - return 0; + public int[] getAccessibleSlotsFromSide(int x, int y, int z, int side) { + BlockPos pos = new BlockPos(x, y, z); + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + BlockPos core = new BlockPos(xCoord, yCoord, zCoord); + core.offset(dir, -1); + + //Red + if(pos.equals(core.clone().offset(rot, -2))) return new int[] {0}; + //Yellow + if(pos.equals(core.clone().offset(rot, -1))) return new int[] {1}; + //Green + if(pos.equals(core)) return new int[] {2}; + //Fuel + if(pos.equals(new BlockPos(xCoord, yCoord, zCoord).offset(dir).offset(rot, -1))) return new int[] {4}; + + return new int[] { }; } + + @Override public FluidTank[] getAllTanks() { return new FluidTank[] {tanks[0], tanks[1], tanks[2], smoke}; } + @Override public FluidTank[] getSendingTanks() { return new FluidTank[] {tanks[2], smoke}; } + @Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {tanks[0], tanks[1]}; } + + @Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerMachineRotaryFurnace(player.inventory, this); } + @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIMachineRotaryFurnace(player.inventory, this); } } diff --git a/src/main/java/com/hbm/tileentity/machine/oil/TileEntityMachinePyroOven.java b/src/main/java/com/hbm/tileentity/machine/oil/TileEntityMachinePyroOven.java index fb5757aef..17c9e8db8 100644 --- a/src/main/java/com/hbm/tileentity/machine/oil/TileEntityMachinePyroOven.java +++ b/src/main/java/com/hbm/tileentity/machine/oil/TileEntityMachinePyroOven.java @@ -12,6 +12,7 @@ import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.gui.GUIPyroOven; import com.hbm.inventory.recipes.PyroOvenRecipes; import com.hbm.inventory.recipes.PyroOvenRecipes.PyroOvenRecipe; +import com.hbm.items.machine.ItemMachineUpgrade; import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; @@ -41,7 +42,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class TileEntityMachinePyroOven extends TileEntityMachinePolluting implements IEnergyReceiverMK2, IFluidStandardTransceiver, IGUIProvider, IUpgradeInfoProvider, IFluidCopiable { public long power; - public static final long maxPower = 1_000_000; + public static final long maxPower = 10_000_000; public boolean isVenting; public boolean isProgressing; public float progress; @@ -61,6 +62,15 @@ public class TileEntityMachinePyroOven extends TileEntityMachinePolluting implem tanks[1] = new FluidTank(Fluids.NONE, 24_000); } + @Override + public void setInventorySlotContents(int i, ItemStack stack) { + super.setInventorySlotContents(i, stack); + + if(stack != null && stack.getItem() instanceof ItemMachineUpgrade && i >= 4 && i <= 5) { + worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F); + } + } + @Override public String getName() { return "container.machinePyroOven"; @@ -96,7 +106,7 @@ public class TileEntityMachinePyroOven extends TileEntityMachinePolluting implem PyroOvenRecipe recipe = getMatchingRecipe(); this.progress += 1F / Math.max((recipe.duration - speed * (recipe.duration / 4)) / (overdrive * 2 + 1), 1); this.isProgressing = true; - this.power -= this.getConsumption(speed, powerSaving); + this.power -= this.getConsumption(speed + overdrive * 2, powerSaving); if(progress >= 1F) { this.progress = 0F; diff --git a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_bottom_alt.png b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_bottom_alt.png index be4b6d73c..051390fba 100644 Binary files a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_bottom_alt.png and b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_bottom_alt.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_front_alt.png b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_front_alt.png index 7049ae709..b8ac27800 100644 Binary files a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_front_alt.png and b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_front_alt.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_side_alt.png b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_side_alt.png index de74959ec..817e0e6b7 100644 Binary files a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_side_alt.png and b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_side_alt.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_top_alt.png b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_top_alt.png index a1c241c4c..edc004f2c 100644 Binary files a/src/main/resources/assets/hbm/textures/blocks/machine_shredder_top_alt.png and b/src/main/resources/assets/hbm/textures/blocks/machine_shredder_top_alt.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/gui_shredder.png b/src/main/resources/assets/hbm/textures/gui/gui_shredder.png index 34e2e4ea5..19b774c76 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/gui_shredder.png and b/src/main/resources/assets/hbm/textures/gui/gui_shredder.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/processing/gui_rotary_furnace.png b/src/main/resources/assets/hbm/textures/gui/processing/gui_rotary_furnace.png index 920a5871c..54854a28d 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/processing/gui_rotary_furnace.png and b/src/main/resources/assets/hbm/textures/gui/processing/gui_rotary_furnace.png differ diff --git a/src/main/resources/assets/hbm/textures/items/ammo.png b/src/main/resources/assets/hbm/textures/items/ammo.png index 4af3055b0..9f9dba693 100644 Binary files a/src/main/resources/assets/hbm/textures/items/ammo.png and b/src/main/resources/assets/hbm/textures/items/ammo.png differ diff --git a/src/main/resources/assets/hbm/textures/items/ingot_gunmetal.png b/src/main/resources/assets/hbm/textures/items/ingot_gunmetal.png index c2dda38d8..dc26658ee 100644 Binary files a/src/main/resources/assets/hbm/textures/items/ingot_gunmetal.png and b/src/main/resources/assets/hbm/textures/items/ingot_gunmetal.png differ diff --git a/src/main/resources/assets/hbm/textures/models/machines/rotary_furnace.png b/src/main/resources/assets/hbm/textures/models/machines/rotary_furnace.png index c576ba9ff..851cf91ab 100644 Binary files a/src/main/resources/assets/hbm/textures/models/machines/rotary_furnace.png and b/src/main/resources/assets/hbm/textures/models/machines/rotary_furnace.png differ