Just some refactoring before a sprint of work tomorrow

This commit is contained in:
pahimar 2013-12-26 20:59:51 -05:00
parent 1bcfc551be
commit 6daa78de20
7 changed files with 86 additions and 79 deletions

View file

@ -24,7 +24,7 @@ import java.util.Random;
*
* @author pahimar
*/
public class BlockAlchemicalChest extends BlockEE
public class BlockAlchemicalChest extends BlockContainerEE
{
/**

View file

@ -27,7 +27,7 @@ import java.util.Random;
*
* @author pahimar
*/
public class BlockAludelBase extends BlockEE
public class BlockAludelBase extends BlockContainerEE
{
/**

View file

@ -23,7 +23,7 @@ import java.util.Random;
*
* @author pahimar
*/
public class BlockCalcinator extends BlockEE
public class BlockCalcinator extends BlockContainerEE
{
/**
* Is the random generator used by calcinator to drop the inventory contents in random directions.

View file

@ -0,0 +1,77 @@
package com.pahimar.ee3.block;
import com.pahimar.ee3.lib.Reference;
import com.pahimar.ee3.tileentity.TileEE;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/**
* Equivalent-Exchange-3
* <p/>
* BlockContainerEE
*
* @author pahimar
*/
public abstract class BlockContainerEE extends BlockContainer
{
public BlockContainerEE(int id, Material material)
{
super(id, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon(String.format("%s:%s", Reference.MOD_ID.toLowerCase(), getUnwrappedUnlocalizedName(this.getUnlocalizedName())));
}
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(":") + 1);
}
/**
* Sets the direction of the block when placed
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
{
int direction = 0;
int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if (facing == 0)
{
direction = ForgeDirection.NORTH.ordinal();
}
else if (facing == 1)
{
direction = ForgeDirection.EAST.ordinal();
}
else if (facing == 2)
{
direction = ForgeDirection.SOUTH.ordinal();
}
else if (facing == 3)
{
direction = ForgeDirection.WEST.ordinal();
}
world.setBlockMetadataWithNotify(x, y, z, direction, 3);
if (itemStack.hasDisplayName())
{
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
}
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(direction);
}
}

View file

@ -1,82 +1,12 @@
package com.pahimar.ee3.block;
import com.pahimar.ee3.lib.Reference;
import com.pahimar.ee3.tileentity.TileEE;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
/**
* Equivalent-Exchange-3
* <p/>
* BlockEE
*
* @author pahimar
*/
public abstract class BlockEE extends BlockContainer
public class BlockEE extends Block
{
public BlockEE(int id, Material material)
public BlockEE(int id)
{
super(id, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon(String.format("%s:%s", Reference.MOD_ID.toLowerCase(), getUnwrappedUnlocalizedName(this.getUnlocalizedName())));
}
protected String getUnwrappedUnlocalizedName(String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(":") + 1);
}
/**
* Sets the direction of the block when placed
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
{
int direction = 0;
int facing = MathHelper.floor_double(entityLiving.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
if (facing == 0)
{
direction = ForgeDirection.NORTH.ordinal();
}
else if (facing == 1)
{
direction = ForgeDirection.EAST.ordinal();
}
else if (facing == 2)
{
direction = ForgeDirection.SOUTH.ordinal();
}
else if (facing == 3)
{
direction = ForgeDirection.WEST.ordinal();
}
world.setBlockMetadataWithNotify(x, y, z, direction, 3);
if (itemStack.hasDisplayName())
{
((TileEE) world.getBlockTileEntity(x, y, z)).setCustomName(itemStack.getDisplayName());
}
((TileEE) world.getBlockTileEntity(x, y, z)).setOrientation(direction);
super(id, Material.rock);
}
}

View file

@ -24,7 +24,7 @@ import net.minecraftforge.common.ForgeDirection;
import java.util.Random;
public class BlockGlassBell extends BlockEE
public class BlockGlassBell extends BlockContainerEE
{
/**

View file

@ -97,7 +97,7 @@ public class EmcRegistry
{
passNumber++;
computedStackValues = computeStackMappings();
// TODO Duplicate entry protection
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
stackMappingsBuilder.putAll(stackMappings);
stackMappingsBuilder.putAll(computedStackValues);