From 8621d2911a3c69e2e95723e1404811dc28c35e59 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 4 Feb 2018 22:38:46 +0100 Subject: [PATCH 1/2] Code cleanup --- src/main/java/cr0s/warpdrive/Commons.java | 15 ++++--- .../java/cr0s/warpdrive/block/BlockLaser.java | 35 ++++++---------- .../warpdrive/block/BlockLaserMedium.java | 36 ++++++++-------- .../block/TileEntityAbstractBase.java | 22 ++++++---- .../cr0s/warpdrive/block/TileEntityLaser.java | 2 +- .../atomic/BlockAcceleratorControlPoint.java | 4 +- .../atomic/BlockAcceleratorController.java | 4 +- .../warpdrive/block/atomic/BlockChiller.java | 2 +- .../block/atomic/BlockElectromagnetGlass.java | 2 +- .../block/atomic/BlockElectromagnetPlain.java | 2 +- .../block/atomic/BlockParticlesInjector.java | 4 +- .../TileEntityAcceleratorController.java | 6 ++- .../block/breathing/BlockAbstractAir.java | 2 +- .../block/breathing/BlockAirGenerator.java | 4 +- .../breathing/BlockAirGeneratorTiered.java | 4 +- .../breathing/TileEntityAirGenerator.java | 2 +- .../TileEntityAirGeneratorTiered.java | 2 +- .../block/building/BlockShipScanner.java | 4 +- .../block/building/TileEntityShipScanner.java | 2 +- .../block/collection/BlockLaserTreeFarm.java | 4 +- .../block/collection/BlockMiningLaser.java | 4 +- .../collection/TileEntityMiningLaser.java | 4 +- .../block/detection/BlockCamera.java | 4 +- .../block/detection/BlockCloakingCoil.java | 2 +- .../block/detection/BlockCloakingCore.java | 4 +- .../block/detection/BlockMonitor.java | 4 +- .../warpdrive/block/detection/BlockRadar.java | 4 +- .../warpdrive/block/detection/BlockSiren.java | 4 +- .../block/detection/BlockWarpIsolation.java | 2 +- .../block/detection/TileEntityCamera.java | 8 ++-- .../block/detection/TileEntityMonitor.java | 10 ++--- .../block/detection/TileEntityRadar.java | 2 +- .../block/energy/BlockEnanReactorCore.java | 2 +- .../block/energy/BlockEnanReactorLaser.java | 4 +- .../block/energy/BlockEnergyBank.java | 39 ++++++++++-------- .../energy/BlockIC2reactorLaserMonitor.java | 4 +- .../energy/TileEntityEnanReactorCore.java | 10 ++--- .../block/energy/TileEntityEnergyBank.java | 13 +++--- .../block/forcefield/BlockForceField.java | 4 +- .../forcefield/BlockForceFieldProjector.java | 4 +- .../forcefield/BlockForceFieldRelay.java | 2 +- .../TileEntityAbstractForceField.java | 2 +- .../forcefield/TileEntityForceField.java | 10 +++-- .../block/hull/BlockHullOmnipanel.java | 2 +- .../warpdrive/block/hull/BlockHullPlain.java | 2 +- .../warpdrive/block/movement/BlockLift.java | 4 +- .../block/movement/BlockShipController.java | 4 +- .../block/movement/BlockShipCore.java | 4 +- .../block/movement/BlockTransporter.java | 4 +- .../movement/TileEntityShipController.java | 2 +- .../block/movement/TileEntityShipCore.java | 11 +++-- .../block/movement/TileEntityTransporter.java | 4 +- .../block/passive/BlockBedrockGlass.java | 2 +- .../block/passive/BlockDecorative.java | 2 +- .../warpdrive/block/passive/BlockGas.java | 2 +- .../passive/BlockHighlyAdvancedMachine.java | 2 +- .../warpdrive/block/passive/BlockIridium.java | 2 +- .../block/passive/BlockTransportBeacon.java | 2 +- .../block/weapon/BlockLaserCamera.java | 4 +- .../block/weapon/BlockWeaponController.java | 4 +- .../block/weapon/TileEntityLaserCamera.java | 2 +- .../weapon/TileEntityWeaponController.java | 2 +- .../cr0s/warpdrive/command/CommandSpace.java | 4 +- .../java/cr0s/warpdrive/data/JumpShip.java | 2 +- .../warpdrive/entity/EntityParticleBunch.java | 4 +- .../cr0s/warpdrive/event/JumpSequencer.java | 6 +-- .../java/cr0s/warpdrive/item/ItemAirTank.java | 2 +- .../cr0s/warpdrive/item/ItemComponent.java | 24 +++++------ .../item/ItemElectromagneticCell.java | 2 +- .../warpdrive/item/ItemForceFieldUpgrade.java | 2 +- .../cr0s/warpdrive/item/ItemShipToken.java | 2 +- .../cr0s/warpdrive/item/ItemTuningDriver.java | 2 +- .../cr0s/warpdrive/item/ItemTuningFork.java | 2 +- .../java/cr0s/warpdrive/item/ItemUpgrade.java | 4 +- .../warpdrive/textures/blocks/chunkLoader.psd | Bin 35326 -> 0 bytes ...hunkLoader.png => chunk_loader-active.png} | Bin .../textures/blocks/chunk_loader-offline.png | Bin 0 -> 3976 bytes .../blocks/chunk_loader-out_of_power.png | Bin 0 -> 3976 bytes .../blocks/{laserSide.png => laser-side.png} | Bin ...MediumSide0.png => laser_medium-side0.png} | Bin ...g.mcmeta => laser_medium-side0.png.mcmeta} | 0 ...MediumSide1.png => laser_medium-side1.png} | Bin ...g.mcmeta => laser_medium-side1.png.mcmeta} | 0 ...MediumSide2.png => laser_medium-side2.png} | Bin ...g.mcmeta => laser_medium-side2.png.mcmeta} | 0 ...MediumSide3.png => laser_medium-side3.png} | Bin ...g.mcmeta => laser_medium-side3.png.mcmeta} | 0 ...MediumSide4.png => laser_medium-side4.png} | Bin ...g.mcmeta => laser_medium-side4.png.mcmeta} | 0 ...MediumSide5.png => laser_medium-side5.png} | Bin ...g.mcmeta => laser_medium-side5.png.mcmeta} | 0 ...MediumSide6.png => laser_medium-side6.png} | Bin ...g.mcmeta => laser_medium-side6.png.mcmeta} | 0 ...MediumSide7.png => laser_medium-side7.png} | Bin ...g.mcmeta => laser_medium-side7.png.mcmeta} | 0 ...Bottom.png => laser_medium-top_bottom.png} | Bin 96 files changed, 211 insertions(+), 210 deletions(-) delete mode 100644 src/main/resources/assets/warpdrive/textures/blocks/chunkLoader.psd rename src/main/resources/assets/warpdrive/textures/blocks/{chunkLoader.png => chunk_loader-active.png} (100%) create mode 100644 src/main/resources/assets/warpdrive/textures/blocks/chunk_loader-offline.png create mode 100644 src/main/resources/assets/warpdrive/textures/blocks/chunk_loader-out_of_power.png rename src/main/resources/assets/warpdrive/textures/blocks/{laserSide.png => laser-side.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide0.png => laser_medium-side0.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide0.png.mcmeta => laser_medium-side0.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide1.png => laser_medium-side1.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide1.png.mcmeta => laser_medium-side1.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide2.png => laser_medium-side2.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide2.png.mcmeta => laser_medium-side2.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide3.png => laser_medium-side3.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide3.png.mcmeta => laser_medium-side3.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide4.png => laser_medium-side4.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide4.png.mcmeta => laser_medium-side4.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide5.png => laser_medium-side5.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide5.png.mcmeta => laser_medium-side5.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide6.png => laser_medium-side6.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide6.png.mcmeta => laser_medium-side6.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide7.png => laser_medium-side7.png} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumSide7.png.mcmeta => laser_medium-side7.png.mcmeta} (100%) rename src/main/resources/assets/warpdrive/textures/blocks/{laserMediumTopBottom.png => laser_medium-top_bottom.png} (100%) diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index 24566989..ed15ed01 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -18,7 +18,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; import java.io.File; import java.io.FileInputStream; @@ -37,6 +36,7 @@ import java.util.Random; import java.util.Set; import cpw.mods.fml.common.Optional; +import net.minecraftforge.common.util.ForgeDirection; /** * Common static methods @@ -166,15 +166,15 @@ public class Commons { fieldToReturn = clazz.getDeclaredField(obfuscatedName); } catch (Exception exception2) { exception2.printStackTrace(); - String map = ""; + StringBuilder map = new StringBuilder(); for (Field fieldDeclared : clazz.getDeclaredFields()) { - if (!map.isEmpty()) { - map += ", "; + if (map.length() > 0) { + map.append(", "); } - map += fieldDeclared.getName(); + map.append(fieldDeclared.getName()); } WarpDrive.logger.error(String.format("Unable to find %1$s field in %2$s class. Available fields are: %3$s", - deobfuscatedName, clazz.toString(), map)); + deobfuscatedName, clazz.toString(), map.toString())); } } if (fieldToReturn != null) { @@ -255,8 +255,7 @@ public class Commons { toIgnore.addAll(Arrays.asList(ignore)); } - Set toIterate = new HashSet<>(); - toIterate.addAll(start); + Set toIterate = new HashSet<>(start); Set toIterateNext; diff --git a/src/main/java/cr0s/warpdrive/block/BlockLaser.java b/src/main/java/cr0s/warpdrive/block/BlockLaser.java index d7423947..87734feb 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockLaser.java +++ b/src/main/java/cr0s/warpdrive/block/BlockLaser.java @@ -19,9 +19,9 @@ public class BlockLaser extends BlockAbstractContainer { @SideOnly(Side.CLIENT) private IIcon[] iconBuffer; - + private static final int ICON_SIDE = 0; - + public BlockLaser() { super(Material.iron); setHardness(50.0F); @@ -31,44 +31,35 @@ public class BlockLaser extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[1]; - // Solid textures - iconBuffer[ICON_SIDE] = iconRegister.registerIcon("warpdrive:laserSide"); + iconBuffer[ICON_SIDE] = iconRegister.registerIcon("warpdrive:laser-side"); } @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(int side, int metadata) { + public IIcon getIcon(final int side, final int metadata) { return iconBuffer[ICON_SIDE]; } - + @Override - public TileEntity createNewTileEntity(World parWorld, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityLaser(); } - - /** - * Returns the quantity of items to drop on block destruction. - */ + @Override - public int quantityDropped(Random par1Random) { + public int quantityDropped(final Random random) { return 1; } - - /** - * Returns the ID of the items to drop on destruction. - */ + @Override - public Item getItemDropped(int par1, Random par2Random, int par3) { + public Item getItemDropped(final int metadata, final Random random, final int fortune) { return Item.getItemFromBlock(this); } - /** - * Called upon block activation (right click on the block.) - */ @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, + final int side, final float hitX, final float hitY, final float hitZ) { if (world.isRemote) { return false; } diff --git a/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java b/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java index e6afd30e..6a44e5cc 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java +++ b/src/main/java/cr0s/warpdrive/block/BlockLaserMedium.java @@ -14,6 +14,8 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockLaserMedium extends BlockAbstractContainer { + + @SideOnly(Side.CLIENT) private IIcon[] iconBuffer; public BlockLaserMedium() { @@ -23,22 +25,22 @@ public class BlockLaserMedium extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[9]; - iconBuffer[0] = iconRegister.registerIcon("warpdrive:laserMediumSide0"); - iconBuffer[1] = iconRegister.registerIcon("warpdrive:laserMediumSide1"); - iconBuffer[2] = iconRegister.registerIcon("warpdrive:laserMediumSide2"); - iconBuffer[3] = iconRegister.registerIcon("warpdrive:laserMediumSide3"); - iconBuffer[4] = iconRegister.registerIcon("warpdrive:laserMediumSide4"); - iconBuffer[5] = iconRegister.registerIcon("warpdrive:laserMediumSide5"); - iconBuffer[6] = iconRegister.registerIcon("warpdrive:laserMediumSide6"); - iconBuffer[7] = iconRegister.registerIcon("warpdrive:laserMediumSide7"); - iconBuffer[8] = iconRegister.registerIcon("warpdrive:laserMediumTopBottom"); + iconBuffer[0] = iconRegister.registerIcon("warpdrive:laser_medium-side0"); + iconBuffer[1] = iconRegister.registerIcon("warpdrive:laser_medium-side1"); + iconBuffer[2] = iconRegister.registerIcon("warpdrive:laser_medium-side2"); + iconBuffer[3] = iconRegister.registerIcon("warpdrive:laser_medium-side3"); + iconBuffer[4] = iconRegister.registerIcon("warpdrive:laser_medium-side4"); + iconBuffer[5] = iconRegister.registerIcon("warpdrive:laser_medium-side5"); + iconBuffer[6] = iconRegister.registerIcon("warpdrive:laser_medium-side6"); + iconBuffer[7] = iconRegister.registerIcon("warpdrive:laser_medium-side7"); + iconBuffer[8] = iconRegister.registerIcon("warpdrive:laser_medium-top_bottom"); } @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) { + public IIcon getIcon(final IBlockAccess blockAccess, final int x, final int y, final int z, final int side) { final int metadata = blockAccess.getBlockMetadata(x, y, z); if (side == 0 || side == 1) { return iconBuffer[8]; @@ -49,7 +51,7 @@ public class BlockLaserMedium extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(int side, int metadata) { + public IIcon getIcon(final int side, final int metadata) { if (side == 0 || side == 1) { return iconBuffer[8]; } @@ -58,21 +60,19 @@ public class BlockLaserMedium extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityLaserMedium(); } - /** - * Called upon block activation (right click on the block.) - */ @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, + final int side, final float hitX, final float hitY, final float hitZ) { if (world.isRemote) { return false; } if (entityPlayer.getHeldItem() == null) { - TileEntity tileEntity = world.getTileEntity(x, y, z); + final TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity instanceof TileEntityLaserMedium) { Commons.addChatMessage(entityPlayer, ((TileEntityLaserMedium) tileEntity).getStatus()); return true; diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java index a60298a9..0e0fd970 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java @@ -306,21 +306,25 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc return mapResult; } + public int getValidUpgradeCount(final Object upgrade) { + return Math.min(getUpgradeMaxCount(upgrade), getUpgradeCount(upgrade)); + } + public int getUpgradeCount(final Object upgrade) { - Integer value = installedUpgrades.get(upgrade); + final Integer value = installedUpgrades.get(upgrade); return value == null ? 0 : value; } public int getUpgradeMaxCount(final Object upgrade) { - Integer value = maxUpgrades.get(upgrade); + final Integer value = maxUpgrades.get(upgrade); return value == null ? 0 : value; } protected String getUpgradesAsString() { - String message = ""; + final StringBuilder message = new StringBuilder(); for (final Entry entry : installedUpgrades.entrySet()) { - if (!message.isEmpty()) { - message += ", "; + if (message.length() > 0) { + message.append(", "); } final Object key = entry.getKey(); String keyName = key.toString(); @@ -330,12 +334,12 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc keyName = ((Block) key).getUnlocalizedName(); } if (entry.getValue() == 1) { - message += keyName; + message.append(keyName); } else { - message += entry.getValue() + " x " + keyName; + message.append(entry.getValue()).append(" x ").append(keyName); } } - return message; + return message.toString(); } protected void setUpgradeMaxCount(final Object upgrade, final int value) { @@ -356,7 +360,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc } public boolean dismountUpgrade(final Object upgrade) { - int count = getUpgradeCount(upgrade); + final int count = getUpgradeCount(upgrade); if (count > 1) { installedUpgrades.put(upgrade, count - 1); markDirty(); diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java b/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java index dd656379..f21e4b06 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityLaser.java @@ -675,7 +675,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre return String.format("%s Beam \'%d\' @ %s (%d %d %d)", getClass().getSimpleName(), beamFrequency, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorControlPoint.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorControlPoint.java index 2bd208b4..c04ae7ad 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorControlPoint.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorControlPoint.java @@ -25,7 +25,7 @@ public class BlockAcceleratorControlPoint extends BlockAbstractAccelerator imple @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[2]; icons[0] = iconRegister.registerIcon(getTextureName() + "-off"); @@ -57,7 +57,7 @@ public class BlockAcceleratorControlPoint extends BlockAbstractAccelerator imple } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityAcceleratorControlPoint(); } } diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorController.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorController.java index 882c41e6..58f6ef02 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorController.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockAcceleratorController.java @@ -28,7 +28,7 @@ public class BlockAcceleratorController extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[2]; icons[0] = iconRegister.registerIcon(getTextureName() + "-off"); @@ -64,7 +64,7 @@ public class BlockAcceleratorController extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityAcceleratorController(); } } diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockChiller.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockChiller.java index 39b93a63..c47aad6d 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockChiller.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockChiller.java @@ -32,7 +32,7 @@ public class BlockChiller extends BlockAbstractAccelerator { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[2]; icons[0] = iconRegister.registerIcon(getTextureName() + "-off"); diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetGlass.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetGlass.java index d997b711..9f754898 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetGlass.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetGlass.java @@ -17,7 +17,7 @@ public class BlockElectromagnetGlass extends BlockElectromagnetPlain { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconSide = iconRegister.registerIcon("warpdrive:atomic/electromagnet" + tier + "_glass-side"); iconTop = iconRegister.registerIcon("warpdrive:atomic/electromagnet" + tier + "_glass-top"); } diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetPlain.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetPlain.java index fbe2b2ed..90aca367 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetPlain.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockElectromagnetPlain.java @@ -20,7 +20,7 @@ public class BlockElectromagnetPlain extends BlockAbstractAccelerator { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconSide = iconRegister.registerIcon("warpdrive:atomic/electromagnet" + tier + "_plain-side"); iconTop = iconRegister.registerIcon("warpdrive:atomic/electromagnet" + tier + "_plain-top"); } diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockParticlesInjector.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockParticlesInjector.java index b9651704..962b361f 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockParticlesInjector.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockParticlesInjector.java @@ -21,7 +21,7 @@ public class BlockParticlesInjector extends BlockAcceleratorControlPoint { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[2]; icons[0] = iconRegister.registerIcon(getTextureName() + "-off"); @@ -35,7 +35,7 @@ public class BlockParticlesInjector extends BlockAcceleratorControlPoint { } @Override - public TileEntity createNewTileEntity(World world, int p_149915_2_) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityParticlesInjector(); } } diff --git a/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorController.java b/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorController.java index 1ba41651..f8bf85ee 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorController.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/TileEntityAcceleratorController.java @@ -58,7 +58,9 @@ public class TileEntityAcceleratorController extends TileEntityAbstractEnergy im @Override public String toString() { - return String.format("%s @ \'%s\' (%d %d %d)", getClass().getSimpleName(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), xCoord, yCoord, zCoord); + return String.format("%s @ \'%s\' (%d %d %d)", + getClass().getSimpleName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); } } diff --git a/src/main/java/cr0s/warpdrive/block/breathing/BlockAbstractAir.java b/src/main/java/cr0s/warpdrive/block/breathing/BlockAbstractAir.java index 4e602bae..51191ca0 100644 --- a/src/main/java/cr0s/warpdrive/block/breathing/BlockAbstractAir.java +++ b/src/main/java/cr0s/warpdrive/block/breathing/BlockAbstractAir.java @@ -82,7 +82,7 @@ public abstract class BlockAbstractAir extends BlockAbstractBase { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { if (WarpDriveConfig.BREATHING_AIR_BLOCK_DEBUG) { iconBuffer = new IIcon[16]; iconBuffer[ 0] = iconRegister.registerIcon("warpdrive:breathing/air0"); diff --git a/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGenerator.java b/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGenerator.java index 92eb8f3b..f7dec8ad 100644 --- a/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGenerator.java +++ b/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGenerator.java @@ -38,7 +38,7 @@ public class BlockAirGenerator extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[3]; iconBuffer[ICON_INACTIVE_SIDE] = iconRegister.registerIcon("warpdrive:breathing/air_generator-side_inactive"); iconBuffer[ICON_BOTTOM] = iconRegister.registerIcon("warpdrive:breathing/air_generator-connection"); @@ -77,7 +77,7 @@ public class BlockAirGenerator extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityAirGenerator(); } diff --git a/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGeneratorTiered.java b/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGeneratorTiered.java index 892f6382..8b07170a 100644 --- a/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGeneratorTiered.java +++ b/src/main/java/cr0s/warpdrive/block/breathing/BlockAirGeneratorTiered.java @@ -42,7 +42,7 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[3]; iconBuffer[ICON_INACTIVE_SIDE] = iconRegister.registerIcon("warpdrive:breathing/air_generator-side_inactive"); iconBuffer[ICON_BOTTOM] = iconRegister.registerIcon("warpdrive:breathing/air_generator-connection"); @@ -75,7 +75,7 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityAirGeneratorTiered(); } diff --git a/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGenerator.java b/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGenerator.java index c507c9d8..2e2bbff7 100644 --- a/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGenerator.java +++ b/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGenerator.java @@ -126,7 +126,7 @@ public class TileEntityAirGenerator extends TileEntityAbstractEnergy { public String toString() { return String.format("%s @ %s (%d %d %d)", getClass().getSimpleName(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } diff --git a/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGeneratorTiered.java b/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGeneratorTiered.java index ac01f06d..3dd19b0d 100644 --- a/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGeneratorTiered.java +++ b/src/main/java/cr0s/warpdrive/block/breathing/TileEntityAirGeneratorTiered.java @@ -148,7 +148,7 @@ public class TileEntityAirGeneratorTiered extends TileEntityAbstractEnergy { public String toString() { return String.format("%s @ %s (%d %d %d)", getClass().getSimpleName(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } diff --git a/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java index c7c73811..1a66c7a1 100644 --- a/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java @@ -38,7 +38,7 @@ public class BlockShipScanner extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[16]; iconBuffer[ICON_BOTTOM ] = iconRegister.registerIcon("warpdrive:building/shipScannerBottom"); iconBuffer[ICON_TOP ] = iconRegister.registerIcon("warpdrive:building/shipScannerTop"); @@ -111,7 +111,7 @@ public class BlockShipScanner extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityShipScanner(); } diff --git a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java index 4b35d74c..cd1c73ab 100644 --- a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java @@ -775,7 +775,7 @@ public class TileEntityShipScanner extends TileEntityAbstractInterfaced implemen public String toString() { return String.format("%s @ %s (%d %d %d)", getClass().getSimpleName(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } } diff --git a/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java b/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java index 35ddc398..887cd3c5 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java +++ b/src/main/java/cr0s/warpdrive/block/collection/BlockLaserTreeFarm.java @@ -38,7 +38,7 @@ public class BlockLaserTreeFarm extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[16]; iconBuffer[ICON_IDLE ] = iconRegister.registerIcon("warpdrive:collection/laserTreeFarmSide_idle"); iconBuffer[ICON_FARMING_LOW_POWER ] = iconRegister.registerIcon("warpdrive:collection/laserTreeFarmSide_farmingLowPower"); @@ -80,7 +80,7 @@ public class BlockLaserTreeFarm extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityLaserTreeFarm(); } diff --git a/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java b/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java index c305e36f..5b9bcad1 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java +++ b/src/main/java/cr0s/warpdrive/block/collection/BlockMiningLaser.java @@ -36,7 +36,7 @@ public class BlockMiningLaser extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[16]; iconBuffer[ICON_IDLE ] = iconRegister.registerIcon("warpdrive:collection/miningLaserSide_idle"); iconBuffer[ICON_MINING_LOW_POWER ] = iconRegister.registerIcon("warpdrive:collection/miningLaserSide_miningLowPower"); @@ -76,7 +76,7 @@ public class BlockMiningLaser extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityMiningLaser(); } diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java index fa21398d..010cb01f 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java @@ -556,6 +556,8 @@ public class TileEntityMiningLaser extends TileEntityAbstractMiner { @Override public String toString() { return String.format("%s @ \'%s\' %d, %d, %d", - getClass().getSimpleName(), worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), xCoord, yCoord, zCoord); + getClass().getSimpleName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); } } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java b/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java index d915aade..f27a1a5f 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockCamera.java @@ -31,7 +31,7 @@ public class BlockCamera extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[1]; // Solid textures iconBuffer[ICON_SIDE] = iconRegister.registerIcon("warpdrive:detection/cameraSide"); @@ -49,7 +49,7 @@ public class BlockCamera extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityCamera(); } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCoil.java b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCoil.java index 96b6af0c..ea9e531d 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCoil.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCoil.java @@ -38,7 +38,7 @@ public class BlockCloakingCoil extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[4]; iconBuffer[0] = iconRegister.registerIcon("warpdrive:detection/cloaking_coil-channeling_inactive"); iconBuffer[1] = iconRegister.registerIcon("warpdrive:detection/cloaking_coil-projecting_inactive"); diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java index 919d5126..10938086 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java @@ -32,7 +32,7 @@ public class BlockCloakingCore extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[2]; iconBuffer[0] = iconRegister.registerIcon("warpdrive:detection/cloakingCoreInactive"); iconBuffer[1] = iconRegister.registerIcon("warpdrive:detection/cloakingCoreActive"); @@ -56,7 +56,7 @@ public class BlockCloakingCore extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityCloakingCore(); } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java index c868e586..19416b6f 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockMonitor.java @@ -33,7 +33,7 @@ public class BlockMonitor extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconFront = iconRegister.registerIcon("warpdrive:detection/monitorFront"); iconSide = iconRegister.registerIcon("warpdrive:detection/monitorSide"); } @@ -85,7 +85,7 @@ public class BlockMonitor extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityMonitor(); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java b/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java index e84d8be3..0ddf8a76 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockRadar.java @@ -36,7 +36,7 @@ public class BlockRadar extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[16]; iconBuffer[ICON_SIDE_INACTIVE ] = iconRegister.registerIcon("warpdrive:detection/radarSideInactive"); iconBuffer[ICON_BOTTOM ] = iconRegister.registerIcon("warpdrive:detection/radarBottom"); @@ -80,7 +80,7 @@ public class BlockRadar extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityRadar(); } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockSiren.java b/src/main/java/cr0s/warpdrive/block/detection/BlockSiren.java index 09420e5a..0f73d35b 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockSiren.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockSiren.java @@ -42,7 +42,7 @@ public class BlockSiren extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[4]; // Solid textures iconBuffer[ICON_INDUSTRIAL] = iconRegister.registerIcon("warpdrive:detection/siren_industrial"); @@ -75,7 +75,7 @@ public class BlockSiren extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntitySiren(); } diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockWarpIsolation.java b/src/main/java/cr0s/warpdrive/block/detection/BlockWarpIsolation.java index 2fb16ea7..13904474 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockWarpIsolation.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockWarpIsolation.java @@ -28,7 +28,7 @@ public class BlockWarpIsolation extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[1]; iconBuffer[0] = iconRegister.registerIcon("warpdrive:detection/warpIsolation"); } diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java index 264d90e5..2a3cd149 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java @@ -190,9 +190,9 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV @Override public String toString() { return String.format("%s %d @ %s (%d %d %d)", - getClass().getSimpleName(), - videoChannel, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), - xCoord, yCoord, zCoord); + getClass().getSimpleName(), + videoChannel, + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java index 85033f4d..1b83c84d 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java @@ -148,10 +148,10 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I @Override public String toString() { - return String.format("%s %d @ %s (%d %d %d)", - getClass().getSimpleName(), - videoChannel, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), - xCoord, yCoord, zCoord); + return String.format("%s %d @ %s (%d %d %d)", + getClass().getSimpleName(), + videoChannel, + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java index ea2c7682..6858c4b3 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityRadar.java @@ -109,7 +109,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergy { Vector3 vec3Position = StarMapRegistry.getUniversalCoordinates(celestialObject, xCoord, yCoord, zCoord); return new Object[] { xCoord, yCoord, zCoord, celestialObject.getDisplayName(), vec3Position.x, vec3Position.y, vec3Position.z }; } else { - String name = worldObj.getWorldInfo().getWorldName(); + String name = worldObj.provider.getDimensionName(); if (name == null || name.isEmpty()) { name = "DIM" + worldObj.provider.dimensionId; } diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorCore.java b/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorCore.java index 4d7134c7..83d944dd 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorCore.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorCore.java @@ -32,7 +32,7 @@ public class BlockEnanReactorCore extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[17]; iconBuffer[16] = iconRegister.registerIcon("warpdrive:energy/enan_reactor_core-top_bottom"); iconBuffer[ 0] = iconRegister.registerIcon("warpdrive:energy/enan_reactor_core-side00"); diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java b/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java index f859a053..0231ee40 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockEnanReactorLaser.java @@ -25,13 +25,13 @@ public class BlockEnanReactorLaser extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityEnanReactorLaser(); } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[3]; iconBuffer[0] = iconRegister.registerIcon("warpdrive:energy/enan_reactor_laser-top_bottom"); iconBuffer[1] = iconRegister.registerIcon("warpdrive:energy/enan_reactor_laser-side_inactive"); diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java b/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java index 89399ab7..7adfa9ae 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockEnergyBank.java @@ -39,18 +39,18 @@ public class BlockEnergyBank extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityEnergyBank((byte)(metadata % 4)); } @Override - public int damageDropped(int metadata) { + public int damageDropped(final int metadata) { return metadata; } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativeTab, List list) { + public void getSubBlocks(final Item item, final CreativeTabs creativeTab, final List list) { for (byte tier = 0; tier < 4; tier++) { ItemStack itemStack = new ItemStack(item, 1, tier); list.add(itemStack); @@ -67,7 +67,7 @@ public class BlockEnergyBank extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[12]; icons[ 0] = iconRegister.registerIcon("warpdrive:energy/energy_bank_creative-disabled"); icons[ 1] = iconRegister.registerIcon("warpdrive:energy/energy_bank_creative-input"); @@ -119,21 +119,22 @@ public class BlockEnergyBank extends BlockAbstractContainer { return false; } - TileEntity tileEntity = world.getTileEntity(x, y, z); + final TileEntity tileEntity = world.getTileEntity(x, y, z); if (!(tileEntity instanceof TileEntityEnergyBank)) { return false; } - TileEntityEnergyBank tileEntityEnergyBank = (TileEntityEnergyBank) tileEntity; - ItemStack itemStackHeld = entityPlayer.getHeldItem(); - EnumFacing facing = EnumFacing.getFront(side); + final TileEntityEnergyBank tileEntityEnergyBank = (TileEntityEnergyBank) tileEntity; + final ItemStack itemStackHeld = entityPlayer.getHeldItem(); + final EnumFacing facing = EnumFacing.getFront(side); - if (itemStackHeld != null && itemStackHeld.getItem() instanceof IWarpTool) { + if ( itemStackHeld != null + && itemStackHeld.getItem() instanceof IWarpTool ) { if (entityPlayer.isSneaking()) { tileEntityEnergyBank.setMode(facing, (byte)((tileEntityEnergyBank.getMode(facing) + 2) % 3)); } else { tileEntityEnergyBank.setMode(facing, (byte)((tileEntityEnergyBank.getMode(facing) + 1) % 3)); } - ItemStack itemStack = new ItemStack(Item.getItemFromBlock(this), 1, world.getBlockMetadata(x, y, z)); + final ItemStack itemStack = new ItemStack(Item.getItemFromBlock(this), 1, world.getBlockMetadata(x, y, z)); switch (tileEntityEnergyBank.getMode(facing)) { case TileEntityEnergyBank.MODE_INPUT: Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.guide.prefix", @@ -155,17 +156,20 @@ public class BlockEnergyBank extends BlockAbstractContainer { } EnumComponentType enumComponentType = null; - if (itemStackHeld != null && itemStackHeld.getItem() instanceof ItemComponent) { + if ( itemStackHeld != null + && itemStackHeld.getItem() instanceof ItemComponent ) { enumComponentType = EnumComponentType.get(itemStackHeld.getItemDamage()); } // sneaking with an empty hand or an upgrade item in hand to dismount current upgrade if (entityPlayer.isSneaking()) { - // using an upgrade item or an empty means dismount upgrade - if (itemStackHeld == null || enumComponentType != null) { + // using an upgrade item or an empty hand means dismount upgrade + if ( itemStackHeld == null + || enumComponentType != null ) { // find a valid upgrade to dismount - if (itemStackHeld == null || !tileEntityEnergyBank.hasUpgrade(enumComponentType)) { - enumComponentType = (EnumComponentType)tileEntityEnergyBank.getFirstUpgradeOfType(EnumComponentType.class, null); + if ( itemStackHeld == null + || !tileEntityEnergyBank.hasUpgrade(enumComponentType) ) { + enumComponentType = (EnumComponentType) tileEntityEnergyBank.getFirstUpgradeOfType(EnumComponentType.class, null); } if (enumComponentType == null) { @@ -176,8 +180,8 @@ public class BlockEnergyBank extends BlockAbstractContainer { if (!entityPlayer.capabilities.isCreativeMode) { // dismount the current upgrade item - ItemStack itemStackDrop = ItemComponent.getItemStackNoCache(enumComponentType, 1); - EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop); + final ItemStack itemStackDrop = ItemComponent.getItemStackNoCache(enumComponentType, 1); + final EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop); entityItem.delayBeforeCanPickup = 0; world.spawnEntityInWorld(entityItem); } @@ -186,7 +190,6 @@ public class BlockEnergyBank extends BlockAbstractContainer { // upgrade dismounted Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumComponentType.name())); return false; - } } else if (itemStackHeld == null) {// no sneaking and no item in hand => show status diff --git a/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java b/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java index 9871bd33..3518e8fb 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/energy/BlockIC2reactorLaserMonitor.java @@ -31,13 +31,13 @@ public class BlockIC2reactorLaserMonitor extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityIC2reactorLaserMonitor(); } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[5]; icons[ICON_DISCONNECTED] = iconRegister.registerIcon("warpdrive:energy/ic2_reactor_laser_cooler-invalid"); icons[ICON_HEAD_VALID ] = iconRegister.registerIcon("warpdrive:energy/ic2_reactor_laser_cooler-head-valid"); diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java index 252e84ba..c4ac711f 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java @@ -738,10 +738,10 @@ public class TileEntityEnanReactorCore extends TileEntityAbstractEnergy implemen @Override public String toString() { - return String.format("%s %s @ %s (%d %d %d)", - getClass().getSimpleName(), - connectedComputers == null ? "~NULL~" : connectedComputers, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), - xCoord, yCoord, zCoord); + return String.format("%s %s @ %s (%d %d %d)", + getClass().getSimpleName(), + connectedComputers == null ? "~NULL~" : connectedComputers, + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java index db0fa987..575138e3 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnergyBank.java @@ -1,6 +1,5 @@ package cr0s.warpdrive.block.energy; -import cr0s.warpdrive.Commons; import cr0s.warpdrive.block.TileEntityAbstractEnergy; import cr0s.warpdrive.config.WarpDriveConfig; import cr0s.warpdrive.data.EnumComponentType; @@ -49,7 +48,7 @@ public class TileEntityEnergyBank extends TileEntityAbstractEnergy { } private double getEfficiency() { - int upgradeCount = Commons.clamp(0, getUpgradeMaxCount(EnumComponentType.SUPERCONDUCTOR), getUpgradeCount(EnumComponentType.SUPERCONDUCTOR)); + final int upgradeCount = getValidUpgradeCount(EnumComponentType.SUPERCONDUCTOR); return WarpDriveConfig.ENERGY_BANK_EFFICIENCY_PER_UPGRADE[upgradeCount]; } @@ -173,10 +172,10 @@ public class TileEntityEnergyBank extends TileEntityAbstractEnergy { @Override public String toString() { - return String.format("%s @ %s (%d %d %d) %8d", - getClass().getSimpleName(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), - xCoord, yCoord, zCoord, - energy_getEnergyStored()); + return String.format("%s @ %s (%d %d %d) %8d", + getClass().getSimpleName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord, + energy_getEnergyStored()); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java index 478ccf0c..2382e599 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java @@ -55,7 +55,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityForceField(); } @@ -96,7 +96,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[16]; for (int i = 0; i < 16; ++i) { diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java index 95d8c9ef..3f8a4899 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java @@ -40,7 +40,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[11]; icons[ 0] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_notConnected"); icons[ 1] = iconRegister.registerIcon("warpdrive:forcefield/projectorSide_connectedNotPowered"); @@ -258,7 +258,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityForceFieldProjector(); } } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldRelay.java b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldRelay.java index 2b5852f5..016b4a92 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldRelay.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldRelay.java @@ -157,7 +157,7 @@ public class BlockForceFieldRelay extends BlockAbstractForceField { } @Override - public TileEntity createNewTileEntity(World world, int metadata) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityForceFieldRelay(); } } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java index 81339a83..2e8f7b9f 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityAbstractForceField.java @@ -217,7 +217,7 @@ public class TileEntityAbstractForceField extends TileEntityAbstractEnergy imple return String.format("%s Beam \'%d\' @ %s (%d %d %d)", getClass().getSimpleName(), beamFrequency, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java index af482b45..304de505 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/TileEntityForceField.java @@ -129,8 +129,9 @@ public class TileEntityForceField extends TileEntityAbstractBase { // projector is disabled or out of power worldObj.setBlockToAir(xCoord, yCoord, zCoord); if (WarpDriveConfig.LOGGING_FORCEFIELD) { - WarpDrive.logger.info("Removed a force field from an offline projector at " - + (worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName()) + " " + xCoord + " " + yCoord + " " + zCoord); + WarpDrive.logger.info(String.format("Removed a force field from an offline projector @ %s (%d %d %d)", + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord)); } } } @@ -142,8 +143,9 @@ public class TileEntityForceField extends TileEntityAbstractBase { if (gracePeriod_calls < 0) { worldObj.setBlockToAir(xCoord, yCoord, zCoord); if (WarpDriveConfig.LOGGING_FORCEFIELD) { - WarpDrive.logger.info("Removed a force field with no projector defined at " - + (worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName()) + " " + xCoord + " " + yCoord + " " + zCoord); + WarpDrive.logger.info(String.format("Removed a force field with no projector defined @ %s (%d %d %d)", + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord)); } } } diff --git a/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java b/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java index dc6b869b..c651a592 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java +++ b/src/main/java/cr0s/warpdrive/block/hull/BlockHullOmnipanel.java @@ -71,7 +71,7 @@ public class BlockHullOmnipanel extends BlockAbstractOmnipanel implements IDamag @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[16]; for (int i = 0; i < 16; i++) { diff --git a/src/main/java/cr0s/warpdrive/block/hull/BlockHullPlain.java b/src/main/java/cr0s/warpdrive/block/hull/BlockHullPlain.java index daa743ba..eb809dab 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/BlockHullPlain.java +++ b/src/main/java/cr0s/warpdrive/block/hull/BlockHullPlain.java @@ -72,7 +72,7 @@ public class BlockHullPlain extends BlockAbstractBase implements IDamageReceiver @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[16]; for (int i = 0; i < 16; ++i) { diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java b/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java index 67ad5528..17135467 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockLift.java @@ -29,7 +29,7 @@ public class BlockLift extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[6]; iconBuffer[0] = iconRegister.registerIcon("warpdrive:movement/liftSideOffline"); iconBuffer[1] = iconRegister.registerIcon("warpdrive:movement/liftSideUp"); @@ -79,7 +79,7 @@ public class BlockLift extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityLift(); } diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java b/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java index 489be9f8..8331aa53 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockShipController.java @@ -34,7 +34,7 @@ public class BlockShipController extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[11]; // Solid textures iconBuffer[ICON_INACTIVE_SIDE] = iconRegister.registerIcon("warpdrive:movement/ship_controller-side_inactive"); @@ -85,7 +85,7 @@ public class BlockShipController extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityShipController(); } diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java index 67d9e458..a094b518 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java @@ -47,7 +47,7 @@ public class BlockShipCore extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[18]; iconBuffer[ICON_TOP_BOTTOM ] = iconRegister.registerIcon("warpdrive:movement/ship_core-top-bottom"); iconBuffer[ICON_LEFT_OFFLINE ] = iconRegister.registerIcon("warpdrive:movement/ship_core-left_offline"); @@ -131,7 +131,7 @@ public class BlockShipCore extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World var1, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityShipCore(); } diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java b/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java index 39dd3315..26084dd3 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockTransporter.java @@ -24,13 +24,13 @@ public class BlockTransporter extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityTransporter(); } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[3]; // Solid textures iconBuffer[0] = iconRegister.registerIcon("warpdrive:movement/transporterBottom"); diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java index 06486772..b74f802c 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipController.java @@ -799,7 +799,7 @@ public class TileEntityShipController extends TileEntityAbstractInterfaced imple return String.format("%s \'%s\' @ %s (%d %d %d)", getClass().getSimpleName(), tileEntityShipCore == null ? "-NULL-" : tileEntityShipCore.shipName, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } } diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java index 9e862be8..acb58d7e 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java @@ -1232,11 +1232,10 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy implements ISta @Override public String toString() { - return String.format( - "%s \'%s\' @ %s (%d %d %d)", - getClass().getSimpleName(), - shipName, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), - xCoord, yCoord, zCoord); + return String.format("%s \'%s\' @ %s (%d %d %d)", + getClass().getSimpleName(), + shipName, + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); } } diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java index 9b42a93c..d84467a2 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityTransporter.java @@ -503,8 +503,8 @@ public class TileEntityTransporter extends TileEntityAbstractEnergy { @Override public int energy_getMaxStorage() { - int energyUgrades = getUpgradeCount(ItemUpgrade.getItemStack(UpgradeType.Energy)); - int max = (int) Math.floor(WarpDriveConfig.TRANSPORTER_MAX_ENERGY_STORED * Math.pow(1.2, energyUgrades)); + int energyUpgrades = getUpgradeCount(ItemUpgrade.getItemStack(UpgradeType.Energy)); + int max = (int) Math.floor(WarpDriveConfig.TRANSPORTER_MAX_ENERGY_STORED * Math.pow(1.2, energyUpgrades)); return max; } diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockBedrockGlass.java b/src/main/java/cr0s/warpdrive/block/passive/BlockBedrockGlass.java index 1eb69390..ab4bc5da 100644 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockBedrockGlass.java +++ b/src/main/java/cr0s/warpdrive/block/passive/BlockBedrockGlass.java @@ -55,7 +55,7 @@ public class BlockBedrockGlass extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icon = iconRegister.registerIcon("warpdrive:decoration/bedrock_glass"); } diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java b/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java index ce152348..4534638a 100644 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java +++ b/src/main/java/cr0s/warpdrive/block/passive/BlockDecorative.java @@ -42,7 +42,7 @@ public class BlockDecorative extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { icons = new IIcon[EnumDecorativeType.length]; for (final EnumDecorativeType enumDecorativeType : EnumDecorativeType.values()) { icons[enumDecorativeType.ordinal()] = iconRegister.registerIcon("warpdrive:decoration/decorative-" + enumDecorativeType.unlocalizedName); diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockGas.java b/src/main/java/cr0s/warpdrive/block/passive/BlockGas.java index 23cf4a1d..ab27d2ce 100644 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockGas.java +++ b/src/main/java/cr0s/warpdrive/block/passive/BlockGas.java @@ -76,7 +76,7 @@ public class BlockGas extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[12]; iconBuffer[0] = iconRegister.registerIcon("warpdrive:decoration/gas-blue"); iconBuffer[1] = iconRegister.registerIcon("warpdrive:decoration/gas-red"); diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockHighlyAdvancedMachine.java b/src/main/java/cr0s/warpdrive/block/passive/BlockHighlyAdvancedMachine.java index 2be7d673..fae50d02 100644 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockHighlyAdvancedMachine.java +++ b/src/main/java/cr0s/warpdrive/block/passive/BlockHighlyAdvancedMachine.java @@ -24,7 +24,7 @@ public class BlockHighlyAdvancedMachine extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { blockIcon = iconRegister.registerIcon("warpdrive:passive/highlyAdvancedMachineSide"); } diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockIridium.java b/src/main/java/cr0s/warpdrive/block/passive/BlockIridium.java index f3cff424..7acdf61e 100644 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockIridium.java +++ b/src/main/java/cr0s/warpdrive/block/passive/BlockIridium.java @@ -25,7 +25,7 @@ public class BlockIridium extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { blockIcon = iconRegister.registerIcon("warpdrive:passive/iridiumSide"); } diff --git a/src/main/java/cr0s/warpdrive/block/passive/BlockTransportBeacon.java b/src/main/java/cr0s/warpdrive/block/passive/BlockTransportBeacon.java index c489cb86..a5282623 100644 --- a/src/main/java/cr0s/warpdrive/block/passive/BlockTransportBeacon.java +++ b/src/main/java/cr0s/warpdrive/block/passive/BlockTransportBeacon.java @@ -29,7 +29,7 @@ public class BlockTransportBeacon extends Block { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { blockIcon = iconRegister.registerIcon("warpdrive:passive/transportBeacon"); } diff --git a/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java b/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java index 077ad0e6..3ca716e8 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/BlockLaserCamera.java @@ -36,7 +36,7 @@ public class BlockLaserCamera extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[1]; // Solid textures iconBuffer[ICON_SIDE] = iconRegister.registerIcon("warpdrive:weapon/laserCameraSide"); @@ -54,7 +54,7 @@ public class BlockLaserCamera extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World parWorld, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityLaserCamera(); } diff --git a/src/main/java/cr0s/warpdrive/block/weapon/BlockWeaponController.java b/src/main/java/cr0s/warpdrive/block/weapon/BlockWeaponController.java index 5ef59f6d..24a7bdcb 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/BlockWeaponController.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/BlockWeaponController.java @@ -36,7 +36,7 @@ public class BlockWeaponController extends BlockAbstractContainer { @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { + public void registerBlockIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[3]; iconBuffer[ICON_TOP] = iconRegister.registerIcon("warpdrive:movement/ship_controller-top"); iconBuffer[ICON_BOTTOM] = iconRegister.registerIcon("warpdrive:movement/ship_controller-bottom"); @@ -55,7 +55,7 @@ public class BlockWeaponController extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World parWorld, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityWeaponController(); } diff --git a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java index dc7bbc91..311d2d69 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java @@ -187,7 +187,7 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan getClass().getSimpleName(), beamFrequency, videoChannel, - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java index dda3bb1d..a0a5c2dc 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityWeaponController.java @@ -36,7 +36,7 @@ public class TileEntityWeaponController extends TileEntityAbstractInterfaced { public String toString() { return String.format("%s @ %s (%d %d %d)", getClass().getSimpleName(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), xCoord, yCoord, zCoord); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/command/CommandSpace.java b/src/main/java/cr0s/warpdrive/command/CommandSpace.java index 4a3cfbab..6dcfcc36 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandSpace.java +++ b/src/main/java/cr0s/warpdrive/command/CommandSpace.java @@ -167,11 +167,11 @@ public class CommandSpace extends CommandBase { } // inform player - String message = "§aTeleporting player " + entityPlayerMP.getCommandSenderName() + " to dimension " + dimensionIdTarget + "..."; // + ":" + worldTarget.getWorldInfo().getWorldName(); + String message = "§aTeleporting player " + entityPlayerMP.getCommandSenderName() + " to dimension " + dimensionIdTarget + "..."; // + ":" + worldTarget.provider.getDimensionName(); Commons.addChatMessage(commandSender, message); WarpDrive.logger.info(message); if (commandSender != entityPlayerMP) { - Commons.addChatMessage(entityPlayerMP, commandSender.getCommandSenderName() + " is teleporting you to dimension " + dimensionIdTarget); // + ":" + worldTarget.getWorldInfo().getWorldName()); + Commons.addChatMessage(entityPlayerMP, commandSender.getCommandSenderName() + " is teleporting you to dimension " + dimensionIdTarget); // + ":" + worldTarget.provider.getDimensionName()); } // find a good spot diff --git a/src/main/java/cr0s/warpdrive/data/JumpShip.java b/src/main/java/cr0s/warpdrive/data/JumpShip.java index bad674ac..ab04bcd9 100644 --- a/src/main/java/cr0s/warpdrive/data/JumpShip.java +++ b/src/main/java/cr0s/warpdrive/data/JumpShip.java @@ -229,7 +229,7 @@ public class JumpShip { return String.format("%s/%d \'%s\' @ %s (%d %d %d)", getClass().getSimpleName(), hashCode(), shipCore == null ? "~NULL~" : (shipCore.uuid + ":" + shipCore.shipName), - worldObj == null || worldObj.getWorldInfo() == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), coreX, coreY, coreZ); } diff --git a/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java b/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java index d5325173..59458541 100644 --- a/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java +++ b/src/main/java/cr0s/warpdrive/entity/EntityParticleBunch.java @@ -36,7 +36,7 @@ public class EntityParticleBunch extends Entity { public EntityParticleBunch(World world) { super(world); if (WarpDriveConfig.LOGGING_ACCELERATOR) { - WarpDrive.logger.info(this + " created in dimension '" + worldObj.getWorldInfo().getWorldName() + "'"); + WarpDrive.logger.info(this + " created in dimension " + worldObj.provider.getDimensionName()); } } @@ -171,7 +171,7 @@ public class EntityParticleBunch extends Entity { return String.format("%s/%d @ \'%s\' %.2f %.2f %.2f", getClass().getSimpleName(), getEntityId(), - worldObj == null ? "~NULL~" : worldObj.getWorldInfo().getWorldName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), posX, posY, posZ); } } \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java index d906456b..28189d93 100644 --- a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java +++ b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java @@ -315,7 +315,7 @@ public class JumpSequencer extends AbstractSequencer { sourceWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, sourceWorld, Type.NORMAL); if (sourceWorldTicket == null) { reason.append(String.format("Chunkloading rejected in source world %s. Aborting.", - sourceWorld.getWorldInfo().getWorldName())); + sourceWorld.provider.getDimensionName())); return false; } @@ -347,7 +347,7 @@ public class JumpSequencer extends AbstractSequencer { targetWorldTicket = ForgeChunkManager.requestTicket(WarpDrive.instance, targetWorld, Type.NORMAL); if (targetWorldTicket == null) { reason.append(String.format("Chunkloading rejected in target world %s. Aborting.", - targetWorld.getWorldInfo().getWorldName())); + targetWorld.provider.getDimensionName())); return false; } @@ -1561,7 +1561,7 @@ public class JumpSequencer extends AbstractSequencer { return String.format("%s/%d \'%s\' @ %s (%d %d %d) #%d", getClass().getSimpleName(), hashCode(), (ship == null || ship.shipCore == null) ? "~NULL~" : (ship.shipCore.uuid + ":" + ship.shipCore.shipName), - sourceWorld == null ? "~NULL~" : sourceWorld.getWorldInfo().getWorldName(), + sourceWorld == null ? "~NULL~" : sourceWorld.provider.getDimensionName(), ship == null ? -1 : ship.coreX, ship == null ? -1 : ship.coreY, ship == null ? -1 : ship.coreZ, ticks); } diff --git a/src/main/java/cr0s/warpdrive/item/ItemAirTank.java b/src/main/java/cr0s/warpdrive/item/ItemAirTank.java index 3fb3a9dc..1746228e 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemAirTank.java +++ b/src/main/java/cr0s/warpdrive/item/ItemAirTank.java @@ -33,7 +33,7 @@ public class ItemAirTank extends Item implements IAirContainerItem { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[24]; icons[ 0] = iconRegister.registerIcon("warpdrive:breathing/air_canister"); icons[ 1] = iconRegister.registerIcon("warpdrive:breathing/air_canister"); diff --git a/src/main/java/cr0s/warpdrive/item/ItemComponent.java b/src/main/java/cr0s/warpdrive/item/ItemComponent.java index fe2104c4..66d124d4 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemComponent.java +++ b/src/main/java/cr0s/warpdrive/item/ItemComponent.java @@ -54,7 +54,7 @@ public class ItemComponent extends Item implements IAirContainerItem { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[EnumComponentType.length]; for (final EnumComponentType enumComponentType : EnumComponentType.values()) { icons[enumComponentType.ordinal()] = iconRegister.registerIcon("warpdrive:component/" + enumComponentType.unlocalizedName); @@ -62,7 +62,7 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public String getUnlocalizedName(ItemStack itemStack) { + public String getUnlocalizedName(final ItemStack itemStack) { int damage = itemStack.getItemDamage(); if (damage >= 0 && damage < EnumComponentType.length) { return "item.warpdrive.crafting." + EnumComponentType.get(damage).unlocalizedName; @@ -71,7 +71,7 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public IIcon getIconFromDamage(int damage) { + public IIcon getIconFromDamage(final int damage) { if (damage >= 0 && damage < EnumComponentType.length) { return icons[damage]; } @@ -79,7 +79,7 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public void getSubItems(Item item, CreativeTabs creativeTab, List list) { + public void getSubItems(final Item item, final CreativeTabs creativeTab, final List list) { for (final EnumComponentType enumComponentType : EnumComponentType.values()) { list.add(new ItemStack(item, 1, enumComponentType.ordinal())); } @@ -87,12 +87,12 @@ public class ItemComponent extends Item implements IAirContainerItem { // IAirContainerItem overrides for empty air canister @Override - public boolean canContainAir(ItemStack itemStack) { + public boolean canContainAir(final ItemStack itemStack) { return (itemStack.getItem() instanceof ItemComponent && itemStack.getItemDamage() == EnumComponentType.AIR_CANISTER.ordinal()); } @Override - public int getMaxAirStorage(ItemStack itemStack) { + public int getMaxAirStorage(final ItemStack itemStack) { if (canContainAir(itemStack)) { return WarpDrive.itemAirTanks[0].getMaxAirStorage(itemStack); } else { @@ -101,18 +101,18 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public int getCurrentAirStorage(ItemStack itemStack) { + public int getCurrentAirStorage(final ItemStack itemStack) { return 0; } @Override - public ItemStack consumeAir(ItemStack itemStack) { + public ItemStack consumeAir(final ItemStack itemStack) { WarpDrive.logger.error(this + " consumeAir() with itemStack " + itemStack); throw new RuntimeException("Invalid call to consumeAir() on non or empty container"); } @Override - public int getAirTicksPerConsumption(ItemStack itemStack) { + public int getAirTicksPerConsumption(final ItemStack itemStack) { if (canContainAir(itemStack)) { return WarpDrive.itemAirTanks[0].getAirTicksPerConsumption(itemStack); } else { @@ -121,7 +121,7 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public ItemStack getFullAirContainer(ItemStack itemStack) { + public ItemStack getFullAirContainer(final ItemStack itemStack) { if (canContainAir(itemStack)) { return WarpDrive.itemAirTanks[0].getFullAirContainer(itemStack); } @@ -129,7 +129,7 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public ItemStack getEmptyAirContainer(ItemStack itemStack) { + public ItemStack getEmptyAirContainer(final ItemStack itemStack) { if (canContainAir(itemStack)) { return WarpDrive.itemAirTanks[0].getEmptyAirContainer(itemStack); } @@ -145,7 +145,7 @@ public class ItemComponent extends Item implements IAirContainerItem { } @Override - public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean advancedItemTooltips) { + public void addInformation(final ItemStack itemStack, final EntityPlayer entityPlayer, final List list, final boolean advancedItemTooltips) { super.addInformation(itemStack, entityPlayer, list, advancedItemTooltips); String tooltip = ""; diff --git a/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java b/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java index 5d8ac87a..23d8c456 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java +++ b/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java @@ -43,7 +43,7 @@ public class ItemElectromagneticCell extends ItemAbstractBase implements IPartic @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[31]; icons[ 0] = iconRegister.registerIcon("warpdrive:atomic/electromagnetic_cell-empty"); icons[ 1] = iconRegister.registerIcon("warpdrive:atomic/electromagnetic_cell-blue-20"); diff --git a/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java b/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java index f902280c..4184f300 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java +++ b/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java @@ -54,7 +54,7 @@ public class ItemForceFieldUpgrade extends Item { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[EnumForceFieldUpgrade.length]; for (final EnumForceFieldUpgrade enumForceFieldUpgrade : EnumForceFieldUpgrade.values()) { icons[enumForceFieldUpgrade.ordinal()] = iconRegister.registerIcon("warpdrive:forcefield/upgrade_" + enumForceFieldUpgrade.unlocalizedName); diff --git a/src/main/java/cr0s/warpdrive/item/ItemShipToken.java b/src/main/java/cr0s/warpdrive/item/ItemShipToken.java index cee13a56..2238ab30 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemShipToken.java +++ b/src/main/java/cr0s/warpdrive/item/ItemShipToken.java @@ -57,7 +57,7 @@ public class ItemShipToken extends Item { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[VALID_METADATAS.length]; for (int index = 0; index < VALID_METADATAS.length; index++) { icons[index] = iconRegister.registerIcon("warpdrive:tool/ship_token-" + VALID_METADATAS[index]); diff --git a/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java b/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java index 72f92596..e3f96787 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java +++ b/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java @@ -49,7 +49,7 @@ public class ItemTuningDriver extends Item implements IWarpTool { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[3]; icons[MODE_VIDEO_CHANNEL ] = iconRegister.registerIcon("warpdrive:tool/tuning_driver-cyan"); diff --git a/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java b/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java index a10eca2f..3616b8b6 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java +++ b/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java @@ -43,7 +43,7 @@ public class ItemTuningFork extends Item implements IWarpTool { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister iconRegister) { + public void registerIcons(final IIconRegister iconRegister) { icons = new IIcon[16]; for (int i = 0; i < 16; ++i) { diff --git a/src/main/java/cr0s/warpdrive/item/ItemUpgrade.java b/src/main/java/cr0s/warpdrive/item/ItemUpgrade.java index d67b1206..2f1eda96 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemUpgrade.java +++ b/src/main/java/cr0s/warpdrive/item/ItemUpgrade.java @@ -92,10 +92,10 @@ public class ItemUpgrade extends Item { @SideOnly(Side.CLIENT) @Override - public void registerIcons(IIconRegister ir) { + public void registerIcons(final IIconRegister iconRegister) { iconBuffer = new IIcon[UpgradeType.values().length]; for (UpgradeType val : UpgradeType.values()) { - iconBuffer[val.ordinal()] = ir.registerIcon("warpdrive:upgrade" + val); + iconBuffer[val.ordinal()] = iconRegister.registerIcon("warpdrive:upgrade" + val); } } diff --git a/src/main/resources/assets/warpdrive/textures/blocks/chunkLoader.psd b/src/main/resources/assets/warpdrive/textures/blocks/chunkLoader.psd deleted file mode 100644 index c652bc535a80f0abd318d161bb4aee5e3a2814e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35326 zcmeG^2Vj%c);FU`_hzq9_UImzLZO=$C@pQ750x}Y+d!IxjJ6<%Aff`Ytq3TyOa%mi zg34CpiOepbKnt>54@E#$^Ph9Sj4!1n;PZd~d+*Op^L^)@b=Ocxq6pI$oA1PoAWaWlkEBC7Co{(p&1+zn^p8qNt*Lb-qj|78T_yl-j7GXg{%3 zl`V?`7}0@#BFds0AMF>51kuRUbWyxYBNK%Og!)T@f`dg75dpzr;SmwRJw+iw!6AV` z@E74992ONG5f#!)WK4ejoB`^qk>*5YBqSM&gIu&*Ok>2=$7yReD{tpC1-vPR4rWtIY)| zwE?t_0TNYyV3AlI7#t83Xx0pZeZePD@fw*}r_yApREmB~&C~N#I+Zq0r543!Mu@tO zkSnFCLT$Icf%Vxf)ks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pLPvuAwv zEusG)k5yqD1%}Xl2i^+#9HRb&HaOCV1xigjUH6#&+{vSi1{ zxcmehUO*GAF4~W^E8nqp%SPG)uqVRqfX)QVu|J_Tdp=&YWz$+{V#qddwzOx*n%V1@ z&t19%WkDr%0u}8XVpw#nX%Q1@`g(uN?m;FI=p6#`r&drL^=) zd86b1)RofRyGv`!8X5nmFPHAzv14axZAHW5|3c~R9ox3;*j;+D;qh;#S2sNVE3Yv6 zYtA<^{;Q~cH5VEk|L1F=en4(?{8v?9s44Z!{fh-77v^M3yqBbbCls) cb))0|0_@pu0J+ief9`VaMf>>wSC0Sx0d^`&6951J diff --git a/src/main/resources/assets/warpdrive/textures/blocks/chunkLoader.png b/src/main/resources/assets/warpdrive/textures/blocks/chunk_loader-active.png similarity index 100% rename from src/main/resources/assets/warpdrive/textures/blocks/chunkLoader.png rename to src/main/resources/assets/warpdrive/textures/blocks/chunk_loader-active.png diff --git a/src/main/resources/assets/warpdrive/textures/blocks/chunk_loader-offline.png b/src/main/resources/assets/warpdrive/textures/blocks/chunk_loader-offline.png new file mode 100644 index 0000000000000000000000000000000000000000..4de2e952cd446451553b8699d53790bf2450f041 GIT binary patch literal 3976 zcmV;34|nj1P)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69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HB zo9f9)k_7QN=Yq0@R{7rV_h~d56h(oxmR74pr_&^o#ehtB{rWZScAJBP1F}w+ z)_ztiJfBnMby{6tU(@ULRz#}Th#gKhsaFFL^!H+q+xb10Igf4oLUgG@84#S}peX z_t(m|)_@L8x=o$>o@E*BcAIv$$4=I*7k5B)m&^}8{K!dZkPM_ z?_=>)vvCa~`Kh3^261-ujij8DT0@$qcMGVB8JFPzz&W>8<26;gySsOBtsE>Se0cb8 z&4j7bFe&FGh7h*-d>-rx813Xr7U-0VL!fJfc;+jIpWkwJnAiF#mRNJArRj9Kv3t@i z2s7y>A!+Zm5nY;_jg+cdV!Z_e##oXhVKSMlsXul`i*aQ;j#E(6rRftUn$2c-PScdx zY({KPG9XUv6$awHIz}0{S9zXO6vf6`FWrycNj2qL87-zF%Iua z9nj*~*6YP>c<%QD`-f6t~}F+ObQ zelhMBbPK=fv?N(1_2$#3Pc?gGS>l}I-Me=i>%b<1nwfZai_Zsf%#AU8{rZ(W&lwJf zccs{SAI@%?ULChh?YB-*Nx5w&BV!C-zI>r53g+`Ui^T$)=Q-o?n2U=Grqe0?et#wB zwJ3FJ$pKY&JyM3_wq5L Date: Mon, 5 Feb 2018 03:39:41 +0100 Subject: [PATCH 2/2] Reimplemented chunk loader from scratch - removed ticket count bypass - added guide message (wip) - added configuration - added upgrades (fixing #277) --- src/main/java/cr0s/warpdrive/WarpDrive.java | 59 +--- .../warpdrive/block/BlockChunkLoader.java | 125 +++++++- .../block/TileEntityAbstractChunkLoading.java | 284 ++++++++---------- .../block/TileEntityChunkLoader.java | 284 +++++++++++------- .../warpdrive/config/WarpDriveConfig.java | 19 +- .../warpdrive/event/ChunkLoadingHandler.java | 142 +++++++++ .../cr0s/warpdrive/item/ItemComponent.java | 10 +- 7 files changed, 571 insertions(+), 352 deletions(-) create mode 100644 src/main/java/cr0s/warpdrive/event/ChunkLoadingHandler.java diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index 1cb810f9..2b10b967 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -4,7 +4,6 @@ import cr0s.warpdrive.block.BlockChunkLoader; import cr0s.warpdrive.block.BlockLaser; import cr0s.warpdrive.block.BlockLaserMedium; import cr0s.warpdrive.block.ItemBlockAbstractBase; -import cr0s.warpdrive.block.TileEntityAbstractChunkLoading; import cr0s.warpdrive.block.TileEntityChunkLoader; import cr0s.warpdrive.block.TileEntityLaser; import cr0s.warpdrive.block.TileEntityLaserMedium; @@ -117,6 +116,7 @@ import cr0s.warpdrive.data.EnumHullPlainType; import cr0s.warpdrive.data.JumpgatesRegistry; import cr0s.warpdrive.data.StarMapRegistry; import cr0s.warpdrive.event.ChunkHandler; +import cr0s.warpdrive.event.ChunkLoadingHandler; import cr0s.warpdrive.event.ClientHandler; import cr0s.warpdrive.event.CommonWorldGenerator; import cr0s.warpdrive.event.ItemHandler; @@ -148,7 +148,6 @@ import cr0s.warpdrive.world.SpaceWorldProvider; import org.apache.logging.log4j.Logger; import java.lang.reflect.Field; -import java.util.List; import java.util.UUID; import com.mojang.authlib.GameProfile; @@ -160,10 +159,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemDye; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; import net.minecraft.world.biome.BiomeGenBase; import cpw.mods.fml.client.registry.RenderingRegistry; @@ -182,16 +177,13 @@ import cpw.mods.fml.relauncher.Side; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.ForgeChunkManager; -import net.minecraftforge.common.ForgeChunkManager.LoadingCallback; -import net.minecraftforge.common.ForgeChunkManager.Ticket; -import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.oredict.RecipeSorter; @Mod(modid = WarpDrive.MODID, name = "WarpDrive", version = WarpDrive.VERSION, dependencies = "after:IC2;" + " after:CoFHCore;" + " after:ComputerCraft;" + " after:OpenComputer;" + " after:CCTurtle;" + " after:gregtech;" + " after:AppliedEnergistics;" + " after:EnderIO;" + " after:DefenseTech;" + " after:icbmclassic;") -public class WarpDrive implements LoadingCallback { +public class WarpDrive { public static final String MODID = "WarpDrive"; public static final String VERSION = "@version@"; public static final boolean isDev = VERSION.equals("@" + "version" + "@") || VERSION.contains("-dev"); @@ -679,7 +671,7 @@ public class WarpDrive implements LoadingCallback { proxy.registerEntities(); proxy.registerRendering(); - ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance); + ForgeChunkManager.setForcedChunkLoadingCallback(instance, ChunkLoadingHandler.INSTANCE); commonWorldGenerator = new CommonWorldGenerator(); GameRegistry.registerWorldGenerator(commonWorldGenerator, 0); @@ -763,51 +755,6 @@ public class WarpDrive implements LoadingCallback { event.registerServerCommand(new CommandSpace()); } - public Ticket registerChunkLoadTileEntity(TileEntityAbstractChunkLoading tileEntity) { - World worldObj = tileEntity.getWorldObj(); - if (ForgeChunkManager.ticketCountAvailableFor(this, worldObj) > 0) { - Ticket ticket = ForgeChunkManager.requestTicket(this, worldObj, Type.NORMAL); - if (ticket != null) { - tileEntity.giveTicket(ticket); // FIXME calling the caller is a bad idea - return ticket; - } else { - WarpDrive.logger.error("Ticket not granted"); - } - } else { - WarpDrive.logger.error("No tickets left!"); - } - return null; - } - - @Override - public void ticketsLoaded(List tickets, World world) { - for (Ticket ticket : tickets) { - NBTTagCompound data = ticket.getModData(); - if (data != null) { - int w = data.getInteger("ticketWorldObj"); - int x = data.getInteger("ticketX"); - int y = data.getInteger("ticketY"); - int z = data.getInteger("ticketZ"); - if (w != 0 || x != 0 || y != 0 || z != 0) { - WorldServer worldServer = DimensionManager.getWorld(w); - if (worldServer != null) {// skip non-loaded worlds - TileEntity tileEntity = worldServer.getTileEntity(x, y, z); - if (tileEntity != null && tileEntity instanceof TileEntityAbstractChunkLoading) { - if (((TileEntityAbstractChunkLoading) tileEntity).shouldChunkLoad()) { - WarpDrive.logger.info("ChunkLoadingTicket is loading " + tileEntity); - ((TileEntityAbstractChunkLoading) tileEntity).giveTicket(ticket); - ((TileEntityAbstractChunkLoading) tileEntity).refreshLoading(true); - return; - } - } - } - } - } - - ForgeChunkManager.releaseTicket(ticket); - } - } - @Mod.EventHandler public void onFMLMissingMappings(FMLMissingMappingsEvent event) { for (FMLMissingMappingsEvent.MissingMapping mapping: event.get()) { diff --git a/src/main/java/cr0s/warpdrive/block/BlockChunkLoader.java b/src/main/java/cr0s/warpdrive/block/BlockChunkLoader.java index 5aec3819..9d7c176c 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockChunkLoader.java +++ b/src/main/java/cr0s/warpdrive/block/BlockChunkLoader.java @@ -1,9 +1,18 @@ package cr0s.warpdrive.block; +import cr0s.warpdrive.Commons; +import cr0s.warpdrive.data.EnumComponentType; +import cr0s.warpdrive.item.ItemComponent; + import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; @@ -12,7 +21,7 @@ import cpw.mods.fml.relauncher.SideOnly; public class BlockChunkLoader extends BlockAbstractContainer { @SideOnly(Side.CLIENT) - IIcon iconBuffer; + private IIcon[] icons; public BlockChunkLoader() { super(Material.iron); @@ -20,19 +29,123 @@ public class BlockChunkLoader extends BlockAbstractContainer { } @Override - public TileEntity createNewTileEntity(World world, int i) { + public TileEntity createNewTileEntity(final World world, final int metadata) { return new TileEntityChunkLoader(); } @SideOnly(Side.CLIENT) @Override - public void registerBlockIcons(IIconRegister iconRegister) { - iconBuffer = iconRegister.registerIcon("warpdrive:chunkLoader"); + public void registerBlockIcons(final IIconRegister iconRegister) { + icons = new IIcon[3]; + icons[0] = iconRegister.registerIcon("warpdrive:chunk_loader-offline"); + icons[1] = iconRegister.registerIcon("warpdrive:chunk_loader-out_of_power"); + icons[2] = iconRegister.registerIcon("warpdrive:chunk_loader-active"); } @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(int side, int damage) { - return iconBuffer; + public IIcon getIcon(final IBlockAccess blockAccess, final int x, final int y, final int z, final int side) { + final int metadata = blockAccess.getBlockMetadata(x, y, z); + if (metadata < icons.length) { + return icons[metadata]; + } + + return icons[0]; + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(final int side, final int damage) { + return icons[2]; + } + + @Override + public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, + final int side, final float hitX, final float hitY, final float hitZ) { + if (world.isRemote) { + return false; + } + + final TileEntity tileEntity = world.getTileEntity(x, y, z); + if (!(tileEntity instanceof TileEntityChunkLoader)) { + return false; + } + final TileEntityChunkLoader tileEntityChunkLoader = (TileEntityChunkLoader) tileEntity; + final ItemStack itemStackHeld = entityPlayer.getHeldItem(); + + EnumComponentType enumComponentType = null; + if ( itemStackHeld != null + && itemStackHeld.getItem() instanceof ItemComponent ) { + enumComponentType = EnumComponentType.get(itemStackHeld.getItemDamage()); + } + + // sneaking with an empty hand or an upgrade item in hand to dismount current upgrade + if (entityPlayer.isSneaking()) { + // using an upgrade item or an empty hand means dismount upgrade + if ( itemStackHeld == null + || enumComponentType != null ) { + // find a valid upgrade to dismount + if ( itemStackHeld == null + || !tileEntityChunkLoader.hasUpgrade(enumComponentType) ) { + enumComponentType = (EnumComponentType) tileEntityChunkLoader.getFirstUpgradeOfType(EnumComponentType.class, null); + } + + if (enumComponentType == null) { + // no more upgrades to dismount + Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.noUpgradeToDismount")); + return true; + } + + if (!entityPlayer.capabilities.isCreativeMode) { + // dismount the current upgrade item + final ItemStack itemStackDrop = ItemComponent.getItemStackNoCache(enumComponentType, 1); + final EntityItem entityItem = new EntityItem(world, entityPlayer.posX, entityPlayer.posY + 0.5D, entityPlayer.posZ, itemStackDrop); + entityItem.delayBeforeCanPickup = 0; + world.spawnEntityInWorld(entityItem); + } + + tileEntityChunkLoader.dismountUpgrade(enumComponentType); + // upgrade dismounted + Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.dismounted", enumComponentType.name())); + return false; + } + + } else if (itemStackHeld == null) {// no sneaking and no item in hand => show status + Commons.addChatMessage(entityPlayer, tileEntityChunkLoader.getStatus()); + return true; + + } else if (enumComponentType != null) {// no sneaking and an upgrade in hand => mounting an upgrade + // validate type + if (tileEntityChunkLoader.getUpgradeMaxCount(enumComponentType) <= 0) { + // invalid upgrade type + Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.invalidUpgrade")); + return true; + } + if (!tileEntityChunkLoader.canUpgrade(enumComponentType)) { + // too many upgrades + Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.tooManyUpgrades", + tileEntityChunkLoader.getUpgradeMaxCount(enumComponentType))); + return true; + } + + if (!entityPlayer.capabilities.isCreativeMode) { + // validate quantity + if (itemStackHeld.stackSize < 1) { + // not enough upgrade items + Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.notEnoughUpgrades")); + return true; + } + + // update player inventory + itemStackHeld.stackSize -= 1; + } + + // mount the new upgrade item + tileEntityChunkLoader.mountUpgrade(enumComponentType); + // upgrade mounted + Commons.addChatMessage(entityPlayer, StatCollector.translateToLocalFormatted("warpdrive.upgrade.result.mounted", enumComponentType.name())); + } + + return false; } } diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java index 391b7ba5..c837bd0a 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractChunkLoading.java @@ -1,222 +1,174 @@ package cr0s.warpdrive.block; -import com.google.common.collect.ImmutableSet; import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.config.WarpDriveConfig; +import cr0s.warpdrive.event.ChunkLoadingHandler; import java.util.ArrayList; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.ChunkCoordIntPair; -import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; -public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractEnergy -{ - private final ArrayList ticketList = new ArrayList<>(); +public abstract class TileEntityAbstractChunkLoading extends TileEntityAbstractEnergy { - public abstract boolean shouldChunkLoad(); - protected ChunkCoordIntPair minChunk = null; - protected ChunkCoordIntPair maxChunk = null; + // persistent properties + protected ChunkCoordIntPair chunkMin = null; + protected ChunkCoordIntPair chunkMax = null; + // computed properties + private Ticket ticket = null; + private boolean isRefreshNeeded = true; protected boolean areChunksLoaded = false; - - // OVERRIDES + + @Override + protected void onFirstUpdateTick() { + super.onFirstUpdateTick(); + + if (worldObj.isRemote) { + return; + } + + if ( chunkMin == null + || chunkMax == null ) { + WarpDrive.logger.warn(this + " No chunk coordinates defined, assuming current chunk"); + chunkMin = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); + chunkMax = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); + } + } + @Override public void updateEntity() { super.updateEntity(); - if (shouldChunkLoad() != areChunksLoaded) { - refreshLoading(); + if (worldObj.isRemote) { + return; } - if (shouldChunkLoad()) { - handleLoadedTick(); + if ( isRefreshNeeded + || shouldChunkLoad() != areChunksLoaded ) { + refreshLoading(isRefreshNeeded); + isRefreshNeeded = false; } } - public void handleLoadedTick() { - + public abstract boolean shouldChunkLoad(); + + public void refreshChunkLoading() { + isRefreshNeeded = true; } - public synchronized void refreshLoading(boolean force) { - boolean loadRequested = shouldChunkLoad(); - if (!ticketList.isEmpty()) { - if (loadRequested && (!areChunksLoaded || force)) { - int ticketSize = ticketList.get(0).getMaxChunkListDepth(); - ArrayList chunkList = getChunksToLoad(); - int numTicketsRequired = (int) Math.ceil((double) chunkList.size() / ticketSize); // FIXME there should be only one ticket per requesting TileEntity - if (ticketList.size() != numTicketsRequired) { - for(int i = ticketList.size(); i < numTicketsRequired; i++) { - WarpDrive.instance.registerChunkLoadTileEntity(this); - } + public synchronized void refreshLoading(final boolean force) { + final boolean shouldChunkLoad = shouldChunkLoad(); + if (shouldChunkLoad) { + if (ticket == null) { + chunkloading_giveTicket(ChunkLoadingHandler.forgeTicket_requestNormal(worldObj, this)); + } else if (force) { + ChunkLoadingHandler.forgeTicket_clearChunks(ticket); + } + + if (!areChunksLoaded || force) { + final int ticketSize = ticket.getMaxChunkListDepth(); + final ArrayList chunksToLoad = getChunksToLoad(); + if (chunksToLoad.size() > ticketSize) { + WarpDrive.logger.error(String.format("Too many chunk requested for loading @ %s (%d %d %d)", + worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord)); + return; } - int tickNum = 0; - int chunkInTicket = 0; - - Ticket t = ticketList.get(0); - for(ChunkCoordIntPair chunk:chunkList) { - if (chunkInTicket >= ticketSize) { - chunkInTicket = 0; - tickNum++; - t = ticketList.get(tickNum); - } - - WarpDrive.logger.info("Attempting to force chunk" + chunk); - ForgeChunkManager.forceChunk(t, chunk); - chunkInTicket++; + for (final ChunkCoordIntPair chunk : chunksToLoad) { + ChunkLoadingHandler.forgeTicket_addChunks(ticket, chunk); } areChunksLoaded = true; - } else if(!loadRequested) { - for(Ticket ticket:ticketList) { - ImmutableSet chunks = ticket.getChunkList(); - for(ChunkCoordIntPair chunk:chunks) { - ForgeChunkManager.unforceChunk(ticket, chunk); - } - - ForgeChunkManager.releaseTicket(ticket); - } - ticketList.clear(); - areChunksLoaded = false; } - } else if (loadRequested) { - WarpDrive.instance.registerChunkLoadTileEntity(this); - refreshLoading(); + + } else if (ticket != null) { + ChunkLoadingHandler.forgeTicket_release(ticket); + ticket = null; + areChunksLoaded = false; } } - public void refreshLoading() { - refreshLoading(false); + public void chunkloading_giveTicket(final Ticket ticket) { + if (this.ticket != null) { + ChunkLoadingHandler.forgeTicket_release(this.ticket); + this.ticket = null; + } + this.ticket = ticket; } - public void giveTicket(Ticket t) { - NBTTagCompound nbt = t.getModData(); - nbt.setInteger("ticketWorldObj", worldObj.provider.dimensionId); - nbt.setInteger("ticketX", xCoord); - nbt.setInteger("ticketY", yCoord); - nbt.setInteger("ticketZ", zCoord); - ticketList.add(t); + public int chunkloading_getArea() { + return (chunkMax.chunkXPos - chunkMin.chunkXPos + 1) + * (chunkMax.chunkZPos - chunkMin.chunkZPos + 1); } - private static int dX(int dir) - { - if (dir == 1) - return 1; - else if (dir == 3) - return -1; - return 0; - } - - private static int dZ(int dir) - { - if (dir == 0) - return 1; - else if (dir == 2) - return -1; - return 0; - } - - public ArrayList getChunksFromCentre(ChunkCoordIntPair chunkA,ChunkCoordIntPair chunkB) - { - if(!shouldChunkLoad()) - return null; - int minX = Math.min(chunkA.chunkXPos, chunkB.chunkXPos); - int maxX = Math.max(chunkA.chunkXPos, chunkB.chunkXPos); - int minZ = Math.min(chunkA.chunkZPos, chunkB.chunkZPos); - int maxZ = Math.max(chunkA.chunkZPos, chunkB.chunkZPos); - WarpDrive.logger.info("ChunkLoading from " + minX + "," + minZ + " to " + maxX + "," + maxZ); + @Override + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); - //REMOVE ODD SIZES - int deltaX = (maxX - minX + 1); - int deltaZ = (maxZ - minZ + 1); - - maxX = minX + deltaX - 1; - maxZ = minZ + deltaZ - 1; - WarpDrive.logger.info("Allocating " + deltaX + " x " + deltaZ + " blocks from " + minX + "," + minZ + " to " + maxX + "," + maxZ); - - int maxEntries = (deltaX) * (deltaZ); - ArrayList chunkList = new ArrayList<>(maxEntries); - - int dir = 1; - int x = minX; - int z = maxZ; - for(int i = 0; i < maxEntries; i++) - { - chunkList.add(new ChunkCoordIntPair(x, z)); - int dX = dX(dir); - int dZ = dZ(dir); - if(x + dX > maxX || x + dX < minX || z + dZ > maxZ || z + dZ < minZ) - { - dir++; - if(dir >= 4) - dir = 0; - dX = dX(dir); - dZ = dZ(dir); - - if(dX == 1) - minX++; - if(dX == -1) - maxX--; - if(dZ == 1) - minZ++; - if(dZ == -1) - maxZ--; - - } - x += dX; - z += dZ; + if (chunkMin == null) { + chunkMin = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); } - return chunkList; - } - - @Override - public void writeToNBT(NBTTagCompound tag) - { - super.writeToNBT(tag); - if(minChunk == null) - minChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); + if (chunkMax == null) { + chunkMax = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); + } - if(maxChunk == null) - maxChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); - tag.setInteger("minChunkX", minChunk.chunkXPos); - tag.setInteger("minChunkZ", minChunk.chunkZPos); - tag.setInteger("maxChunkX", maxChunk.chunkXPos); - tag.setInteger("maxChunkZ", maxChunk.chunkZPos); + tagCompound.setInteger("minChunkX", chunkMin.chunkXPos); + tagCompound.setInteger("minChunkZ", chunkMin.chunkZPos); + tagCompound.setInteger("maxChunkX", chunkMax.chunkXPos); + tagCompound.setInteger("maxChunkZ", chunkMax.chunkZPos); } @Override - public void readFromNBT(NBTTagCompound tag) - { - super.readFromNBT(tag); - if(tag.hasKey("minChunkX")) - { - int mx = tag.getInteger("minChunkX"); - int mz = tag.getInteger("minChunkZ"); - minChunk = new ChunkCoordIntPair(mx,mz); - mx = tag.getInteger("maxChunkX"); - mz = tag.getInteger("maxChunkZ"); - maxChunk = new ChunkCoordIntPair(mx,mz); + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + + if (tagCompound.hasKey("minChunkX")) { + final int xMin = tagCompound.getInteger("minChunkX"); + final int zMin = tagCompound.getInteger("minChunkZ"); + chunkMin = new ChunkCoordIntPair(xMin, zMin); + + final int xMax = tagCompound.getInteger("maxChunkX"); + final int zMax = tagCompound.getInteger("maxChunkZ"); + chunkMax = new ChunkCoordIntPair(xMax, zMax); } } @Override public void invalidate() { super.invalidate(); - for(Ticket t : ticketList) { - ForgeChunkManager.releaseTicket(t); + if (ticket != null) { + ChunkLoadingHandler.forgeTicket_release(ticket); + ticket = null; } } - public ArrayList getChunksToLoad() - { - if(minChunk == null || maxChunk == null) - { - ArrayList chunkList = new ArrayList<>(1); - chunkList.add(worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair()); - return chunkList; + public ArrayList getChunksToLoad() { + if (!shouldChunkLoad()) { + return null; } - return getChunksFromCentre(minChunk,maxChunk); + + assert(chunkMin.chunkXPos <= chunkMax.chunkXPos); + assert(chunkMin.chunkZPos <= chunkMax.chunkZPos); + + final int count = chunkloading_getArea(); + if (WarpDriveConfig.LOGGING_CHUNK_LOADING) { + WarpDrive.logger.info(String.format("Collecting %d chunks to be loaded @ %s from %s to %s", + count, + worldObj.provider.getDimensionName(), + chunkMin, chunkMax)); + } + final ArrayList chunkCoords = new ArrayList<>(count); + + for (int x = chunkMin.chunkXPos; x <= chunkMax.chunkXPos; x++) { + for (int z = chunkMin.chunkZPos; z <= chunkMax.chunkZPos; z++) { + chunkCoords.add(new ChunkCoordIntPair(x, z)); + } + } + + return chunkCoords; } } diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java b/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java index 73384460..df2b41e0 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityChunkLoader.java @@ -2,8 +2,7 @@ package cr0s.warpdrive.block; import cr0s.warpdrive.Commons; import cr0s.warpdrive.config.WarpDriveConfig; -import cr0s.warpdrive.data.UpgradeType; -import cr0s.warpdrive.item.ItemUpgrade; +import cr0s.warpdrive.data.EnumComponentType; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; import li.cil.oc.api.machine.Arguments; @@ -12,30 +11,32 @@ import li.cil.oc.api.machine.Context; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.world.chunk.Chunk; import cpw.mods.fml.common.Optional; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading { - private boolean isActive = false; + + // persistent properties private boolean isEnabled = false; - - private boolean initialised = false; - private ChunkCoordIntPair myChunk; - - int negDX, posDX, negDZ, posDZ; - int area = 1; - + private int radiusXneg = 0; + private int radiusXpos = 0; + private int radiusZneg = 0; + private int radiusZpos = 0; + + // fuel status is needed before first tick + private boolean isPowered = false; + + // computed properties + // (none) + public TileEntityChunkLoader() { super(); + IC2_sinkTier = 2; IC2_sourceTier = 2; - negDX = 0; - negDZ = 0; - posDX = 0; - posDZ = 0; - peripheralName = "warpdriveChunkloader"; + + peripheralName = "warpdriveChunkLoader"; addMethods(new String[] { "enable", "bounds", @@ -44,135 +45,174 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading { "getEnergyRequired" }); - setUpgradeMaxCount(ItemUpgrade.getItemStack(UpgradeType.Energy), 2); - setUpgradeMaxCount(ItemUpgrade.getItemStack(UpgradeType.Power), 2); + setUpgradeMaxCount(EnumComponentType.SUPERCONDUCTOR, 5); + setUpgradeMaxCount(EnumComponentType.EMERALD_CRYSTAL, WarpDriveConfig.CHUNK_LOADER_MAX_RADIUS); } @Override public int energy_getMaxStorage() { - return WarpDriveConfig.CL_MAX_ENERGY; + return WarpDriveConfig.CHUNK_LOADER_MAX_ENERGY_STORED; } @Override - public boolean energy_canInput(ForgeDirection from) { + public boolean energy_canInput(final ForgeDirection from) { return true; } - public long energy_getEnergyRequired() { - return area * WarpDriveConfig.CL_RF_PER_CHUNKTICK; + @Override + public boolean dismountUpgrade(Object upgrade) { + final boolean isSuccess = super.dismountUpgrade(upgrade); + if (isSuccess) { + final int maxRange = getMaxRange(); + setBounds(maxRange, maxRange, maxRange, maxRange); + } + return isSuccess; } @Override - public boolean shouldChunkLoad() - { - return isEnabled && isActive; + public boolean mountUpgrade(Object upgrade) { + final boolean isSuccess = super.mountUpgrade(upgrade); + if (isSuccess) { + final int maxRange = getMaxRange(); + setBounds(maxRange, maxRange, maxRange, maxRange); + } + return isSuccess; + } + + private int getMaxRange() { + return getValidUpgradeCount(EnumComponentType.EMERALD_CRYSTAL); + } + + private double getEnergyFactor() { + final int upgradeCount = getValidUpgradeCount(EnumComponentType.SUPERCONDUCTOR); + return 1.0D - 0.1D * upgradeCount; + } + + public long chunkloading_getEnergyRequired() { + return (long) Math.ceil(getEnergyFactor() * chunkloading_getArea() * WarpDriveConfig.CHUNK_LOADER_ENERGY_PER_CHUNK); } @Override - public void updateEntity() - { - super.updateEntity(); - - if(!initialised) - { - initialised = true; - myChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); - changedDistance(); - } - - if(isEnabled) - { - isActive = energy_consume(energy_getEnergyRequired(), false); - } - else - { - isActive = energy_consume(energy_getEnergyRequired(), true); - } + public boolean shouldChunkLoad() { + return isEnabled && isPowered; } - private void setBounds(int negX, int posX, int negZ, int posZ) { - negDX = - Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, Math.abs(negX)); - posDX = Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, Math.abs(posX)); - negDZ = - Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, Math.abs(negZ)); - posDZ = Commons.clamp(0, WarpDriveConfig.CL_MAX_DISTANCE, Math.abs(posZ)); - } + @Override + protected void onFirstUpdateTick() { + super.onFirstUpdateTick(); - private void changedDistance() - { - if(worldObj == null) { + if (worldObj.isRemote) { return; } - if (myChunk == null) { - Chunk aChunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord); - if (aChunk != null) { - myChunk = aChunk.getChunkCoordIntPair(); - } else { - return; - } - } - - minChunk = new ChunkCoordIntPair(myChunk.chunkXPos + negDX, myChunk.chunkZPos + negDZ); - maxChunk = new ChunkCoordIntPair(myChunk.chunkXPos + posDX, myChunk.chunkZPos + posDZ); - area = (posDX - negDX + 1) * (posDZ - negDZ + 1); - refreshLoading(true); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - setBounds(nbt.getInteger("negDX"), nbt.getInteger("posDX"), nbt.getInteger("negDZ"), nbt.getInteger("posDZ")); - changedDistance(); - } - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - nbt.setInteger("negDX", negDX); - nbt.setInteger("negDZ", negDZ); - nbt.setInteger("posDX", posDX); - nbt.setInteger("posDZ", posDZ); + + refreshChunkRange(); } - //Common LUA functions + @Override + public void updateEntity() { + super.updateEntity(); + + if (worldObj.isRemote) { + return; + } + + isPowered = energy_consume(chunkloading_getEnergyRequired(), !isEnabled); + } + + private void setBounds(final int negX, final int posX, final int negZ, final int posZ) { + // compute new values + final int maxRange = getMaxRange(); + final int radiusXneg_new = - Commons.clamp(0, 1000, Math.abs(negX)); + final int radiusXpos_new = Commons.clamp(0, 1000, Math.abs(posX)); + final int radiusZneg_new = - Commons.clamp(0, 1000, Math.abs(negZ)); + final int radiusZpos_new = Commons.clamp(0, 1000, Math.abs(posZ)); + + // validate size constrains + final int maxArea = (1 + 2 * maxRange) * (1 + 2 * maxRange); + final int newArea = (-radiusXneg_new + 1 + radiusXpos_new) + * (-radiusZneg_new + 1 + radiusZpos_new); + if (newArea <= maxArea) { + radiusXneg = radiusXneg_new; + radiusXpos = radiusXpos_new; + radiusZneg = radiusZneg_new; + radiusZpos = radiusZpos_new; + refreshChunkRange(); + } + } + + private void refreshChunkRange() { + if (worldObj == null) { + return; + } + final ChunkCoordIntPair chunkSelf = worldObj.getChunkFromBlockCoords(xCoord, zCoord).getChunkCoordIntPair(); + + chunkMin = new ChunkCoordIntPair(chunkSelf.chunkXPos + radiusXneg, chunkSelf.chunkZPos + radiusZneg); + chunkMax = new ChunkCoordIntPair(chunkSelf.chunkXPos + radiusXpos, chunkSelf.chunkZPos + radiusZpos); + refreshChunkLoading(); + } + + @Override + public String getStatus() { + return super.getStatus() + + "\n" + getUpgradeStatus(); + } + + // Forge overrides + @Override + public void readFromNBT(final NBTTagCompound tagCompound) { + super.readFromNBT(tagCompound); + isEnabled = !tagCompound.hasKey("isEnabled") || tagCompound.getBoolean("isEnabled"); + setBounds(tagCompound.getInteger("radiusXneg"), tagCompound.getInteger("radiusXpos"), tagCompound.getInteger("radiusZneg"), tagCompound.getInteger("radiusZpos")); + isPowered = tagCompound.getBoolean("isPowered"); + } + + @Override + public void writeToNBT(final NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + tagCompound.setBoolean("isEnabled", isEnabled); + tagCompound.setInteger("radiusXneg", radiusXneg); + tagCompound.setInteger("radiusZneg", radiusZneg); + tagCompound.setInteger("radiusXpos", radiusXpos); + tagCompound.setInteger("radiusZpos", radiusZpos); + tagCompound.setBoolean("isPowered", isPowered); + } + + // Common OC/CC methods public Object[] enable(Object[] arguments) { - if (arguments.length == 1) + if (arguments.length == 1) { isEnabled = Commons.toBool(arguments[0]); - return new Object[]{shouldChunkLoad()}; + } + return new Object[] { isEnabled }; } public Object[] bounds(Object[] arguments) { if (arguments.length == 4) { setBounds(Commons.toInt(arguments[0]), Commons.toInt(arguments[1]), Commons.toInt(arguments[2]), Commons.toInt(arguments[3])); - changedDistance(); } - return new Object[]{negDX, posDX, negDZ, posDZ}; + return new Object[] { radiusXneg, radiusXpos, radiusZneg, radiusZpos }; } public Object[] radius(Object[] arguments) { if (arguments.length == 1) { - int dist = Commons.toInt(arguments[0]); - setBounds(dist,dist,dist,dist); - changedDistance(); - return new Object[]{true}; + final int radius = Commons.toInt(arguments[0]); + setBounds(radius, radius, radius, radius); } - return new Object[]{false}; + return new Object[] { radiusXneg, radiusXpos, radiusZneg, radiusZpos }; } - public Object[] upgrades(Object[] arguments) { + public Object[] upgrades() { return new Object[] { getUpgradesAsString() }; } - public Object[] getEnergyRequired(Object[] arguments) { - return new Object[] { energy_getEnergyRequired() }; + public Object[] getEnergyRequired() { + return new Object[] { chunkloading_getEnergyRequired() }; } - + // OpenComputer callback methods @Callback @Optional.Method(modid = "OpenComputers") - public Object[] radius(Context context, Arguments arguments) { - return radius(argumentsOCtoCC(arguments)); + public Object[] enable(Context context, Arguments arguments) { + return enable(argumentsOCtoCC(arguments)); } @Callback @@ -183,42 +223,54 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading { @Callback @Optional.Method(modid = "OpenComputers") - public Object[] enable(Context context, Arguments arguments) { - return enable(argumentsOCtoCC(arguments)); + public Object[] radius(Context context, Arguments arguments) { + return radius(argumentsOCtoCC(arguments)); } @Callback @Optional.Method(modid = "OpenComputers") public Object[] upgrades(Context context, Arguments arguments) { - return upgrades(argumentsOCtoCC(arguments)); + return upgrades(); } @Callback @Optional.Method(modid = "OpenComputers") public Object[] getEnergyRequired(Context context, Arguments arguments) { - return getEnergyRequired(argumentsOCtoCC(arguments)); - } + return getEnergyRequired(); + } - //CC method + // ComputerCraft IPeripheral methods @Override @Optional.Method(modid = "ComputerCraft") public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) { final String methodName = getMethodName(method); switch (methodName) { - case "radius": - return radius(arguments); - case "bounds": - return bounds(arguments); - case "enable": - return enable(arguments); - case "upgrades": - return upgrades(arguments); - case "getEnergyRequired": - return getEnergyRequired(arguments); + case "radius": + return radius(arguments); + + case "bounds": + return bounds(arguments); + + case "enable": + return enable(arguments); + + case "upgrades": + return upgrades(); + + case "getEnergyRequired": + return getEnergyRequired(); } return super.callMethod(computer, context, method, arguments); } + @Override + public String toString() { + return String.format( + "%s @ %s (%d %d %d)", + getClass().getSimpleName(), + worldObj == null ? "~NULL~" : worldObj.provider.getDimensionName(), + xCoord, yCoord, zCoord); + } } diff --git a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java index 88c4d7a2..9d91a252 100644 --- a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java @@ -52,7 +52,6 @@ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -203,6 +202,7 @@ public class WarpDriveConfig { public static boolean LOGGING_XML_PREPROCESSOR = false; public static boolean LOGGING_RENDERING = false; public static boolean LOGGING_CHUNK_HANDLER = false; + public static boolean LOGGING_CHUNK_LOADING = true; public static boolean LOGGING_CLIENT_SYNCHRONIZATION = false; // Starmap @@ -379,9 +379,9 @@ public class WarpDriveConfig { public static int LIFT_ENTITY_COOLDOWN_TICKS = 40; // Chunk loader - public static int CL_MAX_ENERGY = 1000000; - public static int CL_MAX_DISTANCE = 2; - public static int CL_RF_PER_CHUNKTICK = 320; + public static int CHUNK_LOADER_MAX_ENERGY_STORED = 1000000; + public static int CHUNK_LOADER_MAX_RADIUS = 2; + public static int CHUNK_LOADER_ENERGY_PER_CHUNK = 8; // Hull public static float[] HULL_HARDNESS = { 25.0F, 50.0F, 80.0F }; @@ -652,6 +652,7 @@ public class WarpDriveConfig { LOGGING_XML_PREPROCESSOR = config.get("logging", "enable_XML_preprocessor_logs", LOGGING_XML_PREPROCESSOR, "Save XML preprocessor results as output*.xml file, enable it to debug your XML configuration files").getBoolean(false); LOGGING_RENDERING = config.get("logging", "enable_rendering_logs", LOGGING_RENDERING, "Detailed rendering logs to help debug the mod.").getBoolean(false); LOGGING_CHUNK_HANDLER = config.get("logging", "enable_chunk_handler_logs", LOGGING_CHUNK_HANDLER, "Detailed chunk data logs to help debug the mod.").getBoolean(false); + LOGGING_CHUNK_LOADING = config.get("logging", "enable_chunk_loading_logs", LOGGING_CHUNK_LOADING, "Chunk loading logs, enable it to report chunk loaders updates").getBoolean(false); // Starmap registry STARMAP_REGISTRY_UPDATE_INTERVAL_SECONDS = Commons.clamp(0, 300, @@ -990,6 +991,16 @@ public class WarpDriveConfig { LIFT_ENTITY_COOLDOWN_TICKS = Commons.clamp(1, 6000, config.get("lift", "entity_cooldown_ticks", LIFT_ENTITY_COOLDOWN_TICKS, "Cooldown after moving an entity").getInt()); + + // Chunk loader + CHUNK_LOADER_MAX_ENERGY_STORED = Commons.clamp(1, Integer.MAX_VALUE, + config.get("chunk_loader", "max_energy_stored", CHUNK_LOADER_MAX_ENERGY_STORED, "Maximum energy stored").getInt()); + CHUNK_LOADER_MAX_RADIUS = Commons.clamp(1, Integer.MAX_VALUE, + config.get("chunk_loader", "max_radius", CHUNK_LOADER_MAX_RADIUS, "Maximum radius when loading a square shape, measured in chunks. A linear shape can be up to 1 chunk wide by (radius + 1 + radius) ^ 2 chunks long.").getInt()); + CHUNK_LOADER_ENERGY_PER_CHUNK = Commons.clamp(1, 100, + config.get("chunk_loader", "energy_per_chunk", CHUNK_LOADER_ENERGY_PER_CHUNK, "Energy consumed per chunk loaded").getInt()); + + // Particles accelerator ACCELERATOR_ENABLE = config.get("accelerator", "enable", ACCELERATOR_ENABLE, "Enable accelerator blocks. Requires a compatible server, as it won't work in single player").getBoolean(false); diff --git a/src/main/java/cr0s/warpdrive/event/ChunkLoadingHandler.java b/src/main/java/cr0s/warpdrive/event/ChunkLoadingHandler.java new file mode 100644 index 00000000..6bd980b8 --- /dev/null +++ b/src/main/java/cr0s/warpdrive/event/ChunkLoadingHandler.java @@ -0,0 +1,142 @@ +package cr0s.warpdrive.event; + +import com.google.common.collect.ImmutableSet; +import cr0s.warpdrive.WarpDrive; +import cr0s.warpdrive.block.TileEntityAbstractChunkLoading; +import cr0s.warpdrive.config.WarpDriveConfig; + +import java.util.List; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; + +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.ForgeChunkManager.LoadingCallback; +import net.minecraftforge.common.ForgeChunkManager.Ticket; +import net.minecraftforge.common.ForgeChunkManager.Type; + +public class ChunkLoadingHandler implements LoadingCallback { + + public final static ChunkLoadingHandler INSTANCE = new ChunkLoadingHandler(); + + /* event catchers */ + @Override + public void ticketsLoaded(List tickets, World world) { + for (final Ticket ticket : tickets) { + final NBTTagCompound tagCompound = ticket.getModData(); + if ( !tagCompound.hasKey("posX") + || !tagCompound.hasKey("posY") + || !tagCompound.hasKey("posZ") ) { + WarpDrive.logger.error(String.format("Unable to resume chunkloading: incomplete or corrupted NBT data %s", + tagCompound)); + ForgeChunkManager.releaseTicket(ticket); + continue; + } + + final int x = tagCompound.getInteger("posX"); + final int y = tagCompound.getInteger("posY"); + final int z = tagCompound.getInteger("posZ"); + final TileEntity tileEntity = world.getTileEntity(x, y, z); + if (!(tileEntity instanceof TileEntityAbstractChunkLoading)) { + WarpDrive.logger.error(String.format("Unable to resume chunkloading @ %s (%d %d %d): invalid tile entity %s", + world.provider.getDimensionName(), + x, y, z, + tileEntity == null ? "-null-" : tileEntity)); + ForgeChunkManager.releaseTicket(ticket); + continue; + } + + final TileEntityAbstractChunkLoading tileEntityAbstractChunkLoading = (TileEntityAbstractChunkLoading) tileEntity; + final boolean shouldChunkLoad = tileEntityAbstractChunkLoading.shouldChunkLoad(); + if (!shouldChunkLoad) { + WarpDrive.logger.warn(String.format("Unable to resume chunkloading @ %s (%d %d %d): chunk loader is disabled or out of power %s", + world.provider.getDimensionName(), + x, y, z, + tileEntity)); + ForgeChunkManager.releaseTicket(ticket); + continue; + } + + WarpDrive.logger.info(String.format("Resuming chunkloading of %s", tileEntity)); + tileEntityAbstractChunkLoading.chunkloading_giveTicket(ticket); + tileEntityAbstractChunkLoading.refreshChunkLoading(); + } + } + + /* Forge wrappers */ + public static Ticket forgeTicket_requestNormal(final World world, final TileEntity tileEntity) { + if (ForgeChunkManager.ticketCountAvailableFor(WarpDrive.instance, world) <= 0) { + WarpDrive.logger.error(String.format("No ChunkLoader tickets available for %s", + world.provider.getDimensionName())); + return null; + } + + final Ticket ticket = ForgeChunkManager.requestTicket(WarpDrive.instance, world, Type.NORMAL); + if (ticket == null) { + WarpDrive.logger.error(String.format("Failed to register ChunkLoader Ticket for %s", + world.provider.getDimensionName())); + return null; + } + + if (WarpDriveConfig.LOGGING_CHUNK_LOADING) { + WarpDrive.logger.info(String.format("Forcing chunk loading @ %s (%d %d %d)", + ticket.world.provider.getDimensionName(), + tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)); + } + + final NBTTagCompound tagCompound = ticket.getModData(); + tagCompound.setString("id", tileEntity.getClass().getSimpleName()); + tagCompound.setInteger("posX", tileEntity.xCoord); + tagCompound.setInteger("posY", tileEntity.yCoord); + tagCompound.setInteger("posZ", tileEntity.zCoord); + + return ticket; + } + + public static void forgeTicket_release(final Ticket ticket) { + if (ticket == null) { + return; + } + + forgeTicket_clearChunks(ticket); + + ForgeChunkManager.releaseTicket(ticket); + } + + public static void forgeTicket_addChunks(final Ticket ticket, final ChunkCoordIntPair chunk) { + if (WarpDrive.isDev) { + WarpDrive.logger.info(String.format("Forcing chunk loading @ %s %s", + ticket.world.provider.getDimensionName(), + chunk)); + } + ForgeChunkManager.forceChunk(ticket, chunk); + } + + public static void forgeTicket_clearChunks(final Ticket ticket) { + if (ticket == null) { + return; + } + + if (WarpDriveConfig.LOGGING_CHUNK_LOADING) { + final NBTTagCompound tagCompound = ticket.getModData(); + final int x = tagCompound.getInteger("posX"); + final int y = tagCompound.getInteger("posY"); + final int z = tagCompound.getInteger("posZ"); + WarpDrive.logger.info(String.format("Releasing chunk loading @ %s (%d %d %d)", + ticket.world.provider.getDimensionName(), + x, y, z)); + } + + final ImmutableSet chunks = ticket.getChunkList(); + for (final ChunkCoordIntPair chunk : chunks) { + if (WarpDrive.isDev) { + WarpDrive.logger.info(String.format("Releasing chunk loading @ %s %s", + ticket.world.provider.getDimensionName(), + chunk)); + } + ForgeChunkManager.unforceChunk(ticket, chunk); + } + } +} \ No newline at end of file diff --git a/src/main/java/cr0s/warpdrive/item/ItemComponent.java b/src/main/java/cr0s/warpdrive/item/ItemComponent.java index 66d124d4..8d364d8b 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemComponent.java +++ b/src/main/java/cr0s/warpdrive/item/ItemComponent.java @@ -3,7 +3,7 @@ package cr0s.warpdrive.item; import cr0s.warpdrive.Commons; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IAirContainerItem; -import cr0s.warpdrive.block.energy.BlockEnergyBank; +import cr0s.warpdrive.block.BlockAbstractContainer; import cr0s.warpdrive.data.EnumComponentType; import java.util.List; @@ -139,9 +139,11 @@ public class ItemComponent extends Item implements IAirContainerItem { @Override - public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { - Block block = world.getBlock(x, y, z); - return block instanceof BlockEnergyBank || super.doesSneakBypassUse(world, x, y, z, player); + public boolean doesSneakBypassUse(final World world, final int x, final int y, final int z, final EntityPlayer player) { + final Block block = world.getBlock(x, y, z); + + return block instanceof BlockAbstractContainer + || super.doesSneakBypassUse(world, x, y, z, player); } @Override