Cleared battery classes, starting rewrite
This commit is contained in:
parent
8e27fb2364
commit
76873c9873
4 changed files with 2 additions and 231 deletions
|
@ -33,120 +33,6 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
this.setTextureName(ResonantInduction.PREFIX + "machine");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer entityPlayer)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
TileBattery tileEntity = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
ItemStack itemStack = ListUtil.getTop(tileEntity.structure.inventory);
|
||||
|
||||
if (tileEntity.structure.inventory.remove(itemStack))
|
||||
{
|
||||
entityPlayer.dropPlayerItem(itemStack);
|
||||
tileEntity.updateAllClients();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float xClick, float yClick, float zClick)
|
||||
{
|
||||
TileBattery tileEntity = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (entityPlayer.isSneaking())
|
||||
{
|
||||
boolean result = tileEntity.toggleSide(ForgeDirection.getOrientation(side));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entityPlayer.addChatMessage("Toggled side to: " + (result ? "input" : "output"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem() != null)
|
||||
{
|
||||
if (entityPlayer.getCurrentEquippedItem().getItem() instanceof ICapacitor)
|
||||
{
|
||||
if (side != 0 && side != 1)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tileEntity.structure.addCell(entityPlayer.getCurrentEquippedItem()))
|
||||
{
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
tileEntity.updateAllClients();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Place cells into block. 2 Dimensional Click Zone.
|
||||
*
|
||||
* TODO: In the future.
|
||||
*/
|
||||
float xHit = 0;
|
||||
float yHit = yClick;
|
||||
|
||||
if (side == 2 || side == 3)
|
||||
{
|
||||
xHit = xClick;
|
||||
|
||||
if (side == 2)
|
||||
{
|
||||
xHit = 1 - xHit;
|
||||
}
|
||||
}
|
||||
else if (side == 4 || side == 5)
|
||||
{
|
||||
xHit = zClick;
|
||||
|
||||
if (side == 5)
|
||||
{
|
||||
xHit = 1 - xHit;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert to quadrant coords.
|
||||
xHit -= 0.5f;
|
||||
yHit -= 0.5f;
|
||||
|
||||
// Quadrant 1
|
||||
if (xHit > 0 && yHit > 0)
|
||||
{
|
||||
|
||||
}// Quadrant 2
|
||||
if (xHit > 0 && yHit < 0)
|
||||
{
|
||||
|
||||
}// Quadrant 3
|
||||
if (xHit < 0 && yHit < 0)
|
||||
{
|
||||
|
||||
}// Quadrant 4
|
||||
if (xHit < 0 && yHit > 0)
|
||||
{
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entityPlayer.openGui(ResonantInduction.INSTANCE, 0, world, x, y, z);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int id)
|
||||
{
|
||||
|
@ -155,7 +41,6 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
if (id == blockID)
|
||||
{
|
||||
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
battery.update();
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +52,6 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
if (!world.isRemote)
|
||||
{
|
||||
TileBattery battery = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
battery.update();
|
||||
}
|
||||
}
|
||||
|
@ -184,32 +68,6 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
if (!world.isRemote && canHarvestBlock(player, world.getBlockMetadata(x, y, z)))
|
||||
{
|
||||
TileBattery tileEntity = (TileBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (!tileEntity.structure.isMultiblock)
|
||||
{
|
||||
for (ItemStack itemStack : tileEntity.structure.inventory)
|
||||
{
|
||||
float motion = 0.7F;
|
||||
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
|
||||
|
||||
EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack);
|
||||
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.removeBlockByPlayer(world, player, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderType()
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
package resonantinduction.battery;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import resonantinduction.battery.BatteryManager.SlotBattery;
|
||||
import resonantinduction.battery.BatteryManager.SlotOut;
|
||||
import calclavia.lib.gui.ContainerBase;
|
||||
|
||||
public class ContainerBattery extends ContainerBase
|
||||
{
|
||||
private TileBattery tileEntity;
|
||||
|
||||
public ContainerBattery(InventoryPlayer inventory, TileBattery unit)
|
||||
{
|
||||
super(unit);
|
||||
tileEntity = unit;
|
||||
addSlotToContainer(new SlotBattery(unit, 0, 8, 22));
|
||||
addSlotToContainer(new SlotOut(unit, 1, 8, 58));
|
||||
addSlotToContainer(new SlotBattery(unit, 2, 31, 22));
|
||||
addSlotToContainer(new SlotBattery(unit, 3, 31, 58));
|
||||
|
||||
int slotX;
|
||||
|
||||
for (slotX = 0; slotX < 3; ++slotX)
|
||||
{
|
||||
for (int slotY = 0; slotY < 9; ++slotY)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 125 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (slotX = 0; slotX < 9; ++slotX)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 183));
|
||||
}
|
||||
|
||||
tileEntity.openChest();
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotID, int par2, int par3, EntityPlayer par4EntityPlayer)
|
||||
{
|
||||
ItemStack stack = super.slotClick(slotID, par2, par3, par4EntityPlayer);
|
||||
|
||||
if (slotID == 1)
|
||||
{
|
||||
ItemStack itemstack = ((Slot) inventorySlots.get(slotID)).getStack();
|
||||
ItemStack itemstack1 = itemstack == null ? null : itemstack.copy();
|
||||
inventoryItemStacks.set(slotID, itemstack1);
|
||||
|
||||
for (int j = 0; j < crafters.size(); ++j)
|
||||
{
|
||||
((ICrafting) crafters.get(j)).sendSlotContents(this, slotID, itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
tileEntity.closeChest();
|
||||
tileEntity.playersUsing.remove(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer)
|
||||
{
|
||||
return tileEntity.isUseableByPlayer(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotID)
|
||||
{
|
||||
if (slotID != 1)
|
||||
{
|
||||
return super.transferStackInSlot(par1EntityPlayer, slotID);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ public class RenderBattery extends TileEntitySpecialRenderer
|
|||
private Random random = new Random();
|
||||
protected RenderManager renderManager;
|
||||
|
||||
public static final IModelCustom batteryModel = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY + "battery.tcn");
|
||||
//public static final IModelCustom batteryModel = AdvancedModelLoader.loadModel(ResonantInduction.MODEL_DIRECTORY + "battery.tcn");
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TileBattery extends TileEntityElectrical implements IPacketSender,
|
|||
|
||||
public TileBattery()
|
||||
{
|
||||
|
||||
this.energy.setCapacity(1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue