Added method to armbot for PowerTo command
untested so far but just setting stuff up.
This commit is contained in:
parent
1b0a386f5c
commit
5330d60d8a
3 changed files with 50 additions and 12 deletions
|
@ -5,7 +5,9 @@ import java.util.Random;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.BlockMachine;
|
||||
|
@ -39,10 +41,7 @@ public class BlockArmbot extends BlockMachine
|
|||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null && tileEntity instanceof IMultiBlock)
|
||||
{
|
||||
return ((IMultiBlock) tileEntity).onActivated(player);
|
||||
}
|
||||
if (tileEntity != null && tileEntity instanceof IMultiBlock) { return ((IMultiBlock) tileEntity).onActivated(player); }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -86,4 +85,15 @@ public class BlockArmbot extends BlockMachine
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
if(ent instanceof TileEntityArmbot)
|
||||
{
|
||||
return ((TileEntityArmbot)ent).isProvidingPowerSide(ForgeDirection.getOrientation(side));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.network.packet.Packet;
|
|||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.electricity.ElectricityConnections;
|
||||
import universalelectricity.core.implement.IJouleStorage;
|
||||
|
@ -75,8 +76,11 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
|||
public float renderYaw = 0;
|
||||
private int ticksSincePower = 0;
|
||||
public final float ROTATION_SPEED = 1.3f;
|
||||
|
||||
private String displayText = "";
|
||||
|
||||
public boolean isProvidingPower = false;
|
||||
|
||||
/**
|
||||
* An entity that the Armbot is grabbed onto. Entity Items are held separately.
|
||||
*/
|
||||
|
@ -774,10 +778,7 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
|||
{
|
||||
for (int i = 0; i < found.size(); i++)
|
||||
{
|
||||
if (found.get(i) != null && !(found.get(i) instanceof EntityPlayer) && found.get(i).ridingEntity == null)
|
||||
{
|
||||
return new Object[] { true };
|
||||
}
|
||||
if (found.get(i) != null && !(found.get(i) instanceof EntityPlayer) && found.get(i).ridingEntity == null) { return new Object[] { true }; }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -934,4 +935,33 @@ public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMult
|
|||
this.grabbedEntities.clear();
|
||||
this.grabbedItems.clear();
|
||||
}
|
||||
|
||||
public boolean isProvidingPowerSide(ForgeDirection dir)
|
||||
{
|
||||
return this.isProvidingPower && dir == this.getFacingDirectionFromAngle();
|
||||
}
|
||||
|
||||
public ForgeDirection getFacingDirectionFromAngle()
|
||||
{
|
||||
float angle = MathHelper.wrapAngleTo180_float(this.rotationYaw);
|
||||
if (angle >= -45 && angle <= 45)
|
||||
{
|
||||
return ForgeDirection.NORTH;
|
||||
}
|
||||
else if (angle >= 45 && angle <= 135)
|
||||
{
|
||||
|
||||
return ForgeDirection.WEST;
|
||||
}
|
||||
else if (angle >= 135 && angle <= -135)
|
||||
{
|
||||
|
||||
return ForgeDirection.NORTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ForgeDirection.EAST;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,13 +65,11 @@ public class CommandPowerTo extends Command
|
|||
{
|
||||
if (!on)
|
||||
{
|
||||
// unpower block
|
||||
//DebugToPlayer.SendToClosest(this.tileEntity, 20, "Power Off");
|
||||
this.tileEntity.isProvidingPower = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// power block
|
||||
//DebugToPlayer.SendToClosest(this.tileEntity, 20, "Power on");
|
||||
this.tileEntity.isProvidingPower = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue