Code cleanup
This commit is contained in:
parent
c8241775a3
commit
a5a336f3db
11 changed files with 28 additions and 24 deletions
|
@ -447,13 +447,14 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
|
|||
private void CC_mount(@Nonnull final IComputerAccess computer) {
|
||||
if (CC_hasResource && WarpDriveConfig.G_LUA_SCRIPTS != WarpDriveConfig.LUA_SCRIPTS_NONE) {
|
||||
try {
|
||||
final String modid = WarpDrive.MODID.toLowerCase();
|
||||
final String folderPeripheral = peripheralName.replace(modid, modid + "/");
|
||||
computer.mount("/" + modid , ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/common"));
|
||||
computer.mount("/" + folderPeripheral, ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/" + peripheralName));
|
||||
CC_mount(computer, "lua.ComputerCraft/common", "/" + WarpDrive.MODID);
|
||||
|
||||
final String folderPeripheral = peripheralName.replace(WarpDrive.MODID, WarpDrive.MODID + "/");
|
||||
CC_mount(computer, "lua.ComputerCraft/" + peripheralName, "/" + folderPeripheral);
|
||||
|
||||
if (WarpDriveConfig.G_LUA_SCRIPTS == WarpDriveConfig.LUA_SCRIPTS_ALL) {
|
||||
for (final String script : CC_scripts) {
|
||||
computer.mount("/" + script, ComputerCraftAPI.createResourceMount(WarpDrive.class, modid, "lua.ComputerCraft/" + peripheralName + "/" + script));
|
||||
CC_mount(computer, "lua.ComputerCraft/" + peripheralName + "/" + script, "/" + script);
|
||||
}
|
||||
}
|
||||
} catch (final Exception exception) {
|
||||
|
@ -466,6 +467,13 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
|
|||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "computercraft")
|
||||
private void CC_mount(@Nonnull final IComputerAccess computer, final String pathAsset, final String pathLUA) {
|
||||
final IMount mountCommon = ComputerCraftAPI.createResourceMount(WarpDrive.class, WarpDrive.MODID, pathAsset);
|
||||
assert mountCommon != null;
|
||||
computer.mount(pathLUA, mountCommon);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "computercraft")
|
||||
private void CC_unmount() {
|
||||
for (final IComputerAccess computerAccess : CC_connectedComputers.values()) {
|
||||
|
@ -477,9 +485,8 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
|
|||
private void CC_unmount(@Nonnull final IComputerAccess computer) {
|
||||
if (CC_hasResource && WarpDriveConfig.G_LUA_SCRIPTS != WarpDriveConfig.LUA_SCRIPTS_NONE) {
|
||||
try {
|
||||
final String modid = WarpDrive.MODID.toLowerCase();
|
||||
final String folderPeripheral = peripheralName.replace(modid, modid + "/");
|
||||
computer.unmount("/" + modid );
|
||||
final String folderPeripheral = peripheralName.replace(WarpDrive.MODID, WarpDrive.MODID + "/");
|
||||
computer.unmount("/" + WarpDrive.MODID);
|
||||
computer.unmount("/" + folderPeripheral);
|
||||
if (WarpDriveConfig.G_LUA_SCRIPTS == WarpDriveConfig.LUA_SCRIPTS_ALL) {
|
||||
for (final String script : CC_scripts) {
|
||||
|
|
|
@ -774,7 +774,6 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
|
|||
final float deltaY = -Commons.toFloat(arguments[1]);
|
||||
final float deltaZ = Commons.toFloat(arguments[2]);
|
||||
final double horizontalDistance = MathHelper.sqrt(deltaX * deltaX + deltaZ * deltaZ);
|
||||
//noinspection SuspiciousNameCombination
|
||||
newYaw = (float) (Math.atan2(deltaX, deltaZ) * 180.0D / Math.PI);
|
||||
newPitch = (float) (Math.atan2(deltaY, horizontalDistance) * 180.0D / Math.PI);
|
||||
initiateBeamEmission(newYaw, newPitch);
|
||||
|
|
|
@ -627,7 +627,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager networkManager, SPacketUpdateTileEntity packet) {
|
||||
public void onDataPacket(final NetworkManager networkManager, final SPacketUpdateTileEntity packet) {
|
||||
final NBTTagCompound tagCompound = packet.getNbtCompound();
|
||||
readFromNBT(tagCompound);
|
||||
}
|
||||
|
|
|
@ -480,10 +480,11 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner {
|
|||
if (isActive()) {
|
||||
retValuablesInLayer = valuablesInLayer.size();
|
||||
retValuablesMined = valuableIndex;
|
||||
|
||||
return new Object[] { status, isActive(), energy, currentLayer, retValuablesMined, retValuablesInLayer };
|
||||
} else {
|
||||
retValuablesInLayer = 0;
|
||||
retValuablesMined = 0;
|
||||
}
|
||||
return new Object[] { status, isActive(), energy, currentLayer, 0, 0 };
|
||||
return new Object[] { status, isActive(), energy, currentLayer, retValuablesMined, retValuablesInLayer };
|
||||
}
|
||||
|
||||
private Object[] onlyOres(final Object[] arguments) {
|
||||
|
|
|
@ -76,10 +76,10 @@ public class TileEntityCamera extends TileEntityAbstractMachine implements IVide
|
|||
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
|
||||
WarpDrive.logger.info(this + " Video channel set to " + videoChannel);
|
||||
}
|
||||
markDirty();
|
||||
// force update through main thread since CC runs on server as 'client'
|
||||
packetSendTicks = 0;
|
||||
registryUpdateTicks = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ public class TileEntityMonitor extends TileEntityAbstractMachine implements IVid
|
|||
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
|
||||
WarpDrive.logger.info(this + " Monitor video channel set to " + videoChannel);
|
||||
}
|
||||
markDirty();
|
||||
// force update through main thread since CC runs on server as 'client'
|
||||
packetSendTicks = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,8 +107,8 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
private GlobalPosition globalPositionLocal = null;
|
||||
private GlobalPosition globalPositionRemote = null;
|
||||
private ArrayList<BlockPos> vRemoteScanners = null;
|
||||
private HashMap<Integer, MovingEntity> movingEntitiesLocal = new HashMap<>(8);
|
||||
private HashMap<Integer, MovingEntity> movingEntitiesRemote = new HashMap<>(8);
|
||||
private final HashMap<Integer, MovingEntity> movingEntitiesLocal = new HashMap<>(8);
|
||||
private final HashMap<Integer, MovingEntity> movingEntitiesRemote = new HashMap<>(8);
|
||||
private int tickEnergizing = 0;
|
||||
|
||||
public TileEntityTransporterCore() {
|
||||
|
@ -646,7 +646,6 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
vMax.x + 1.0D, vMax.y + 1.0D, vMax.z + 1.0D);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<BlockPos> getContainments() {
|
||||
return vLocalContainments;
|
||||
}
|
||||
|
@ -1480,7 +1479,6 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
if ( tagCompound.hasKey("scanners", Constants.NBT.TAG_LIST)
|
||||
&& tagCompound.hasKey("containments", Constants.NBT.TAG_LIST)) {
|
||||
final NBTTagList tagListScanners = (NBTTagList) tagCompound.getTag("scanners");
|
||||
assert tagListScanners != null;
|
||||
final ArrayList<BlockPos> vScanners = new ArrayList<>(tagListScanners.tagCount());
|
||||
for (int indexScanner = 0; indexScanner < tagListScanners.tagCount(); indexScanner++) {
|
||||
final BlockPos vScanner = Commons.createBlockPosFromNBT(tagListScanners.getCompoundTagAt(indexScanner));
|
||||
|
@ -1488,7 +1486,6 @@ public class TileEntityTransporterCore extends TileEntityAbstractEnergyConsumer
|
|||
}
|
||||
|
||||
final NBTTagList tagListContainments = (NBTTagList) tagCompound.getTag("containments");
|
||||
assert tagListContainments != null;
|
||||
final ArrayList<BlockPos> vContainments = new ArrayList<>(tagListContainments.tagCount());
|
||||
for (int indexContainment = 0; indexContainment < tagListContainments.tagCount(); indexContainment++) {
|
||||
final BlockPos vContainment = Commons.createBlockPosFromNBT(tagListContainments.getCompoundTagAt(indexContainment));
|
||||
|
|
|
@ -73,10 +73,10 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
|
|||
public void setVideoChannel(final int parVideoChannel) {
|
||||
if (videoChannel != parVideoChannel && (parVideoChannel <= VIDEO_CHANNEL_MAX) && (parVideoChannel > VIDEO_CHANNEL_MIN)) {
|
||||
videoChannel = parVideoChannel;
|
||||
markDirty();
|
||||
if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) {
|
||||
WarpDrive.logger.info(this + " Video channel updated from " + videoChannel + " to " + parVideoChannel);
|
||||
}
|
||||
markDirty();
|
||||
// force update through main thread since CC runs on server as 'client'
|
||||
packetSendTicks = 0;
|
||||
registryUpdateTicks = 0;
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.minecraft.util.text.TextComponentTranslation;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CommandDump extends AbstractCommand {
|
||||
|
||||
|
@ -95,7 +96,8 @@ public class CommandDump extends AbstractCommand {
|
|||
return "/wdump: write loot table in console for item container below or next to player";
|
||||
}
|
||||
|
||||
private IInventory getInventory(final World world, final int x, final int y, final int z) {
|
||||
@Nullable
|
||||
private IInventory getInventory(@Nonnull final World world, final int x, final int y, final int z) {
|
||||
final BlockPos blockPos = new BlockPos(x, y, z);
|
||||
final IBlockState blockState = world.getBlockState(blockPos);
|
||||
if (blockState.getBlock() instanceof ITileEntityProvider) {
|
||||
|
|
|
@ -279,7 +279,6 @@ end
|
|||
|
||||
function ship_page_setRotation()
|
||||
local inputAbort = false
|
||||
local drun = true
|
||||
w.page_begin("<==== Set ship rotation ====>")
|
||||
w.setCursorPos(1, 8)
|
||||
w.setColorHelp()
|
||||
|
|
|
@ -284,7 +284,6 @@ end
|
|||
|
||||
function ship_page_setRotation()
|
||||
local inputAbort = false
|
||||
local drun = true
|
||||
w.page_begin("<==== Set ship rotation ====>")
|
||||
w.setCursorPos(1, 11)
|
||||
w.setColorHelp()
|
||||
|
|
Loading…
Reference in a new issue