Lots of changes, things will likely not work for a bit - rethinking the structure of Alchemy Arrays

This commit is contained in:
Pahimar 2014-10-21 15:59:00 -04:00
parent bbfb204472
commit 6fc59ede05
16 changed files with 687 additions and 248 deletions

View file

@ -1,5 +1,6 @@
package com.pahimar.ee3; package com.pahimar.ee3;
import com.pahimar.ee3.array.AlchemyArrayRegistry;
import com.pahimar.ee3.array.GlyphTextureRegistry; import com.pahimar.ee3.array.GlyphTextureRegistry;
import com.pahimar.ee3.command.CommandSetCurrentItemValue; import com.pahimar.ee3.command.CommandSetCurrentItemValue;
import com.pahimar.ee3.command.CommandSetValue; import com.pahimar.ee3.command.CommandSetValue;
@ -149,4 +150,9 @@ public class EquivalentExchange3
{ {
return GlyphTextureRegistry.getInstance(); return GlyphTextureRegistry.getInstance();
} }
public AlchemyArrayRegistry getAlchemyArrayRegistry()
{
return AlchemyArrayRegistry.getInstance();
}
} }

View file

@ -11,82 +11,105 @@ import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
public class AlchemyArray implements Comparable<AlchemyArray> { public class AlchemyArray implements Comparable<AlchemyArray>
{
private SortedSet<Glyph> glyphs; private SortedSet<Glyph> glyphs;
private int largestGlyphSize; private int largestGlyphSize;
public AlchemyArray() { public AlchemyArray()
{
glyphs = new TreeSet<Glyph>(); glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0; largestGlyphSize = 0;
} }
public AlchemyArray(Collection<Glyph> glyphs) { public AlchemyArray(Collection<Glyph> glyphs)
{
this.glyphs = new TreeSet<Glyph>(glyphs); this.glyphs = new TreeSet<Glyph>(glyphs);
largestGlyphSize = 0; largestGlyphSize = 0;
for (Glyph glyph : glyphs) { for (Glyph glyph : glyphs)
if (glyph.getSize() > largestGlyphSize) { {
if (glyph.getSize() > largestGlyphSize)
{
largestGlyphSize = glyph.getSize(); largestGlyphSize = glyph.getSize();
} }
} }
} }
public boolean addGlyph(Glyph glyph) { public boolean addGlyph(Glyph glyph)
if (glyph.getSize() > largestGlyphSize) { {
if (glyph.getSize() > largestGlyphSize)
{
largestGlyphSize = glyph.getSize(); largestGlyphSize = glyph.getSize();
} }
return glyphs.add(glyph); return glyphs.add(glyph);
} }
public void addGlyph(Glyph glyph, int size) { public void addGlyph(Glyph glyph, int size)
if (size > largestGlyphSize) { {
if (size > largestGlyphSize)
{
largestGlyphSize = size; largestGlyphSize = size;
} }
glyphs.add(new Glyph(glyph, size)); glyphs.add(new Glyph(glyph, size));
} }
public Set<Glyph> getGlyphs() { public Set<Glyph> getGlyphs()
{
return ImmutableSortedSet.copyOf(glyphs); return ImmutableSortedSet.copyOf(glyphs);
} }
public int getLargestGlyphSize() { public int getLargestGlyphSize()
{
return largestGlyphSize; return largestGlyphSize;
} }
public void onAlchemyArrayActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) { public void onAlchemyArrayActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ)
{
} }
public void readFromNBT(NBTTagCompound nbtTagCompound) { public void readFromNBT(NBTTagCompound nbtTagCompound)
if (nbtTagCompound != null && nbtTagCompound.hasKey("glyphs")) { {
if (nbtTagCompound != null && nbtTagCompound.hasKey("glyphs"))
{
// Read in the ItemStacks in the inventory from NBT // Read in the ItemStacks in the inventory from NBT
if (nbtTagCompound.hasKey("glyphs")) { if (nbtTagCompound.hasKey("glyphs"))
{
NBTTagList tagList = nbtTagCompound.getTagList("glyphs", 10); NBTTagList tagList = nbtTagCompound.getTagList("glyphs", 10);
glyphs = new TreeSet<Glyph>(); glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0; largestGlyphSize = 0;
for (int i = 0; i < tagList.tagCount(); ++i) { for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
Glyph glyph = Glyph.readGlyphFromNBT(tagCompound); Glyph glyph = Glyph.readGlyphFromNBT(tagCompound);
glyphs.add(glyph); glyphs.add(glyph);
if (glyph.getSize() > largestGlyphSize) { if (glyph.getSize() > largestGlyphSize)
{
largestGlyphSize = glyph.getSize(); largestGlyphSize = glyph.getSize();
} }
} }
} else { }
else
{
glyphs = new TreeSet<Glyph>(); glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0; largestGlyphSize = 0;
} }
} else { }
else
{
glyphs = new TreeSet<Glyph>(); glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0; largestGlyphSize = 0;
} }
} }
public void writeToNBT(NBTTagCompound nbtTagCompound) { public void writeToNBT(NBTTagCompound nbtTagCompound)
{
NBTTagList tagList = new NBTTagList(); NBTTagList tagList = new NBTTagList();
for (Glyph glyph : glyphs) { for (Glyph glyph : glyphs)
{
NBTTagCompound tagCompound = new NBTTagCompound(); NBTTagCompound tagCompound = new NBTTagCompound();
glyph.writeToNBT(tagCompound); glyph.writeToNBT(tagCompound);
tagList.appendTag(tagCompound); tagList.appendTag(tagCompound);
@ -95,17 +118,20 @@ public class AlchemyArray implements Comparable<AlchemyArray> {
nbtTagCompound.setInteger("largestGlyphSize", largestGlyphSize); nbtTagCompound.setInteger("largestGlyphSize", largestGlyphSize);
} }
public static AlchemyArray readAlchemyArrayFromNBT(NBTTagCompound nbtTagCompound) { public static AlchemyArray readAlchemyArrayFromNBT(NBTTagCompound nbtTagCompound)
{
AlchemyArray alchemyArray = new AlchemyArray(); AlchemyArray alchemyArray = new AlchemyArray();
alchemyArray.readFromNBT(nbtTagCompound); alchemyArray.readFromNBT(nbtTagCompound);
return alchemyArray; return alchemyArray;
} }
@Override @Override
public String toString() { public String toString()
{
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
for (Glyph glyph : glyphs) { for (Glyph glyph : glyphs)
{
stringBuilder.append(glyph.toString() + ", "); stringBuilder.append(glyph.toString() + ", ");
} }
@ -113,8 +139,10 @@ public class AlchemyArray implements Comparable<AlchemyArray> {
} }
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object)
if (object instanceof AlchemyArray) { {
if (object instanceof AlchemyArray)
{
return this.compareTo((AlchemyArray) object) == 0; return this.compareTo((AlchemyArray) object) == 0;
} }
@ -122,16 +150,22 @@ public class AlchemyArray implements Comparable<AlchemyArray> {
} }
@Override @Override
public int compareTo(AlchemyArray alchemyArray) { public int compareTo(AlchemyArray alchemyArray)
if (this.glyphs.size() == alchemyArray.glyphs.size()) { {
for (Glyph glyph : this.glyphs) { if (this.glyphs.size() == alchemyArray.glyphs.size())
if (!alchemyArray.glyphs.contains(glyph)) { {
for (Glyph glyph : this.glyphs)
{
if (!alchemyArray.glyphs.contains(glyph))
{
return -1; return -1;
} }
} }
return 0; return 0;
} else { }
else
{
return this.glyphs.size() - alchemyArray.glyphs.size(); return this.glyphs.size() - alchemyArray.glyphs.size();
} }
} }

View file

@ -0,0 +1,23 @@
package com.pahimar.ee3.api;
import com.pahimar.ee3.EquivalentExchange3;
import cpw.mods.fml.common.Mod;
public class AlchemyArrayRegistryProxy
{
@Mod.Instance("EE3")
private static Object ee3Mod;
private static class EE3Wrapper
{
private static EquivalentExchange3 ee3mod;
}
private static void init()
{
if (ee3Mod != null)
{
EE3Wrapper.ee3mod = (EquivalentExchange3) ee3Mod;
}
}
}

View file

@ -19,7 +19,7 @@ public class GlyphTextureRegistryProxy
return; return;
} }
EE3Wrapper.ee3mod.getGlyphRegistry().addGlyph(glyphTexture, unLocalizedName); EE3Wrapper.ee3mod.getGlyphRegistry().registerGlyph(glyphTexture, unLocalizedName);
} }
private static class EE3Wrapper private static class EE3Wrapper

View file

@ -0,0 +1,48 @@
package com.pahimar.ee3.array;
import com.google.common.collect.ImmutableSortedSet;
import com.pahimar.ee3.api.AlchemyArray;
import java.util.SortedSet;
import java.util.TreeSet;
public class AlchemyArrayRegistry
{
private static AlchemyArrayRegistry alchemyArrayRegistry = null;
private SortedSet<AlchemyArray> registeredAlchemyArrays;
private AlchemyArrayRegistry()
{
}
public static AlchemyArrayRegistry getInstance()
{
if (alchemyArrayRegistry == null)
{
alchemyArrayRegistry = new AlchemyArrayRegistry();
alchemyArrayRegistry.init();
}
return alchemyArrayRegistry;
}
private void init()
{
registeredAlchemyArrays = new TreeSet<AlchemyArray>();
}
public SortedSet<AlchemyArray> getRegisteredAlchemyArrays()
{
return ImmutableSortedSet.copyOf(registeredAlchemyArrays);
}
public boolean registerAlchemyArray(AlchemyArray alchemyArray)
{
if (!registeredAlchemyArrays.contains(alchemyArray))
{
return registeredAlchemyArrays.add(alchemyArray);
}
return false;
}
}

View file

@ -12,7 +12,7 @@ import java.util.TreeMap;
public class GlyphTextureRegistry public class GlyphTextureRegistry
{ {
private static GlyphTextureRegistry glyphTextureRegistry = null; private static GlyphTextureRegistry glyphTextureRegistry = null;
private SortedMap<ResourceLocation, String> glyphTextureSortedMap; private SortedMap<ResourceLocation, String> registeredGlyphTextures;
private GlyphTextureRegistry() private GlyphTextureRegistry()
{ {
@ -31,40 +31,40 @@ public class GlyphTextureRegistry
private void init() private void init()
{ {
glyphTextureSortedMap = new TreeMap<ResourceLocation, String>(comparator); registeredGlyphTextures = new TreeMap<ResourceLocation, String>(comparator);
} }
public void addGlyph(Glyph glyph) public void registerGlyph(Glyph glyph)
{ {
if (glyph.getTexture() != null) if (glyph.getTexture() != null)
{ {
glyphTextureSortedMap.put(glyph.getTexture(), glyph.getUnLocalizedName()); registeredGlyphTextures.put(glyph.getTexture(), glyph.getUnLocalizedName());
} }
} }
public void addGlyph(ResourceLocation glyphTexture, String unLocalizedName) public void registerGlyph(ResourceLocation glyphTexture, String unLocalizedName)
{ {
if (glyphTexture != null) if (glyphTexture != null)
{ {
glyphTextureSortedMap.put(glyphTexture, unLocalizedName); registeredGlyphTextures.put(glyphTexture, unLocalizedName);
} }
} }
public ResourceLocation getResourceLocation(int index) public ResourceLocation getRegisteredGlyphAt(int index)
{ {
if (index >= glyphTextureSortedMap.size() || index < 0) if (index >= registeredGlyphTextures.size() || index < 0)
{ {
return null; return null;
} }
ResourceLocation[] glyphTextures = glyphTextureSortedMap.keySet().toArray(new ResourceLocation[]{}); ResourceLocation[] registeredGlyphTextures = this.registeredGlyphTextures.keySet().toArray(new ResourceLocation[]{});
return glyphTextures[index]; return registeredGlyphTextures[index];
} }
public Map<ResourceLocation, String> getGlyphs() public Map<ResourceLocation, String> getRegisteredGlyphTextures()
{ {
return ImmutableMap.copyOf(glyphTextureSortedMap); return ImmutableMap.copyOf(registeredGlyphTextures);
} }
private static Comparator<ResourceLocation> comparator = new Comparator<ResourceLocation>() private static Comparator<ResourceLocation> comparator = new Comparator<ResourceLocation>()

View file

@ -28,30 +28,36 @@ import java.util.Random;
import static net.minecraftforge.common.util.ForgeDirection.*; import static net.minecraftforge.common.util.ForgeDirection.*;
public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider { public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
public BlockAlchemyArray() { {
public BlockAlchemyArray()
{
super(Material.circuits); super(Material.circuits);
this.setCreativeTab(null); this.setCreativeTab(null);
this.setBlockName(Names.Blocks.ALCHEMY_ARRAY); this.setBlockName(Names.Blocks.ALCHEMY_ARRAY);
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock()
{
return false; return false;
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube()
{
return false; return false;
} }
@Override @Override
public int getRenderType() { public int getRenderType()
{
return RenderIds.alchemyArray; return RenderIds.alchemyArray;
} }
@Override @Override
public Item getItemDropped(int par1, Random random, int par2) { public Item getItemDropped(int par1, Random random, int par2)
{
return null; return null;
} }
@ -62,12 +68,14 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
* @param metaData * @param metaData
*/ */
@Override @Override
public TileEntity createNewTileEntity(World world, int metaData) { public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileEntityAlchemyArray(); return new TileEntityAlchemyArray();
} }
@Override @Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) { public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && return world.getBlock(x, y, z).isReplaceable(world, x, y, z) &&
(world.isSideSolid(x - 1, y, z, EAST) || (world.isSideSolid(x - 1, y, z, EAST) ||
world.isSideSolid(x + 1, y, z, WEST) || world.isSideSolid(x + 1, y, z, WEST) ||
@ -78,7 +86,8 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit) { public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit)
{
ForgeDirection side = ForgeDirection.getOrientation(sideHit); ForgeDirection side = ForgeDirection.getOrientation(sideHit);
return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && return world.getBlock(x, y, z).isReplaceable(world, x, y, z) &&
((side == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) || ((side == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) ||
@ -90,36 +99,52 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
{
return false; return false;
} }
@Override @Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return true; return true;
} }
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { {
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
boolean invalidateAlchemyArray = false; boolean invalidateAlchemyArray = false;
if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true)) { if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH && !world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH && !world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH && !world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH && !world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST && !world.isSideSolid(x - 1, y, z, ForgeDirection.EAST, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST && !world.isSideSolid(x - 1, y, z, ForgeDirection.EAST, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST && !world.isSideSolid(x + 1, y, z, ForgeDirection.WEST, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST && !world.isSideSolid(x + 1, y, z, ForgeDirection.WEST, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} }
if (invalidateAlchemyArray) { if (invalidateAlchemyArray)
{
tileEntityAlchemyArray.invalidate(); tileEntityAlchemyArray.invalidate();
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
} }
@ -127,15 +152,18 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) { public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
{
return sideHit; return sideHit;
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
{
((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray && entityLiving instanceof EntityPlayer) { if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray && entityLiving instanceof EntityPlayer)
{
NBTTagCompound customEntityData = EntityHelper.getCustomEntityData(entityLiving); NBTTagCompound customEntityData = EntityHelper.getCustomEntityData(entityLiving);
ChalkSettings chalkSettings = new ChalkSettings(); ChalkSettings chalkSettings = new ChalkSettings();
chalkSettings.readFromNBT(customEntityData); chalkSettings.readFromNBT(customEntityData);
@ -144,32 +172,39 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).setRotation(chalkSettings.getRotation(), facing); ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).setRotation(chalkSettings.getRotation(), facing);
ResourceLocation glyphTexture = GlyphTextureRegistry.getInstance().getResourceLocation(chalkSettings.getIndex()); ResourceLocation glyphTexture = GlyphTextureRegistry.getInstance().getRegisteredGlyphAt(chalkSettings.getIndex());
((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(new Glyph(glyphTexture, GlyphTextureRegistry.getInstance().getGlyphs().get(glyphTexture)), chalkSettings.getSize()); ((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(new Glyph(glyphTexture, GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().get(glyphTexture)), chalkSettings.getSize());
CommonSoundHelper.playChalkSoundAt((EntityPlayer) entityLiving); CommonSoundHelper.playChalkSoundAt((EntityPlayer) entityLiving);
} }
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ)
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { {
if (entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemChalk) { if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
if (entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemChalk && !entityPlayer.isSneaking())
{
NBTTagCompound customEntityData = EntityHelper.getCustomEntityData(entityPlayer); NBTTagCompound customEntityData = EntityHelper.getCustomEntityData(entityPlayer);
ChalkSettings chalkSettings = new ChalkSettings(); ChalkSettings chalkSettings = new ChalkSettings();
chalkSettings.readFromNBT(customEntityData); chalkSettings.readFromNBT(customEntityData);
ResourceLocation glyphTexture = GlyphTextureRegistry.getInstance().getResourceLocation(chalkSettings.getIndex()); ResourceLocation glyphTexture = GlyphTextureRegistry.getInstance().getRegisteredGlyphAt(chalkSettings.getIndex());
if (((TileEntityAlchemyArray) world.getTileEntity(x, y, z)).addGlyphToAlchemyArray(new Glyph(glyphTexture, GlyphTextureRegistry.getInstance().getGlyphs().get(glyphTexture)), chalkSettings.getSize())) { if (tileEntityAlchemyArray.addGlyphToAlchemyArray(new Glyph(glyphTexture, GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().get(glyphTexture)), chalkSettings.getSize()))
{
world.markBlockForUpdate(x, y, z); world.markBlockForUpdate(x, y, z);
world.getTileEntity(x, y, z).markDirty(); world.getTileEntity(x, y, z).markDirty();
CommonSoundHelper.playChalkSoundAt(entityPlayer); CommonSoundHelper.playChalkSoundAt(entityPlayer);
return true; return true;
} }
} else { }
// TODO: If the Alchemy Array in the TileEntity associated with this block is valid (registered) fire its onActivate event else
{
tileEntityAlchemyArray.onBlockActivated(world, x, y, z, entityPlayer, sideHit, hitX, hitY, hitZ);
} }
} }
@ -177,7 +212,8 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
return null; return null;
} }
@ -186,36 +222,46 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
* x, y, z, startVec, endVec * x, y, z, startVec, endVec
*/ */
@Override @Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) { public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) { {
if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z); TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
switch (tileEntityAlchemyArray.getOrientation()) { switch (tileEntityAlchemyArray.getOrientation())
case DOWN: { {
case DOWN:
{
this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f); this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f);
break; break;
} }
case UP: { case UP:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f); this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f);
break; break;
} }
case NORTH: { case NORTH:
{
this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f); this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f);
break; break;
} }
case SOUTH: { case SOUTH:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f); this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f);
break; break;
} }
case EAST: { case EAST:
{
this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f); this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f);
break; break;
} }
case WEST: { case WEST:
{
this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f); this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f);
break; break;
} }
case UNKNOWN: { case UNKNOWN:
{
break; break;
} }
} }

View file

@ -5,7 +5,6 @@ import com.pahimar.ee3.reference.RenderIds;
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
import com.pahimar.ee3.tileentity.TileEntityDummyArray; import com.pahimar.ee3.tileentity.TileEntityDummyArray;
import com.pahimar.ee3.tileentity.TileEntityEE; import com.pahimar.ee3.tileentity.TileEntityEE;
import com.pahimar.ee3.util.LogHelper;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -25,40 +24,48 @@ import java.util.Random;
import static net.minecraftforge.common.util.ForgeDirection.*; import static net.minecraftforge.common.util.ForgeDirection.*;
public class BlockDummyArray extends BlockEE implements ITileEntityProvider { public class BlockDummyArray extends BlockEE implements ITileEntityProvider
public BlockDummyArray() { {
public BlockDummyArray()
{
super(Material.circuits); super(Material.circuits);
setCreativeTab(null); setCreativeTab(null);
this.setBlockName(Names.Blocks.DUMMY_ARRAY); this.setBlockName(Names.Blocks.DUMMY_ARRAY);
} }
@Override @Override
public boolean isOpaqueCube() { public boolean isOpaqueCube()
{
return false; return false;
} }
@Override @Override
public boolean renderAsNormalBlock() { public boolean renderAsNormalBlock()
{
return false; return false;
} }
@Override @Override
public int getRenderType() { public int getRenderType()
{
return RenderIds.dummyArray; return RenderIds.dummyArray;
} }
@Override @Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
{
return false; return false;
} }
@Override @Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
return true; return true;
} }
@Override @Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) { public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && return world.getBlock(x, y, z).isReplaceable(world, x, y, z) &&
(world.isSideSolid(x - 1, y, z, EAST) || (world.isSideSolid(x - 1, y, z, EAST) ||
world.isSideSolid(x + 1, y, z, WEST) || world.isSideSolid(x + 1, y, z, WEST) ||
@ -69,7 +76,8 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit) { public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int sideHit)
{
ForgeDirection side = ForgeDirection.getOrientation(sideHit); ForgeDirection side = ForgeDirection.getOrientation(sideHit);
return world.getBlock(x, y, z).isReplaceable(world, x, y, z) && return world.getBlock(x, y, z).isReplaceable(world, x, y, z) &&
((side == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) || ((side == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) ||
@ -81,24 +89,27 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) { public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
{
((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z)); ((TileEntityEE) world.getTileEntity(x, y, z)).setOrientation(world.getBlockMetadata(x, y, z));
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z), 3); world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z), 3);
} }
@Override @Override
public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData) { public int onBlockPlaced(World world, int x, int y, int z, int sideHit, float hitX, float hitY, float hitZ, int metaData)
{
return sideHit; return sideHit;
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ) { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ)
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { {
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord(); int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord();
int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord(); int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord();
int trueZCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueZCoord(); int trueZCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueZCoord();
LogHelper.info(String.format("Routing onAlchemyArrayActivated to (x: %s, y: %s, z: %s)", trueXCoord, trueYCoord, trueZCoord));
return world.getBlock(trueXCoord, trueYCoord, trueZCoord).onBlockActivated(world, trueXCoord, trueYCoord, trueZCoord, entityPlayer, sideHit, hitX, hitY, hitZ); return world.getBlock(trueXCoord, trueYCoord, trueZCoord).onBlockActivated(world, trueXCoord, trueYCoord, trueZCoord, entityPlayer, sideHit, hitX, hitY, hitZ);
} }
@ -106,31 +117,46 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { {
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord(); int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord();
int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord(); int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord();
int trueZCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueZCoord(); int trueZCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueZCoord();
if (world.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray) { if (world.getTileEntity(trueXCoord, trueYCoord, trueZCoord) instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(trueXCoord, trueYCoord, trueZCoord); TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(trueXCoord, trueYCoord, trueZCoord);
boolean invalidateAlchemyArray = false; boolean invalidateAlchemyArray = false;
if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true)) { if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.UP && !world.isSideSolid(x, y - 1, z, ForgeDirection.UP, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.DOWN && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH && !world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.NORTH && !world.isSideSolid(x, y, z + 1, ForgeDirection.NORTH, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH && !world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.SOUTH && !world.isSideSolid(x, y, z - 1, ForgeDirection.SOUTH, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST && !world.isSideSolid(x - 1, y, z, ForgeDirection.EAST, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.EAST && !world.isSideSolid(x - 1, y, z, ForgeDirection.EAST, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST && !world.isSideSolid(x + 1, y, z, ForgeDirection.WEST, true)) { }
else if (tileEntityAlchemyArray.getOrientation() == ForgeDirection.WEST && !world.isSideSolid(x + 1, y, z, ForgeDirection.WEST, true))
{
invalidateAlchemyArray = true; invalidateAlchemyArray = true;
} }
if (invalidateAlchemyArray) { if (invalidateAlchemyArray)
{
world.getTileEntity(x, y, z).invalidate(); world.getTileEntity(x, y, z).invalidate();
tileEntityAlchemyArray.invalidate(); tileEntityAlchemyArray.invalidate();
world.setBlockToAir(x, y, z); world.setBlockToAir(x, y, z);
@ -141,46 +167,58 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
} }
@Override @Override
public Item getItemDropped(int par1, Random random, int par2) { public Item getItemDropped(int par1, Random random, int par2)
{
return null; return null;
} }
@Override @Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
return null; return null;
} }
@Override @Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) { public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { {
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) world.getTileEntity(x, y, z); TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) world.getTileEntity(x, y, z);
switch (tileEntityDummyArray.getOrientation()) { switch (tileEntityDummyArray.getOrientation())
case DOWN: { {
case DOWN:
{
this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f); this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f);
break; break;
} }
case UP: { case UP:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f); this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f);
break; break;
} }
case NORTH: { case NORTH:
{
this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f); this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f);
break; break;
} }
case SOUTH: { case SOUTH:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f); this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f);
break; break;
} }
case EAST: { case EAST:
{
this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f); this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f);
break; break;
} }
case WEST: { case WEST:
{
this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f); this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f);
break; break;
} }
case UNKNOWN: { case UNKNOWN:
{
break; break;
} }
} }
@ -189,8 +227,10 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
return super.collisionRayTrace(world, x, y, z, startVec, endVec); return super.collisionRayTrace(world, x, y, z, startVec, endVec);
} }
public void breakBlock(World world, int x, int y, int z, Block block, int metaData) { public void breakBlock(World world, int x, int y, int z, Block block, int metaData)
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { {
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
TileEntity tileEntity = world.getTileEntity(x, y, z); TileEntity tileEntity = world.getTileEntity(x, y, z);
super.breakBlock(world, ((TileEntityDummyArray) tileEntity).getTrueXCoord(), ((TileEntityDummyArray) tileEntity).getTrueYCoord(), ((TileEntityDummyArray) tileEntity).getTrueZCoord(), block, metaData); super.breakBlock(world, ((TileEntityDummyArray) tileEntity).getTrueXCoord(), ((TileEntityDummyArray) tileEntity).getTrueYCoord(), ((TileEntityDummyArray) tileEntity).getTrueZCoord(), block, metaData);
} }
@ -204,7 +244,8 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
* @param metaData * @param metaData
*/ */
@Override @Override
public TileEntity createNewTileEntity(World world, int metaData) { public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileEntityDummyArray(); return new TileEntityDummyArray();
} }
} }

View file

@ -8,8 +8,8 @@ import com.pahimar.ee3.reference.ToolMode;
import com.pahimar.ee3.settings.ChalkSettings; import com.pahimar.ee3.settings.ChalkSettings;
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray; import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
import com.pahimar.ee3.tileentity.TileEntityDummyArray; import com.pahimar.ee3.tileentity.TileEntityDummyArray;
import com.pahimar.ee3.tileentity.TileEntityEE;
import com.pahimar.ee3.util.IModalTool; import com.pahimar.ee3.util.IModalTool;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -220,21 +220,156 @@ public class DrawBlockHighlightEventHandler
private void drawGlyphOverlay(DrawBlockHighlightEvent event) private void drawGlyphOverlay(DrawBlockHighlightEvent event)
{ {
ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings; drawGlyphInWorld(event);
ResourceLocation texture = GlyphTextureRegistry.getInstance().getResourceLocation(chalkSettings.getIndex()); }
int chargeLevel = chalkSettings.getSize();
int rotation = chalkSettings.getRotation();
TileEntity tileEntity = FMLClientHandler.instance().getClient().theWorld.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
if (tileEntity instanceof TileEntityAlchemyArray || tileEntity instanceof TileEntityDummyArray) { private static void drawGlyphInWorld(DrawBlockHighlightEvent event)
drawGlyphInWorld(event, texture, chargeLevel, rotation); {
} else { ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings;
// NOT an already placed array, render as normal ResourceLocation texture = GlyphTextureRegistry.getInstance().getRegisteredGlyphAt(chalkSettings.getIndex());
drawGlyphInWorld(event, texture, chargeLevel, rotation); int rotation = chalkSettings.getRotation();
double x = event.target.blockX + 0.5F;
double y = event.target.blockY + 0.5F;
double z = event.target.blockZ + 0.5F;
double iPX = event.player.prevPosX + (event.player.posX - event.player.prevPosX) * event.partialTicks;
double iPY = event.player.prevPosY + (event.player.posY - event.player.prevPosY) * event.partialTicks;
double iPZ = event.player.prevPosZ + (event.player.posZ - event.player.prevPosZ) * event.partialTicks;
float xScale, yScale, zScale;
float xShift, yShift, zShift;
float xRotate, yRotate, zRotate;
int zCorrection = 1;
int rotationAngle = 0;
int playerFacing = MathHelper.floor_double(event.player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
int facingCorrectionAngle = 0;
xScale = yScale = zScale = 1;
xShift = yShift = zShift = 0;
xRotate = yRotate = zRotate = 0;
int chargeLevel = chalkSettings.getSize();
ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
TileEntity tileEntity = event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
boolean shouldRender = true;
if (tileEntity instanceof TileEntityEE)
{
if (((TileEntityEE) tileEntity).getOrientation() != sideHit)
{
shouldRender = false;
}
}
switch (sideHit)
{
case UP:
{
xScale = zScale = chargeLevel;
yShift = 0.001f;
xRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray)
{
y -= 1;
}
if (tileEntity instanceof TileEntityDummyArray)
{
x = ((TileEntityDummyArray) tileEntity).getTrueXCoord() + 0.5f;
y = ((TileEntityDummyArray) tileEntity).getTrueYCoord() + 0.5f - 1;
z = ((TileEntityDummyArray) tileEntity).getTrueXCoord() + 0.5f;
}
break;
}
case DOWN:
{
xScale = zScale = chargeLevel;
yShift = -0.001f;
xRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray)
{
y += 1;
}
break;
}
case NORTH:
{
xScale = yScale = chargeLevel;
zCorrection = -1;
zShift = -0.001f;
zRotate = 1;
rotationAngle = (-90 * (rotation + 1)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray)
{
z += 1;
}
break;
}
case SOUTH:
{
xScale = yScale = chargeLevel;
zShift = 0.001f;
zRotate = -1;
rotationAngle = (-90 * (rotation + 1)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray)
{
z -= 1;
}
break;
}
case EAST:
{
yScale = zScale = chargeLevel;
xShift = 0.001f;
yRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray)
{
x -= 1;
}
break;
}
case WEST:
{
yScale = zScale = chargeLevel;
xShift = -0.001f;
yRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray)
{
x += 1;
}
break;
}
default:
break;
}
if (shouldRender)
{
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glPushMatrix();
GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
GL11.glRotatef(rotationAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ);
GL11.glRotatef(facingCorrectionAngle, sideHit.offsetX, sideHit.offsetY, sideHit.offsetZ);
GL11.glRotatef(90, xRotate, yRotate, zRotate);
GL11.glTranslated(0, 0, 0.5f * zCorrection);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
RenderUtils.renderPulsingQuad(texture, 1f);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(true);
} }
} }
private static void drawGlyphInWorld(DrawBlockHighlightEvent event, ResourceLocation texture, int size, int rotation) { private static void drawGlyphInWorld(DrawBlockHighlightEvent event, ResourceLocation texture, int size, int rotation)
{
double x = event.target.blockX + 0.5F; double x = event.target.blockX + 0.5F;
double y = event.target.blockY + 0.5F; double y = event.target.blockY + 0.5F;
double z = event.target.blockZ + 0.5F; double z = event.target.blockZ + 0.5F;
@ -258,66 +393,79 @@ public class DrawBlockHighlightEventHandler
ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit); ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
TileEntity tileEntity = event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ); TileEntity tileEntity = event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
switch (sideHit) { switch (sideHit)
case UP: { {
case UP:
{
xScale = zScale = chargeLevel; xScale = zScale = chargeLevel;
yShift = 0.001f; yShift = 0.001f;
xRotate = -1; xRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360; rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360; facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) { if (tileEntity instanceof TileEntityAlchemyArray)
{
y -= 1; y -= 1;
} }
break; break;
} }
case DOWN: { case DOWN:
{
xScale = zScale = chargeLevel; xScale = zScale = chargeLevel;
yShift = -0.001f; yShift = -0.001f;
xRotate = 1; xRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360; rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360; facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) { if (tileEntity instanceof TileEntityAlchemyArray)
{
y += 1; y += 1;
} }
break; break;
} }
case NORTH: { case NORTH:
{
xScale = yScale = chargeLevel; xScale = yScale = chargeLevel;
zCorrection = -1; zCorrection = -1;
zShift = -0.001f; zShift = -0.001f;
zRotate = 1; zRotate = 1;
rotationAngle = (-90 * (rotation + 1)) % 360; rotationAngle = (-90 * (rotation + 1)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) { if (tileEntity instanceof TileEntityAlchemyArray)
{
z += 1; z += 1;
} }
break; break;
} }
case SOUTH: { case SOUTH:
{
xScale = yScale = chargeLevel; xScale = yScale = chargeLevel;
zShift = 0.001f; zShift = 0.001f;
zRotate = -1; zRotate = -1;
rotationAngle = (-90 * (rotation + 1)) % 360; rotationAngle = (-90 * (rotation + 1)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) { if (tileEntity instanceof TileEntityAlchemyArray)
{
z -= 1; z -= 1;
} }
break; break;
} }
case EAST: { case EAST:
{
yScale = zScale = chargeLevel; yScale = zScale = chargeLevel;
xShift = 0.001f; xShift = 0.001f;
yRotate = 1; yRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360; rotationAngle = (-90 * (rotation + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) { if (tileEntity instanceof TileEntityAlchemyArray)
{
x -= 1; x -= 1;
} }
break; break;
} }
case WEST: { case WEST:
{
yScale = zScale = chargeLevel; yScale = zScale = chargeLevel;
xShift = -0.001f; xShift = -0.001f;
yRotate = -1; yRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360; rotationAngle = (-90 * (rotation + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) { if (tileEntity instanceof TileEntityAlchemyArray)
{
x += 1; x += 1;
} }
break; break;
@ -325,6 +473,7 @@ public class DrawBlockHighlightEventHandler
default: default:
break; break;
} }
GL11.glDepthMask(false); GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glPushMatrix(); GL11.glPushMatrix();

View file

@ -64,8 +64,8 @@ public class ItemRendererGlassBell implements IItemRenderer
private void renderGlassBell(float x, float y, float z) private void renderGlassBell(float x, float y, float z)
{ {
GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix(); GL11.glPushMatrix();
// Scale, Translate, Rotate // Scale, Translate, Rotate

View file

@ -22,12 +22,9 @@ public class TileEntityRendererAlchemyArray extends TileEntitySpecialRenderer
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) FMLClientHandler.instance().getClient().theWorld.getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
int scale; int scale;
double xShift, yShift, zShift; double xShift = 0.5d, yShift = 0.5d, zShift = 0.5d;
float xRotate, yRotate, zRotate; float xRotate = 0, yRotate = 0, zRotate = 0;
int rotationAngle; int rotationAngle = 0;
xShift = yShift = zShift = 0.5d;
xRotate = yRotate = zRotate = 0;
rotationAngle = 0;
GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_LIGHTING);

View file

@ -362,8 +362,8 @@ public class WrappedStack implements Comparable<WrappedStack>, JsonDeserializer<
* the same type passing {@code jsonElement} since that will cause an infinite loop (Gson will call your * the same type passing {@code jsonElement} since that will cause an infinite loop (Gson will call your
* call-back method again). * call-back method again).
* *
* @param jsonElement The Json data being deserialized * @param jsonElement The Json data being deserialized
* @param typeOfT The type of the Object to deserialize to * @param typeOfT The type of the Object to deserialize to
* @param context * @param context
* @return a deserialized object of the specified type typeOfT which is a subclass of {@code T} * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T}
* @throws com.google.gson.JsonParseException if jsonElement is not in the expected format of {@code typeofT} * @throws com.google.gson.JsonParseException if jsonElement is not in the expected format of {@code typeofT}

View file

@ -23,16 +23,16 @@ public class Glyphs
public static void init() public static void init()
{ {
GlyphTextureRegistry.getInstance().addGlyph(BASE_CIRCLE); GlyphTextureRegistry.getInstance().registerGlyph(BASE_CIRCLE);
GlyphTextureRegistry.getInstance().addGlyph(DOT); GlyphTextureRegistry.getInstance().registerGlyph(DOT);
GlyphTextureRegistry.getInstance().addGlyph(LINE); GlyphTextureRegistry.getInstance().registerGlyph(LINE);
GlyphTextureRegistry.getInstance().addGlyph(CIRCLE); GlyphTextureRegistry.getInstance().registerGlyph(CIRCLE);
GlyphTextureRegistry.getInstance().addGlyph(TRIANGLE); GlyphTextureRegistry.getInstance().registerGlyph(TRIANGLE);
GlyphTextureRegistry.getInstance().addGlyph(SQUARE); GlyphTextureRegistry.getInstance().registerGlyph(SQUARE);
GlyphTextureRegistry.getInstance().addGlyph(DIAMOND); GlyphTextureRegistry.getInstance().registerGlyph(DIAMOND);
GlyphTextureRegistry.getInstance().addGlyph(PENTAGON); GlyphTextureRegistry.getInstance().registerGlyph(PENTAGON);
GlyphTextureRegistry.getInstance().addGlyph(HEXAGON); GlyphTextureRegistry.getInstance().registerGlyph(HEXAGON);
GlyphTextureRegistry.getInstance().addGlyph(HEPTAGON); GlyphTextureRegistry.getInstance().registerGlyph(HEPTAGON);
GlyphTextureRegistry.getInstance().addGlyph(OCTAGON); GlyphTextureRegistry.getInstance().registerGlyph(OCTAGON);
} }
} }

View file

@ -37,9 +37,9 @@ public class ChalkSettings implements INBTTaggable
{ {
this.index = 0; this.index = 0;
} }
else if (this.index >= GlyphTextureRegistry.getInstance().getGlyphs().size()) else if (this.index >= GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size())
{ {
this.index = GlyphTextureRegistry.getInstance().getGlyphs().size() - 1; this.index = GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size() - 1;
} }
} }
@ -47,7 +47,7 @@ public class ChalkSettings implements INBTTaggable
{ {
index += 1; index += 1;
if (index >= GlyphTextureRegistry.getInstance().getGlyphs().size()) if (index >= GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size())
{ {
index = 0; index = 0;
} }
@ -59,7 +59,7 @@ public class ChalkSettings implements INBTTaggable
if (index < 0) if (index < 0)
{ {
this.index = GlyphTextureRegistry.getInstance().getGlyphs().size() - 1; this.index = GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size() - 1;
} }
} }
@ -142,7 +142,7 @@ public class ChalkSettings implements INBTTaggable
{ {
this.index = chalkSettings.getInteger("index"); this.index = chalkSettings.getInteger("index");
if (this.index < 0 || this.index >= GlyphTextureRegistry.getInstance().getGlyphs().size()) if (this.index < 0 || this.index >= GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size())
{ {
this.index = 0; this.index = 0;
} }

View file

@ -6,98 +6,160 @@ import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageTileEntityAlchemyArray; import com.pahimar.ee3.network.message.MessageTileEntityAlchemyArray;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityAlchemyArray extends TileEntityEE { public class TileEntityAlchemyArray extends TileEntityEE
{
private AlchemyArray alchemyArray; private AlchemyArray alchemyArray;
private ForgeDirection rotation; private ForgeDirection rotation;
private int ticksSinceSync; private int ticksSinceSync;
public TileEntityAlchemyArray() { public TileEntityAlchemyArray()
{
super(); super();
alchemyArray = new AlchemyArray(); alchemyArray = new AlchemyArray();
rotation = ForgeDirection.UNKNOWN; rotation = ForgeDirection.UNKNOWN;
} }
public AlchemyArray getAlchemyArray() { public AlchemyArray getAlchemyArray()
{
return alchemyArray; return alchemyArray;
} }
public boolean addGlyphToAlchemyArray(Glyph glyph) { public boolean addGlyphToAlchemyArray(Glyph glyph)
{
return alchemyArray.addGlyph(glyph); return alchemyArray.addGlyph(glyph);
} }
public boolean addGlyphToAlchemyArray(Glyph glyph, int size) { public boolean addGlyphToAlchemyArray(Glyph glyph, int size)
{
return addGlyphToAlchemyArray(new Glyph(glyph, size)); return addGlyphToAlchemyArray(new Glyph(glyph, size));
} }
public ForgeDirection getRotation() { public ForgeDirection getRotation()
{
return rotation; return rotation;
} }
public void setRotation(int rotation, int facing) { public void setRotation(int rotation, int facing)
if (this.orientation == ForgeDirection.UP) { {
if ((rotation + facing) % 4 == 0) { if (this.orientation == ForgeDirection.UP)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.NORTH; this.rotation = ForgeDirection.NORTH;
} else if ((rotation + facing) % 4 == 1) { }
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST; this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) { }
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH; this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) { }
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.WEST; this.rotation = ForgeDirection.WEST;
} }
} else if (this.orientation == ForgeDirection.DOWN) { }
if ((rotation + facing) % 4 == 0) { else if (this.orientation == ForgeDirection.DOWN)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.NORTH; this.rotation = ForgeDirection.NORTH;
} else if ((rotation + facing) % 4 == 1) { }
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST; this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) { }
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH; this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) { }
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.WEST; this.rotation = ForgeDirection.WEST;
} }
} else if (this.orientation == ForgeDirection.NORTH) { }
if ((rotation + facing) % 4 == 0) { else if (this.orientation == ForgeDirection.NORTH)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.UP; this.rotation = ForgeDirection.UP;
} else if ((rotation + facing) % 4 == 1) { }
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST; this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) { }
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.DOWN; this.rotation = ForgeDirection.DOWN;
} else if ((rotation + facing) % 4 == 3) { }
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.WEST; this.rotation = ForgeDirection.WEST;
} }
} else if (this.orientation == ForgeDirection.SOUTH) { }
if ((rotation + facing) % 4 == 0) { else if (this.orientation == ForgeDirection.SOUTH)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.DOWN; this.rotation = ForgeDirection.DOWN;
} else if ((rotation + facing) % 4 == 1) { }
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST; this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) { }
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.UP; this.rotation = ForgeDirection.UP;
} else if ((rotation + facing) % 4 == 3) { }
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.WEST; this.rotation = ForgeDirection.WEST;
} }
} else if (this.orientation == ForgeDirection.EAST) { }
if ((rotation + facing) % 4 == 0) { else if (this.orientation == ForgeDirection.EAST)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.NORTH; this.rotation = ForgeDirection.NORTH;
} else if ((rotation + facing) % 4 == 1) { }
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.UP; this.rotation = ForgeDirection.UP;
} else if ((rotation + facing) % 4 == 2) { }
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH; this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) { }
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.DOWN; this.rotation = ForgeDirection.DOWN;
} }
} else if (this.orientation == ForgeDirection.WEST) { }
if ((rotation + facing) % 4 == 0) { else if (this.orientation == ForgeDirection.WEST)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.NORTH; this.rotation = ForgeDirection.NORTH;
} else if ((rotation + facing) % 4 == 1) { }
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.DOWN; this.rotation = ForgeDirection.DOWN;
} else if ((rotation + facing) % 4 == 2) { }
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH; this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) { }
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.UP; this.rotation = ForgeDirection.UP;
} }
} }
@ -105,12 +167,18 @@ public class TileEntityAlchemyArray extends TileEntityEE {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox()
if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN) { {
if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN)
{
return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord - 1, zCoord - alchemyArray.getLargestGlyphSize(), xCoord + alchemyArray.getLargestGlyphSize(), yCoord + 1, zCoord + alchemyArray.getLargestGlyphSize()); return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord - 1, zCoord - alchemyArray.getLargestGlyphSize(), xCoord + alchemyArray.getLargestGlyphSize(), yCoord + 1, zCoord + alchemyArray.getLargestGlyphSize());
} else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH) { }
else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH)
{
return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord - alchemyArray.getLargestGlyphSize(), zCoord - 1, xCoord + alchemyArray.getLargestGlyphSize(), yCoord + alchemyArray.getLargestGlyphSize(), zCoord + 1); return AxisAlignedBB.getBoundingBox(xCoord - alchemyArray.getLargestGlyphSize(), yCoord - alchemyArray.getLargestGlyphSize(), zCoord - 1, xCoord + alchemyArray.getLargestGlyphSize(), yCoord + alchemyArray.getLargestGlyphSize(), zCoord + 1);
} else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST) { }
else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST)
{
return AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord - alchemyArray.getLargestGlyphSize(), zCoord - alchemyArray.getLargestGlyphSize(), xCoord + 1, yCoord + alchemyArray.getLargestGlyphSize(), zCoord + alchemyArray.getLargestGlyphSize()); return AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord - alchemyArray.getLargestGlyphSize(), zCoord - alchemyArray.getLargestGlyphSize(), xCoord + 1, yCoord + alchemyArray.getLargestGlyphSize(), zCoord + alchemyArray.getLargestGlyphSize());
} }
@ -118,12 +186,14 @@ public class TileEntityAlchemyArray extends TileEntityEE {
} }
@Override @Override
public Packet getDescriptionPacket() { public Packet getDescriptionPacket()
{
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this)); return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this));
} }
@Override @Override
public void readFromNBT(NBTTagCompound nbtTagCompound) { public void readFromNBT(NBTTagCompound nbtTagCompound)
{
super.readFromNBT(nbtTagCompound); super.readFromNBT(nbtTagCompound);
NBTTagCompound alchemyArrayTagCompound = nbtTagCompound.getCompoundTag("alchemyArray"); NBTTagCompound alchemyArrayTagCompound = nbtTagCompound.getCompoundTag("alchemyArray");
@ -133,7 +203,8 @@ public class TileEntityAlchemyArray extends TileEntityEE {
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbtTagCompound) { public void writeToNBT(NBTTagCompound nbtTagCompound)
{
super.writeToNBT(nbtTagCompound); super.writeToNBT(nbtTagCompound);
NBTTagCompound alchemyArrayTagCompound = new NBTTagCompound(); NBTTagCompound alchemyArrayTagCompound = new NBTTagCompound();
@ -145,12 +216,16 @@ public class TileEntityAlchemyArray extends TileEntityEE {
} }
@Override @Override
public void updateEntity() { public void updateEntity()
{
super.updateEntity(); super.updateEntity();
if (!worldObj.isRemote) { if (!worldObj.isRemote)
if (++ticksSinceSync % 100 == 0) { {
if (!areDummyBlocksValid()) { if (++ticksSinceSync % 100 == 0)
{
if (!areDummyBlocksValid())
{
this.invalidate(); this.invalidate();
worldObj.setBlockToAir(xCoord, yCoord, zCoord); worldObj.setBlockToAir(xCoord, yCoord, zCoord);
} }
@ -158,30 +233,51 @@ public class TileEntityAlchemyArray extends TileEntityEE {
} }
} }
private boolean areDummyBlocksValid() { public void onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int sideHit, float hitX, float hitY, float hitZ)
{
// TODO: Perform the action for the registered alchemy array
this.alchemyArray.onAlchemyArrayActivated(world, x, y, z, entityPlayer, sideHit, hitX, hitY, hitZ);
}
private boolean areDummyBlocksValid()
{
boolean validDummyBlocks = true; boolean validDummyBlocks = true;
int coordOffset = this.alchemyArray.getLargestGlyphSize() / 2; int coordOffset = this.alchemyArray.getLargestGlyphSize() / 2;
if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN) { if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN)
for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++) { {
for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; j++) { for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++)
if ((i != this.xCoord || j != this.zCoord) && !isValidDummyBlock(i, this.yCoord, j)) { {
for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; j++)
{
if ((i != this.xCoord || j != this.zCoord) && !isValidDummyBlock(i, this.yCoord, j))
{
validDummyBlocks = false; validDummyBlocks = false;
} }
} }
} }
} else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH) { }
for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++) { else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH)
for (int j = this.yCoord - coordOffset; j <= this.yCoord + coordOffset; j++) { {
if ((i != this.xCoord || j != this.yCoord) && !isValidDummyBlock(i, j, this.zCoord)) { for (int i = this.xCoord - coordOffset; i <= this.xCoord + coordOffset; i++)
{
for (int j = this.yCoord - coordOffset; j <= this.yCoord + coordOffset; j++)
{
if ((i != this.xCoord || j != this.yCoord) && !isValidDummyBlock(i, j, this.zCoord))
{
validDummyBlocks = false; validDummyBlocks = false;
} }
} }
} }
} else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST) { }
for (int i = this.yCoord - coordOffset; i <= this.yCoord + coordOffset; i++) { else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST)
for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; j++) { {
if ((i != this.yCoord || j != this.zCoord) && !isValidDummyBlock(this.xCoord, i, j)) { for (int i = this.yCoord - coordOffset; i <= this.yCoord + coordOffset; i++)
{
for (int j = this.zCoord - coordOffset; j <= this.zCoord + coordOffset; j++)
{
if ((i != this.yCoord || j != this.zCoord) && !isValidDummyBlock(this.xCoord, i, j))
{
validDummyBlocks = false; validDummyBlocks = false;
} }
} }
@ -191,9 +287,12 @@ public class TileEntityAlchemyArray extends TileEntityEE {
return validDummyBlocks; return validDummyBlocks;
} }
private boolean isValidDummyBlock(int x, int y, int z) { private boolean isValidDummyBlock(int x, int y, int z)
if (!this.worldObj.isRemote) { {
if (this.worldObj.getTileEntity(x, y, z) instanceof TileEntityDummyArray) { if (!this.worldObj.isRemote)
{
if (this.worldObj.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) this.worldObj.getTileEntity(x, y, z); TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) this.worldObj.getTileEntity(x, y, z);
return tileEntityDummyArray.getOrientation() == this.orientation && return tileEntityDummyArray.getOrientation() == this.orientation &&

View file

@ -26,9 +26,7 @@ public class RecipeHelper
/** /**
* Returns a list of elements that constitute the input in a crafting recipe * Returns a list of elements that constitute the input in a crafting recipe
* *
* @param recipe * @param recipe The IRecipe being examined
* The IRecipe being examined
*
* @return List of elements that constitute the input of the given IRecipe. Could be an ItemStack or an Arraylist * @return List of elements that constitute the input of the given IRecipe. Could be an ItemStack or an Arraylist
*/ */
public static List<WrappedStack> getRecipeInputs(IRecipe recipe) public static List<WrappedStack> getRecipeInputs(IRecipe recipe)
@ -137,9 +135,7 @@ public class RecipeHelper
/** /**
* Collates an uncollated, unsorted List of Objects into a sorted, collated List of WrappedStacks * Collates an uncollated, unsorted List of Objects into a sorted, collated List of WrappedStacks
* *
* @param uncollatedStacks * @param uncollatedStacks List of objects for collating
* List of objects for collating
*
* @return A sorted, collated List of WrappedStacks * @return A sorted, collated List of WrappedStacks
*/ */
public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks) public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks)