diff --git a/build.gradle b/build.gradle index d41d2d7..910625c 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ repositories { dependencies { implementation "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:deobf" - implementation "dev.tilera:auracore:1.6.0:deobf" + implementation "dev.tilera:auracore:1.6.1:deobf" implementation "com.github.tox1cozZ:mixin-booter-legacy:1.1.2" } diff --git a/src/main/java/net/anvilcraft/classiccasting/ClientProxy.java b/src/main/java/net/anvilcraft/classiccasting/ClientProxy.java index 633e847..a926e02 100644 --- a/src/main/java/net/anvilcraft/classiccasting/ClientProxy.java +++ b/src/main/java/net/anvilcraft/classiccasting/ClientProxy.java @@ -3,8 +3,10 @@ package net.anvilcraft.classiccasting; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; +import dev.tilera.auracore.api.research.IResearchTable; import net.anvilcraft.classiccasting.entities.EntityFrostShard; import net.anvilcraft.classiccasting.gui.GuiInfusionWorkbench; +import net.anvilcraft.classiccasting.gui.GuiResearchTable; import net.anvilcraft.classiccasting.render.BlockAlembicRenderer; import net.anvilcraft.classiccasting.render.BlockCrystalRenderer; import net.anvilcraft.classiccasting.render.BlockInfusionWorkbenchRenderer; @@ -14,6 +16,7 @@ import net.anvilcraft.classiccasting.render.TileAlembicRenderer; import net.anvilcraft.classiccasting.render.TileCrystalCapacitorRenderer; import net.anvilcraft.classiccasting.render.TileCrystalCoreRenderer; import net.anvilcraft.classiccasting.render.TileInfusionWorkbenchRenderer; +import net.anvilcraft.classiccasting.research.ClassicResearchTableExtension; import net.anvilcraft.classiccasting.tiles.TileAlembic; import net.anvilcraft.classiccasting.tiles.TileCrystalCapacitor; import net.anvilcraft.classiccasting.tiles.TileCrystalCore; @@ -81,6 +84,14 @@ public class ClientProxy extends CommonProxy { player.inventory, (TileInfusionWorkbench) world.getTileEntity(x, y, z) ); + case RESEARCH_TABLE: + return new GuiResearchTable( + player, + (ClassicResearchTableExtension + ) ((IResearchTable) world.getTileEntity(x, y, z)) + .getInternalExtension() + ); + default: return null; } diff --git a/src/main/java/net/anvilcraft/classiccasting/CommonProxy.java b/src/main/java/net/anvilcraft/classiccasting/CommonProxy.java index ef3340b..ef4063c 100644 --- a/src/main/java/net/anvilcraft/classiccasting/CommonProxy.java +++ b/src/main/java/net/anvilcraft/classiccasting/CommonProxy.java @@ -3,7 +3,10 @@ package net.anvilcraft.classiccasting; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.registry.GameRegistry; +import dev.tilera.auracore.api.research.IResearchTable; import net.anvilcraft.classiccasting.container.ContainerInfusionWorkbench; +import net.anvilcraft.classiccasting.container.ContainerResearchTable; +import net.anvilcraft.classiccasting.research.ClassicResearchTableExtension; import net.anvilcraft.classiccasting.tiles.TileAlembic; import net.anvilcraft.classiccasting.tiles.TileCrystalCapacitor; import net.anvilcraft.classiccasting.tiles.TileCrystalCore; @@ -38,6 +41,14 @@ public class CommonProxy implements IGuiHandler { player.inventory, (TileInfusionWorkbench) world.getTileEntity(x, y, z) ); + case RESEARCH_TABLE: + return new ContainerResearchTable( + player.inventory, + (ClassicResearchTableExtension + ) ((IResearchTable) world.getTileEntity(x, y, z)) + .getInternalExtension() + ); + default: return null; } diff --git a/src/main/java/net/anvilcraft/classiccasting/GuiType.java b/src/main/java/net/anvilcraft/classiccasting/GuiType.java index 2b91017..4415fa5 100644 --- a/src/main/java/net/anvilcraft/classiccasting/GuiType.java +++ b/src/main/java/net/anvilcraft/classiccasting/GuiType.java @@ -1,7 +1,8 @@ package net.anvilcraft.classiccasting; public enum GuiType { - INFUSION_WORKBENCH; + INFUSION_WORKBENCH, + RESEARCH_TABLE; public static GuiType get(int id) { if (id < 0 || id >= GuiType.values().length) diff --git a/src/main/java/net/anvilcraft/classiccasting/Recipes.java b/src/main/java/net/anvilcraft/classiccasting/Recipes.java index a40edd2..467541b 100644 --- a/src/main/java/net/anvilcraft/classiccasting/Recipes.java +++ b/src/main/java/net/anvilcraft/classiccasting/Recipes.java @@ -29,6 +29,22 @@ public class Recipes { ) ); + Research.arcaneRecipes.put( + "AuraCompass", + ThaumcraftApi.addArcaneCraftingRecipe( + "AURACOMPASS", + new ItemStack(CCItems.auraCompass), + new AspectList().add(Aspects.VIS, 20), + " G ", + "GCG", + " G ", + 'G', + Items.gold_ingot, + 'C', + new ItemStack(ConfigItems.itemShard, 1, 2) + ) + ); + Research.infusionRecipes.put( "CrystalCore", AuracoreRecipes.addInfusionCraftingRecipe( diff --git a/src/main/java/net/anvilcraft/classiccasting/Research.java b/src/main/java/net/anvilcraft/classiccasting/Research.java index 3538e0e..b073268 100644 --- a/src/main/java/net/anvilcraft/classiccasting/Research.java +++ b/src/main/java/net/anvilcraft/classiccasting/Research.java @@ -105,6 +105,25 @@ public class Research { .setParents("THAUMIUM") .registerResearchItem(); + new ResearchItem( + "AURACOMPASS", + "CLASSICCASTING", + new AspectList() + .add(Aspect.MAGIC, 8) + .add(Aspect.MIND, 8) + .add(Aspect.MECHANISM, 4), + -2, + 0, + 2, + new ItemStack(CCItems.auraCompass) + ) + .setPages( + new ResearchPage("classiccasting.research_page.AURACOMPASS"), + new ResearchPage(arcaneRecipes.get("AuraCompass")) + ) + .setParents("MAGBLOCKS") + .registerResearchItem(); + new ResearchItem( "CRYSTALCORE", "CLASSICCASTING", diff --git a/src/main/java/net/anvilcraft/classiccasting/container/ContainerResearchTable.java b/src/main/java/net/anvilcraft/classiccasting/container/ContainerResearchTable.java new file mode 100644 index 0000000..3076cc4 --- /dev/null +++ b/src/main/java/net/anvilcraft/classiccasting/container/ContainerResearchTable.java @@ -0,0 +1,156 @@ +package net.anvilcraft.classiccasting.container; + +import net.anvilcraft.classiccasting.research.ClassicResearchTableExtension; +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 ContainerResearchTable extends Container { + public ClassicResearchTableExtension extension; + + public ContainerResearchTable( + InventoryPlayer iinventory, ClassicResearchTableExtension extension + ) { + this.extension = extension; + + for (int a = 0; a < 5; ++a) { + this.addSlotToContainer(new Slot(extension, a, 15, 16 + 24 * a)); + } + + this.addSlotToContainer(new SlotResearchTableOutput(extension, 5, 75, 65)); + this.addSlotToContainer(new SlotResearchTablePaper(extension, 6, 75, 97)); + this.bindPlayerInventory(iinventory); + } + + protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) { + int i; + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.addSlotToContainer( + new Slot(inventoryPlayer, j + i * 9 + 9, 40 + j * 18, 160 + i * 18) + ); + } + } + + for (i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 40 + i * 18, 218)); + } + } + + public boolean enchantItem(EntityPlayer par1EntityPlayer, int button) { + if (button == 0) { + this.extension.researcher = par1EntityPlayer; + this.extension.startResearch(); + return true; + } else if (button == 1) { + this.extension.toggleSafe(); + return true; + } else { + return false; + } + } + + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slot) { + ItemStack stack = null; + Slot slotObject = (Slot) super.inventorySlots.get(slot); + if (slotObject != null && slotObject.getHasStack()) { + ItemStack stackInSlot = slotObject.getStack(); + stack = stackInSlot.copy(); + if (slot < 7) { + if (!this.mergeItemStack( + stackInSlot, 7, super.inventorySlots.size(), true + )) { + return null; + } + } else if (!this.mergeItemStack(stackInSlot, 0, 7, false)) { + return null; + } + + if (stackInSlot.stackSize == 0) { + slotObject.putStack((ItemStack) null); + } else { + slotObject.onSlotChanged(); + } + } + + return stack; + } + + protected boolean + mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4) { + boolean var5 = false; + int var6 = par2; + if (par4) { + var6 = par3 - 1; + } + + Slot var7; + ItemStack var8; + if (par1ItemStack.isStackable()) { + while (par1ItemStack.stackSize > 0 + && (!par4 && var6 < par3 || par4 && var6 >= par2)) { + var7 = (Slot) super.inventorySlots.get(var6); + var8 = var7.getStack(); + if (var8 != null && var7.isItemValid(par1ItemStack) + && var8.getItem() == par1ItemStack.getItem() + && (!par1ItemStack.getHasSubtypes() + || par1ItemStack.getItemDamage() == var8.getItemDamage()) + && ItemStack.areItemStackTagsEqual(par1ItemStack, var8)) { + int var9 = var8.stackSize + par1ItemStack.stackSize; + if (var9 <= par1ItemStack.getMaxStackSize()) { + par1ItemStack.stackSize = 0; + var8.stackSize = var9; + var7.onSlotChanged(); + var5 = true; + } else if (var8.stackSize < par1ItemStack.getMaxStackSize()) { + par1ItemStack.stackSize + -= par1ItemStack.getMaxStackSize() - var8.stackSize; + var8.stackSize = par1ItemStack.getMaxStackSize(); + var7.onSlotChanged(); + var5 = true; + } + } + + if (par4) { + --var6; + } else { + ++var6; + } + } + } + + if (par1ItemStack.stackSize > 0) { + if (par4) { + var6 = par3 - 1; + } else { + var6 = par2; + } + + while (!par4 && var6 < par3 || par4 && var6 >= par2) { + var7 = (Slot) super.inventorySlots.get(var6); + var8 = var7.getStack(); + if (var8 == null && var7.isItemValid(par1ItemStack)) { + var7.putStack(par1ItemStack.copy()); + var7.onSlotChanged(); + par1ItemStack.stackSize = 0; + var5 = true; + break; + } + + if (par4) { + --var6; + } else { + ++var6; + } + } + } + + return var5; + } + + public boolean canInteractWith(EntityPlayer player) { + return this.extension.isUseableByPlayer(player); + } +} diff --git a/src/main/java/net/anvilcraft/classiccasting/container/SlotResearchTableOutput.java b/src/main/java/net/anvilcraft/classiccasting/container/SlotResearchTableOutput.java new file mode 100644 index 0000000..83fb803 --- /dev/null +++ b/src/main/java/net/anvilcraft/classiccasting/container/SlotResearchTableOutput.java @@ -0,0 +1,19 @@ +package net.anvilcraft.classiccasting.container; + +import net.anvilcraft.classiccasting.CCItems; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +class SlotResearchTableOutput extends Slot { + public SlotResearchTableOutput( + IInventory par2IInventory, int par3, int par4, int par5 + ) { + super(par2IInventory, par3, par4, par5); + } + + public boolean isItemValid(ItemStack par1ItemStack) { + return par1ItemStack.getItem() == CCItems.researchNotes + && par1ItemStack.getItemDamage() < 64; + } +} diff --git a/src/main/java/net/anvilcraft/classiccasting/container/SlotResearchTablePaper.java b/src/main/java/net/anvilcraft/classiccasting/container/SlotResearchTablePaper.java new file mode 100644 index 0000000..ffe43c9 --- /dev/null +++ b/src/main/java/net/anvilcraft/classiccasting/container/SlotResearchTablePaper.java @@ -0,0 +1,18 @@ +package net.anvilcraft.classiccasting.container; + +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +class SlotResearchTablePaper extends Slot { + public SlotResearchTablePaper( + IInventory par2IInventory, int par3, int par4, int par5 + ) { + super(par2IInventory, par3, par4, par5); + } + + public boolean isItemValid(ItemStack par1ItemStack) { + return par1ItemStack.isItemEqual(new ItemStack(Items.paper)); + } +} diff --git a/src/main/java/net/anvilcraft/classiccasting/gui/GuiResearchTable.java b/src/main/java/net/anvilcraft/classiccasting/gui/GuiResearchTable.java new file mode 100644 index 0000000..a697dc4 --- /dev/null +++ b/src/main/java/net/anvilcraft/classiccasting/gui/GuiResearchTable.java @@ -0,0 +1,464 @@ +package net.anvilcraft.classiccasting.gui; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +import dev.tilera.auracore.api.Aspects; +import net.anvilcraft.classiccasting.CCItems; +import net.anvilcraft.classiccasting.container.ContainerResearchTable; +import net.anvilcraft.classiccasting.research.ClassicResearchTableExtension; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.research.ResearchCategories; +import thaumcraft.client.lib.UtilsFX; + +public class GuiResearchTable extends GuiContainer { + public float xSize_lo; + public float ySize_lo; + public long butcount = 0L; + public ClassicResearchTableExtension extension; + public FontRenderer galFontRenderer; + public float popupScale = 0.05F; + ArrayList coords = new ArrayList<>(); + ArrayList aspects = new ArrayList<>(); + + public GuiResearchTable(EntityPlayer player, ClassicResearchTableExtension e) { + super(new ContainerResearchTable(player.inventory, e)); + this.extension = e; + this.xSize = 240; + this.ySize = 242; + this.galFontRenderer = Minecraft.getMinecraft().standardGalacticFontRenderer; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) {} + + @Override + public void drawScreen(int par1, int par2, float par3) { + super.drawScreen(par1, par2, par3); + this.xSize_lo = (float) par1; + this.ySize_lo = (float) par2; + int var5 = this.guiLeft; + int var6 = this.guiTop; + // decompiler, wtf + //int mposx = false; + //int mposy = false; + int mposx = par1 - (var5 + 51); + int mposy = par2 - (var6 + 130); + String text; + int w; + if (mposx >= 0 && mposy >= 0 && mposx < 29 && mposy < 7) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) (var5 + 65), (float) (var6 + 142), 0.0F); + GL11.glScalef(0.65F, 0.65F, 0.0F); + text = "Cursory"; + if (!this.extension.safe) { + text = "Thorough"; + } + + w = this.fontRendererObj.getStringWidth(text) / 2; + this.fontRendererObj.drawString(text, -w, 0, 11447982); + GL11.glScalef(1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + int a; + for (a = 0; a < 5; ++a) { + if (this.extension.tags[a] != null) { + mposx = par1 - (var5 + 48); + mposy = par2 - (var6 + 32 + 16 * a); + if (mposx >= 0 && mposy >= 0 && mposx < 16 && mposy < 16) { + UtilsFX.drawCustomTooltip( + this, + GuiContainer.itemRender, + this.fontRendererObj, + Arrays.asList( + this.extension.tags[a].getName(), + this.extension.tags[a].getLocalizedDescription() + ), + par1, + par2, + 11 + ); + } + } + } + + if (this.aspects.size() > 0) { + for (a = 0; a < this.aspects.size(); ++a) { + mposx = par1 - ((Coord2D) this.coords.get(a)).x; + mposy = par2 - ((Coord2D) this.coords.get(a)).y; + if (mposx >= 0 && mposy >= 0 && mposx < 16 && mposy < 16) { + ArrayList l = new ArrayList<>(); + l.add(this.aspects.get(a).getName()); + l.add(this.aspects.get(a).getLocalizedDescription()); + if (this.extension.data.getTagProgress(this.aspects.get(a)) + > 0.333332F) { + l.add( + (int + ) (this.extension.data.getTagProgress(this.aspects.get(a)) + * 100.0F) + + "% complete" + ); + } + + UtilsFX.drawCustomTooltip( + this, + GuiContainer.itemRender, + this.fontRendererObj, + l, + par1, + par2, + 11 + ); + } + } + + mposx = par1 - (var5 + 103); + mposy = par2 - (var6 + 12); + if (this.popupScale < 0.48F && mposx >= 0 && mposy >= 0 && mposx < 17 + && mposy < 17) { + this.popupScale *= 1.25F; + if (this.popupScale > 0.48F) { + this.popupScale = 0.48F; + } + } + + if (this.popupScale > 0.05F + && (mposx < 0 || mposy < 0 + || (float) mposx > 17.0F * this.popupScale * 15.5F + || (float) mposy > 17.0F * this.popupScale * 15.5F)) { + this.popupScale *= 0.75F; + if (this.popupScale < 0.05F) { + this.popupScale = 0.05F; + } + } + + GL11.glPushMatrix(); + GL11.glTranslatef((float) (var5 + 105), (float) (var6 + 14), 505.0F); + GL11.glDisable(2896); + GL11.glScalef(this.popupScale, this.popupScale, 0.0F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture( + // TODO: texture might not exist + new ResourceLocation("thaumcraft", "textures/misc/parchment.png") + ); + this.drawTexturedModalRect(0, 0, 0, 0, 256, 256); + GL11.glScalef(1.5F, 1.5F, 0.0F); + // TODO: this used to be the longer description from TC3 that has been yoinked + // from TC4. We should somehow hack this in for ClassicCasting researches + text = ResearchCategories.getResearch(this.extension.data.key).getText(); + int y; + if (this.extension.data.getTotalProgress() >= 0.5F) { + w = this.fontRendererObj.getStringWidth(text); + y = (int + ) ((float) w / 130.0F * ((float) this.galFontRenderer.FONT_HEIGHT / 2.0F) + ); + this.fontRendererObj.drawSplitString(text, 22, 80 - y, 130, 0); + } else { + w = this.galFontRenderer.getStringWidth(text); + y = (int + ) ((float) w / 130.0F * ((float) this.galFontRenderer.FONT_HEIGHT / 2.0F) + ); + this.galFontRenderer.drawSplitString(text, 22, 80 - y, 130, 0); + } + + GL11.glEnable(2896); + GL11.glPopMatrix(); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + int var5 = this.guiLeft; + int var6 = this.guiTop; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture( + new ResourceLocation("classiccasting", "textures/gui/gui_researchtable.png") + ); + this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); + // WTF + if (this.butcount > System.currentTimeMillis() || this.extension.tags[0] == null + || (this.extension.contents[5] != null || this.extension.contents[6] == null) + && (this.extension.contents[5] == null + || this.extension.contents[5].getItem() != CCItems.researchNotes + || this.extension.contents[5].getItemDamage() >= 64)) { + this.drawTexturedModalRect(var5 + 76, var6 + 40, 241, 15, 15, 15); + } else { + this.drawTexturedModalRect(var5 + 76, var6 + 40, 241, 0, 15, 15); + } + + if (this.extension.safe) { + this.drawTexturedModalRect(var5 + 51, var6 + 130, 109, 246, 29, 7); + } else { + this.drawTexturedModalRect(var5 + 51, var6 + 130, 87, 246, 29, 7); + } + + for (int a = 0; a < 5; ++a) { + if (this.extension.tags[a] != null) { + float op = 1.0F; + if (this.extension.data != null + && this.extension.data.failedTags != null + // TODO: 64 makes no sense in todays TC version + //&& this.extension.data.failedTags.size() == 64 + && this.extension.data.failedTags.getAmount(this.extension.tags[a]) + >= 10) { + op = 0.15F; + } + + UtilsFX.drawTag( + var5 + 48, + var6 + 32 + 16 * a, + this.extension.tags[a], + this.extension.tagAmounts[a], + Math.round(this.extension.tagBonus[a]), + 0.0, + 771, + op + ); + } + } + + this.drawResearchData(var5 + 167, var6 + 76); + } + + private void drawResearchData(int x, int y) { + this.coords = new ArrayList<>(); + this.aspects = new ArrayList<>(); + if (this.extension.data != null) { + for (Aspect a : this.extension.data.tags.aspects.keySet()) { + if (this.extension.data.getTagProgress(a) > 0.0F + || this.extension.data.getTotalProgress() >= 0.5F) { + if (!(this.extension.data.getTagProgress(a) >= 0.3F) + && !(this.extension.data.getTotalProgress() >= 0.75F)) { + this.aspects.add(Aspects.OBSCURE); + } else { + this.aspects.add(a); + } + } + } + + if (this.aspects.size() > 0) { + float pieSlice = (float) (360 / this.aspects.size()); + float currentRot = -90.0F; + + int b; + for (int a = 0; a < this.aspects.size(); ++a) { + float progmod = 15.0F + + 40.0F * this.extension.data.getTagProgress(this.aspects.get(a)); + b = (int + ) ((float) x + + MathHelper.cos(currentRot / 180.0F * 3.1415927F) * progmod) + - 8; + int yy + = (int + ) ((float) y + + MathHelper.sin(currentRot / 180.0F * 3.1415927F) * progmod) + - 8; + currentRot += pieSlice; + this.coords.add(new Coord2D(b, yy)); + } + + new Random(); + + for (int a = 0; a < this.aspects.size(); ++a) { + Aspect tt = this.aspects.get(a); + if (this.extension.data.getTagProgress(tt) < 0.2F + && this.extension.data.getTotalProgress() < 0.75F) { + tt = Aspects.OBSCURE; + } + + UtilsFX.drawTag( + ((Coord2D) this.coords.get(a)).x, + ((Coord2D) this.coords.get(a)).y, + tt, + 0, + 0, + 0.0 + ); + } + + if (this.aspects.size() > 1) { + for (int a = 0; a < this.aspects.size(); ++a) { + this.drawLine( + x, + y, + ((Coord2D) this.coords.get(a)).x + 8, + ((Coord2D) this.coords.get(a)).y + 8, + 1.0F + - (this.extension.data.getTagProgress(this.aspects.get(a)) + + this.extension.data.getTotalProgress()) + / 2.0F, + 0.5F + ); + if (this.aspects.size() > 2) { + for (b = a + 1; b < this.aspects.size(); ++b) { + this.drawLine( + ((Coord2D) this.coords.get(b)).x + 8, + ((Coord2D) this.coords.get(b)).y + 8, + ((Coord2D) this.coords.get(a)).x + 8, + ((Coord2D) this.coords.get(a)).y + 8, + 1.0F + - (this.extension.data.getTagProgress( + this.aspects.get(a) + ) + + this.extension.data.getTotalProgress()) + / 2.0F, + 0.5F + ); + } + } + } + } + + for (int a = 0; a < this.aspects.size(); ++a) { + if (this.extension.data.getTagProgress(this.aspects.get(a)) >= 1.0F) { + this.drawLine( + ((Coord2D) this.coords.get(a)).x - 1, + ((Coord2D) this.coords.get(a)).y - 1, + ((Coord2D) this.coords.get(a)).x - 1, + ((Coord2D) this.coords.get(a)).y + 17, + 0.3F, + 1.0F + ); + this.drawLine( + ((Coord2D) this.coords.get(a)).x - 1, + ((Coord2D) this.coords.get(a)).y - 1, + ((Coord2D) this.coords.get(a)).x + 17, + ((Coord2D) this.coords.get(a)).y - 1, + 0.3F, + 1.0F + ); + this.drawLine( + ((Coord2D) this.coords.get(a)).x + 17, + ((Coord2D) this.coords.get(a)).y - 1, + ((Coord2D) this.coords.get(a)).x + 17, + ((Coord2D) this.coords.get(a)).y + 17, + 0.3F, + 1.0F + ); + this.drawLine( + ((Coord2D) this.coords.get(a)).x - 1, + ((Coord2D) this.coords.get(a)).y + 17, + ((Coord2D) this.coords.get(a)).x + 17, + ((Coord2D) this.coords.get(a)).y + 17, + 0.3F, + 1.0F + ); + } + } + } + } + } + + private void drawLine(int x, int y, int x2, int y2, float instability, float op) { + if (instability > 0.01F) { + double dist = (double + ) (MathHelper.sqrt_float((float) ((x - x2) * (x - x2) + (y - y2) * (y - y2))) + * instability); + double xd = (double) (x2 - x) / dist; + double yd = (double) (y2 - y) / dist; + Random rand = new Random(); + int xr = 0; + int yr = 0; + int inc = (int) Math.floor(dist - 1.0); + + int a; + for (a = 0; a < inc; ++a) { + int xrn = rand.nextInt(2) - rand.nextInt(2); + int yrn = rand.nextInt(2) - rand.nextInt(2); + this.drawLine( + (int) ((double) x + xd * (double) a) + xr, + (int) ((double) y + yd * (double) a) + yr, + (int) ((double) x + xd * (double) (a + 1)) + xrn, + (int) ((double) y + yd * (double) (a + 1)) + yrn, + op + ); + xr = xrn; + yr = yrn; + } + + this.drawLine( + (int) ((double) x + xd * (double) a) + xr, + (int) ((double) y + yd * (double) a) + yr, + x2, + y2, + op + ); + } else { + this.drawLine(x, y, x2, y2, op); + } + } + + private void drawLine(int x, int y, int x2, int y2, float op) { + int count = Minecraft.getMinecraft().thePlayer.ticksExisted; + float bob = MathHelper.sin(((float) count + (float) x2) / 10.0F) * 0.15F + 0.15F; + float bob2 + = MathHelper.sin(((float) count + (float) x + (float) y2) / 11.0F) * 0.15F + + 0.15F; + float bob3 = MathHelper.sin(((float) count + (float) y) / 12.0F) * 0.15F + 0.15F; + Tessellator var12 = Tessellator.instance; + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glDisable(2896); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 1); + var12.startDrawing(3); + var12.setColorRGBA_F(bob, bob2, bob3, op); + var12.addVertex((double) x, (double) y, 0.0); + var12.addVertex((double) x2, (double) y2, 0.0); + var12.draw(); + GL11.glDisable(3042); + GL11.glDisable(32826); + GL11.glEnable(2896); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3) { + super.mouseClicked(par1, par2, par3); + int var4 = (this.width - this.xSize) / 2; + int var5 = (this.height - this.ySize) / 2; + int var7 = par1 - (var4 + 76); + int var8 = par2 - (var5 + 40); + if (this.butcount > System.currentTimeMillis() || var7 < 0 || var8 < 0 + || var7 >= 15 || var8 >= 15 || this.extension.tags[0] == null + || (this.extension.contents[5] != null || this.extension.contents[6] == null) + && (this.extension.contents[5] == null + || this.extension.contents[5].getItem() != CCItems.researchNotes + || this.extension.contents[5].getItemDamage() >= 64)) { + var7 = par1 - (var4 + 51); + var8 = par2 - (var5 + 130); + if (this.butcount <= System.currentTimeMillis() && var7 >= 0 && var8 >= 0 + && var7 < 29 && var8 < 7) { + this.mc.playerController.sendEnchantPacket( + this.inventorySlots.windowId, 1 + ); + this.extension.toggleSafe(); + } + } else { + this.mc.playerController.sendEnchantPacket(this.inventorySlots.windowId, 0); + this.extension.startResearch(); + this.butcount = System.currentTimeMillis() + 150L; + } + } + + class Coord2D { + int x; + int y; + + Coord2D(int x, int y) { + this.x = x; + this.y = y; + } + } +} diff --git a/src/main/java/net/anvilcraft/classiccasting/items/ItemResearchNotes.java b/src/main/java/net/anvilcraft/classiccasting/items/ItemResearchNotes.java index f8274df..a835cc5 100644 --- a/src/main/java/net/anvilcraft/classiccasting/items/ItemResearchNotes.java +++ b/src/main/java/net/anvilcraft/classiccasting/items/ItemResearchNotes.java @@ -76,7 +76,7 @@ public class ItemResearchNotes extends Item { )) { PacketHandler.INSTANCE.sendTo( new PacketResearchComplete( - ResearchManager.getData((ItemStack) stack).key + CCResearchManager.getData((ItemStack) stack).key ), (EntityPlayerMP) player ); @@ -86,7 +86,7 @@ public class ItemResearchNotes extends Item { String[] siblings = ResearchCategories .getResearch( - (String) ResearchManager.getData((ItemStack) stack).key + (String) CCResearchManager.getData((ItemStack) stack).key ) .siblings; if (siblings != null) { @@ -158,7 +158,7 @@ public class ItemResearchNotes extends Item { ) { if (CCResearchManager.getData(stack).getTotalProgress() >= 0.2f) { ResearchItem item = ResearchCategories.getResearch( - ResearchManager.getData((ItemStack) stack).key + CCResearchManager.getData((ItemStack) stack).key ); if (item != null) list.add(item.getName()); diff --git a/src/main/java/net/anvilcraft/classiccasting/research/ClassicResearchTableExtension.java b/src/main/java/net/anvilcraft/classiccasting/research/ClassicResearchTableExtension.java index eb01504..b9bc0a0 100644 --- a/src/main/java/net/anvilcraft/classiccasting/research/ClassicResearchTableExtension.java +++ b/src/main/java/net/anvilcraft/classiccasting/research/ClassicResearchTableExtension.java @@ -8,6 +8,8 @@ import dev.tilera.auracore.api.Aspects; import dev.tilera.auracore.api.research.IResearchTable; import dev.tilera.auracore.api.research.ResearchTableExtension; import net.anvilcraft.classiccasting.CCItems; +import net.anvilcraft.classiccasting.ClassicCasting; +import net.anvilcraft.classiccasting.GuiType; import net.anvilcraft.classiccasting.items.ItemResearchNotes; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -81,12 +83,12 @@ public class ClassicResearchTableExtension @Override public void writeToPacket(NBTTagCompound nbt) { - nbt.setBoolean("safe", this.safe); + this.writeToNBT(nbt); } @Override public void readFromPacket(NBTTagCompound nbt) { - this.safe = nbt.getBoolean("safe"); + this.readFromNBT(nbt); } @Override @@ -107,8 +109,15 @@ public class ClassicResearchTableExtension @Override public boolean openGUI(EntityPlayer player) { - // TODO: Implement this - return false; + player.openGui( + ClassicCasting.INSTANCE, + GuiType.RESEARCH_TABLE.ordinal(), + this.getWorld(), + this.getXCoord(), + this.getYCoord(), + this.getZCoord() + ); + return true; } @Override @@ -130,7 +139,7 @@ public class ClassicResearchTableExtension CCResearchManager.createResearchNoteForTable(this, key); if (this.contents[5] != null) { CCResearchManager.progressTableResearch( - this.world, + this.getWorld(), this.researcher, this, this.contents[5], @@ -149,7 +158,7 @@ public class ClassicResearchTableExtension } } else if (this.contents[5].getItem() == CCItems.researchNotes && this.contents[5].getItemDamage() < 64) { CCResearchManager.progressTableResearch( - this.world, + this.getWorld(), this.researcher, this, this.contents[5], @@ -166,19 +175,20 @@ public class ClassicResearchTableExtension } public void startResearch() { - this.world.playSoundEffect( - (double) this.xCoord, - (double) this.yCoord, - (double) this.zCoord, + this.getWorld().playSoundEffect( + (double) this.getXCoord(), + (double) this.getYCoord(), + (double) this.getZCoord(), "random.click", 0.15f, 0.8f ); - if (!this.world.isRemote) { + if (!this.getWorld().isRemote) { this.doResearch(); int chance = this.baseLoss; for (int a = 0; a < 5; ++a) { - if (this.contents[a] == null || this.world.rand.nextInt(100) >= chance) + if (this.contents[a] == null + || this.getWorld().rand.nextInt(100) >= chance) continue; --this.contents[a].stackSize; if (this.contents[a].stackSize != 0) @@ -186,17 +196,19 @@ public class ClassicResearchTableExtension this.contents[a] = null; } } - this.world.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.getWorld().markBlockForUpdate( + this.getXCoord(), this.getYCoord(), this.getZCoord() + ); this.markDirty(); } public void toggleSafe() { this.safe = !this.safe; this.recalcBaseChance(); - this.world.playSoundEffect( - (double) this.xCoord, - (double) this.yCoord, - (double) this.zCoord, + this.getWorld().playSoundEffect( + (double) this.getXCoord(), + (double) this.getYCoord(), + (double) this.getZCoord(), "step.wood", 0.3f, 1.2f @@ -276,46 +288,54 @@ public class ClassicResearchTableExtension private void recalculateBonus() { List ents; - if (!this.world.isDaytime() - && this.world.getBlockLightValue(this.xCoord, this.yCoord + 1, this.zCoord) - < 4 - && !this.world.canBlockSeeTheSky(this.xCoord, this.yCoord + 1, this.zCoord)) { + if (!this.getWorld().isDaytime() + && this.getWorld().getBlockLightValue( + this.getXCoord(), this.getYCoord() + 1, this.getZCoord() + ) < 4 + && !this.getWorld().canBlockSeeTheSky( + this.getXCoord(), this.getYCoord() + 1, this.getZCoord() + )) { this.incrementTagBonus(1.0f, Arrays.asList(new Aspect[] { Aspect.DARKNESS })); } - if (this.world.isDaytime() - && this.world.getBlockLightValue(this.xCoord, this.yCoord + 1, this.zCoord) - > 11 - && this.world.canBlockSeeTheSky(this.xCoord, this.yCoord + 1, this.zCoord)) { + if (this.getWorld().isDaytime() + && this.getWorld().getBlockLightValue( + this.getXCoord(), this.getYCoord() + 1, this.getZCoord() + ) > 11 + && this.getWorld().canBlockSeeTheSky( + this.getXCoord(), this.getYCoord() + 1, this.getZCoord() + )) { this.incrementTagBonus(1.0f, Arrays.asList(new Aspect[] { Aspect.LIGHT })); } - if ((float) this.yCoord > (float) this.world.getActualHeight() * 0.5f) { + if ((float) this.getYCoord() > (float) this.getWorld().getActualHeight() * 0.5f) { this.incrementTagBonus(1.0f, Arrays.asList(new Aspect[] { Aspect.AIR })); } - if ((float) this.yCoord > (float) this.world.getActualHeight() * 0.66f) { + if ((float) this.getYCoord() + > (float) this.getWorld().getActualHeight() * 0.66f) { this.incrementTagBonus(1.0f, Arrays.asList(new Aspect[] { Aspect.AIR })); } - if ((float) this.yCoord > (float) this.world.getActualHeight() * 0.75f) { + if ((float) this.getYCoord() + > (float) this.getWorld().getActualHeight() * 0.75f) { this.incrementTagBonus(1.0f, Arrays.asList(new Aspect[] { Aspect.AIR })); } - if (this.world.isRaining()) { + if (this.getWorld().isRaining()) { this.incrementTagBonus(1.0f, Arrays.asList(new Aspect[] { Aspect.WEATHER })); } - if (this.world.isThundering()) { + if (this.getWorld().isThundering()) { this.incrementTagBonus( 1.0f, Arrays.asList(new Aspect[] { Aspect.WEATHER, Aspect.ENERGY, Aspect.AIR }) ); } - if ((ents = this.world.getEntitiesWithinAABB( + if ((ents = this.getWorld().getEntitiesWithinAABB( EntityLivingBase.class, AxisAlignedBB .getBoundingBox( - (double) this.xCoord, - (double) this.yCoord, - (double) this.zCoord, - (double) (this.xCoord + 1), - (double) (this.yCoord + 1), - (double) (this.zCoord + 1) + (double) this.getXCoord(), + (double) this.getYCoord(), + (double) this.getZCoord(), + (double) (this.getXCoord() + 1), + (double) (this.getYCoord() + 1), + (double) (this.getZCoord() + 1) ) .expand(15.0, 15.0, 15.0) )) @@ -422,14 +442,14 @@ public class ClassicResearchTableExtension for (int x = -10; x <= 10; ++x) { for (int z = -10; z <= 10; ++z) { for (int y = -10; y <= 10; ++y) { - if (y + this.yCoord <= 0 - || y + this.yCoord >= this.world.getActualHeight()) + if (y + this.getYCoord() <= 0 + || y + this.getYCoord() >= this.getWorld().getActualHeight()) continue; - Block bi = this.world.getBlock( - x + this.xCoord, y + this.yCoord, z + this.zCoord + Block bi = this.getWorld().getBlock( + x + this.getXCoord(), y + this.getYCoord(), z + this.getZCoord() ); - int md = this.world.getBlockMetadata( - x + this.xCoord, y + this.yCoord, z + this.zCoord + int md = this.getWorld().getBlockMetadata( + x + this.getXCoord(), y + this.getYCoord(), z + this.getZCoord() ); Material bm = bi.getMaterial(); if (bi == Blocks.jukebox) { @@ -797,13 +817,14 @@ public class ClassicResearchTableExtension @Override public boolean isUseableByPlayer(EntityPlayer var1) { - return this.world.getTileEntity(this.xCoord, this.yCoord, this.zCoord) - != this.getResearchTable() + return this.getWorld().getTileEntity( + this.getXCoord(), this.getYCoord(), this.getZCoord() + ) != this.getResearchTable() ? false : var1.getDistanceSq( - (double) this.xCoord + 0.5, - (double) this.yCoord + 0.5, - (double) this.zCoord + 0.5 + (double) this.getXCoord() + 0.5, + (double) this.getYCoord() + 0.5, + (double) this.getZCoord() + 0.5 ) <= 64.0; } diff --git a/src/main/resources/assets/classiccasting/lang/en_US.lang b/src/main/resources/assets/classiccasting/lang/en_US.lang index 65fe71c..588ae25 100644 --- a/src/main/resources/assets/classiccasting/lang/en_US.lang +++ b/src/main/resources/assets/classiccasting/lang/en_US.lang @@ -70,3 +70,7 @@ classiccasting.research_page.WANDEXCAVATE=You have successfully adapted the ench tc.research_name.WANDLIGHTNING=Wand of Lightning tc.research_text.WANDLIGHTNING=...very, very frightening classiccasting.research_page.WANDLIGHTNING=You have successfully adapted the enchantment on an apprentice wand. It is now capable of focusing elemental energy into bolts of lightning.

However the wand has lost the ability to renew its charge and will eventually run out of energy and break. + +tc.research_name.AURACOMPASS=Aura Compass +tc.research_text.AURACOMPASS=Magical detector +classiccasting.research_page.AURACOMPASS=The Aura Compass acts like a mystical compass, pointing you towards the center of the nearest magical aura.

You are confident you will be able to craft more refined devices in the future allowing you to discover more information about aura nodes.
For now this will have to do. diff --git a/src/main/resources/assets/classiccasting/textures/gui/gui_researchtable.png b/src/main/resources/assets/classiccasting/textures/gui/gui_researchtable.png new file mode 100644 index 0000000..91ffb09 Binary files /dev/null and b/src/main/resources/assets/classiccasting/textures/gui/gui_researchtable.png differ