From 6e727a5a7f6952a4eac20a21b501186fbc0d8ba2 Mon Sep 17 00:00:00 2001 From: Pahimar Date: Tue, 7 Oct 2014 16:20:41 -0400 Subject: [PATCH] More glyph work --- build.properties | 2 +- .../com/pahimar/ee3/EquivalentExchange3.java | 6 +- .../com/pahimar/ee3/api/AlchemyArray.java | 34 +++++++- src/main/java/com/pahimar/ee3/api/Glyph.java | 85 ++++++++++++++----- ...xy.java => GlyphTextureRegistryProxy.java} | 7 +- .../com/pahimar/ee3/array/GlyphRegistry.java | 44 ---------- .../ee3/array/GlyphTextureRegistry.java | 73 ++++++++++++++++ .../pahimar/ee3/block/BlockAlchemyArray.java | 11 ++- .../TileEntityRendererAlchemyArray.java | 62 ++++++++++++-- .../ee3/handler/PlayerEventHandler.java | 33 ++++++- .../java/com/pahimar/ee3/init/Glyphs.java | 26 +++--- .../tileentity/TileEntityAlchemyArray.java | 8 +- .../com/pahimar/ee3/util/EntityHelper.java | 26 ++++++ 13 files changed, 320 insertions(+), 97 deletions(-) rename src/main/java/com/pahimar/ee3/api/{GlyphRegistryProxy.java => GlyphTextureRegistryProxy.java} (69%) delete mode 100644 src/main/java/com/pahimar/ee3/array/GlyphRegistry.java create mode 100644 src/main/java/com/pahimar/ee3/array/GlyphTextureRegistry.java create mode 100644 src/main/java/com/pahimar/ee3/util/EntityHelper.java diff --git a/build.properties b/build.properties index 6fad51f7..4210ef89 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ # #Sat Dec 28 00:14:08 EST 2013 minecraft_version = 1.7.10 -forge_version = 10.13.1.1217 +forge_version = 10.13.1.1222 mod_version = 0.2 diff --git a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java index 756bc9d1..01504f68 100644 --- a/src/main/java/com/pahimar/ee3/EquivalentExchange3.java +++ b/src/main/java/com/pahimar/ee3/EquivalentExchange3.java @@ -1,6 +1,6 @@ package com.pahimar.ee3; -import com.pahimar.ee3.array.GlyphRegistry; +import com.pahimar.ee3.array.GlyphTextureRegistry; import com.pahimar.ee3.command.CommandSetCurrentItemValue; import com.pahimar.ee3.command.CommandSetValue; import com.pahimar.ee3.command.CommandSyncValues; @@ -145,8 +145,8 @@ public class EquivalentExchange3 return SkillRegistry.getInstance(); } - public GlyphRegistry getGlyphRegistry() + public GlyphTextureRegistry getGlyphRegistry() { - return GlyphRegistry.getInstance(); + return GlyphTextureRegistry.getInstance(); } } diff --git a/src/main/java/com/pahimar/ee3/api/AlchemyArray.java b/src/main/java/com/pahimar/ee3/api/AlchemyArray.java index 37b9d819..d3bc8101 100644 --- a/src/main/java/com/pahimar/ee3/api/AlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/api/AlchemyArray.java @@ -9,7 +9,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -public class AlchemyArray +public class AlchemyArray implements Comparable { private SortedSet glyphs; private int largestGlyphSize; @@ -130,4 +130,36 @@ public class AlchemyArray return stringBuilder.toString(); } + + @Override + public boolean equals(Object object) + { + if (object instanceof AlchemyArray) + { + return this.compareTo((AlchemyArray) object) == 0; + } + + return false; + } + + @Override + public int compareTo(AlchemyArray alchemyArray) + { + if (this.glyphs.size() == alchemyArray.glyphs.size()) + { + for (Glyph glyph : this.glyphs) + { + if (!alchemyArray.glyphs.contains(glyph)) + { + return -1; + } + } + + return 0; + } + else + { + return this.glyphs.size() - alchemyArray.glyphs.size(); + } + } } diff --git a/src/main/java/com/pahimar/ee3/api/Glyph.java b/src/main/java/com/pahimar/ee3/api/Glyph.java index afe5de2f..74564654 100644 --- a/src/main/java/com/pahimar/ee3/api/Glyph.java +++ b/src/main/java/com/pahimar/ee3/api/Glyph.java @@ -1,6 +1,5 @@ package com.pahimar.ee3.api; -import com.pahimar.ee3.util.ResourceLocationHelper; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; @@ -9,6 +8,7 @@ public class Glyph implements Comparable private ResourceLocation texture; private String unLocalizedName; private int size; + private int rotation; private Glyph() { @@ -20,28 +20,27 @@ public class Glyph implements Comparable this(texture, unLocalizedName, 1); } - 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, unLocalizedName, size, 0); + } + + public Glyph(ResourceLocation texture, String unLocalizedName, int size, int rotation) { this.texture = texture; this.unLocalizedName = unLocalizedName; this.size = size; + this.rotation = rotation; } public Glyph(Glyph glyph, int size) { - this.texture = glyph.texture; - this.unLocalizedName = glyph.unLocalizedName; - this.size = size; + this(glyph, size, glyph.rotation); + } + + public Glyph(Glyph glyph, int size, int rotation) + { + this(glyph.texture, glyph.unLocalizedName, size, rotation); } public ResourceLocation getTexture() @@ -59,19 +58,57 @@ public class Glyph implements Comparable return size; } + public int getRotation() + { + return rotation; + } + public void readFromNBT(NBTTagCompound nbtTagCompound) { - if (nbtTagCompound != null && nbtTagCompound.hasKey("textureDomain") && nbtTagCompound.hasKey("texturePath") && nbtTagCompound.hasKey("unLocalizedName") && nbtTagCompound.hasKey("size")) + if (nbtTagCompound != null) { - this.texture = new ResourceLocation(nbtTagCompound.getString("textureDomain"), nbtTagCompound.getString("texturePath")); - this.unLocalizedName = nbtTagCompound.getString("unLocalizedName"); - this.size = nbtTagCompound.getInteger("size"); + if (nbtTagCompound.hasKey("textureDomain") && nbtTagCompound.hasKey("texturePath")) + { + this.texture = new ResourceLocation(nbtTagCompound.getString("textureDomain"), nbtTagCompound.getString("texturePath")); + } + else + { + this.texture = new ResourceLocation(""); + } + + if (nbtTagCompound.hasKey("unLocalizedName")) + { + this.unLocalizedName = nbtTagCompound.getString("unLocalizedName"); + } + else + { + this.unLocalizedName = ""; + } + + if (nbtTagCompound.hasKey("size")) + { + this.size = nbtTagCompound.getInteger("size"); + } + else + { + this.size = 0; + } + + if (nbtTagCompound.hasKey("rotation")) + { + this.rotation = nbtTagCompound.getInteger("rotation"); + } + else + { + this.rotation = 0; + } } else { this.texture = new ResourceLocation(""); this.unLocalizedName = ""; this.size = 0; + this.rotation = 0; } } @@ -81,6 +118,7 @@ public class Glyph implements Comparable nbtTagCompound.setString("texturePath", texture.getResourcePath()); nbtTagCompound.setString("unLocalizedName", unLocalizedName); nbtTagCompound.setInteger("size", size); + nbtTagCompound.setInteger("rotation", rotation); } public static Glyph readGlyphFromNBT(NBTTagCompound nbtTagCompound) @@ -93,7 +131,7 @@ public class Glyph implements Comparable @Override public String toString() { - return String.format("texture: %s, unLocalizedName: %s, size: %s", texture.getResourceDomain() + ":" + texture.getResourcePath(), unLocalizedName, size); + return String.format("texture: %s, unLocalizedName: %s, size: %s, orientation: %s", texture.getResourceDomain() + ":" + texture.getResourcePath(), unLocalizedName, size, rotation); } @Override @@ -114,7 +152,14 @@ public class Glyph implements Comparable { if (this.texture.getResourcePath().equalsIgnoreCase(glyph.getTexture().getResourcePath())) { - return this.size - glyph.size; + if (this.size == glyph.size) + { + return this.rotation - glyph.rotation; + } + else + { + return this.size - glyph.size; + } } else { diff --git a/src/main/java/com/pahimar/ee3/api/GlyphRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/GlyphTextureRegistryProxy.java similarity index 69% rename from src/main/java/com/pahimar/ee3/api/GlyphRegistryProxy.java rename to src/main/java/com/pahimar/ee3/api/GlyphTextureRegistryProxy.java index 89820f84..7e9e43a5 100644 --- a/src/main/java/com/pahimar/ee3/api/GlyphRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/GlyphTextureRegistryProxy.java @@ -2,13 +2,14 @@ package com.pahimar.ee3.api; import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; +import net.minecraft.util.ResourceLocation; -public class GlyphRegistryProxy +public class GlyphTextureRegistryProxy { @Mod.Instance("EE3") private static Object ee3Mod; - public static void addGlyph(Glyph glyph) + public static void addGlyph(ResourceLocation glyphTexture, String unLocalizedName) { init(); @@ -18,7 +19,7 @@ public class GlyphRegistryProxy return; } - EE3Wrapper.ee3mod.getGlyphRegistry().addGlyph(glyph); + EE3Wrapper.ee3mod.getGlyphRegistry().addGlyph(glyphTexture, unLocalizedName); } private static class EE3Wrapper diff --git a/src/main/java/com/pahimar/ee3/array/GlyphRegistry.java b/src/main/java/com/pahimar/ee3/array/GlyphRegistry.java deleted file mode 100644 index e4ce93ea..00000000 --- a/src/main/java/com/pahimar/ee3/array/GlyphRegistry.java +++ /dev/null @@ -1,44 +0,0 @@ -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/GlyphTextureRegistry.java b/src/main/java/com/pahimar/ee3/array/GlyphTextureRegistry.java new file mode 100644 index 00000000..a9ed0700 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/array/GlyphTextureRegistry.java @@ -0,0 +1,73 @@ +package com.pahimar.ee3.array; + +import com.google.common.collect.ImmutableMap; +import com.pahimar.ee3.api.Glyph; +import net.minecraft.util.ResourceLocation; + +import java.util.Comparator; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + +public class GlyphTextureRegistry +{ + private static GlyphTextureRegistry glyphTextureRegistry = null; + private SortedMap glyphTextureSortedMap; + + private GlyphTextureRegistry() + { + } + + public static GlyphTextureRegistry getInstance() + { + if (glyphTextureRegistry == null) + { + glyphTextureRegistry = new GlyphTextureRegistry(); + glyphTextureRegistry.init(); + } + + return glyphTextureRegistry; + } + + private void init() + { + glyphTextureSortedMap = new TreeMap(comparator); + } + + public void addGlyph(Glyph glyph) + { + if (glyph.getTexture() != null) + { + glyphTextureSortedMap.put(glyph.getTexture(), glyph.getUnLocalizedName()); + } + } + + public void addGlyph(ResourceLocation glyphTexture, String unLocalizedName) + { + if (glyphTexture != null) + { + glyphTextureSortedMap.put(glyphTexture, unLocalizedName); + } + } + + public Map getGlyphs() + { + return ImmutableMap.copyOf(glyphTextureSortedMap); + } + + private static Comparator comparator = new Comparator() + { + @Override + public int compare(ResourceLocation resourceLocation1, ResourceLocation resourceLocation2) + { + if (resourceLocation1.getResourceDomain().equalsIgnoreCase(resourceLocation2.getResourceDomain())) + { + return resourceLocation1.getResourcePath().compareToIgnoreCase(resourceLocation2.getResourcePath()); + } + else + { + return resourceLocation1.getResourceDomain().compareToIgnoreCase(resourceLocation2.getResourceDomain()); + } + } + }; +} diff --git a/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java b/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java index 470a051e..e6f04b64 100644 --- a/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/block/BlockAlchemyArray.java @@ -11,6 +11,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; @@ -57,11 +58,17 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { + int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { // TODO: Place the first glyph of the alchemy glyphs from the player's currently selected glyph - ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.BASE_CIRCLE, 3); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.BASE_CIRCLE, 3, facing); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.BASE_CIRCLE, 2, facing); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.BASE_CIRCLE, 1, facing); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.TRIANGLE, 1, facing); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.TRIANGLE, 2); + ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(Glyphs.TRIANGLE, 3); } } @@ -74,7 +81,7 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { - return super.getCollisionBoundingBoxFromPool(world, x, y, z); + return null; } /** 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 93d4e917..ee4c7a8a 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 @@ -8,6 +8,7 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) @@ -26,7 +27,7 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer for (Glyph glyph : tileEntityAlchemyArray.getAlchemyArray().getGlyphs()) { this.bindTexture(glyph.getTexture()); - renderSymbol(glyph, x, y, z); + renderSymbol(glyph, x, y, z, tileEntityAlchemyArray.getOrientation()); } GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); @@ -34,19 +35,64 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer } } - private void renderSymbol(Glyph glyph, double x, double y, double z) + private void renderSymbol(Glyph glyph, double x, double y, double z, ForgeDirection orientation) { + // TODO handle facing variants of glyphs Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); - GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0f, 0.5f - (glyph.getSize() / 2f)); - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.001d, z + glyph.getSize(), 0, 0); - tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.001d, z, 0, 1); - tessellator.addVertexWithUV(x, y + 0.001d, z, 1, 1); - tessellator.addVertexWithUV(x, y + 0.001d, z + glyph.getSize(), 1, 0); + + if (orientation == ForgeDirection.DOWN) + { + GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0f, 0.5f - (glyph.getSize() / 2f)); + tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.999d, z + glyph.getSize(), 0, 0); + tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.999d, z, 0, 1); + tessellator.addVertexWithUV(x, y + 0.999d, z, 1, 1); + tessellator.addVertexWithUV(x, y + 0.999d, z + glyph.getSize(), 1, 0); + } + else if (orientation == ForgeDirection.UP) + { + GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0f, 0.5f - (glyph.getSize() / 2f)); + tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.001d, z + glyph.getSize(), 0, 0); + tessellator.addVertexWithUV(x + glyph.getSize(), y + 0.001d, z, 0, 1); + tessellator.addVertexWithUV(x, y + 0.001d, z, 1, 1); + tessellator.addVertexWithUV(x, y + 0.001d, z + glyph.getSize(), 1, 0); + } + else if (orientation == ForgeDirection.NORTH) + { + GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f), 0f); + tessellator.addVertexWithUV(x, y + glyph.getSize(), z + 0.999d, 1, 0); + tessellator.addVertexWithUV(x + glyph.getSize(), y + glyph.getSize(), z + 0.999d, 0, 0); + tessellator.addVertexWithUV(x + glyph.getSize(), y, z + 0.999d, 0, 1); + tessellator.addVertexWithUV(x, y, z + 0.999d, 1, 1); + } + else if (orientation == ForgeDirection.SOUTH) + { + GL11.glTranslatef(0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f), 0f); + tessellator.addVertexWithUV(x, y + glyph.getSize(), z + 0.001d, 1, 0); + tessellator.addVertexWithUV(x + glyph.getSize(), y + glyph.getSize(), z + 0.001d, 0, 0); + tessellator.addVertexWithUV(x + glyph.getSize(), y, z + 0.001d, 0, 1); + tessellator.addVertexWithUV(x, y, z + 0.001d, 1, 1); + } + else if (orientation == ForgeDirection.WEST) + { + GL11.glTranslatef(0f, 0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f)); + tessellator.addVertexWithUV(x + 0.999d, y + glyph.getSize(), z, 0, 0); + tessellator.addVertexWithUV(x + 0.999d, y + glyph.getSize(), z + glyph.getSize(), 0, 1); + tessellator.addVertexWithUV(x + 0.999d, y, z + glyph.getSize(), 1, 1); + tessellator.addVertexWithUV(x + 0.999d, y, z, 1, 0); + } + else if (orientation == ForgeDirection.EAST) + { + GL11.glTranslatef(0f, 0.5f - (glyph.getSize() / 2f), 0.5f - (glyph.getSize() / 2f)); + tessellator.addVertexWithUV(x + 0.001d, y + glyph.getSize(), z, 0, 0); + tessellator.addVertexWithUV(x + 0.001d, y + glyph.getSize(), z + glyph.getSize(), 0, 1); + tessellator.addVertexWithUV(x + 0.001d, y, z + glyph.getSize(), 1, 1); + tessellator.addVertexWithUV(x + 0.001d, y, z, 1, 0); + } + tessellator.draw(); GL11.glPopMatrix(); } diff --git a/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java b/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java index ffd5ce2e..5cc66276 100644 --- a/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java +++ b/src/main/java/com/pahimar/ee3/handler/PlayerEventHandler.java @@ -4,9 +4,11 @@ import com.pahimar.ee3.exchange.EnergyValueRegistry; import com.pahimar.ee3.network.PacketHandler; import com.pahimar.ee3.network.message.MessageSyncEnergyValues; import com.pahimar.ee3.reference.Reference; +import com.pahimar.ee3.util.EntityHelper; import com.pahimar.ee3.util.LogHelper; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.event.entity.player.PlayerEvent; import java.io.*; @@ -53,8 +55,37 @@ public class PlayerEventHandler } @SubscribeEvent - public void onPlayerLoggedInEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) + public void syncEnergyValuesOnLogin(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) { PacketHandler.INSTANCE.sendTo(new MessageSyncEnergyValues(EnergyValueRegistry.getInstance()), (EntityPlayerMP) event.player); } + + @SubscribeEvent + public void initPlayerCustomData(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent event) + { + if (event.player != null) + { + if (EntityHelper.getCustomEntityData(event.player) == null) + { + NBTTagCompound playerCustomData = new NBTTagCompound(); + + NBTTagCompound glyphCustomData = new NBTTagCompound(); + glyphCustomData.setInteger("index", 0); + glyphCustomData.setInteger("size", 1); + glyphCustomData.setInteger("rotation", 0); + playerCustomData.setTag("chalkSettings", glyphCustomData); + + EntityHelper.saveCustomEntityData(event.player, playerCustomData); + } + else + { + NBTTagCompound playerCustomData = EntityHelper.getCustomEntityData(event.player); + + for (Object object : playerCustomData.func_150296_c()) + { + LogHelper.info(String.format("key: %s, value: %s", object.toString(), playerCustomData.getTag(object.toString()))); + } + } + } + } } diff --git a/src/main/java/com/pahimar/ee3/init/Glyphs.java b/src/main/java/com/pahimar/ee3/init/Glyphs.java index fee287e7..76a894a8 100644 --- a/src/main/java/com/pahimar/ee3/init/Glyphs.java +++ b/src/main/java/com/pahimar/ee3/init/Glyphs.java @@ -1,7 +1,7 @@ package com.pahimar.ee3.init; import com.pahimar.ee3.api.Glyph; -import com.pahimar.ee3.api.GlyphRegistryProxy; +import com.pahimar.ee3.array.GlyphTextureRegistry; import com.pahimar.ee3.reference.Names; import com.pahimar.ee3.reference.Textures; @@ -24,17 +24,17 @@ public class Glyphs 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(HEPTAGON); - GlyphRegistryProxy.addGlyph(OCTAGON); + GlyphTextureRegistry.getInstance().addGlyph(BASE_CIRCLE); + GlyphTextureRegistry.getInstance().addGlyph(DOT); + GlyphTextureRegistry.getInstance().addGlyph(LINE); + GlyphTextureRegistry.getInstance().addGlyph(CIRCLE); + GlyphTextureRegistry.getInstance().addGlyph(TRIANGLE); + GlyphTextureRegistry.getInstance().addGlyph(INVERTED_TRIANGLE); + GlyphTextureRegistry.getInstance().addGlyph(SQUARE); + GlyphTextureRegistry.getInstance().addGlyph(DIAMOND); + GlyphTextureRegistry.getInstance().addGlyph(PENTAGON); + GlyphTextureRegistry.getInstance().addGlyph(HEXAGON); + GlyphTextureRegistry.getInstance().addGlyph(HEPTAGON); + GlyphTextureRegistry.getInstance().addGlyph(OCTAGON); } } diff --git a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java index 39733861..45f0195e 100644 --- a/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java +++ b/src/main/java/com/pahimar/ee3/tileentity/TileEntityAlchemyArray.java @@ -35,11 +35,17 @@ public class TileEntityAlchemyArray extends TileEntityEE alchemyArray.addGlyph(new Glyph(glyph, size)); } + public void addGlyphToAlchemyArray(Glyph glyph, int size, int facing) + { + alchemyArray.addGlyph(new Glyph(glyph, size, facing)); + } + @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord, zCoord - alchemyArray.getLargestGlyphSize(), xCoord + alchemyArray.getLargestGlyphSize(), yCoord, zCoord + alchemyArray.getLargestGlyphSize()); + // TODO: Make this glyph size and orientation sensitive + return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord - alchemyArray.getLargestGlyphSize(), zCoord - alchemyArray.getLargestGlyphSize(), xCoord + alchemyArray.getLargestGlyphSize(), yCoord + alchemyArray.getLargestGlyphSize(), zCoord + alchemyArray.getLargestGlyphSize()); } @Override diff --git a/src/main/java/com/pahimar/ee3/util/EntityHelper.java b/src/main/java/com/pahimar/ee3/util/EntityHelper.java new file mode 100644 index 00000000..25635185 --- /dev/null +++ b/src/main/java/com/pahimar/ee3/util/EntityHelper.java @@ -0,0 +1,26 @@ +package com.pahimar.ee3.util; + +import com.pahimar.ee3.reference.Reference; +import net.minecraft.entity.Entity; +import net.minecraft.nbt.NBTTagCompound; + +public class EntityHelper +{ + public static NBTTagCompound getCustomEntityData(Entity entity) + { + if (entity != null && entity.getEntityData().hasKey(Reference.MOD_ID.toLowerCase()) && entity.getEntityData().getTag(Reference.MOD_ID.toLowerCase()) instanceof NBTTagCompound) + { + return entity.getEntityData().getCompoundTag(Reference.MOD_ID.toLowerCase()); + } + + return null; + } + + public static void saveCustomEntityData(Entity entity, NBTTagCompound nbtTagCompound) + { + if (entity != null) + { + entity.getEntityData().setTag(Reference.MOD_ID.toLowerCase(), nbtTagCompound); + } + } +}