Rewrite to use new RebornCore Power API. Texture fixes.
This commit is contained in:
parent
6f54e3801f
commit
b292fdd352
77 changed files with 1342 additions and 3008 deletions
|
@ -5,90 +5,48 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.tile.TilePowerAcceptor;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class TilePlayerDectector extends TilePowerAcceptor
|
||||
{
|
||||
public class TilePlayerDectector extends TilePowerAcceptor {
|
||||
|
||||
public String owenerUdid = "";
|
||||
boolean redstone = false;
|
||||
|
||||
public TilePlayerDectector()
|
||||
{
|
||||
super(1);
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 8000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower()
|
||||
{
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(EnumFacing direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(EnumFacing direction)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput()
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumPowerTier getTier()
|
||||
{
|
||||
public EnumPowerTier getTier() {
|
||||
return EnumPowerTier.LOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0)
|
||||
{
|
||||
public void update() {
|
||||
super.update();
|
||||
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) {
|
||||
boolean lastRedstone = redstone;
|
||||
redstone = false;
|
||||
if (canUseEnergy(10))
|
||||
{
|
||||
if (canUseEnergy(10)) {
|
||||
Iterator tIterator = super.worldObj.playerEntities.iterator();
|
||||
while (tIterator.hasNext())
|
||||
{
|
||||
while (tIterator.hasNext()) {
|
||||
EntityPlayer player = (EntityPlayer) tIterator.next();
|
||||
if (player.getDistanceSq((double) super.getPos().getX() + 0.5D,
|
||||
(double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D)
|
||||
{
|
||||
(double) super.getPos().getY() + 0.5D, (double) super.getPos().getZ() + 0.5D) <= 256.0D) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) worldObj.getBlockState(pos).getBlock();
|
||||
int meta = blockMachineBase.getMetaFromState(worldObj.getBlockState(pos));
|
||||
if (meta == 0)
|
||||
{// ALL
|
||||
if (meta == 0) {// ALL
|
||||
redstone = true;
|
||||
} else if (meta == 1)
|
||||
{// Others
|
||||
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString()))
|
||||
{
|
||||
} else if (meta == 1) {// Others
|
||||
if (!owenerUdid.isEmpty() && !owenerUdid.equals(player.getUniqueID().toString())) {
|
||||
redstone = true;
|
||||
}
|
||||
} else
|
||||
{// You
|
||||
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString()))
|
||||
{
|
||||
} else {// You
|
||||
if (!owenerUdid.isEmpty() && owenerUdid.equals(player.getUniqueID().toString())) {
|
||||
redstone = true;
|
||||
}
|
||||
}
|
||||
|
@ -97,31 +55,28 @@ public class TilePlayerDectector extends TilePowerAcceptor
|
|||
}
|
||||
useEnergy(10);
|
||||
}
|
||||
if (lastRedstone != redstone)
|
||||
{
|
||||
if (lastRedstone != redstone) {
|
||||
WorldUtils.updateBlock(worldObj, getPos());
|
||||
worldObj.notifyNeighborsOfStateChange(getPos(), worldObj.getBlockState(getPos()).getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isProvidingPower()
|
||||
{
|
||||
public boolean isProvidingPower() {
|
||||
return redstone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
owenerUdid = tag.getString("ownerID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tag.setString("ownerID", owenerUdid);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue