mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
welcome to the age of OC controlled turrets and artillery
This commit is contained in:
parent
df34a51913
commit
f2ed1e897d
@ -345,7 +345,7 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
@Callback(direct = true)
|
@Callback(direct = true)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getFluid(Context context, Arguments args) {
|
public Object[] getFluid(Context context, Arguments args) {
|
||||||
return new Object[] {tanks[0].getFill(), tanks[1].getFill(), tanks[1].getFill(), tanks[1].getMaxFill()};
|
return new Object[] {tanks[0].getFill(), tanks[0].getMaxFill(), tanks[1].getFill(), tanks[1].getMaxFill()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(direct = true)
|
@Callback(direct = true)
|
||||||
|
|||||||
@ -347,7 +347,7 @@ public class TileEntityMachineTurbine extends TileEntityLoadedBase implements IS
|
|||||||
@Callback(direct = true)
|
@Callback(direct = true)
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] getFluid(Context context, Arguments args) {
|
public Object[] getFluid(Context context, Arguments args) {
|
||||||
return new Object[] {tanks[0].getFill(), tanks[1].getFill(), tanks[1].getFill(), tanks[1].getMaxFill()};
|
return new Object[] {tanks[0].getFill(), tanks[0].getMaxFill(), tanks[1].getFill(), tanks[1].getMaxFill()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Callback(direct = true)
|
@Callback(direct = true)
|
||||||
|
|||||||
@ -15,9 +15,13 @@ import com.hbm.packet.AuxParticlePacketNT;
|
|||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
@ -464,4 +468,11 @@ public class TileEntityTurretArty extends TileEntityTurretBaseArtillery implemen
|
|||||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
return new GUITurretArty(player.inventory, this);
|
return new GUITurretArty(player.inventory, this);
|
||||||
}
|
}
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] addCoords(Context context, Arguments args) {
|
||||||
|
this.mode = MODE_MANUAL;
|
||||||
|
targetQueue.add(Vec3.createVectorHelper(args.checkDouble(0), args.checkDouble(1), args.checkDouble(2)));
|
||||||
|
return new Object[] {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,12 @@ import java.util.List;
|
|||||||
import com.hbm.blocks.BlockDummyable;
|
import com.hbm.blocks.BlockDummyable;
|
||||||
import com.hbm.tileentity.IRadarCommandReceiver;
|
import com.hbm.tileentity.IRadarCommandReceiver;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
@ -69,4 +74,14 @@ public abstract class TileEntityTurretBaseArtillery extends TileEntityTurretBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComponentName() {
|
||||||
|
return "ntm_artillery";
|
||||||
|
}
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getCurrentTarget(Context context, Arguments args) {
|
||||||
|
return new Object[] {targetQueue.get(0).xCoord, targetQueue.get(0).yCoord, targetQueue.get(0).zCoord};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,14 @@ import com.hbm.util.CompatExternal;
|
|||||||
|
|
||||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||||
import api.hbm.entity.IRadarDetectableNT;
|
import api.hbm.entity.IRadarDetectableNT;
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
|
import li.cil.oc.api.network.SimpleComponent;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
@ -48,6 +53,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
@ -58,7 +64,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
* @author hbm
|
* @author hbm
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase implements IEnergyReceiverMK2, IControlReceiver, IGUIProvider {
|
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers")})
|
||||||
|
public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase implements IEnergyReceiverMK2, IControlReceiver, IGUIProvider, SimpleComponent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(EntityPlayer player) {
|
public boolean hasPermission(EntityPlayer player) {
|
||||||
@ -899,4 +906,110 @@ public abstract class TileEntityTurretBaseNT extends TileEntityMachineBase imple
|
|||||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
return new ContainerTurretBase(player.inventory, this);
|
return new ContainerTurretBase(player.inventory, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OC stuff
|
||||||
|
// This is a large compat, so I have to leave comments to know what I'm doing
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getComponentName() {
|
||||||
|
return "ntm_turret";
|
||||||
|
}
|
||||||
|
|
||||||
|
// On/Off
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] setActive(Context context, Arguments args) {
|
||||||
|
this.isOn = args.checkBoolean(0);
|
||||||
|
return new Object[] {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] isActive(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.isOn};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Energy information
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getEnergyInfo(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.getPower(), this.getMaxPower()};
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
// Whitelist Control //
|
||||||
|
///////////////////////
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getWhitelisted(Context context, Arguments args) {
|
||||||
|
if(slots[0] != null && slots[0].getItem() == ModItems.turret_chip) {
|
||||||
|
String[] array = ItemTurretBiometry.getNames(slots[0]);
|
||||||
|
return new Object[] {array};
|
||||||
|
}
|
||||||
|
return new Object[] {};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] addWhitelist(Context context, Arguments args) {
|
||||||
|
if(this.getWhitelist() != null) {
|
||||||
|
List<String> names = this.getWhitelist();
|
||||||
|
if (names.contains(args.checkString(0)))
|
||||||
|
return new Object[]{false};
|
||||||
|
}
|
||||||
|
this.addName(args.checkString(0));
|
||||||
|
return new Object[]{true};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] removeWhitelist(Context context, Arguments args) {
|
||||||
|
List<String> names = this.getWhitelist();
|
||||||
|
if(!names.contains(args.checkString(0)))
|
||||||
|
return new Object[] {false};
|
||||||
|
this.removeName(names.indexOf(args.checkString(0)));
|
||||||
|
return new Object[] {true};
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////
|
||||||
|
// Targeting Control //
|
||||||
|
///////////////////////
|
||||||
|
@Callback(direct = true, limit = 4)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] setTargeting(Context context, Arguments args) {
|
||||||
|
Object[] oldTargeting = new Object[] {this.targetPlayers, this.targetAnimals, this.targetMobs, this.targetMachines};
|
||||||
|
this.targetPlayers = args.checkBoolean(0);
|
||||||
|
this.targetAnimals = args.checkBoolean(1);
|
||||||
|
this.targetMobs = args.checkBoolean(2);
|
||||||
|
this.targetMachines = args.checkBoolean(3);
|
||||||
|
return oldTargeting;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getTargeting(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.targetPlayers, this.targetAnimals, this.targetMobs, this.targetMachines};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] hasTarget(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.target != null};
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// Angle Control //
|
||||||
|
///////////////////
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] getAngle(Context context, Arguments args) {
|
||||||
|
return new Object[] {Math.toDegrees(this.rotationPitch), Math.toDegrees(this.rotationYaw)};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Callback(direct = true)
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] isAligned(Context context, Arguments args) {
|
||||||
|
return new Object[] {this.aligned};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,8 +14,12 @@ import com.hbm.lib.Library;
|
|||||||
import com.hbm.main.MainRegistry;
|
import com.hbm.main.MainRegistry;
|
||||||
import com.hbm.tileentity.IGUIProvider;
|
import com.hbm.tileentity.IGUIProvider;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.Optional;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import li.cil.oc.api.machine.Arguments;
|
||||||
|
import li.cil.oc.api.machine.Callback;
|
||||||
|
import li.cil.oc.api.machine.Context;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
@ -373,4 +377,11 @@ public class TileEntityTurretHIMARS extends TileEntityTurretBaseArtillery implem
|
|||||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
return new GUITurretHIMARS(player.inventory, this);
|
return new GUITurretHIMARS(player.inventory, this);
|
||||||
}
|
}
|
||||||
|
@Callback
|
||||||
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
public Object[] addCoords(Context context, Arguments args) {
|
||||||
|
this.mode = MODE_MANUAL;
|
||||||
|
targetQueue.add(Vec3.createVectorHelper(args.checkDouble(0), args.checkDouble(1), args.checkDouble(2)));
|
||||||
|
return new Object[] {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user