Changed battery box to use all 6 sides
This commit is contained in:
parent
8a29a78e9e
commit
dc80c87140
4 changed files with 61 additions and 32 deletions
|
@ -59,6 +59,7 @@ import dark.core.common.machines.BlockEnergyStorage;
|
||||||
import dark.core.common.machines.BlockSmallSteamGen;
|
import dark.core.common.machines.BlockSmallSteamGen;
|
||||||
import dark.core.common.machines.BlockDebug;
|
import dark.core.common.machines.BlockDebug;
|
||||||
import dark.core.common.machines.BlockSolarPanel;
|
import dark.core.common.machines.BlockSolarPanel;
|
||||||
|
import dark.core.common.machines.ItemBlockEnergyStorage;
|
||||||
import dark.core.common.transmit.BlockWire;
|
import dark.core.common.transmit.BlockWire;
|
||||||
import dark.core.common.transmit.ItemBlockWire;
|
import dark.core.common.transmit.ItemBlockWire;
|
||||||
import dark.core.helpers.PacketDataWatcher;
|
import dark.core.helpers.PacketDataWatcher;
|
||||||
|
@ -280,7 +281,7 @@ public class DarkMain extends ModPrefab
|
||||||
CoreRecipeLoader.blockGlowGlass = ModObjectRegistry.createNewBlock("DMBlockGlowGlass", DarkMain.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class);
|
CoreRecipeLoader.blockGlowGlass = ModObjectRegistry.createNewBlock("DMBlockGlowGlass", DarkMain.MOD_ID, BlockColorGlowGlass.class, ItemBlockColored.class);
|
||||||
CoreRecipeLoader.blockSolar = ModObjectRegistry.createNewBlock("DMBlockSolar", DarkMain.MOD_ID, BlockSolarPanel.class, ItemBlockHolder.class);
|
CoreRecipeLoader.blockSolar = ModObjectRegistry.createNewBlock("DMBlockSolar", DarkMain.MOD_ID, BlockSolarPanel.class, ItemBlockHolder.class);
|
||||||
CoreRecipeLoader.blockGas = ModObjectRegistry.createNewBlock("DMBlockGas", DarkMain.MOD_ID, BlockGasOre.class, ItemBlockHolder.class);
|
CoreRecipeLoader.blockGas = ModObjectRegistry.createNewBlock("DMBlockGas", DarkMain.MOD_ID, BlockGasOre.class, ItemBlockHolder.class);
|
||||||
CoreRecipeLoader.blockBatBox = ModObjectRegistry.createNewBlock("DMBlockBatBox", DarkMain.MOD_ID, BlockEnergyStorage.class, ItemBlockHolder.class);
|
CoreRecipeLoader.blockBatBox = ModObjectRegistry.createNewBlock("DMBlockBatBox", DarkMain.MOD_ID, BlockEnergyStorage.class, ItemBlockEnergyStorage.class);
|
||||||
|
|
||||||
/* ITEMS */
|
/* ITEMS */
|
||||||
CoreRecipeLoader.itemTool = ModObjectRegistry.createNewItem("DMReadoutTools", DarkMain.MOD_ID, ItemReadoutTools.class, true);
|
CoreRecipeLoader.itemTool = ModObjectRegistry.createNewItem("DMReadoutTools", DarkMain.MOD_ID, ItemReadoutTools.class, true);
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraftforge.common.ForgeDirection;
|
||||||
import universalelectricity.core.UniversalElectricity;
|
import universalelectricity.core.UniversalElectricity;
|
||||||
import universalelectricity.core.block.IConductor;
|
import universalelectricity.core.block.IConductor;
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
|
import dark.core.common.DMCreativeTab;
|
||||||
import dark.core.common.DarkMain;
|
import dark.core.common.DarkMain;
|
||||||
import dark.core.helpers.MathHelper;
|
import dark.core.helpers.MathHelper;
|
||||||
import dark.core.prefab.machine.BlockMachine;
|
import dark.core.prefab.machine.BlockMachine;
|
||||||
|
@ -24,22 +25,17 @@ import dark.core.prefab.machine.BlockMachine;
|
||||||
* @author Rseifert */
|
* @author Rseifert */
|
||||||
public class BlockEnergyStorage extends BlockMachine
|
public class BlockEnergyStorage extends BlockMachine
|
||||||
{
|
{
|
||||||
public static final int BATTERY_BOX_METADATA = 0;
|
|
||||||
|
|
||||||
public BlockEnergyStorage()
|
public BlockEnergyStorage()
|
||||||
{
|
{
|
||||||
super(DarkMain.CONFIGURATION, "DMEnergyStorage", UniversalElectricity.machine);
|
super(DarkMain.CONFIGURATION, "DMEnergyStorage", UniversalElectricity.machine);
|
||||||
|
this.setCreativeTab(DMCreativeTab.tabIndustrial);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
|
public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side)
|
||||||
{
|
{
|
||||||
Vector3 vec = new Vector3(x, y, z);
|
Vector3 vec = new Vector3(x, y, z);
|
||||||
int meta = vec.getBlockMetadata(world);
|
int meta = vec.getBlockMetadata(world);
|
||||||
if (side == 0 || side == 1)
|
if (side == (meta))
|
||||||
{
|
|
||||||
return this.blockIcon;
|
|
||||||
}
|
|
||||||
if(side == (meta - BlockEnergyStorage.BATTERY_BOX_METADATA + 2))
|
|
||||||
{
|
{
|
||||||
return this.iconOutput;
|
return this.iconOutput;
|
||||||
}
|
}
|
||||||
|
@ -47,28 +43,11 @@ public class BlockEnergyStorage extends BlockMachine
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
super.onBlockPlacedBy(world, x, y, z, entityLiving, itemStack);
|
|
||||||
int metadata = world.getBlockMetadata(x, y, z);
|
|
||||||
int angle = MathHelper.floor_double((entityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, ((metadata / 4) * 4) + angle, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
if (world.getBlockMetadata(x, y, z) % 4 < 3)
|
world.setBlockMetadataWithNotify(x, y, z, side, 3);
|
||||||
{
|
return true;
|
||||||
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) + 1, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 3, 3);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,13 +72,13 @@ public class BlockEnergyStorage extends BlockMachine
|
||||||
@Override
|
@Override
|
||||||
public int damageDropped(int metadata)
|
public int damageDropped(int metadata)
|
||||||
{
|
{
|
||||||
return metadata / 4;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
return new ItemStack(this, 1, (world.getBlockMetadata(x, y, z) / 4) * 4);
|
return new ItemStack(this, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
49
src/dark/core/common/machines/ItemBlockEnergyStorage.java
Normal file
49
src/dark/core/common/machines/ItemBlockEnergyStorage.java
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
package dark.core.common.machines;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/** Item version of the enrgy storage block
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public class ItemBlockEnergyStorage extends ItemBlock
|
||||||
|
{
|
||||||
|
public ItemBlockEnergyStorage(int id)
|
||||||
|
{
|
||||||
|
super(id);
|
||||||
|
this.setMaxDamage(0);
|
||||||
|
this.setHasSubtypes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetadata(int damage)
|
||||||
|
{
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName(ItemStack itemStack)
|
||||||
|
{
|
||||||
|
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
|
||||||
|
{
|
||||||
|
if (!world.setBlock(x, y, z, this.getBlockID(), side, 3))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world.getBlockId(x, y, z) == this.getBlockID())
|
||||||
|
{
|
||||||
|
Block.blocksList[this.getBlockID()].onBlockPlacedBy(world, x, y, z, player, stack);
|
||||||
|
Block.blocksList[this.getBlockID()].onPostBlockPlaced(world, x, y, z, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,7 +41,7 @@ public class TileEntityBatteryBox extends TileEntityEnergyMachine
|
||||||
/** Decharge electric item. */
|
/** Decharge electric item. */
|
||||||
EnergyHelper.discharge(this.getStackInSlot(1), this);
|
EnergyHelper.discharge(this.getStackInSlot(1), this);
|
||||||
|
|
||||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockEnergyStorage.BATTERY_BOX_METADATA + 2);
|
ForgeDirection outputDirection = ForgeDirection.getOrientation(this.getBlockMetadata());
|
||||||
TileEntity inputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection.getOpposite());
|
TileEntity inputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection.getOpposite());
|
||||||
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
|
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
|
||||||
|
|
||||||
|
@ -83,13 +83,13 @@ public class TileEntityBatteryBox extends TileEntityEnergyMachine
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection direction)
|
public boolean canConnect(ForgeDirection direction)
|
||||||
{
|
{
|
||||||
return direction == ForgeDirection.getOrientation(this.getBlockMetadata() - BlockEnergyStorage.BATTERY_BOX_METADATA + 2) || direction == ForgeDirection.getOrientation(this.getBlockMetadata() - BlockEnergyStorage.BATTERY_BOX_METADATA + 2).getOpposite();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumSet<ForgeDirection> getOutputDirections()
|
public EnumSet<ForgeDirection> getOutputDirections()
|
||||||
{
|
{
|
||||||
return EnumSet.of(ForgeDirection.getOrientation(this.getBlockMetadata() - BlockEnergyStorage.BATTERY_BOX_METADATA + 2).getOpposite());
|
return EnumSet.of(ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue