diff --git a/build.gradle b/build.gradle index bcdf79c8..63ebc592 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ repositories { } } dependencies { - compile "mcp.mobius.waila:Waila:1.5.5_1.7.10" + compile "mcp.mobius.waila:Waila:1.5.6_dev1_1.7.10" } ext.configFile = file "build.properties" @@ -151,7 +151,7 @@ task signJar(dependsOn: ["reobf", "devJar"]) { task copyChicken(type: Copy, dependsOn: "extractUserDev") { from { configurations.compile } - include "**/*Chicken*.jar", "**/*NotEnoughItems*.jar", "**/*Waila*.jar" + include "**/*Chicken*.jar", "**/*NotEnoughItems*.jar" exclude "**/CodeChickenLib*" // because CCC downloads it anyways.. -_- into file("./run/mods") // paralell to the assets dir mustRunAfter "deobfBinJar" diff --git a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java index a2707b5a..c65217b7 100644 --- a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java @@ -1,5 +1,6 @@ package com.pahimar.ee3; +import com.pahimar.ee3.array.GlyphRegistry; import com.pahimar.ee3.command.CommandSetCurrentItemValue; import com.pahimar.ee3.command.CommandSetValue; import com.pahimar.ee3.command.CommandSyncValues; @@ -69,6 +70,8 @@ public class EquivalentExchange3 ModBlocks.init(); + Glyphs.init(); + EnergyValues.addDefaultEnergyValues(); Skills.addDefaultSkills(); @@ -140,4 +143,9 @@ public class EquivalentExchange3 { return SkillRegistry.getInstance(); } + + public GlyphRegistry getGlyphRegistry() + { + return GlyphRegistry.getInstance(); + } } diff --git a/src/main/java/com/pahimar/ee3/api/AlchemyArray.java b/src/main/java/com/pahimar/ee3/api/AlchemyArray.java new file mode 100644 index 00000000..37b9d819 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/api/AlchemyArray.java @@ -0,0 +1,133 @@ +package com.pahimar.ee3.api; + +import com.google.common.collect.ImmutableSortedSet; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; + +import java.util.Collection; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +public class AlchemyArray +{ + private SortedSet glyphs; + private int largestGlyphSize; + + public AlchemyArray() + { + glyphs = new TreeSet(); + largestGlyphSize = 0; + } + + public AlchemyArray(Collection glyphs) + { + this.glyphs = new TreeSet(glyphs); + largestGlyphSize = 0; + + for (Glyph glyph : glyphs) + { + if (glyph.getSize() > largestGlyphSize) + { + largestGlyphSize = glyph.getSize(); + } + } + } + + public void addGlyph(Glyph glyph) + { + if (glyph.getSize() > largestGlyphSize) + { + largestGlyphSize = glyph.getSize(); + } + + glyphs.add(glyph); + } + + public void addGlyph(Glyph glyph, int size) + { + if (size > largestGlyphSize) + { + largestGlyphSize = size; + } + + glyphs.add(new Glyph(glyph, size)); + } + + public Set getGlyphs() + { + return ImmutableSortedSet.copyOf(glyphs); + } + + public int getLargestGlyphSize() + { + return largestGlyphSize; + } + + public void readFromNBT(NBTTagCompound nbtTagCompound) + { + if (nbtTagCompound != null && nbtTagCompound.hasKey("glyphs")) + { + // Read in the ItemStacks in the inventory from NBT + if (nbtTagCompound.hasKey("glyphs")) + { + NBTTagList tagList = nbtTagCompound.getTagList("glyphs", 10); + glyphs = new TreeSet(); + largestGlyphSize = 0; + for (int i = 0; i < tagList.tagCount(); ++i) + { + NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); + Glyph glyph = Glyph.readGlyphFromNBT(tagCompound); + glyphs.add(glyph); + if (glyph.getSize() > largestGlyphSize) + { + largestGlyphSize = glyph.getSize(); + } + } + } + else + { + glyphs = new TreeSet(); + largestGlyphSize = 0; + } + } + else + { + glyphs = new TreeSet(); + largestGlyphSize = 0; + } + } + + public void writeToNBT(NBTTagCompound nbtTagCompound) + { + NBTTagList tagList = new NBTTagList(); + for (Glyph glyph : glyphs) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + glyph.writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + nbtTagCompound.setTag("glyphs", tagList); + nbtTagCompound.setInteger("largestGlyphSize", largestGlyphSize); + } + + public static AlchemyArray readAlchemyArrayFromNBT(NBTTagCompound nbtTagCompound) + { + AlchemyArray alchemyArray = new AlchemyArray(); + alchemyArray.readFromNBT(nbtTagCompound); + return alchemyArray; + } + + @Override + public String toString() + { + StringBuilder stringBuilder = new StringBuilder(); + + for (Glyph glyph : glyphs) + { + stringBuilder.append(glyph.toString() + ", "); + } + + return stringBuilder.toString(); + } +} diff --git a/src/main/java/com/pahimar/ee3/api/EnergyValue.java b/src/main/java/com/pahimar/ee3/api/EnergyValue.java index f1d167f9..e062f1d5 100644 --- a/src/main/java/com/pahimar/ee3/api/EnergyValue.java +++ b/src/main/java/com/pahimar/ee3/api/EnergyValue.java @@ -8,7 +8,7 @@ import java.lang.reflect.Type; public final class EnergyValue implements Comparable, JsonDeserializer, JsonSerializer { private static final Gson jsonSerializer = (new GsonBuilder()).registerTypeAdapter(EnergyValue.class, new EnergyValue()).create(); - private final float energyValue; + private float energyValue; private final EnergyType energyType; public EnergyValue() @@ -84,6 +84,22 @@ public final class EnergyValue implements Comparable, JsonDeseriali return this.energyValue; } + public void add(EnergyValue energyValue) + { + if (this.energyType == energyValue.energyType && energyValue.energyValue > 0f) + { + this.energyValue += energyValue.energyValue; + } + } + + public void subtract(EnergyValue energyValue) + { + if (this.energyType == energyValue.energyType && (this.energyValue - energyValue.energyValue) >= 0f) + { + this.energyValue -= energyValue.energyValue; + } + } + public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { nbtTagCompound.setFloat("energyValue", energyValue); diff --git a/src/main/java/com/pahimar/ee3/api/Glyph.java b/src/main/java/com/pahimar/ee3/api/Glyph.java new file mode 100644 index 00000000..5ea01ee8 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/api/Glyph.java @@ -0,0 +1,124 @@ +package com.pahimar.ee3.api; + +import com.pahimar.ee3.util.ResourceLocationHelper; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; + +public class Glyph implements Comparable +{ + private ResourceLocation texture; + private String unLocalizedName; + private int size; + + private Glyph() + { + + } + + public Glyph(String texture, String unLocalizedName) + { + this(texture, unLocalizedName, 1); + } + + public Glyph(String texture, String unLocalizedName, int size) + { + this(ResourceLocationHelper.getResourceLocation(texture), unLocalizedName, size); + } + + public Glyph(ResourceLocation texture, String unLocalizedName, int size) + { + this.texture = texture; + this.unLocalizedName = unLocalizedName; + this.size = size; + } + + public Glyph(Glyph glyph, int size) + { + this.texture = glyph.texture; + this.unLocalizedName = glyph.unLocalizedName; + this.size = size; + } + + public ResourceLocation getTexture() + { + return texture; + } + + public String getUnLocalizedName() + { + return unLocalizedName; + } + + public int getSize() + { + return size; + } + + public void readFromNBT(NBTTagCompound nbtTagCompound) + { + if (nbtTagCompound != null && nbtTagCompound.hasKey("textureDomain") && nbtTagCompound.hasKey("texturePath") && nbtTagCompound.hasKey("unLocalizedName") && nbtTagCompound.hasKey("size")) + { + this.texture = new ResourceLocation(nbtTagCompound.getString("textureDomain"), nbtTagCompound.getString("texturePath")); + this.unLocalizedName = nbtTagCompound.getString("unLocalizedName"); + this.size = nbtTagCompound.getInteger("size"); + } + else + { + this.texture = new ResourceLocation(""); + this.unLocalizedName = ""; + this.size = 0; + } + } + + public void writeToNBT(NBTTagCompound nbtTagCompound) + { + nbtTagCompound.setString("textureDomain", texture.getResourceDomain()); + nbtTagCompound.setString("texturePath", texture.getResourcePath()); + nbtTagCompound.setString("unLocalizedName", unLocalizedName); + nbtTagCompound.setInteger("size", size); + } + + public static Glyph readGlyphFromNBT(NBTTagCompound nbtTagCompound) + { + Glyph glyph = new Glyph(); + glyph.readFromNBT(nbtTagCompound); + return glyph; + } + + @Override + public String toString() + { + return String.format("texture: %s, unLocalizedName: %s, size: %s", texture.getResourcePath() + ":" + texture.getResourcePath(), unLocalizedName, size); + } + + @Override + public boolean equals(Object object) + { + if (object instanceof Glyph) + { + return this.compareTo((Glyph) object) == 0; + } + + return false; + } + + @Override + public int compareTo(Glyph glyph) + { + if (this.texture.getResourceDomain().equalsIgnoreCase(glyph.getTexture().getResourceDomain())) + { + if (this.texture.getResourcePath().equalsIgnoreCase(glyph.getTexture().getResourcePath())) + { + return this.size - glyph.size; + } + else + { + return this.texture.getResourcePath().compareToIgnoreCase(glyph.getTexture().getResourcePath()); + } + } + else + { + return this.texture.getResourceDomain().compareToIgnoreCase(glyph.getTexture().getResourceDomain()); + } + } +} diff --git a/src/main/java/com/pahimar/ee3/api/GlyphRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/GlyphRegistryProxy.java new file mode 100644 index 00000000..89820f84 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/api/GlyphRegistryProxy.java @@ -0,0 +1,36 @@ +package com.pahimar.ee3.api; + +import com.pahimar.ee3.EquivalentExchange3; +import cpw.mods.fml.common.Mod; + +public class GlyphRegistryProxy +{ + @Mod.Instance("EE3") + private static Object ee3Mod; + + public static void addGlyph(Glyph glyph) + { + init(); + + // NOOP if EquivalentExchange3 is not present + if (ee3Mod == null) + { + return; + } + + EE3Wrapper.ee3mod.getGlyphRegistry().addGlyph(glyph); + } + + private static class EE3Wrapper + { + private static EquivalentExchange3 ee3mod; + } + + private static void init() + { + if (ee3Mod != null) + { + EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod; + } + } +} diff --git a/src/main/java/com/pahimar/ee3/api/SkillRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/SkillRegistryProxy.java index 1eaebc2f..6f24bc70 100644 --- a/src/main/java/com/pahimar/ee3/api/SkillRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/SkillRegistryProxy.java @@ -74,7 +74,7 @@ public final class SkillRegistryProxy return false; } - return EE3Wrapper.ee3mod.getSkillRegistry().isLearnable(itemStack); + return EE3Wrapper.ee3mod.getSkillRegistry().canBeLearned(itemStack); } public static boolean isRecoverable(Block block) diff --git a/src/main/java/com/pahimar/ee3/array/AbstractGlyph.java b/src/main/java/com/pahimar/ee3/array/AbstractGlyph.java deleted file mode 100644 index e7016cbc..00000000 --- a/src/main/java/com/pahimar/ee3/array/AbstractGlyph.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pahimar.ee3.array; - -import net.minecraft.util.ResourceLocation; - -public abstract class AbstractGlyph -{ - public abstract String getUnlocalizedName(); - - public abstract ResourceLocation getResourceLocation(); -} diff --git a/src/main/java/com/pahimar/ee3/array/Glyph.java b/src/main/java/com/pahimar/ee3/array/Glyph.java deleted file mode 100644 index 56b02f58..00000000 --- a/src/main/java/com/pahimar/ee3/array/Glyph.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.pahimar.ee3.array; - -import com.pahimar.ee3.util.ResourceLocationHelper; -import net.minecraft.util.ResourceLocation; - -public class Glyph -{ - private final ResourceLocation texture; - private final int size; - - public Glyph(String texture) - { - this(texture, 1); - } - - public Glyph(String texture, int size) - { - this(ResourceLocationHelper.getResourceLocation(texture), size); - } - - public Glyph(ResourceLocation texture, int size) - { - this.texture = texture; - this.size = size; - } - - public ResourceLocation getTexture() - { - return texture; - } - - public int getSize() - { - return size; - } - - @Override - public boolean equals(Object object) - { - if (object instanceof Glyph) - { - return this.texture.equals(((Glyph) object).getTexture()) && this.size == ((Glyph) object).size; - } - - return false; - } -} diff --git a/src/main/java/com/pahimar/ee3/array/GlyphRegistry.java b/src/main/java/com/pahimar/ee3/array/GlyphRegistry.java new file mode 100644 index 00000000..e4ce93ea --- /dev/null +++ b/src/main/java/com/pahimar/ee3/array/GlyphRegistry.java @@ -0,0 +1,44 @@ +package com.pahimar.ee3.array; + +import com.google.common.collect.ImmutableSet; +import com.pahimar.ee3.api.Glyph; + +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +public class GlyphRegistry +{ + private static GlyphRegistry glyphRegistry = null; + private SortedSet glyphSortedSet; + + private GlyphRegistry() + { + } + + public static GlyphRegistry getInstance() + { + if (glyphRegistry == null) + { + glyphRegistry = new GlyphRegistry(); + glyphRegistry.init(); + } + + return glyphRegistry; + } + + private void init() + { + glyphSortedSet = new TreeSet(); + } + + public void addGlyph(Glyph glyph) + { + glyphSortedSet.add(new Glyph(glyph, 1)); + } + + public Set getGlyphs() + { + return ImmutableSet.copyOf(glyphSortedSet); + } +} diff --git a/src/main/java/com/pahimar/ee3/array/Symbols.java b/src/main/java/com/pahimar/ee3/array/Symbols.java deleted file mode 100644 index 07ea2c3c..00000000 --- a/src/main/java/com/pahimar/ee3/array/Symbols.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.pahimar.ee3.array; - -public class Symbols -{ - private static final String SYMBOL_TEXTURE_LOCATION = "textures/array/"; - - public static final Glyph BASE_CIRCLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transBaseCircle.png"); - public static final Glyph DOT = new Glyph(SYMBOL_TEXTURE_LOCATION + "transDot.png"); - public static final Glyph LINE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transLine.png"); - public static final Glyph CIRCLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transCircle.png"); - public static final Glyph TRIANGLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transTriangle.png"); - public static final Glyph INVERTED_TRIANGLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transInvertedTriangle.png"); - public static final Glyph SQUARE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transSquare.png"); - public static final Glyph DIAMOND = new Glyph(SYMBOL_TEXTURE_LOCATION + "transDiamond.png"); - public static final Glyph PENTAGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transPentagon.png"); - public static final Glyph HEXAGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transHexagon.png"); - public static final Glyph HEPTGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transHeptagon.png"); - public static final Glyph OCTAGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transOctagon.png"); -} diff --git a/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java b/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java index 2c4cd143..e1fb3f5a 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java @@ -5,6 +5,8 @@ import com.pahimar.ee3.reference.RenderIds; import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; @@ -49,6 +51,16 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider return new TileEntityAlchemyArray(); } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) + { + super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack); + if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) + { + // TODO: Place the first glyph of the alchemy array from the player's currently selected glyph + } + } + @Override public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) { diff --git a/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java b/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java index a1f9a993..e830d298 100644 --- a/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java +++ b/src/main/java/com/pahimar/ee3/client/handler/DrawBlockHighlightEventHandler.java @@ -47,6 +47,10 @@ public class DrawBlockHighlightEventHandler { drawSelectionBoxForHoe(event, (IModalTool) event.currentItem.getItem()); } + else if (event.currentItem.getItem() instanceof ItemChalk) + { + + } } } } diff --git a/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java b/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java new file mode 100644 index 00000000..73373b27 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/client/handler/HUDTickHandler.java @@ -0,0 +1,74 @@ +package com.pahimar.ee3.client.handler; + +import com.pahimar.ee3.client.util.RenderUtils; +import com.pahimar.ee3.util.IOverlayItem; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +@SideOnly(Side.CLIENT) +public class HUDTickHandler +{ + @SubscribeEvent + public void renderTick(TickEvent.RenderTickEvent event) + { + if (event.phase == TickEvent.Phase.END) + { + Minecraft minecraft = FMLClientHandler.instance().getClient(); + EntityPlayer entityPlayer = minecraft.thePlayer; + + if (entityPlayer != null) + { + ItemStack currentItemStack = entityPlayer.inventory.getCurrentItem(); + if (Minecraft.isGuiEnabled() && minecraft.inGameHasFocus) + { + if (currentItemStack != null && currentItemStack.getItem() instanceof IOverlayItem) + { + renderHUDOverlayItem(minecraft, entityPlayer, currentItemStack); + } + } + } + } + } + + private static void renderHUDOverlayItem(Minecraft minecraft, EntityPlayer entityPlayer, ItemStack itemStack) + { + float overlayScale = 2f; + float overlayOpacity = 1f; + GL11.glPushMatrix(); + ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight); + GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); + GL11.glMatrixMode(GL11.GL_PROJECTION); + GL11.glLoadIdentity(); + GL11.glOrtho(0.0D, sr.getScaledWidth_double(), sr.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); + GL11.glMatrixMode(GL11.GL_MODELVIEW); + GL11.glLoadIdentity(); + GL11.glTranslatef(0.0F, 0.0F, -2000.0F); + GL11.glPushMatrix(); + RenderHelper.enableGUIStandardItemLighting(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glEnable(GL11.GL_COLOR_MATERIAL); + GL11.glEnable(GL11.GL_LIGHTING); + int hudOverlayX = 0; + int hudOverlayY = 0; + + hudOverlayX = (int) (sr.getScaledWidth() - 16 * overlayScale); + hudOverlayY = (int) (sr.getScaledHeight() - 16 * overlayScale); + + RenderUtils.renderItemIntoGUI(minecraft.fontRenderer, itemStack, hudOverlayX, hudOverlayY, overlayOpacity, overlayScale); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java index 75f93b72..93d4e917 100644 --- a/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/client/renderer/tileentity/TileEntityRendererAlchemyArray.java @@ -1,7 +1,8 @@ package com.pahimar.ee3.client.renderer.tileentity; -import com.pahimar.ee3.array.Glyph; +import com.pahimar.ee3.api.Glyph; import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.Tessellator; @@ -17,12 +18,12 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer { if (tileEntity instanceof TileEntityAlchemyArray) { - TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) tileEntity; + TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glPushMatrix(); - for (Glyph glyph : tileEntityAlchemyArray.getGlyphs()) + for (Glyph glyph : tileEntityAlchemyArray.getAlchemyArray().getGlyphs()) { this.bindTexture(glyph.getTexture()); renderSymbol(glyph, x, y, z); diff --git a/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java b/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java new file mode 100644 index 00000000..3dd43709 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/client/util/RenderUtils.java @@ -0,0 +1,37 @@ +package com.pahimar.ee3.client.util; + +import cpw.mods.fml.client.FMLClientHandler; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import org.lwjgl.opengl.GL11; + +public class RenderUtils +{ + public static void renderItemIntoGUI(FontRenderer fontRenderer, ItemStack itemStack, int x, int y, float opacity, float scale) + { + IIcon icon = itemStack.getIconIndex(); + GL11.glDisable(GL11.GL_LIGHTING); + FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.locationItemsTexture); + int overlayColour = itemStack.getItem().getColorFromItemStack(itemStack, 0); + float red = (overlayColour >> 16 & 255) / 255.0F; + float green = (overlayColour >> 8 & 255) / 255.0F; + float blue = (overlayColour & 255) / 255.0F; + GL11.glColor4f(red, green, blue, opacity); + drawTexturedQuad(x, y, icon, 16 * scale, 16 * scale, -90); + GL11.glEnable(GL11.GL_LIGHTING); + } + + public static void drawTexturedQuad(int x, int y, IIcon icon, float width, float height, double zLevel) + { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getMaxV()); + tessellator.addVertexWithUV(x + width, y + height, zLevel, icon.getMaxU(), icon.getMaxV()); + tessellator.addVertexWithUV(x + width, y, zLevel, icon.getMaxU(), icon.getMinV()); + tessellator.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV()); + tessellator.draw(); + } +} diff --git a/src/main/java/com/pahimar/ee3/init/Glyphs.java b/src/main/java/com/pahimar/ee3/init/Glyphs.java new file mode 100644 index 00000000..ac44f822 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/init/Glyphs.java @@ -0,0 +1,38 @@ +package com.pahimar.ee3.init; + +import com.pahimar.ee3.api.Glyph; +import com.pahimar.ee3.api.GlyphRegistryProxy; + +public class Glyphs +{ + private static final String SYMBOL_TEXTURE_LOCATION = "textures/array/"; + + public static final Glyph BASE_CIRCLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transBaseCircle.png", ""); + public static final Glyph DOT = new Glyph(SYMBOL_TEXTURE_LOCATION + "transDot.png", ""); + public static final Glyph LINE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transLine.png", ""); + public static final Glyph CIRCLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transCircle.png", ""); + public static final Glyph TRIANGLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transTriangle.png", ""); + public static final Glyph INVERTED_TRIANGLE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transInvertedTriangle.png", ""); + public static final Glyph SQUARE = new Glyph(SYMBOL_TEXTURE_LOCATION + "transSquare.png", ""); + public static final Glyph DIAMOND = new Glyph(SYMBOL_TEXTURE_LOCATION + "transDiamond.png", ""); + public static final Glyph PENTAGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transPentagon.png", ""); + public static final Glyph HEXAGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transHexagon.png", ""); + public static final Glyph HEPTGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transHeptagon.png", ""); + public static final Glyph OCTAGON = new Glyph(SYMBOL_TEXTURE_LOCATION + "transOctagon.png", ""); + + public static void init() + { + GlyphRegistryProxy.addGlyph(BASE_CIRCLE); + GlyphRegistryProxy.addGlyph(DOT); + GlyphRegistryProxy.addGlyph(LINE); + GlyphRegistryProxy.addGlyph(CIRCLE); + GlyphRegistryProxy.addGlyph(TRIANGLE); + GlyphRegistryProxy.addGlyph(INVERTED_TRIANGLE); + GlyphRegistryProxy.addGlyph(SQUARE); + GlyphRegistryProxy.addGlyph(DIAMOND); + GlyphRegistryProxy.addGlyph(PENTAGON); + GlyphRegistryProxy.addGlyph(HEXAGON); + GlyphRegistryProxy.addGlyph(HEPTGON); + GlyphRegistryProxy.addGlyph(OCTAGON); + } +} diff --git a/src/main/java/com/pahimar/ee3/item/ItemChalk.java b/src/main/java/com/pahimar/ee3/item/ItemChalk.java index b4f416bb..993f6cde 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemChalk.java +++ b/src/main/java/com/pahimar/ee3/item/ItemChalk.java @@ -5,12 +5,13 @@ import com.pahimar.ee3.init.ModBlocks; import com.pahimar.ee3.reference.GUIs; import com.pahimar.ee3.reference.Key; import com.pahimar.ee3.reference.Names; -import com.pahimar.ee3.util.IKeyBound; +import com.pahimar.ee3.reference.Sounds; +import com.pahimar.ee3.util.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class ItemChalk extends ItemEE implements IKeyBound +public class ItemChalk extends ItemEE implements IKeyBound, IChargeable, IOverlayItem { public ItemChalk() { @@ -24,15 +25,6 @@ public class ItemChalk extends ItemEE implements IKeyBound return true; } - @Override - public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) - { - if (key == Key.TOGGLE) - { - entityPlayer.openGui(EquivalentExchange3.instance, GUIs.SYMBOL_SELECTION.ordinal(), entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ); - } - } - /** * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return * True if something happen and false if it don't. This is for ITEMS, not BLOCKS @@ -102,4 +94,79 @@ public class ItemChalk extends ItemEE implements IKeyBound return true; } + + @Override + public void doKeyBindingAction(EntityPlayer entityPlayer, ItemStack itemStack, Key key) + { + if (key == Key.CHARGE) + { + if (!entityPlayer.isSneaking()) + { + if (getChargeLevel(itemStack) == this.getMaxChargeLevel()) + { + NetworkSoundHelper.playSoundAt(entityPlayer, Sounds.FAIL, 1.5f, 1.5f); + } + else + { + increaseChargeLevel(itemStack); + NetworkSoundHelper.playSoundAt(entityPlayer, Sounds.CHARGE_UP, 0.5F, 0.5F + 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel())); + } + } + else + { + if (getChargeLevel(itemStack) == 0) + { + NetworkSoundHelper.playSoundAt(entityPlayer, Sounds.FAIL, 1.5f, 1.5f); + } + else + { + decreaseChargeLevel(itemStack); + NetworkSoundHelper.playSoundAt(entityPlayer, Sounds.CHARGE_DOWN, 0.5F, 1.0F - (0.5F - 0.5F * (getChargeLevel(itemStack) * 1.0F / this.getMaxChargeLevel()))); + } + } + } + else if (key == Key.TOGGLE) + { + entityPlayer.openGui(EquivalentExchange3.instance, GUIs.SYMBOL_SELECTION.ordinal(), entityPlayer.worldObj, (int) entityPlayer.posX, (int) entityPlayer.posY, (int) entityPlayer.posZ); + } + } + + @Override + public short getMaxChargeLevel() + { + return 6; + } + + @Override + public short getChargeLevel(ItemStack itemStack) + { + return NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL); + } + + @Override + public void setChargeLevel(ItemStack itemStack, short chargeLevel) + { + if (chargeLevel <= this.getMaxChargeLevel()) + { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, chargeLevel); + } + } + + @Override + public void increaseChargeLevel(ItemStack itemStack) + { + if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) < this.getMaxChargeLevel()) + { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) + 1)); + } + } + + @Override + public void decreaseChargeLevel(ItemStack itemStack) + { + if (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) > 0) + { + NBTHelper.setShort(itemStack, Names.NBT.CHARGE_LEVEL, (short) (NBTHelper.getShort(itemStack, Names.NBT.CHARGE_LEVEL) - 1)); + } + } } \ No newline at end of file diff --git a/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java b/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java index a6e43012..6e63c1d5 100644 --- a/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java +++ b/src/main/java/com/pahimar/ee3/item/ItemPhilosophersStone.java @@ -3,11 +3,12 @@ package com.pahimar.ee3.item; import com.pahimar.ee3.reference.Key; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.util.IKeyBound; +import com.pahimar.ee3.util.IOverlayItem; import com.pahimar.ee3.util.LogHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public class ItemPhilosophersStone extends ItemEE implements IKeyBound +public class ItemPhilosophersStone extends ItemEE implements IKeyBound, IOverlayItem { private int maxChargeLevel; diff --git a/src/main/java/com/pahimar/ee3/network/PacketHandler.java b/src/main/java/com/pahimar/ee3/network/PacketHandler.java index 03b0faeb..cf1f1c88 100644 --- a/src/main/java/com/pahimar/ee3/network/PacketHandler.java +++ b/src/main/java/com/pahimar/ee3/network/PacketHandler.java @@ -20,5 +20,6 @@ public class PacketHandler INSTANCE.registerMessage(MessageSoundEvent.class, MessageSoundEvent.class, 5, Side.CLIENT); INSTANCE.registerMessage(MessageSyncEnergyValues.class, MessageSyncEnergyValues.class, 6, Side.CLIENT); INSTANCE.registerMessage(MessageSetEnergyValue.class, MessageSetEnergyValue.class, 7, Side.CLIENT); + INSTANCE.registerMessage(MessageTileEntityAlchemyArray.class, MessageTileEntityAlchemyArray.class, 8, Side.CLIENT); } } diff --git a/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAlchemyArray.java b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAlchemyArray.java new file mode 100644 index 00000000..2d5002e7 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/network/message/MessageTileEntityAlchemyArray.java @@ -0,0 +1,118 @@ +package com.pahimar.ee3.network.message; + +import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +public class MessageTileEntityAlchemyArray implements IMessage, IMessageHandler +{ + public NBTTagCompound tileEntityAlchemyArrayNBT; + + public MessageTileEntityAlchemyArray() + { + } + + public MessageTileEntityAlchemyArray(TileEntityAlchemyArray tileEntityAlchemyArray) + { + tileEntityAlchemyArrayNBT = new NBTTagCompound(); + tileEntityAlchemyArray.writeToNBT(tileEntityAlchemyArrayNBT); + } + + /** + * Convert from the supplied buffer into your specific message type + * + * @param buf + */ + @Override + public void fromBytes(ByteBuf buf) + { + byte[] compressedNBT = null; + int readableBytes = buf.readInt(); + + if (readableBytes > 0) + { + compressedNBT = buf.readBytes(readableBytes).array(); + } + + if (compressedNBT != null) + { + try + { + this.tileEntityAlchemyArrayNBT = CompressedStreamTools.readCompressed(new ByteArrayInputStream(compressedNBT)); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + } + + /** + * Deconstruct your message into the supplied byte buffer + * + * @param buf + */ + @Override + public void toBytes(ByteBuf buf) + { + byte[] compressedNBT = null; + + try + { + if (tileEntityAlchemyArrayNBT != null) + { + compressedNBT = CompressedStreamTools.compress(tileEntityAlchemyArrayNBT); + } + } + catch (IOException e) + { + e.printStackTrace(); + } + + if (compressedNBT != null) + { + buf.writeInt(compressedNBT.length); + buf.writeBytes(compressedNBT); + } + else + { + buf.writeInt(0); + } + } + + /** + * Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply + * is needed. + * + * @param message The message + * @param ctx + * @return an optional return message + */ + @Override + public IMessage onMessage(MessageTileEntityAlchemyArray message, MessageContext ctx) + { + if (message.tileEntityAlchemyArrayNBT != null) + { + TileEntityAlchemyArray tileEntityAlchemyArray = new TileEntityAlchemyArray(); + tileEntityAlchemyArray.readFromNBT(message.tileEntityAlchemyArrayNBT); + + TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntityAlchemyArray.xCoord, tileEntityAlchemyArray.yCoord, tileEntityAlchemyArray.zCoord); + + if (tileEntity instanceof TileEntityAlchemyArray) + { + ((TileEntityAlchemyArray) tileEntity).readFromNBT(message.tileEntityAlchemyArrayNBT); + } + } + + return null; + } +} diff --git a/src/main/java/com/pahimar/ee3/proxy/ClientProxy.java b/src/main/java/com/pahimar/ee3/proxy/ClientProxy.java index 5b988b1e..483780ad 100644 --- a/src/main/java/com/pahimar/ee3/proxy/ClientProxy.java +++ b/src/main/java/com/pahimar/ee3/proxy/ClientProxy.java @@ -1,6 +1,7 @@ package com.pahimar.ee3.proxy; import com.pahimar.ee3.client.handler.DrawBlockHighlightEventHandler; +import com.pahimar.ee3.client.handler.HUDTickHandler; import com.pahimar.ee3.client.handler.ItemTooltipEventHandler; import com.pahimar.ee3.client.handler.KeyInputEventHandler; import com.pahimar.ee3.client.renderer.item.*; @@ -24,6 +25,7 @@ public class ClientProxy extends CommonProxy { super.registerEventHandlers(); FMLCommonHandler.instance().bus().register(new KeyInputEventHandler()); + FMLCommonHandler.instance().bus().register(new HUDTickHandler()); MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler()); MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightEventHandler()); } diff --git a/src/main/java/com/pahimar/ee3/skill/Skill.java b/src/main/java/com/pahimar/ee3/skill/Skill.java index db3f01ae..5726772c 100644 --- a/src/main/java/com/pahimar/ee3/skill/Skill.java +++ b/src/main/java/com/pahimar/ee3/skill/Skill.java @@ -2,7 +2,7 @@ package com.pahimar.ee3.skill; public class Skill { - private final boolean learnable; + private final boolean canBeLearned; private final boolean recoverable; private final int knowledgeTier; @@ -11,14 +11,14 @@ public class Skill this(true, true, 0); } - public Skill(boolean learnable, boolean recoverable) + public Skill(boolean canBeLearned, boolean recoverable) { - this(learnable, recoverable, 0); + this(canBeLearned, recoverable, 0); } - public Skill(boolean learnable, boolean recoverable, int tier) + public Skill(boolean canBeLearned, boolean recoverable, int tier) { - this.learnable = learnable; + this.canBeLearned = canBeLearned; this.recoverable = recoverable; if (tier >= 0) @@ -31,9 +31,9 @@ public class Skill } } - public boolean isLearnable() + public boolean canBeLearned() { - return learnable; + return canBeLearned; } public boolean isRecoverable() @@ -49,12 +49,12 @@ public class Skill @Override public boolean equals(Object object) { - return object instanceof Skill && (this.learnable == ((Skill) object).learnable && this.recoverable == ((Skill) object).recoverable && this.knowledgeTier == ((Skill) object).knowledgeTier); + return object instanceof Skill && (this.canBeLearned == ((Skill) object).canBeLearned && this.recoverable == ((Skill) object).recoverable && this.knowledgeTier == ((Skill) object).knowledgeTier); } @Override public String toString() { - return String.format("Skill[learnable: %s, recoverable: %s, knowledgeTier: %s]", learnable, recoverable, knowledgeTier); + return String.format("Skill[canBeLearned: %s, recoverable: %s, knowledgeTier: %s]", canBeLearned, recoverable, knowledgeTier); } } diff --git a/src/main/java/com/pahimar/ee3/skill/SkillRegistry.java b/src/main/java/com/pahimar/ee3/skill/SkillRegistry.java index 402900b0..a416de2b 100644 --- a/src/main/java/com/pahimar/ee3/skill/SkillRegistry.java +++ b/src/main/java/com/pahimar/ee3/skill/SkillRegistry.java @@ -63,14 +63,14 @@ public class SkillRegistry return skillMap.containsKey(unitItemStack); } - public boolean isLearnable(ItemStack itemStack) + public boolean canBeLearned(ItemStack itemStack) { ItemStack unitItemStack = itemStack.copy(); unitItemStack.stackSize = 1; if (skillMap.containsKey(unitItemStack)) { - return skillMap.get(unitItemStack).isLearnable(); + return skillMap.get(unitItemStack).canBeLearned(); } return false; @@ -88,7 +88,7 @@ public class SkillRegistry { if (SkillRegistry.getInstance().hasSkillMapping(itemStack)) { - return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().isLearnable(itemStack); + return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().canBeLearned(itemStack); } else { @@ -97,19 +97,19 @@ public class SkillRegistry } else if (Settings.Transmutation.knowledgeMode.equalsIgnoreCase("Select")) { - return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().isLearnable(itemStack); + return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().canBeLearned(itemStack); } else if (Settings.Transmutation.knowledgeMode.equalsIgnoreCase("Tier")) { int itemStackKnowledgeTier = SkillRegistry.getInstance().getKnowledgeTier(itemStack); - return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().isLearnable(itemStack) && itemStackKnowledgeTier >= 0 && itemStackKnowledgeTier <= Settings.Transmutation.maxKnowledgeTier; + return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().canBeLearned(itemStack) && itemStackKnowledgeTier >= 0 && itemStackKnowledgeTier <= Settings.Transmutation.maxKnowledgeTier; } else if (Settings.Transmutation.knowledgeMode.equalsIgnoreCase("Restricted")) { PlayerKnowledge allowedKnowledge = PlayerKnowledgeHandler.getAllowedPlayerKnowledge(); - return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().isLearnable(itemStack) && allowedKnowledge.isItemStackKnown(itemStack); + return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && SkillRegistry.getInstance().canBeLearned(itemStack) && allowedKnowledge.isItemStackKnown(itemStack); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java index 86c615ef..d1128591 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemicalChest.java @@ -56,25 +56,6 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor } } - @Override - public void readFromNBT(NBTTagCompound nbtTagCompound) - { - super.readFromNBT(nbtTagCompound); - - // Read in the ItemStacks in the inventory from NBT - NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); - inventory = new ItemStack[this.getSizeInventory()]; - for (int i = 0; i < tagList.tagCount(); ++i) - { - NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < inventory.length) - { - inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } - @Override public int getSizeInventory() { @@ -188,26 +169,6 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor return true; } - @Override - public void writeToNBT(NBTTagCompound nbtTagCompound) - { - super.writeToNBT(nbtTagCompound); - - // Write the ItemStacks in the inventory to NBT - NBTTagList tagList = new NBTTagList(); - for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) - { - if (inventory[currentIndex] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte) currentIndex); - inventory[currentIndex].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - nbtTagCompound.setTag(Names.NBT.ITEMS, tagList); - } - /** * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count * ticks and creates a new spawn inside its implementation. @@ -281,4 +242,43 @@ public class TileEntityAlchemicalChest extends TileEntityEE implements IInventor return super.receiveClientEvent(eventID, numUsingPlayers); } } + + @Override + public void readFromNBT(NBTTagCompound nbtTagCompound) + { + super.readFromNBT(nbtTagCompound); + + // Read in the ItemStacks in the inventory from NBT + NBTTagList tagList = nbtTagCompound.getTagList(Names.NBT.ITEMS, 10); + inventory = new ItemStack[this.getSizeInventory()]; + for (int i = 0; i < tagList.tagCount(); ++i) + { + NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); + byte slotIndex = tagCompound.getByte("Slot"); + if (slotIndex >= 0 && slotIndex < inventory.length) + { + inventory[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTagCompound) + { + super.writeToNBT(nbtTagCompound); + + // Write the ItemStacks in the inventory to NBT + NBTTagList tagList = new NBTTagList(); + for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) + { + if (inventory[currentIndex] != null) + { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) currentIndex); + inventory[currentIndex].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + nbtTagCompound.setTag(Names.NBT.ITEMS, tagList); + } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java index b811504b..39733861 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java @@ -1,41 +1,70 @@ package com.pahimar.ee3.tileentity; -import com.pahimar.ee3.array.Glyph; -import com.pahimar.ee3.array.Symbols; +import com.pahimar.ee3.api.AlchemyArray; +import com.pahimar.ee3.api.Glyph; +import com.pahimar.ee3.network.PacketHandler; +import com.pahimar.ee3.network.message.MessageTileEntityAlchemyArray; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; import net.minecraft.util.AxisAlignedBB; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class TileEntityAlchemyArray extends TileEntityEE { - private List glyphs; - private int largestSymbolSize; + private AlchemyArray alchemyArray; public TileEntityAlchemyArray() { super(); - glyphs = new ArrayList(Arrays.asList(Symbols.BASE_CIRCLE, Symbols.TRIANGLE)); - this.largestSymbolSize = 1; + alchemyArray = new AlchemyArray(); } - public List getGlyphs() + public AlchemyArray getAlchemyArray() { - return glyphs; + return alchemyArray; } - public int getLargestSymbolSize() + public void addGlyphToAlchemyArray(Glyph glyph) { - return largestSymbolSize; + alchemyArray.addGlyph(glyph); + } + + public void addGlyphToAlchemyArray(Glyph glyph, int size) + { + alchemyArray.addGlyph(new Glyph(glyph, size)); } @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord - largestSymbolSize, yCoord, zCoord - largestSymbolSize, xCoord + largestSymbolSize, yCoord, zCoord + largestSymbolSize); + return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord, zCoord - alchemyArray.getLargestGlyphSize(), xCoord + alchemyArray.getLargestGlyphSize(), yCoord, zCoord + alchemyArray.getLargestGlyphSize()); + } + + @Override + public Packet getDescriptionPacket() + { + return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this)); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTagCompound) + { + super.readFromNBT(nbtTagCompound); + + NBTTagCompound alchemyArrayTagCompound = nbtTagCompound.getCompoundTag("alchemyArray"); + alchemyArray = AlchemyArray.readAlchemyArrayFromNBT(alchemyArrayTagCompound); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTagCompound) + { + super.writeToNBT(nbtTagCompound); + + NBTTagCompound alchemyArrayTagCompound = new NBTTagCompound(); + alchemyArray.writeToNBT(alchemyArrayTagCompound); + + nbtTagCompound.setTag("alchemyArray", alchemyArrayTagCompound); } } diff --git a/src/main/java/com/pahimar/ee3/util/IOverlayItem.java b/src/main/java/com/pahimar/ee3/util/IOverlayItem.java new file mode 100644 index 00000000..0175f96e --- /dev/null +++ b/src/main/java/com/pahimar/ee3/util/IOverlayItem.java @@ -0,0 +1,5 @@ +package com.pahimar.ee3.util; + +public interface IOverlayItem +{ +} diff --git a/src/main/java/com/pahimar/ee3/util/PlayerKnowledgeHelper.java b/src/main/java/com/pahimar/ee3/util/PlayerKnowledgeHelper.java index 97384d08..36aa4e0f 100644 --- a/src/main/java/com/pahimar/ee3/util/PlayerKnowledgeHelper.java +++ b/src/main/java/com/pahimar/ee3/util/PlayerKnowledgeHelper.java @@ -37,7 +37,7 @@ public class PlayerKnowledgeHelper { return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && !playerKnowledge.isItemStackKnown(itemStack) - && SkillRegistry.getInstance().isLearnable(itemStack); + && SkillRegistry.getInstance().canBeLearned(itemStack); } else { @@ -49,7 +49,7 @@ public class PlayerKnowledgeHelper { return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && !playerKnowledge.isItemStackKnown(itemStack) - && SkillRegistry.getInstance().isLearnable(itemStack); + && SkillRegistry.getInstance().canBeLearned(itemStack); } else if (Settings.Transmutation.knowledgeMode.equalsIgnoreCase("Tier")) { @@ -57,7 +57,7 @@ public class PlayerKnowledgeHelper return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && !playerKnowledge.isItemStackKnown(itemStack) - && SkillRegistry.getInstance().isLearnable(itemStack) + && SkillRegistry.getInstance().canBeLearned(itemStack) && itemStackKnowledgeTier >= 0 && itemStackKnowledgeTier <= Settings.Transmutation.maxKnowledgeTier; } else if (Settings.Transmutation.knowledgeMode.equalsIgnoreCase("Restricted")) @@ -66,7 +66,7 @@ public class PlayerKnowledgeHelper return EnergyValueRegistry.getInstance().hasEnergyValue(itemStack) && !playerKnowledge.isItemStackKnown(itemStack) - && SkillRegistry.getInstance().isLearnable(itemStack) + && SkillRegistry.getInstance().canBeLearned(itemStack) && allowedKnowledge.isItemStackKnown(itemStack); } } diff --git a/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java b/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java index cde60bd0..c0deea83 100644 --- a/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java +++ b/src/main/java/com/pahimar/ee3/waila/WailaDataProvider.java @@ -20,6 +20,8 @@ public class WailaDataProvider implements IWailaDataProvider @Override public List getWailaHead(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + currentTip.set(0, "Something else"); + return currentTip; }