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;
import com.pahimar.ee3.array.AlchemyArrayRegistry;
import com.pahimar.ee3.array.GlyphTextureRegistry;
import com.pahimar.ee3.command.CommandSetCurrentItemValue;
import com.pahimar.ee3.command.CommandSetValue;
@ -149,4 +150,9 @@ public class EquivalentExchange3
{
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.TreeSet;
public class AlchemyArray implements Comparable<AlchemyArray> {
public class AlchemyArray implements Comparable<AlchemyArray>
{
private SortedSet<Glyph> glyphs;
private int largestGlyphSize;
public AlchemyArray() {
public AlchemyArray()
{
glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0;
}
public AlchemyArray(Collection<Glyph> glyphs) {
public AlchemyArray(Collection<Glyph> glyphs)
{
this.glyphs = new TreeSet<Glyph>(glyphs);
largestGlyphSize = 0;
for (Glyph glyph : glyphs) {
if (glyph.getSize() > largestGlyphSize) {
for (Glyph glyph : glyphs)
{
if (glyph.getSize() > largestGlyphSize)
{
largestGlyphSize = glyph.getSize();
}
}
}
public boolean addGlyph(Glyph glyph) {
if (glyph.getSize() > largestGlyphSize) {
public boolean addGlyph(Glyph glyph)
{
if (glyph.getSize() > largestGlyphSize)
{
largestGlyphSize = glyph.getSize();
}
return glyphs.add(glyph);
}
public void addGlyph(Glyph glyph, int size) {
if (size > largestGlyphSize) {
public void addGlyph(Glyph glyph, int size)
{
if (size > largestGlyphSize)
{
largestGlyphSize = size;
}
glyphs.add(new Glyph(glyph, size));
}
public Set<Glyph> getGlyphs() {
public Set<Glyph> getGlyphs()
{
return ImmutableSortedSet.copyOf(glyphs);
}
public int getLargestGlyphSize() {
public int getLargestGlyphSize()
{
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) {
if (nbtTagCompound != null && nbtTagCompound.hasKey("glyphs")) {
public void readFromNBT(NBTTagCompound nbtTagCompound)
{
if (nbtTagCompound != null && nbtTagCompound.hasKey("glyphs"))
{
// Read in the ItemStacks in the inventory from NBT
if (nbtTagCompound.hasKey("glyphs")) {
if (nbtTagCompound.hasKey("glyphs"))
{
NBTTagList tagList = nbtTagCompound.getTagList("glyphs", 10);
glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0;
for (int i = 0; i < tagList.tagCount(); ++i) {
for (int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
Glyph glyph = Glyph.readGlyphFromNBT(tagCompound);
glyphs.add(glyph);
if (glyph.getSize() > largestGlyphSize) {
if (glyph.getSize() > largestGlyphSize)
{
largestGlyphSize = glyph.getSize();
}
}
} else {
}
else
{
glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0;
}
} else {
}
else
{
glyphs = new TreeSet<Glyph>();
largestGlyphSize = 0;
}
}
public void writeToNBT(NBTTagCompound nbtTagCompound) {
public void writeToNBT(NBTTagCompound nbtTagCompound)
{
NBTTagList tagList = new NBTTagList();
for (Glyph glyph : glyphs) {
for (Glyph glyph : glyphs)
{
NBTTagCompound tagCompound = new NBTTagCompound();
glyph.writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
@ -95,17 +118,20 @@ public class AlchemyArray implements Comparable<AlchemyArray> {
nbtTagCompound.setInteger("largestGlyphSize", largestGlyphSize);
}
public static AlchemyArray readAlchemyArrayFromNBT(NBTTagCompound nbtTagCompound) {
public static AlchemyArray readAlchemyArrayFromNBT(NBTTagCompound nbtTagCompound)
{
AlchemyArray alchemyArray = new AlchemyArray();
alchemyArray.readFromNBT(nbtTagCompound);
return alchemyArray;
}
@Override
public String toString() {
public String toString()
{
StringBuilder stringBuilder = new StringBuilder();
for (Glyph glyph : glyphs) {
for (Glyph glyph : glyphs)
{
stringBuilder.append(glyph.toString() + ", ");
}
@ -113,8 +139,10 @@ public class AlchemyArray implements Comparable<AlchemyArray> {
}
@Override
public boolean equals(Object object) {
if (object instanceof AlchemyArray) {
public boolean equals(Object object)
{
if (object instanceof AlchemyArray)
{
return this.compareTo((AlchemyArray) object) == 0;
}
@ -122,16 +150,22 @@ public class AlchemyArray implements Comparable<AlchemyArray> {
}
@Override
public int compareTo(AlchemyArray alchemyArray) {
if (this.glyphs.size() == alchemyArray.glyphs.size()) {
for (Glyph glyph : this.glyphs) {
if (!alchemyArray.glyphs.contains(glyph)) {
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 {
}
else
{
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;
}
EE3Wrapper.ee3mod.getGlyphRegistry().addGlyph(glyphTexture, unLocalizedName);
EE3Wrapper.ee3mod.getGlyphRegistry().registerGlyph(glyphTexture, unLocalizedName);
}
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
{
private static GlyphTextureRegistry glyphTextureRegistry = null;
private SortedMap<ResourceLocation, String> glyphTextureSortedMap;
private SortedMap<ResourceLocation, String> registeredGlyphTextures;
private GlyphTextureRegistry()
{
@ -31,40 +31,40 @@ public class GlyphTextureRegistry
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)
{
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)
{
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;
}
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>()

View file

@ -28,30 +28,36 @@ import java.util.Random;
import static net.minecraftforge.common.util.ForgeDirection.*;
public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
public BlockAlchemyArray() {
public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider
{
public BlockAlchemyArray()
{
super(Material.circuits);
this.setCreativeTab(null);
this.setBlockName(Names.Blocks.ALCHEMY_ARRAY);
}
@Override
public boolean renderAsNormalBlock() {
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getRenderType() {
public int getRenderType()
{
return RenderIds.alchemyArray;
}
@Override
public Item getItemDropped(int par1, Random random, int par2) {
public Item getItemDropped(int par1, Random random, int par2)
{
return null;
}
@ -62,12 +68,14 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
* @param metaData
*/
@Override
public TileEntity createNewTileEntity(World world, int metaData) {
public TileEntity createNewTileEntity(World world, int metaData)
{
return new TileEntityAlchemyArray();
}
@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) &&
(world.isSideSolid(x - 1, y, z, EAST) ||
world.isSideSolid(x + 1, y, z, WEST) ||
@ -78,7 +86,8 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
}
@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);
return world.getBlock(x, y, z).isReplaceable(world, x, y, z) &&
((side == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) ||
@ -90,36 +99,52 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
}
@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;
}
@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;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) {
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
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;
} 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;
} 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;
} 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;
} 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;
} 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;
}
if (invalidateAlchemyArray) {
if (invalidateAlchemyArray)
{
tileEntityAlchemyArray.invalidate();
world.setBlockToAir(x, y, z);
}
@ -127,15 +152,18 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
}
@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;
}
@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));
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);
ChalkSettings chalkSettings = new ChalkSettings();
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;
((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);
}
}
@Override
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) {
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)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
if (entityPlayer.getCurrentEquippedItem() != null && entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemChalk && !entityPlayer.isSneaking())
{
NBTTagCompound customEntityData = EntityHelper.getCustomEntityData(entityPlayer);
ChalkSettings chalkSettings = new ChalkSettings();
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.getTileEntity(x, y, z).markDirty();
CommonSoundHelper.playChalkSoundAt(entityPlayer);
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
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
{
return null;
}
@ -186,36 +222,46 @@ public class BlockAlchemyArray extends BlockEE implements ITileEntityProvider {
* x, y, z, startVec, endVec
*/
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray) {
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
{
if (world.getTileEntity(x, y, z) instanceof TileEntityAlchemyArray)
{
TileEntityAlchemyArray tileEntityAlchemyArray = (TileEntityAlchemyArray) world.getTileEntity(x, y, z);
switch (tileEntityAlchemyArray.getOrientation()) {
case DOWN: {
switch (tileEntityAlchemyArray.getOrientation())
{
case DOWN:
{
this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f);
break;
}
case UP: {
case UP:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f);
break;
}
case NORTH: {
case NORTH:
{
this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f);
break;
}
case SOUTH: {
case SOUTH:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f);
break;
}
case EAST: {
case EAST:
{
this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f);
break;
}
case WEST: {
case WEST:
{
this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f);
break;
}
case UNKNOWN: {
case UNKNOWN:
{
break;
}
}

View file

@ -5,7 +5,6 @@ import com.pahimar.ee3.reference.RenderIds;
import com.pahimar.ee3.tileentity.TileEntityAlchemyArray;
import com.pahimar.ee3.tileentity.TileEntityDummyArray;
import com.pahimar.ee3.tileentity.TileEntityEE;
import com.pahimar.ee3.util.LogHelper;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
@ -25,40 +24,48 @@ import java.util.Random;
import static net.minecraftforge.common.util.ForgeDirection.*;
public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
public BlockDummyArray() {
public class BlockDummyArray extends BlockEE implements ITileEntityProvider
{
public BlockDummyArray()
{
super(Material.circuits);
setCreativeTab(null);
this.setBlockName(Names.Blocks.DUMMY_ARRAY);
}
@Override
public boolean isOpaqueCube() {
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean renderAsNormalBlock() {
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int getRenderType() {
public int getRenderType()
{
return RenderIds.dummyArray;
}
@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;
}
@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;
}
@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) &&
(world.isSideSolid(x - 1, y, z, EAST) ||
world.isSideSolid(x + 1, y, z, WEST) ||
@ -69,7 +76,8 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
}
@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);
return world.getBlock(x, y, z).isReplaceable(world, x, y, z) &&
((side == DOWN && world.isSideSolid(x, y + 1, z, DOWN)) ||
@ -81,24 +89,27 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
}
@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));
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z), 3);
}
@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;
}
@Override
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) {
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)
{
int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord();
int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord();
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);
}
@ -106,31 +117,46 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) {
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
if (!world.isRemote && world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
int trueXCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueXCoord();
int trueYCoord = ((TileEntityDummyArray) world.getTileEntity(x, y, z)).getTrueYCoord();
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);
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;
} 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;
} 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;
} 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;
} 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;
} 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;
}
if (invalidateAlchemyArray) {
if (invalidateAlchemyArray)
{
world.getTileEntity(x, y, z).invalidate();
tileEntityAlchemyArray.invalidate();
world.setBlockToAir(x, y, z);
@ -141,46 +167,58 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
}
@Override
public Item getItemDropped(int par1, Random random, int par2) {
public Item getItemDropped(int par1, Random random, int par2)
{
return null;
}
@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;
}
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec) {
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) {
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVec, Vec3 endVec)
{
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) world.getTileEntity(x, y, z);
switch (tileEntityDummyArray.getOrientation()) {
case DOWN: {
switch (tileEntityDummyArray.getOrientation())
{
case DOWN:
{
this.setBlockBounds(0f, 1f, 0f, 1f, 1 - 0.0625f, 1f);
break;
}
case UP: {
case UP:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 0.0625f, 1f);
break;
}
case NORTH: {
case NORTH:
{
this.setBlockBounds(0f, 0f, 1 - 0.0625f, 1f, 1f, 1f);
break;
}
case SOUTH: {
case SOUTH:
{
this.setBlockBounds(0f, 0f, 0f, 1f, 1f, 0.0625f);
break;
}
case EAST: {
case EAST:
{
this.setBlockBounds(0f, 0f, 0f, 0.0625f, 1f, 1f);
break;
}
case WEST: {
case WEST:
{
this.setBlockBounds(1f, 0f, 0f, 1 - 0.0625f, 1f, 1f);
break;
}
case UNKNOWN: {
case UNKNOWN:
{
break;
}
}
@ -189,8 +227,10 @@ public class BlockDummyArray extends BlockEE implements ITileEntityProvider {
return super.collisionRayTrace(world, x, y, z, startVec, endVec);
}
public void breakBlock(World world, int x, int y, int z, Block block, int metaData) {
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray) {
public void breakBlock(World world, int x, int y, int z, Block block, int metaData)
{
if (world.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
TileEntity tileEntity = world.getTileEntity(x, y, z);
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
*/
@Override
public TileEntity createNewTileEntity(World world, int metaData) {
public TileEntity createNewTileEntity(World world, int metaData)
{
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.tileentity.TileEntityAlchemyArray;
import com.pahimar.ee3.tileentity.TileEntityDummyArray;
import com.pahimar.ee3.tileentity.TileEntityEE;
import com.pahimar.ee3.util.IModalTool;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -220,21 +220,156 @@ public class DrawBlockHighlightEventHandler
private void drawGlyphOverlay(DrawBlockHighlightEvent event)
{
ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings;
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);
drawGlyphInWorld(event);
}
if (tileEntity instanceof TileEntityAlchemyArray || tileEntity instanceof TileEntityDummyArray) {
drawGlyphInWorld(event, texture, chargeLevel, rotation);
} else {
// NOT an already placed array, render as normal
drawGlyphInWorld(event, texture, chargeLevel, rotation);
private static void drawGlyphInWorld(DrawBlockHighlightEvent event)
{
ChalkSettings chalkSettings = EquivalentExchange3.proxy.getClientProxy().chalkSettings;
ResourceLocation texture = GlyphTextureRegistry.getInstance().getRegisteredGlyphAt(chalkSettings.getIndex());
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 y = event.target.blockY + 0.5F;
double z = event.target.blockZ + 0.5F;
@ -258,66 +393,79 @@ public class DrawBlockHighlightEventHandler
ForgeDirection sideHit = ForgeDirection.getOrientation(event.target.sideHit);
TileEntity tileEntity = event.player.worldObj.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
switch (sideHit) {
case UP: {
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) {
if (tileEntity instanceof TileEntityAlchemyArray)
{
y -= 1;
}
break;
}
case DOWN: {
case DOWN:
{
xScale = zScale = chargeLevel;
yShift = -0.001f;
xRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360;
facingCorrectionAngle = (-90 * (playerFacing + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) {
if (tileEntity instanceof TileEntityAlchemyArray)
{
y += 1;
}
break;
}
case NORTH: {
case NORTH:
{
xScale = yScale = chargeLevel;
zCorrection = -1;
zShift = -0.001f;
zRotate = 1;
rotationAngle = (-90 * (rotation + 1)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) {
if (tileEntity instanceof TileEntityAlchemyArray)
{
z += 1;
}
break;
}
case SOUTH: {
case SOUTH:
{
xScale = yScale = chargeLevel;
zShift = 0.001f;
zRotate = -1;
rotationAngle = (-90 * (rotation + 1)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) {
if (tileEntity instanceof TileEntityAlchemyArray)
{
z -= 1;
}
break;
}
case EAST: {
case EAST:
{
yScale = zScale = chargeLevel;
xShift = 0.001f;
yRotate = 1;
rotationAngle = (-90 * (rotation + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) {
if (tileEntity instanceof TileEntityAlchemyArray)
{
x -= 1;
}
break;
}
case WEST: {
case WEST:
{
yScale = zScale = chargeLevel;
xShift = -0.001f;
yRotate = -1;
rotationAngle = (-90 * (rotation + 2)) % 360;
if (tileEntity instanceof TileEntityAlchemyArray) {
if (tileEntity instanceof TileEntityAlchemyArray)
{
x += 1;
}
break;
@ -325,6 +473,7 @@ public class DrawBlockHighlightEventHandler
default:
break;
}
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glPushMatrix();

View file

@ -64,8 +64,8 @@ public class ItemRendererGlassBell implements IItemRenderer
private void renderGlassBell(float x, float y, float z)
{
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
// 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);
int scale;
double xShift, yShift, zShift;
float xRotate, yRotate, zRotate;
int rotationAngle;
xShift = yShift = zShift = 0.5d;
xRotate = yRotate = zRotate = 0;
rotationAngle = 0;
double xShift = 0.5d, yShift = 0.5d, zShift = 0.5d;
float xRotate = 0, yRotate = 0, zRotate = 0;
int rotationAngle = 0;
GL11.glDisable(GL11.GL_CULL_FACE);
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
* call-back method again).
*
* @param jsonElement The Json data being deserialized
* @param typeOfT The type of the Object to deserialize to
* @param jsonElement The Json data being deserialized
* @param typeOfT The type of the Object to deserialize to
* @param context
* @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}

View file

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

View file

@ -37,9 +37,9 @@ public class ChalkSettings implements INBTTaggable
{
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;
if (index >= GlyphTextureRegistry.getInstance().getGlyphs().size())
if (index >= GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size())
{
index = 0;
}
@ -59,7 +59,7 @@ public class ChalkSettings implements INBTTaggable
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");
if (this.index < 0 || this.index >= GlyphTextureRegistry.getInstance().getGlyphs().size())
if (this.index < 0 || this.index >= GlyphTextureRegistry.getInstance().getRegisteredGlyphTextures().size())
{
this.index = 0;
}

View file

@ -6,98 +6,160 @@ import com.pahimar.ee3.network.PacketHandler;
import com.pahimar.ee3.network.message.MessageTileEntityAlchemyArray;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityAlchemyArray extends TileEntityEE {
public class TileEntityAlchemyArray extends TileEntityEE
{
private AlchemyArray alchemyArray;
private ForgeDirection rotation;
private int ticksSinceSync;
public TileEntityAlchemyArray() {
public TileEntityAlchemyArray()
{
super();
alchemyArray = new AlchemyArray();
rotation = ForgeDirection.UNKNOWN;
}
public AlchemyArray getAlchemyArray() {
public AlchemyArray getAlchemyArray()
{
return alchemyArray;
}
public boolean addGlyphToAlchemyArray(Glyph glyph) {
public boolean addGlyphToAlchemyArray(Glyph 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));
}
public ForgeDirection getRotation() {
public ForgeDirection getRotation()
{
return rotation;
}
public void setRotation(int rotation, int facing) {
if (this.orientation == ForgeDirection.UP) {
if ((rotation + facing) % 4 == 0) {
public void setRotation(int rotation, int facing)
{
if (this.orientation == ForgeDirection.UP)
{
if ((rotation + facing) % 4 == 0)
{
this.rotation = ForgeDirection.NORTH;
} else if ((rotation + facing) % 4 == 1) {
}
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) {
}
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) {
}
else if ((rotation + facing) % 4 == 3)
{
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;
} else if ((rotation + facing) % 4 == 1) {
}
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) {
}
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) {
}
else if ((rotation + facing) % 4 == 3)
{
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;
} else if ((rotation + facing) % 4 == 1) {
}
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) {
}
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.DOWN;
} else if ((rotation + facing) % 4 == 3) {
}
else if ((rotation + facing) % 4 == 3)
{
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;
} else if ((rotation + facing) % 4 == 1) {
}
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.EAST;
} else if ((rotation + facing) % 4 == 2) {
}
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.UP;
} else if ((rotation + facing) % 4 == 3) {
}
else if ((rotation + facing) % 4 == 3)
{
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;
} else if ((rotation + facing) % 4 == 1) {
}
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.UP;
} else if ((rotation + facing) % 4 == 2) {
}
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) {
}
else if ((rotation + facing) % 4 == 3)
{
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;
} else if ((rotation + facing) % 4 == 1) {
}
else if ((rotation + facing) % 4 == 1)
{
this.rotation = ForgeDirection.DOWN;
} else if ((rotation + facing) % 4 == 2) {
}
else if ((rotation + facing) % 4 == 2)
{
this.rotation = ForgeDirection.SOUTH;
} else if ((rotation + facing) % 4 == 3) {
}
else if ((rotation + facing) % 4 == 3)
{
this.rotation = ForgeDirection.UP;
}
}
@ -105,12 +167,18 @@ public class TileEntityAlchemyArray extends TileEntityEE {
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox() {
if (this.orientation == ForgeDirection.UP || this.orientation == ForgeDirection.DOWN) {
public AxisAlignedBB getRenderBoundingBox()
{
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());
} 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);
} 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());
}
@ -118,12 +186,14 @@ public class TileEntityAlchemyArray extends TileEntityEE {
}
@Override
public Packet getDescriptionPacket() {
public Packet getDescriptionPacket()
{
return PacketHandler.INSTANCE.getPacketFrom(new MessageTileEntityAlchemyArray(this));
}
@Override
public void readFromNBT(NBTTagCompound nbtTagCompound) {
public void readFromNBT(NBTTagCompound nbtTagCompound)
{
super.readFromNBT(nbtTagCompound);
NBTTagCompound alchemyArrayTagCompound = nbtTagCompound.getCompoundTag("alchemyArray");
@ -133,7 +203,8 @@ public class TileEntityAlchemyArray extends TileEntityEE {
}
@Override
public void writeToNBT(NBTTagCompound nbtTagCompound) {
public void writeToNBT(NBTTagCompound nbtTagCompound)
{
super.writeToNBT(nbtTagCompound);
NBTTagCompound alchemyArrayTagCompound = new NBTTagCompound();
@ -145,12 +216,16 @@ public class TileEntityAlchemyArray extends TileEntityEE {
}
@Override
public void updateEntity() {
public void updateEntity()
{
super.updateEntity();
if (!worldObj.isRemote) {
if (++ticksSinceSync % 100 == 0) {
if (!areDummyBlocksValid()) {
if (!worldObj.isRemote)
{
if (++ticksSinceSync % 100 == 0)
{
if (!areDummyBlocksValid())
{
this.invalidate();
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;
int coordOffset = this.alchemyArray.getLargestGlyphSize() / 2;
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++) {
if ((i != this.xCoord || j != this.zCoord) && !isValidDummyBlock(i, this.yCoord, j)) {
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++)
{
if ((i != this.xCoord || j != this.zCoord) && !isValidDummyBlock(i, this.yCoord, j))
{
validDummyBlocks = false;
}
}
}
} else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH) {
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)) {
}
else if (this.orientation == ForgeDirection.NORTH || this.orientation == ForgeDirection.SOUTH)
{
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;
}
}
}
} else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST) {
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)) {
}
else if (this.orientation == ForgeDirection.EAST || this.orientation == ForgeDirection.WEST)
{
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;
}
}
@ -191,9 +287,12 @@ public class TileEntityAlchemyArray extends TileEntityEE {
return validDummyBlocks;
}
private boolean isValidDummyBlock(int x, int y, int z) {
if (!this.worldObj.isRemote) {
if (this.worldObj.getTileEntity(x, y, z) instanceof TileEntityDummyArray) {
private boolean isValidDummyBlock(int x, int y, int z)
{
if (!this.worldObj.isRemote)
{
if (this.worldObj.getTileEntity(x, y, z) instanceof TileEntityDummyArray)
{
TileEntityDummyArray tileEntityDummyArray = (TileEntityDummyArray) this.worldObj.getTileEntity(x, y, z);
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
*
* @param recipe
* The IRecipe being examined
*
* @param recipe The IRecipe being examined
* @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)
@ -137,9 +135,7 @@ public class RecipeHelper
/**
* Collates an uncollated, unsorted List of Objects into a sorted, collated List of WrappedStacks
*
* @param uncollatedStacks
* List of objects for collating
*
* @param uncollatedStacks List of objects for collating
* @return A sorted, collated List of WrappedStacks
*/
public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks)