Just some refactoring before a sprint of work tomorrow
This commit is contained in:
parent
1bcfc551be
commit
6daa78de20
7 changed files with 86 additions and 79 deletions
|
@ -24,7 +24,7 @@ import java.util.Random;
|
||||||
*
|
*
|
||||||
* @author pahimar
|
* @author pahimar
|
||||||
*/
|
*/
|
||||||
public class BlockAlchemicalChest extends BlockEE
|
public class BlockAlchemicalChest extends BlockContainerEE
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Random;
|
||||||
*
|
*
|
||||||
* @author pahimar
|
* @author pahimar
|
||||||
*/
|
*/
|
||||||
public class BlockAludelBase extends BlockEE
|
public class BlockAludelBase extends BlockContainerEE
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Random;
|
||||||
*
|
*
|
||||||
* @author pahimar
|
* @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.
|
* Is the random generator used by calcinator to drop the inventory contents in random directions.
|
||||||
|
|
77
src/main/java/com/pahimar/ee3/block/BlockContainerEE.java
Normal file
77
src/main/java/com/pahimar/ee3/block/BlockContainerEE.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,82 +1,12 @@
|
||||||
package com.pahimar.ee3.block;
|
package com.pahimar.ee3.block;
|
||||||
|
|
||||||
import com.pahimar.ee3.lib.Reference;
|
import net.minecraft.block.Block;
|
||||||
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.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;
|
|
||||||
|
|
||||||
/**
|
public class BlockEE extends Block
|
||||||
* Equivalent-Exchange-3
|
|
||||||
* <p/>
|
|
||||||
* BlockEE
|
|
||||||
*
|
|
||||||
* @author pahimar
|
|
||||||
*/
|
|
||||||
public abstract class BlockEE extends BlockContainer
|
|
||||||
{
|
{
|
||||||
|
public BlockEE(int id)
|
||||||
public BlockEE(int id, Material material)
|
|
||||||
{
|
{
|
||||||
|
super(id, Material.rock);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockGlassBell extends BlockEE
|
public class BlockGlassBell extends BlockContainerEE
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class EmcRegistry
|
||||||
{
|
{
|
||||||
passNumber++;
|
passNumber++;
|
||||||
computedStackValues = computeStackMappings();
|
computedStackValues = computeStackMappings();
|
||||||
|
// TODO Duplicate entry protection
|
||||||
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
|
stackMappingsBuilder = ImmutableSortedMap.naturalOrder();
|
||||||
stackMappingsBuilder.putAll(stackMappings);
|
stackMappingsBuilder.putAll(stackMappings);
|
||||||
stackMappingsBuilder.putAll(computedStackValues);
|
stackMappingsBuilder.putAll(computedStackValues);
|
||||||
|
|
Loading…
Reference in a new issue