feat: implement arcane furnace

This commit is contained in:
LordMZTE 2023-05-21 17:12:27 +02:00
parent 9e5e3b8488
commit 40284fb2ec
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
7 changed files with 221 additions and 36 deletions

View file

@ -5,6 +5,7 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.entities.EntitySingularity;
import net.anvilcraft.thaummach.gui.GuiArcaneFurnace;
import net.anvilcraft.thaummach.gui.GuiBore;
import net.anvilcraft.thaummach.gui.GuiCrystallizer;
import net.anvilcraft.thaummach.gui.GuiVoidChest;
@ -17,6 +18,7 @@ import net.anvilcraft.thaummach.render.tile.TileConduitPumpRenderer;
import net.anvilcraft.thaummach.render.tile.TileCrystallizerRenderer;
import net.anvilcraft.thaummach.render.tile.TileVoidChestRenderer;
import net.anvilcraft.thaummach.render.tile.TileVoidInterfaceRenderer;
import net.anvilcraft.thaummach.tiles.TileArcaneFurnace;
import net.anvilcraft.thaummach.tiles.TileBore;
import net.anvilcraft.thaummach.tiles.TileConduit;
import net.anvilcraft.thaummach.tiles.TileConduitPump;
@ -55,6 +57,7 @@ public class ClientProxy extends CommonProxy {
@Override
public void registerTileEntities() {
GameRegistry.registerTileEntity(TileArcaneFurnace.class, "arcane_furnace");
GameRegistry.registerTileEntity(TileConduit.class, "conduit");
GameRegistry.registerTileEntity(TileConduitTank.class, "conduit_tank");
GameRegistry.registerTileEntity(TileConduitValve.class, "conduit_valve");
@ -87,18 +90,21 @@ public class ClientProxy extends CommonProxy {
getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
switch (GuiID.get(id)) {
case ARCANE_FURNACE:
return new GuiArcaneFurnace(player.inventory, (TileArcaneFurnace) te);
case BORE:
return new GuiBore(player.inventory, (TileBore) te);
case CRYSTALLIZER:
return new GuiCrystallizer(player.inventory, (TileCrystallizer) te);
case VOID_CHEST:
return new GuiVoidChest(player.inventory, (TileVoidChest) te);
case VOID_INTERFACE:
return new GuiVoidInterface(player.inventory, (TileVoidInterface) te);
case CRYSTALLIZER:
return new GuiCrystallizer(player.inventory, (TileCrystallizer) te);
default:
throw new IllegalArgumentException("ALEC");
}

View file

@ -2,10 +2,12 @@ package net.anvilcraft.thaummach;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.container.ContainerArcaneFurnace;
import net.anvilcraft.thaummach.container.ContainerBore;
import net.anvilcraft.thaummach.container.ContainerCrystallizer;
import net.anvilcraft.thaummach.container.ContainerVoidChest;
import net.anvilcraft.thaummach.container.ContainerVoidInterface;
import net.anvilcraft.thaummach.tiles.TileArcaneFurnace;
import net.anvilcraft.thaummach.tiles.TileBore;
import net.anvilcraft.thaummach.tiles.TileConduit;
import net.anvilcraft.thaummach.tiles.TileConduitPump;
@ -30,6 +32,7 @@ public class CommonProxy implements IGuiHandler {
public void init() {}
public void registerTileEntities() {
GameRegistry.registerTileEntity(TileArcaneFurnace.class, "arcane_furnace");
GameRegistry.registerTileEntity(TileBore.class, "bore");
GameRegistry.registerTileEntity(TileConduit.class, "conduit");
GameRegistry.registerTileEntity(TileConduitPump.class, "conduit_pump");
@ -53,9 +56,17 @@ public class CommonProxy implements IGuiHandler {
getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
switch (GuiID.get(id)) {
case ARCANE_FURNACE:
return new ContainerArcaneFurnace(
player.inventory, (TileArcaneFurnace) te
);
case BORE:
return new ContainerBore(player.inventory, (TileBore) te);
case CRYSTALLIZER:
return new ContainerCrystallizer(player.inventory, (TileCrystallizer) te);
case VOID_CHEST:
return new ContainerVoidChest(player.inventory, (TileVoidChest) te);
@ -64,9 +75,6 @@ public class CommonProxy implements IGuiHandler {
player.inventory, (TileVoidInterface) te
);
case CRYSTALLIZER:
return new ContainerCrystallizer(player.inventory, (TileCrystallizer) te);
default:
throw new IllegalArgumentException("ALEC");
}

View file

@ -1,10 +1,11 @@
package net.anvilcraft.thaummach;
public enum GuiID {
ARCANE_FURNACE,
BORE,
CRYSTALLIZER,
VOID_CHEST,
VOID_INTERFACE,
CRYSTALLIZER;
VOID_INTERFACE;
public static GuiID get(int id) {
if (id >= 0 && id < GuiID.values().length) {

View file

@ -0,0 +1,108 @@
package net.anvilcraft.thaummach.container;
import net.anvilcraft.thaummach.OutputSlot;
import net.anvilcraft.thaummach.tiles.TileArcaneFurnace;
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 ContainerArcaneFurnace extends Container {
private TileArcaneFurnace arcaneFurnace;
public ContainerArcaneFurnace(
InventoryPlayer inventoryplayer, TileArcaneFurnace tileArcaneFurnace
) {
this.arcaneFurnace = tileArcaneFurnace;
int j;
int k;
for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
this.addSlotToContainer(
new Slot(tileArcaneFurnace, 9 + k + j * 3, 17 + k * 18, 17 + j * 18)
);
}
}
this.addSlotToContainer(new Slot(tileArcaneFurnace, 18, 80, 53));
for (j = 0; j < 3; ++j) {
for (k = 0; k < 3; ++k) {
this.addSlotToContainer(new OutputSlot(
tileArcaneFurnace, k + j * 3, 107 + k * 18, 17 + j * 18
));
}
}
for (j = 0; j < 3; ++j) {
for (k = 0; k < 9; ++k) {
this.addSlotToContainer(
new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 84 + j * 18)
);
}
}
for (j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 142));
}
}
//@Override
//public void updateCraftingResults() {
// super.updateCraftingResults();
// for (int i = 0; i < super.inventorySlots.size(); ++i) {
// ICrafting icrafting = (ICrafting) super.inventorySlots.get(i);
// if (this.lastCookTime != this.arcaneFurnace.furnaceCookTime) {
// icrafting.updateCraftingInventoryInfo(
// this, 0, Math.round((float) this.arcaneFurnace.furnaceCookTime)
// );
// }
// }
// this.lastCookTime = Math.round((float) this.arcaneFurnace.furnaceCookTime);
//}
@Override
public void updateProgressBar(int i, int j) {
if (i == 0) {
this.arcaneFurnace.furnaceCookTime = j;
}
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return this.arcaneFurnace.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int i) {
ItemStack itemstack = null;
Slot slot = (Slot) super.inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (i < 19) {
if (!this.mergeItemStack(itemstack1, 19, 46, true)) {
return null;
}
} else if (i >= 19 && i < 46 && !this.mergeItemStack(itemstack1, 0, 9, false)) {
return null;
}
if (itemstack1.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize) {
return null;
}
}
return itemstack;
}
}

View file

@ -0,0 +1,47 @@
package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.container.ContainerArcaneFurnace;
import net.anvilcraft.thaummach.tiles.TileArcaneFurnace;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiArcaneFurnace extends GuiContainer {
private TileArcaneFurnace arcaneFurnaceInventory;
public GuiArcaneFurnace(
InventoryPlayer inventoryplayer, TileArcaneFurnace tileArcaneFurnace
) {
super(new ContainerArcaneFurnace(inventoryplayer, tileArcaneFurnace));
this.arcaneFurnaceInventory = tileArcaneFurnace;
}
@Override
protected void drawGuiContainerForegroundLayer(int alec1, int alec2) {
super.fontRendererObj.drawString("Thaumic Furnace", 48, 5, 4210752);
super.fontRendererObj.drawString("Inventory", 8, super.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int qq, int ww) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
super.mc.renderEngine.bindTexture(
new ResourceLocation("thaummach", "textures/guis/arcane_furnace.png")
);
int l = (super.width - super.xSize) / 2;
int i1 = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(l, i1, 0, 0, super.xSize, super.ySize);
int j1;
if (this.arcaneFurnaceInventory.isWorking()) {
j1 = this.arcaneFurnaceInventory.getBurnTimeRemainingScaled(16);
this.drawTexturedModalRect(l + 80, i1 + 32 + 16 - j1, 176, 16 - j1, 16, j1);
} else if (this.arcaneFurnaceInventory.furnaceBurnTime > 0) {
j1 = this.arcaneFurnaceInventory.getBurnTimeRemainingScaled(16);
this.drawTexturedModalRect(l + 80, i1 + 32 + 16 - j1, 221, 16 - j1, 16, j1);
}
j1 = this.arcaneFurnaceInventory.getCookProgressScaled(26);
this.drawTexturedModalRect(l + 75, i1 + 22, 176, 28, j1, 4);
}
}

View file

@ -4,12 +4,17 @@ import java.util.stream.IntStream;
import dev.tilera.auracore.api.machine.TileVisUser;
import dev.tilera.auracore.aura.AuraManager;
import net.anvilcraft.thaummach.GuiID;
import net.anvilcraft.thaummach.ITileGui;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.EnumSkyBlock;
@ -17,7 +22,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
public class TileArcaneFurnace extends TileVisUser implements ISidedInventory, ITileGui {
private ItemStack[] furnaceItemStacks = new ItemStack[19];
public int furnaceBurnTime = 0;
public int currentItemBurnTime = 0;
@ -27,10 +32,10 @@ public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
public float vis;
public boolean boost;
// TODO: GUIs
//public GuiScreen getGui(EntityPlayer player) {
// return new GuiArcaneFurnace(player.inventory, this);
//}
@Override
public GuiID getGuiID() {
return GuiID.ARCANE_FURNACE;
}
@Override
public int getSizeInventory() {
@ -198,10 +203,12 @@ public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
if (this.furnaceBurnTime > 0
&& (this.furnaceCookTime > 0 || this.belowHeatableTile())) {
--this.furnaceBurnTime;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
if (this.furnaceBurnTime <= 0
&& (this.canSmelt() || this.belowHeatableTile())) {
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
this.currentItemBurnTime = this.furnaceBurnTime
= getItemBurnTime(this.furnaceItemStacks[18]);
if (this.furnaceBurnTime > 0) {
@ -227,20 +234,10 @@ public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
this.furnaceMaxCookTime = (int
) ((float) this.furnaceMaxCookTime
* (1.0F - (float) this.bellows * 0.1F));
this.worldObj.markBlockForUpdate(
this.xCoord, this.yCoord, this.zCoord
);
super.worldObj.updateLightByType(
EnumSkyBlock.Block, super.xCoord, super.yCoord, super.zCoord
);
// TODO: WTF
//if (this.furnaceItemStacks[18].getItem().func_46056_k()) {
// this.furnaceItemStacks[18] = new ItemStack(
// this.furnaceItemStacks[18].getItem().setFull3D()
// );
//} else {
--this.furnaceItemStacks[18].stackSize;
//}
if (this.furnaceItemStacks[18].stackSize == 0) {
this.furnaceItemStacks[18] = null;
@ -284,8 +281,7 @@ public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
}
if (flag1) {
// TODO: WTF
//this.onInventoryChanged();
this.markDirty();
}
}
@ -364,14 +360,7 @@ public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
} while (tryAgain);
if (smelted) {
// TODO: WTF
//if (this.furnaceItemStacks[input].getItem().func_46056_k()) {
// this.furnaceItemStacks[input] = new ItemStack(
// this.furnaceItemStacks[input].getItem().setFull3D()
// );
//} else {
--this.furnaceItemStacks[input].stackSize;
//}
if (this.furnaceItemStacks[input].stackSize <= 0) {
this.furnaceItemStacks[input] = null;
@ -477,14 +466,40 @@ public class TileArcaneFurnace extends TileVisUser implements ISidedInventory {
}
@Override
public boolean
canInsertItem(int slot, ItemStack is, int side) {
public boolean canInsertItem(int slot, ItemStack is, int side) {
return this.isItemValidForSlot(slot, is);
}
@Override
public boolean
canExtractItem(int slot, ItemStack is, int side) {
public boolean canExtractItem(int slot, ItemStack is, int side) {
return slot >= 9 && slot <= 17;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setInteger("furnaceBurnTime", this.furnaceBurnTime);
nbt.setInteger("currentItemBurnTime", this.currentItemBurnTime);
nbt.setInteger("furnaceCookTime", this.furnaceCookTime);
nbt.setInteger("furnaceMaxCookTime", this.furnaceMaxCookTime);
nbt.setFloat("vis", this.vis);
nbt.setBoolean("boost", this.boost);
return new S35PacketUpdateTileEntity(
this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), nbt
);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbt = pkt.func_148857_g();
this.furnaceBurnTime = nbt.getInteger("furnaceBurnTime");
this.currentItemBurnTime = nbt.getInteger("currentItemBurnTime");
this.furnaceCookTime = nbt.getInteger("furnaceCookTime");
this.furnaceMaxCookTime = nbt.getInteger("furnaceMaxCookTime");
this.vis = nbt.getFloat("vis");
this.boost = nbt.getBoolean("boost");
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB