Fixed Modular Battery not working with BuildCraft
This commit is contained in:
parent
2710f976f9
commit
ada50089e9
5 changed files with 94 additions and 53 deletions
|
@ -1 +1 @@
|
|||
Subproject commit e34b3fdae603d3ae7a4345df8da321c5903b357b
|
||||
Subproject commit 3538b31ba452890fa742b472df2fb9d1555a61cd
|
|
@ -55,9 +55,18 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float xClick, float yClick, float zClick)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (entityPlayer.isSneaking())
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, ForgeDirection.ROTATION_MATRIX[world.getBlockMetadata(x, y, z)][side], 3);
|
||||
boolean result = tileEntity.toggleSide(ForgeDirection.getOrientation(side));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entityPlayer.addChatMessage("Toggled side to: " + (result ? "input" : "output"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -69,8 +78,6 @@ public class BlockBattery extends BlockBase implements ITileEntityProvider
|
|||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
TileEntityBattery tileEntity = (TileEntityBattery) world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity.structure.addCell(entityPlayer.getCurrentEquippedItem()))
|
||||
{
|
||||
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
|
||||
|
|
|
@ -45,6 +45,9 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
|||
public int clientCells;
|
||||
public float clientMaxEnergy;
|
||||
|
||||
private EnumSet inputSides = EnumSet.allOf(ForgeDirection.class);
|
||||
private EnumSet outputSides = EnumSet.noneOf(ForgeDirection.class);
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -327,11 +330,11 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
|||
@Override
|
||||
public float getMaxEnergyStored()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
float max = 0;
|
||||
|
||||
for (ItemStack itemStack : structure.inventory)
|
||||
for (ItemStack itemStack : this.structure.inventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
@ -346,18 +349,18 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
|||
}
|
||||
else
|
||||
{
|
||||
return clientMaxEnergy;
|
||||
return this.clientMaxEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEnergyStored()
|
||||
{
|
||||
if (!worldObj.isRemote)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
float energy = 0;
|
||||
|
||||
for (ItemStack itemStack : structure.inventory)
|
||||
for (ItemStack itemStack : this.structure.inventory)
|
||||
{
|
||||
if (itemStack != null)
|
||||
{
|
||||
|
@ -548,9 +551,9 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemsSack)
|
||||
{
|
||||
return false;
|
||||
return itemsSack.getItem() instanceof IItemElectric;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -565,9 +568,34 @@ public class TileEntityBattery extends TileEntityUniversalElectrical implements
|
|||
return this.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getInputDirections()
|
||||
{
|
||||
return this.inputSides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getOutputDirections()
|
||||
{
|
||||
return EnumSet.allOf(ForgeDirection.class);
|
||||
return this.outputSides;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the input/output sides of the battery.
|
||||
*/
|
||||
public boolean toggleSide(ForgeDirection orientation)
|
||||
{
|
||||
if (this.inputSides.contains(orientation))
|
||||
{
|
||||
this.inputSides.remove(orientation);
|
||||
this.outputSides.add(orientation);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.outputSides.remove(orientation);
|
||||
this.inputSides.add(orientation);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,45 +59,48 @@ public class TileEntityMultimeter extends TileEntityAdvanced implements IPacketR
|
|||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (this.ticks % 20 == 0)
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
float prevDetectedEnergy = this.detectedEnergy;
|
||||
this.detectedEnergy = this.doGetDetectedEnergy();
|
||||
this.detectedAverageEnergy = (detectedAverageEnergy + this.detectedEnergy) / 2;
|
||||
this.peakDetection = Math.max(peakDetection, this.detectedEnergy);
|
||||
|
||||
boolean outputRedstone = false;
|
||||
|
||||
switch (detectMode)
|
||||
if (this.ticks % 20 == 0)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case EQUAL:
|
||||
outputRedstone = this.detectedEnergy == this.energyLimit;
|
||||
break;
|
||||
case GREATER_THAN:
|
||||
outputRedstone = this.detectedEnergy > this.energyLimit;
|
||||
break;
|
||||
case GREATER_THAN_EQUAL:
|
||||
outputRedstone = this.detectedEnergy >= this.energyLimit;
|
||||
break;
|
||||
case LESS_THAN:
|
||||
outputRedstone = this.detectedEnergy < this.energyLimit;
|
||||
break;
|
||||
case LESS_THAN_EQUAL:
|
||||
outputRedstone = this.detectedEnergy <= this.energyLimit;
|
||||
break;
|
||||
}
|
||||
float prevDetectedEnergy = this.detectedEnergy;
|
||||
this.detectedEnergy = this.doGetDetectedEnergy();
|
||||
this.detectedAverageEnergy = (detectedAverageEnergy + this.detectedEnergy) / 2;
|
||||
this.peakDetection = Math.max(peakDetection, this.detectedEnergy);
|
||||
|
||||
if (outputRedstone != this.redstoneOn)
|
||||
{
|
||||
this.redstoneOn = outputRedstone;
|
||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, ResonantInduction.blockMultimeter.blockID);
|
||||
}
|
||||
boolean outputRedstone = false;
|
||||
|
||||
if (prevDetectedEnergy != this.detectedEnergy)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
switch (detectMode)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case EQUAL:
|
||||
outputRedstone = this.detectedEnergy == this.energyLimit;
|
||||
break;
|
||||
case GREATER_THAN:
|
||||
outputRedstone = this.detectedEnergy > this.energyLimit;
|
||||
break;
|
||||
case GREATER_THAN_EQUAL:
|
||||
outputRedstone = this.detectedEnergy >= this.energyLimit;
|
||||
break;
|
||||
case LESS_THAN:
|
||||
outputRedstone = this.detectedEnergy < this.energyLimit;
|
||||
break;
|
||||
case LESS_THAN_EQUAL:
|
||||
outputRedstone = this.detectedEnergy <= this.energyLimit;
|
||||
break;
|
||||
}
|
||||
|
||||
if (outputRedstone != this.redstoneOn)
|
||||
{
|
||||
this.redstoneOn = outputRedstone;
|
||||
this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, ResonantInduction.blockMultimeter.blockID);
|
||||
}
|
||||
|
||||
if (prevDetectedEnergy != this.detectedEnergy)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
|||
{
|
||||
float transferEnergy = this.getEnergyStored() / transferTeslaCoils.size();
|
||||
int count = 0;
|
||||
|
||||
|
||||
for (ITesla tesla : transferTeslaCoils)
|
||||
{
|
||||
if (this.zapCounter % 5 == 0 && ResonantInduction.SOUND_FXS)
|
||||
|
@ -275,13 +275,10 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
|||
BlockFurnace.updateFurnaceBlockState(furnaceTile.furnaceBurnTime > 0, furnaceTile.worldObj, furnaceTile.xCoord, furnaceTile.yCoord, furnaceTile.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ticks % 20 == 0)
|
||||
{
|
||||
this.produce();
|
||||
}
|
||||
}
|
||||
|
||||
this.produce();
|
||||
|
||||
if (!this.worldObj.isRemote && this.getEnergyStored() > 0 != doPacketUpdate)
|
||||
{
|
||||
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
@ -303,6 +300,12 @@ public class TileEntityTesla extends TileEntityUniversalElectrical implements IT
|
|||
return this.canReceive && !this.outputBlacklist.contains(tileEntity) && this.getRequest(ForgeDirection.UNKNOWN) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return this.isController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue