mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Allow for comparator reading and redstone control of the Mana Pump.
This commit is contained in:
1 parent
ff03b03d89
commit
96106edf11
4 files changed
+46
-11
No files matched your search
@@ -91,6 +91,16 @@ public class BlockPump extends BlockModContainer implements ILexiconable {
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side) {
|
||||
return ((TilePump) world.getTileEntity(x, y, z)).comparator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
|
||||
|
||||
@@ -34,8 +34,10 @@ public class TileOpenCrate extends TileSimpleInventory {
|
||||
boolean redstone = false;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
|
||||
if(redstoneSide > 0)
|
||||
if(redstoneSide > 0) {
|
||||
redstone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(canEject()) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.common.block.tile.mana;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.common.block.tile.TileMod;
|
||||
|
||||
public class TilePump extends TileMod {
|
||||
@@ -21,9 +22,22 @@ public class TilePump extends TileMod {
|
||||
public boolean active = false;
|
||||
public boolean hasCart = false;
|
||||
public float moving = 0F;
|
||||
|
||||
|
||||
public int comparator;
|
||||
public boolean hasRedstone = false;
|
||||
int lastComparator = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
hasRedstone = false;
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int redstoneSide = worldObj.getIndirectPowerLevelTo(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir.ordinal());
|
||||
if(redstoneSide > 0) {
|
||||
hasRedstone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float max = 8F;
|
||||
float min = 0F;
|
||||
|
||||
@@ -45,10 +59,19 @@ public class TilePump extends TileMod {
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasCart && active)
|
||||
if(!hasCart) {
|
||||
comparator = 0;
|
||||
if(active)
|
||||
setActive(false);
|
||||
}
|
||||
if(active && hasRedstone)
|
||||
setActive(false);
|
||||
hasCart = false;
|
||||
|
||||
if(comparator != lastComparator)
|
||||
worldObj.func_147453_f(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
lastComparator = comparator;
|
||||
|
||||
super.updateEntity();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,10 @@ public class EntityPoolMinecart extends EntityMinecart {
|
||||
int zp_ = zp + dir.offsetZ;
|
||||
int meta = worldObj.getBlockMetadata(xp, y, zp);
|
||||
TileEntity tile = worldObj.getTileEntity(xp_, y, zp_);
|
||||
if(tile != null && tile instanceof IManaPool) {
|
||||
TileEntity tile_ = worldObj.getTileEntity(xp, y, zp);
|
||||
TilePump pump = (TilePump) tile_;
|
||||
|
||||
if(tile != null && tile instanceof IManaPool && !pump.hasRedstone) {
|
||||
IManaPool pool = (IManaPool) tile;
|
||||
ForgeDirection pumpDir = ForgeDirection.getOrientation(meta);
|
||||
boolean did = false;
|
||||
@@ -104,13 +107,10 @@ public class EntityPoolMinecart extends EntityMinecart {
|
||||
|
||||
if(did) {
|
||||
worldObj.markBlockForUpdate(xp_, y, zp_);
|
||||
TileEntity tile_ = worldObj.getTileEntity(xp, y, zp);
|
||||
if(tile_ != null && tile_ instanceof TilePump) {
|
||||
TilePump pump = (TilePump) tile_;
|
||||
pump.hasCart = true;
|
||||
if(!pump.active)
|
||||
pump.setActive(true);
|
||||
}
|
||||
pump.hasCart = true;
|
||||
pump.comparator = (int) (((double) getMana() / (double) TilePool.MAX_MANA) * 15);
|
||||
if(!pump.active)
|
||||
pump.setActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user