feat: implement crystallizer

This commit is contained in:
LordMZTE 2023-05-20 19:50:11 +02:00
parent b1fdb881e0
commit 9e5e3b8488
Signed by: LordMZTE
GPG Key ID: B64802DC33A64FF6
26 changed files with 489 additions and 212 deletions

View File

@ -6,6 +6,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import net.anvilcraft.thaummach.entities.EntitySingularity;
import net.anvilcraft.thaummach.gui.GuiBore;
import net.anvilcraft.thaummach.gui.GuiCrystallizer;
import net.anvilcraft.thaummach.gui.GuiVoidChest;
import net.anvilcraft.thaummach.gui.GuiVoidInterface;
import net.anvilcraft.thaummach.render.BlockApparatusRenderer;
@ -95,6 +96,9 @@ public class ClientProxy extends CommonProxy {
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

@ -3,6 +3,7 @@ package net.anvilcraft.thaummach;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;
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.TileBore;
@ -63,6 +64,9 @@ 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

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

View File

@ -4,8 +4,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotInventory extends Slot {
public SlotInventory(IInventory inv, int idx, int x, int y) {
public class InventorySlot extends Slot {
public InventorySlot(IInventory inv, int idx, int x, int y) {
super(inv, idx, x, y);
}

View File

@ -0,0 +1,18 @@
package net.anvilcraft.thaummach;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class OutputSlot extends Slot {
public OutputSlot(
IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_
) {
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
}
@Override
public boolean isItemValid(ItemStack p_75214_1_) {
return false;
}
}

View File

@ -5,6 +5,7 @@ import net.anvilcraft.thaummach.items.ItemCrystallineBell;
import net.anvilcraft.thaummach.items.ItemFocus;
import net.anvilcraft.thaummach.items.ItemRunicEssence;
import net.anvilcraft.thaummach.items.ItemSingularity;
import net.anvilcraft.thaummach.items.ItemUpgrade;
import net.minecraft.item.Item;
public class TMItems {
@ -16,6 +17,7 @@ public class TMItems {
public static Item focus4;
public static Item runicEssence;
public static Item singularity;
public static Item upgrade;
public static void init() {
crystallineBell = new ItemCrystallineBell();
@ -30,6 +32,8 @@ public class TMItems {
singularity = new ItemSingularity();
upgrade = new ItemUpgrade();
GameRegistry.registerItem(crystallineBell, "crystalline_bell");
GameRegistry.registerItem(focus0, "focus0");
@ -41,5 +45,7 @@ public class TMItems {
GameRegistry.registerItem(runicEssence, "runic_essence");
GameRegistry.registerItem(singularity, "singularity");
GameRegistry.registerItem(upgrade, "upgrade");
}
}

View File

@ -1,6 +1,6 @@
package net.anvilcraft.thaummach.container;
import net.anvilcraft.thaummach.SlotInventory;
import net.anvilcraft.thaummach.InventorySlot;
import net.anvilcraft.thaummach.items.ItemFocus;
import net.anvilcraft.thaummach.items.ItemSingularity;
import net.anvilcraft.thaummach.tiles.TileBore;
@ -15,8 +15,8 @@ public class ContainerBore extends Container {
public ContainerBore(InventoryPlayer inventoryplayer, TileBore tileBore) {
this.arcaneBore = tileBore;
this.addSlotToContainer(new SlotInventory(tileBore, 0, 65, 17));
this.addSlotToContainer(new SlotInventory(tileBore, 1, 65, 55));
this.addSlotToContainer(new InventorySlot(tileBore, 0, 65, 17));
this.addSlotToContainer(new InventorySlot(tileBore, 1, 65, 55));
int j;
for (j = 0; j < 3; ++j) {

View File

@ -0,0 +1,118 @@
package net.anvilcraft.thaummach.container;
import net.anvilcraft.thaummach.OutputSlot;
import net.anvilcraft.thaummach.tiles.TileCrystallizer;
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 ContainerCrystallizer extends Container {
private TileCrystallizer crystallizer;
private int lastCookTime = 0;
public ContainerCrystallizer(
InventoryPlayer inventoryplayer, TileCrystallizer tileCrystallizer
) {
this.crystallizer = tileCrystallizer;
this.addSlotToContainer(new Slot(tileCrystallizer, 6, 80, 70));
// Air
this.addSlotToContainer(new OutputSlot(tileCrystallizer, 0, 131, 41));
// Fire
this.addSlotToContainer(new OutputSlot(tileCrystallizer, 1, 131, 100));
// Water
this.addSlotToContainer(new OutputSlot(tileCrystallizer, 2, 30, 41));
// Earth
this.addSlotToContainer(new OutputSlot(tileCrystallizer, 3, 30, 100));
// Magic
this.addSlotToContainer(new OutputSlot(tileCrystallizer, 4, 80, 12));
// Taint
this.addSlotToContainer(new OutputSlot(tileCrystallizer, 5, 80, 129));
int j;
for (j = 0; j < 3; ++j) {
for (int k = 0; k < 9; ++k) {
this.addSlotToContainer(
new Slot(inventoryplayer, k + j * 9 + 9, 8 + k * 18, 158 + j * 18)
);
}
}
for (j = 0; j < 9; ++j) {
this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 216));
}
}
// TODO: WTF
//@Override
//public void updateCraftingResults() {
// super.updateCraftingResults();
// for (int i = 0; i < super.inventorySlots.size(); ++i) {
// ICrafting icrafting = (ICrafting) super.inventorySlots.get(i);
// if ((float) this.lastCookTime != this.crystallizer.crystalTime) {
// icrafting.updateCraftingInventoryInfo(
// this, 0, Math.round(this.crystallizer.crystalTime)
// );
// }
// }
// this.lastCookTime = Math.round(this.crystallizer.crystalTime);
//}
@Override
public void updateProgressBar(int i, int j) {
if (i == 0) {
this.crystallizer.crystalTime = (float) j;
}
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return this.crystallizer.canInteractWith(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 < 7) {
if (!this.mergeItemStack(itemstack1, 7, 34, true)) {
return null;
}
} else if (i >= 7 && i <= 34) {
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
return null;
}
} else if (i > 34 && i <= 43) {
if (!this.mergeItemStack(itemstack1, 7, 34, false)) {
return null;
}
} else if (!this.mergeItemStack(itemstack1, 7, 43, 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,59 @@
package net.anvilcraft.thaummach.gui;
import net.anvilcraft.thaummach.TMItems;
import net.anvilcraft.thaummach.container.ContainerCrystallizer;
import net.anvilcraft.thaummach.tiles.TileCrystallizer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class GuiCrystallizer extends GuiContainer {
private TileCrystallizer crystallizerInventory;
public GuiCrystallizer(
InventoryPlayer inventoryplayer, TileCrystallizer tileInfuser
) {
super(new ContainerCrystallizer(inventoryplayer, tileInfuser));
this.crystallizerInventory = tileInfuser;
super.ySize = 239;
}
@Override
protected void drawGuiContainerForegroundLayer(int alec1, int alec2) {
super.fontRendererObj.drawString("Crystallizer", 5, 5, 0x404040);
}
@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/crystallizer.png")
);
int j = (super.width - super.xSize) / 2;
int k = (super.height - super.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, super.xSize, super.ySize);
int i1;
if (this.crystallizerInventory.isCooking()) {
i1 = this.crystallizerInventory.getCookProgressScaled(46);
this.drawTexturedModalRect(j + 160, k + 151 - i1, 176, 46 - i1, 9, i1);
}
if (this.crystallizerInventory.boost > 0) {
i1 = this.crystallizerInventory.getBoostScaled();
this.drawTexturedModalRect(j + 161, k + 38 - i1, 192, 30 - i1, 7, i1);
}
if (this.crystallizerInventory.getUpgrades()[0] >= 0) {
IIcon itemIcon = TMItems.upgrade.getIconFromDamage(
this.crystallizerInventory.getUpgrades()[0]
);
this.mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
this.drawTexturedModelRectFromIcon(j + 8, k + 128, itemIcon, 16, 16);
}
}
}

View File

@ -1,6 +1,7 @@
package net.anvilcraft.thaummach.items;
import java.util.List;
import java.util.stream.IntStream;
import net.anvilcraft.thaummach.TMBlocks;
import net.anvilcraft.thaummach.TMTab;
@ -15,7 +16,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class ItemRunicEssence extends Item {
private IIcon[] icons = new IIcon[6];
private IIcon[] icons;
public ItemRunicEssence() {
super();
@ -27,9 +28,10 @@ public class ItemRunicEssence extends Item {
@Override
public void registerIcons(IIconRegister reg) {
for (int i = 0; i < 6; i++) {
this.icons[i] = reg.registerIcon("thaummach:runic_essence_" + i);
}
this.icons
= IntStream.range(0, 6)
.mapToObj((i) -> reg.registerIcon("thaummach:runic_essence_" + i))
.toArray(IIcon[] ::new);
}
@Override

View File

@ -0,0 +1,154 @@
package net.anvilcraft.thaummach.items;
import java.util.List;
import java.util.stream.IntStream;
import dev.tilera.auracore.api.machine.IUpgradable;
import net.anvilcraft.thaummach.TMTab;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class ItemUpgrade extends Item {
public IIcon[] icons;
public ItemUpgrade() {
super();
this.maxStackSize = 16;
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setCreativeTab(TMTab.INSTANCE);
}
@Override
public void registerIcons(IIconRegister reg) {
this.icons = IntStream.rangeClosed(0, 6)
.mapToObj((i) -> reg.registerIcon("thaummach:upgrade_" + i))
.toArray(IIcon[] ::new);
}
@Override
public EnumRarity getRarity(ItemStack itemstack) {
return EnumRarity.uncommon;
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return "item.thaummach:upgrade_" + stack.getItemDamage();
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void
addInformation(ItemStack stack, EntityPlayer alec1, List list, boolean alec2) {
switch (stack.getItemDamage()) {
case 0:
list.add("Improves speed");
break;
case 1:
list.add("Improves efficiency");
break;
case 2:
list.add("Increases aggression and damage");
break;
case 3:
list.add("Unlocks functions that involve taint");
break;
case 4:
list.add("Upgrades?");
break;
case 5:
list.add("Increases capacity");
break;
case 6:
list.add("Increases mystical capacity or knowledge");
}
}
@Override
public IIcon getIconFromDamage(int meta) {
return this.icons[meta];
}
@Override
public IIcon getIcon(ItemStack stack, int pass) {
return this.getIconFromDamage(stack.getItemDamage());
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List list) {
IntStream.rangeClosed(0, 6).forEach((i) -> list.add(new ItemStack(this, 1, i)));
}
@Override
public boolean onItemUseFirst(
ItemStack ist,
EntityPlayer player,
World world,
int x,
int y,
int z,
int l,
// useless parameters
float alec1,
float alec2,
float alec3
) {
System.out.println("ALEC");
TileEntity ent = world.getTileEntity(x, y, z);
if (ent != null && ent instanceof IUpgradable) {
IUpgradable ue = (IUpgradable) ent;
for (int a = 0; a < ue.getUpgradeLimit(); ++a) {
if (ue.getUpgrades()[a] < 0
&& ue.canAcceptUpgrade((byte) ist.getItemDamage())) {
if (!world.isRemote && ue.setUpgrade((byte) ist.getItemDamage())) {
world.markBlockForUpdate(x, y, z);
ist.stackSize--;
world.playSoundEffect(
(double) x + 0.5,
(double) y + 0.5,
(double) z + 0.5,
"thaummach:upgrade",
0.4F,
1.0F
);
return true;
}
}
}
return false;
}
return super.onItemUseFirst(ist, player, world, x, y, z, l, alec1, alec2, alec3);
}
// TODO: WTF
//@Override
//public void useItemOnEntity(ItemStack ist, EntityLiving ent) {
// if (ent != null && ent instanceof IUpgradable) {
// IUpgradable ue = (IUpgradable) ent;
// for (int a = 0; a < ue.getUpgradeLimit(); ++a) {
// if (ue.getUpgrades()[a] < 0
// && ue.canAcceptUpgrade((byte) ist.getItemDamage())
// && ue.setUpgrade((byte) ist.getItemDamage())) {
// --ist.stackSize;
// ModLoader.getMinecraftInstance().theWorld.playSoundAtEntity(
// ent, "thaumcraft.upgrade", 0.4F, 1.0F
// );
// return;
// }
// }
// }
// super.useItemOnEntity(ist, ent);
//}
}

View File

@ -59,185 +59,4 @@ public class ApparatusRenderingHelper {
tessellator.draw();
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
public static void renderItemIn2D(
Tessellator tes,
float p_78439_1_,
float p_78439_2_,
float p_78439_3_,
float p_78439_4_,
int p_78439_5_,
int p_78439_6_,
float p_78439_7_,
int brightness
) {
tes.startDrawingQuads();
tes.setBrightness(brightness);
tes.setNormal(0.0F, 0.0F, 1.0F);
tes.addVertexWithUV(0.0D, 0.0D, 0.0D, (double) p_78439_1_, (double) p_78439_4_);
tes.addVertexWithUV(1.0D, 0.0D, 0.0D, (double) p_78439_3_, (double) p_78439_4_);
tes.addVertexWithUV(1.0D, 1.0D, 0.0D, (double) p_78439_3_, (double) p_78439_2_);
tes.addVertexWithUV(0.0D, 1.0D, 0.0D, (double) p_78439_1_, (double) p_78439_2_);
tes.draw();
tes.startDrawingQuads();
tes.setBrightness(brightness);
tes.setNormal(0.0F, 0.0F, -1.0F);
tes.addVertexWithUV(
0.0D,
1.0D,
(double) (0.0F - p_78439_7_),
(double) p_78439_1_,
(double) p_78439_2_
);
tes.addVertexWithUV(
1.0D,
1.0D,
(double) (0.0F - p_78439_7_),
(double) p_78439_3_,
(double) p_78439_2_
);
tes.addVertexWithUV(
1.0D,
0.0D,
(double) (0.0F - p_78439_7_),
(double) p_78439_3_,
(double) p_78439_4_
);
tes.addVertexWithUV(
0.0D,
0.0D,
(double) (0.0F - p_78439_7_),
(double) p_78439_1_,
(double) p_78439_4_
);
tes.draw();
float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float) p_78439_5_;
float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float) p_78439_6_;
tes.startDrawingQuads();
tes.setBrightness(brightness);
tes.setNormal(-1.0F, 0.0F, 0.0F);
int k;
float f7;
float f8;
for (k = 0; k < p_78439_5_; ++k) {
f7 = (float) k / (float) p_78439_5_;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
tes.addVertexWithUV(
(double) f7,
0.0D,
(double) (0.0F - p_78439_7_),
(double) f8,
(double) p_78439_4_
);
tes.addVertexWithUV(
(double) f7, 0.0D, 0.0D, (double) f8, (double) p_78439_4_
);
tes.addVertexWithUV(
(double) f7, 1.0D, 0.0D, (double) f8, (double) p_78439_2_
);
tes.addVertexWithUV(
(double) f7,
1.0D,
(double) (0.0F - p_78439_7_),
(double) f8,
(double) p_78439_2_
);
}
tes.draw();
tes.startDrawingQuads();
tes.setBrightness(brightness);
tes.setNormal(1.0F, 0.0F, 0.0F);
float f9;
for (k = 0; k < p_78439_5_; ++k) {
f7 = (float) k / (float) p_78439_5_;
f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
f9 = f7 + 1.0F / (float) p_78439_5_;
tes.addVertexWithUV(
(double) f9,
1.0D,
(double) (0.0F - p_78439_7_),
(double) f8,
(double) p_78439_2_
);
tes.addVertexWithUV(
(double) f9, 1.0D, 0.0D, (double) f8, (double) p_78439_2_
);
tes.addVertexWithUV(
(double) f9, 0.0D, 0.0D, (double) f8, (double) p_78439_4_
);
tes.addVertexWithUV(
(double) f9,
0.0D,
(double) (0.0F - p_78439_7_),
(double) f8,
(double) p_78439_4_
);
}
tes.draw();
tes.startDrawingQuads();
tes.setBrightness(brightness);
tes.setNormal(0.0F, 1.0F, 0.0F);
for (k = 0; k < p_78439_6_; ++k) {
f7 = (float) k / (float) p_78439_6_;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
f9 = f7 + 1.0F / (float) p_78439_6_;
tes.addVertexWithUV(
0.0D, (double) f9, 0.0D, (double) p_78439_1_, (double) f8
);
tes.addVertexWithUV(
1.0D, (double) f9, 0.0D, (double) p_78439_3_, (double) f8
);
tes.addVertexWithUV(
1.0D,
(double) f9,
(double) (0.0F - p_78439_7_),
(double) p_78439_3_,
(double) f8
);
tes.addVertexWithUV(
0.0D,
(double) f9,
(double) (0.0F - p_78439_7_),
(double) p_78439_1_,
(double) f8
);
}
tes.draw();
tes.startDrawingQuads();
tes.setBrightness(brightness);
tes.setNormal(0.0F, -1.0F, 0.0F);
for (k = 0; k < p_78439_6_; ++k) {
f7 = (float) k / (float) p_78439_6_;
f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
tes.addVertexWithUV(
1.0D, (double) f7, 0.0D, (double) p_78439_3_, (double) f8
);
tes.addVertexWithUV(
0.0D, (double) f7, 0.0D, (double) p_78439_1_, (double) f8
);
tes.addVertexWithUV(
0.0D,
(double) f7,
(double) (0.0F - p_78439_7_),
(double) p_78439_1_,
(double) f8
);
tes.addVertexWithUV(
1.0D,
(double) f7,
(double) (0.0F - p_78439_7_),
(double) p_78439_3_,
(double) f8
);
}
tes.draw();
}
}

View File

@ -1,7 +1,7 @@
package net.anvilcraft.thaummach.render.tile;
import net.anvilcraft.thaummach.render.apparatus.ApparatusRenderingHelper;
import net.anvilcraft.thaummach.tiles.TileBore;
import net.anvilcraft.thaummach.utils.UtilsFX;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
@ -50,7 +50,7 @@ public class TileBoreRenderer extends TileEntitySpecialRenderer {
if (cr.boreItemStacks[0] != null) {
mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
IIcon icon = cr.boreItemStacks[0].getIconIndex();
ApparatusRenderingHelper.renderItemIn2D(
UtilsFX.renderItemIn2D(
Tessellator.instance,
icon.getMaxU(),
icon.getMinV(),

View File

@ -308,7 +308,7 @@ public class TileCrucible extends TileEntity implements IConnection {
(double) ((float) super.xCoord + 0.5F),
(double) ((float) super.yCoord + 0.5F),
(double) ((float) super.zCoord + 0.5F),
"thaumcraft.bubbling",
"thaumcraft:bubble",
0.25F,
0.9F + super.worldObj.rand.nextFloat() * 0.2F
);

View File

@ -1,22 +1,30 @@
package net.anvilcraft.thaummach.tiles;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
import dev.tilera.auracore.api.machine.IUpgradable;
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.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.minecraftforge.common.util.ForgeDirection;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.lib.world.biomes.BiomeHandler;
public class TileCrystallizer
extends TileVisUser implements ISidedInventory, IUpgradable {
extends TileVisUser implements ISidedInventory, IUpgradable, ITileGui {
private ItemStack[] crystalizerItemStacks = new ItemStack[10];
public float crystalTime = 0.0F;
public float maxTime = 30.0F;
@ -25,10 +33,23 @@ public class TileCrystallizer
private byte[] upgrades = new byte[] { -1 };
int boostDelay = 20;
// TODO: GUIs
//public GuiScreen getGui(EntityPlayer player) {
// return new GuiCrystalizer(player.inventory, this);
//}
private static Map<Aspect, Integer> CRYSTAL_MAP = new HashMap<>();
static {
CRYSTAL_MAP.put(Aspect.AIR, 0);
CRYSTAL_MAP.put(Aspect.FIRE, 1);
CRYSTAL_MAP.put(Aspect.WATER, 2);
CRYSTAL_MAP.put(Aspect.EARTH, 3);
CRYSTAL_MAP.put(Aspect.MAGIC, 4);
CRYSTAL_MAP.put(Aspect.ORDER, 4);
CRYSTAL_MAP.put(Aspect.TAINT, 5);
CRYSTAL_MAP.put(Aspect.ENTROPY, 5);
}
@Override
public GuiID getGuiID() {
return GuiID.CRYSTALLIZER;
}
@Override
public int getSizeInventory() {
@ -138,6 +159,7 @@ public class TileCrystallizer
+ (this.hasUpgrade((byte) 0) ? 0.025F : 0.0F);
this.sucked = this.getAvailablePureVis(sa);
this.crystalTime -= this.sucked;
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
} else {
this.sucked = 0.0F;
}
@ -159,13 +181,25 @@ public class TileCrystallizer
if (this.crystalTime < 0.0F && this.crystalizerItemStacks[6] != null
&& this.crystalizerItemStacks[6].getItem() == ConfigItems.itemShard) {
// TODO: WTF
//this.addCrystal(ThaumCraftCore.getCrystalByBiome(
// super.worldObj,
// super.xCoord,
// super.zCoord,
// this.hasUpgrade((byte) 3) ? 3 : 0
//));
int rand = this.worldObj.rand.nextInt(11);
int crystalN = -1;
if (rand > 5) {
Aspect biomeAspect = BiomeHandler.getRandomBiomeTag(
this.worldObj.getBiomeGenForCoords(this.xCoord, this.zCoord)
.biomeID,
this.worldObj.rand
);
crystalN = CRYSTAL_MAP.getOrDefault(biomeAspect, -1);
}
if (crystalN == -1)
crystalN = rand % 6;
this.addCrystal(crystalN);
this.crystalTime = 0.0F;
AuraManager.addFluxToClosest(
this.worldObj,
@ -174,14 +208,13 @@ public class TileCrystallizer
this.zCoord,
new AspectList().add(Aspect.CRYSTAL, 5)
);
this.markDirty();
}
if (this.crystalTime == 0.0F && this.crystalizerItemStacks[6] != null
if (this.crystalTime <= 0.0F && this.crystalizerItemStacks[6] != null
&& this.crystalizerItemStacks[6].getItem() == ConfigItems.itemShard) {
if (this.crystalizerItemStacks[6].isItemEqual(
// TODO: definetely wrong meta
new ItemStack(ConfigItems.itemShard, 1, 6)
)) {
if (this.crystalizerItemStacks[6].getItemDamage() == 8) {
this.crystalTime = this.maxTime;
} else {
this.crystalTime = this.maxTime * 2.0F / 3.0F;
@ -212,7 +245,25 @@ public class TileCrystallizer
}
private void addCrystal(int type) {
ItemStack itemstack = new ItemStack(ConfigItems.itemShard, 1, type);
int meta = -1;
switch (type) {
case 0:
case 1:
case 2:
case 3:
meta = type;
break;
case 4:
meta = 7;
break;
case 5:
meta = 9;
break;
}
ItemStack itemstack = new ItemStack(ConfigItems.itemShard, 1, meta);
if (this.crystalizerItemStacks[type] == null) {
this.crystalizerItemStacks[type] = itemstack.copy();
} else if (this.crystalizerItemStacks[type].isItemEqual(itemstack) && this.crystalizerItemStacks[type].stackSize < itemstack.getMaxStackSize()) {
@ -358,4 +409,28 @@ public class TileCrystallizer
// TODO: WTF
return true;
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("crystalTime", this.crystalTime);
nbt.setFloat("maxTime", this.maxTime);
nbt.setInteger("boost", this.boost);
nbt.setByteArray("upgrades", this.upgrades);
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.crystalTime = nbt.getFloat("crystalTime");
this.maxTime = nbt.getFloat("maxTime");
this.boost = nbt.getInteger("boost");
this.upgrades = nbt.getByteArray("upgrades");
}
}

View File

@ -39,6 +39,14 @@ item.thaummach:focus_2.name=Arcane Focus: Water
item.thaummach:focus_3.name=Arcane Focus: Earth
item.thaummach:focus_4.name=Arcane Focus: Fire
item.thaummach:upgrade_0.name=Quicksilver Core
item.thaummach:upgrade_1.name=Stabilized Singularity
item.thaummach:upgrade_2.name=Harnessed Rage
item.thaummach:upgrade_3.name=Concentrated Evil
item.thaummach:upgrade_4.name=Infinite Sadness
item.thaummach:upgrade_5.name=Contained Emptiness
item.thaummach:upgrade_6.name=Collected Wisdom
item.thaummach:singularity.name=Arcane Singularity
item.thaummach:crystalline_bell.name=Crystalline Bell

View File

@ -43,5 +43,14 @@
"stream": false
}
]
},
"upgrade": {
"category": "master",
"sounds": [
{
"name": "upgrade",
"stream": false
}
]
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B