Fixed a minor bug in the coordinate OC compat for launch pads, also removed a feature because it keeps throwing a NullPointerException and I have no clue how to fix it

This commit is contained in:
BallOfEnergy 2023-08-03 02:36:58 -05:00
parent 5e1f3b3134
commit 39e37f0676
3 changed files with 23 additions and 18 deletions

View File

@ -4,6 +4,8 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.bomb.LaunchPad;
import com.hbm.inventory.container.ContainerLaunchPadTier1;
import com.hbm.inventory.gui.GUILaunchPadTier1;
import com.hbm.items.ModItems;
import com.hbm.items.tool.ItemDesingator;
import com.hbm.lib.Library;
import com.hbm.packet.AuxElectricityPacket;
import com.hbm.packet.PacketDispatcher;
@ -298,8 +300,13 @@ public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedI
@Optional.Method(modid = "OpenComputers")
public Object[] getCoords(Context context, Arguments args) {
if (slots[1] != null && slots[1].getItem() instanceof IDesignatorItem) {
int xCoord2 = slots[1].stackTagCompound.getInteger("xCoord");
int zCoord2 = slots[1].stackTagCompound.getInteger("zCoord");
int xCoord2;
int zCoord2;
if (slots[1].stackTagCompound != null) {
xCoord2 = slots[1].stackTagCompound.getInteger("xCoord");
zCoord2 = slots[1].stackTagCompound.getInteger("zCoord");
} else
return new Object[] {false};
// Not sure if i should have this
/*
@ -307,7 +314,7 @@ public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedI
xCoord2 += 1;
}
*/
return new Object[] {xCoord2, zCoord2};
}
return new Object[] {false, "Designator not found"};
@ -316,9 +323,10 @@ public class TileEntityLaunchPad extends TileEntityLoadedBase implements ISidedI
@Optional.Method(modid = "OpenComputers")
public Object[] setCoords(Context context, Arguments args) {
if (slots[1] != null && slots[1].getItem() instanceof IDesignatorItem) {
slots[1].stackTagCompound = new NBTTagCompound();
slots[1].stackTagCompound.setInteger("xCoord", args.checkInteger(0));
slots[1].stackTagCompound.setInteger("zCoord", args.checkInteger(1));
return new Object[] {true};
}
return new Object[] {false, "Designator not found"};

View File

@ -645,10 +645,15 @@ public class TileEntityLaunchTable extends TileEntityLoadedBase implements ISide
@Optional.Method(modid = "OpenComputers")
public Object[] getCoords(Context context, Arguments args) {
if (slots[1] != null && slots[1].getItem() instanceof IDesignatorItem) {
int xCoord2 = slots[1].stackTagCompound.getInteger("xCoord");
int zCoord2 = slots[1].stackTagCompound.getInteger("zCoord");
int xCoord2;
int zCoord2;
if (slots[1].stackTagCompound != null) {
xCoord2 = slots[1].stackTagCompound.getInteger("xCoord");
zCoord2 = slots[1].stackTagCompound.getInteger("zCoord");
} else
return new Object[] {false};
//unsure if this is needed, leaving here in case it is
// Not sure if i should have this
/*
if(xCoord2 == xCoord && zCoord2 == zCoord) {
xCoord2 += 1;
@ -663,6 +668,7 @@ public class TileEntityLaunchTable extends TileEntityLoadedBase implements ISide
@Optional.Method(modid = "OpenComputers")
public Object[] setCoords(Context context, Arguments args) {
if (slots[1] != null && slots[1].getItem() instanceof IDesignatorItem) {
slots[1].stackTagCompound = new NBTTagCompound();
slots[1].stackTagCompound.setInteger("xCoord", args.checkInteger(0));
slots[1].stackTagCompound.setInteger("zCoord", args.checkInteger(1));

View File

@ -2,6 +2,7 @@ package com.hbm.tileentity.machine.storage;
import api.hbm.energy.*;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.bomb.LaunchPad;
import com.hbm.blocks.machine.MachineBattery;
import com.hbm.inventory.container.ContainerMachineBattery;
import com.hbm.inventory.gui.GUIMachineBattery;
@ -394,17 +395,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
// do some opencomputer stuff
@Override
public String getComponentName() {
Block block = worldObj.getBlock(xCoord, yCoord, zCoord);
if (block.equals(ModBlocks.machine_battery_potato)) {
return "ntm_energy_storage_potato";
} else if (block.equals(ModBlocks.machine_lithium_battery)) {
return "ntm_energy_storage_lithium";
} else if (block.equals(ModBlocks.machine_schrabidium_battery)) {
return "ntm_energy_storage_schrabidum";
} else if (block.equals(ModBlocks.machine_dineutronium_battery)) {
return "ntm_energy_storage_dineutronium";
} else
return "ntm_energy_storage";
return "ntm_energy_storage"; //ok if someone else can figure out how to do this that'd be nice (change the component name based on the type of storage block)
}
@Callback(direct = true, limit = 8)