Code cleanup
This commit is contained in:
parent
495407cadb
commit
22f9f39cc5
8 changed files with 214 additions and 201 deletions
|
@ -51,7 +51,7 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@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);
|
final int metadata = blockAccess.getBlockMetadata(x, y, z);
|
||||||
if (side == (metadata & 7)) {
|
if (side == (metadata & 7)) {
|
||||||
if ((metadata & 8) == 0) { // Inactive state
|
if ((metadata & 8) == 0) { // Inactive state
|
||||||
|
@ -66,7 +66,7 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@Override
|
@Override
|
||||||
public IIcon getIcon(int side, int metadata) {
|
public IIcon getIcon(final int side, final int metadata) {
|
||||||
if (side == 3) {
|
if (side == 3) {
|
||||||
return iconBuffer[ICON_SIDE_ACTIVATED];
|
return iconBuffer[ICON_SIDE_ACTIVATED];
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int quantityDropped(Random random) {
|
public int quantityDropped(final Random random) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,28 +95,29 @@ public class BlockAirGeneratorTiered extends BlockAbstractContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (world.isRemote) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
final TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||||
if (tileEntity instanceof TileEntityAirGeneratorTiered) {
|
if (tileEntity instanceof TileEntityAirGeneratorTiered) {
|
||||||
TileEntityAirGeneratorTiered airGenerator = (TileEntityAirGeneratorTiered)tileEntity;
|
final TileEntityAirGeneratorTiered airGenerator = (TileEntityAirGeneratorTiered)tileEntity;
|
||||||
ItemStack itemStackHeld = entityPlayer.getHeldItem();
|
final ItemStack itemStackHeld = entityPlayer.getHeldItem();
|
||||||
if (itemStackHeld == null) {
|
if (itemStackHeld == null) {
|
||||||
Commons.addChatMessage(entityPlayer, airGenerator.getStatus());
|
Commons.addChatMessage(entityPlayer, airGenerator.getStatus());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Item itemHeld = itemStackHeld.getItem();
|
final Item itemHeld = itemStackHeld.getItem();
|
||||||
if (itemHeld instanceof IAirContainerItem) {
|
if (itemHeld instanceof IAirContainerItem) {
|
||||||
IAirContainerItem airCanister = (IAirContainerItem) itemHeld;
|
final IAirContainerItem airCanister = (IAirContainerItem) itemHeld;
|
||||||
if (airCanister.canContainAir(itemStackHeld) && airGenerator.energy_consume(WarpDriveConfig.BREATHING_ENERGY_PER_CANISTER, true)) {
|
if (airCanister.canContainAir(itemStackHeld) && airGenerator.energy_consume(WarpDriveConfig.BREATHING_ENERGY_PER_CANISTER, true)) {
|
||||||
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
entityPlayer.inventory.decrStackSize(entityPlayer.inventory.currentItem, 1);
|
||||||
ItemStack toAdd = airCanister.getFullAirContainer(itemStackHeld);
|
final ItemStack toAdd = airCanister.getFullAirContainer(itemStackHeld);
|
||||||
if (toAdd != null) {
|
if (toAdd != null) {
|
||||||
if (!entityPlayer.inventory.addItemStackToInventory(toAdd)) {
|
if (!entityPlayer.inventory.addItemStackToInventory(toAdd)) {
|
||||||
EntityItem entityItem = new EntityItem(entityPlayer.worldObj, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, toAdd);
|
final EntityItem entityItem = new EntityItem(entityPlayer.worldObj, entityPlayer.posX, entityPlayer.posY, entityPlayer.posZ, toAdd);
|
||||||
entityPlayer.worldObj.spawnEntityInWorld(entityItem);
|
entityPlayer.worldObj.spawnEntityInWorld(entityItem);
|
||||||
}
|
}
|
||||||
((EntityPlayerMP)entityPlayer).sendContainerToPlayer(entityPlayer.inventoryContainer);
|
((EntityPlayerMP)entityPlayer).sendContainerToPlayer(entityPlayer.inventoryContainer);
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class TileEntityAirGeneratorTiered extends TileEntityAbstractEnergy {
|
||||||
@Override
|
@Override
|
||||||
protected void onFirstUpdateTick() {
|
protected void onFirstUpdateTick() {
|
||||||
super.onFirstUpdateTick();
|
super.onFirstUpdateTick();
|
||||||
Block block = getBlockType();
|
final Block block = getBlockType();
|
||||||
if (block instanceof BlockAirGeneratorTiered) {
|
if (block instanceof BlockAirGeneratorTiered) {
|
||||||
tier = ((BlockAirGeneratorTiered) block).tier;
|
tier = ((BlockAirGeneratorTiered) block).tier;
|
||||||
maxEnergyStored = WarpDriveConfig.BREATHING_MAX_ENERGY_STORED[tier - 1];
|
maxEnergyStored = WarpDriveConfig.BREATHING_MAX_ENERGY_STORED[tier - 1];
|
||||||
|
@ -152,7 +152,7 @@ public class TileEntityAirGeneratorTiered extends TileEntityAbstractEnergy {
|
||||||
xCoord, yCoord, zCoord);
|
xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] enable(Object[] arguments) {
|
public Object[] enable(final Object[] arguments) {
|
||||||
if (arguments.length == 1 && arguments[0] != null) {
|
if (arguments.length == 1 && arguments[0] != null) {
|
||||||
isEnabled = Commons.toBool(arguments[0]);
|
isEnabled = Commons.toBool(arguments[0]);
|
||||||
}
|
}
|
||||||
|
@ -162,14 +162,14 @@ public class TileEntityAirGeneratorTiered extends TileEntityAbstractEnergy {
|
||||||
// OpenComputer callback methods
|
// OpenComputer callback methods
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
public Object[] enable(Context context, Arguments arguments) {
|
public Object[] enable(final Context context, final Arguments arguments) {
|
||||||
return enable(argumentsOCtoCC(arguments));
|
return enable(argumentsOCtoCC(arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ComputerCraft IPeripheral methods implementation
|
// ComputerCraft IPeripheral methods implementation
|
||||||
@Override
|
@Override
|
||||||
@Optional.Method(modid = "ComputerCraft")
|
@Optional.Method(modid = "ComputerCraft")
|
||||||
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) {
|
public Object[] callMethod(final IComputerAccess computer, final ILuaContext context, final int method, final Object[] arguments) {
|
||||||
final String methodName = getMethodName(method);
|
final String methodName = getMethodName(method);
|
||||||
|
|
||||||
switch (methodName) {
|
switch (methodName) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ import cr0s.warpdrive.data.EnumDisplayAlignment;
|
||||||
import cr0s.warpdrive.data.EnumTooltipCondition;
|
import cr0s.warpdrive.data.EnumTooltipCondition;
|
||||||
import cr0s.warpdrive.network.PacketHandler;
|
import cr0s.warpdrive.network.PacketHandler;
|
||||||
import org.xml.sax.ErrorHandler;
|
import org.xml.sax.ErrorHandler;
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
import org.xml.sax.SAXParseException;
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
@ -435,7 +434,7 @@ public class WarpDriveConfig {
|
||||||
public static Block getModBlock(final String mod, final String id) {
|
public static Block getModBlock(final String mod, final String id) {
|
||||||
try {
|
try {
|
||||||
return GameRegistry.findBlock(mod, id);
|
return GameRegistry.findBlock(mod, id);
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.info(String.format("Failed to get mod block for %s:%s", mod, id));
|
WarpDrive.logger.info(String.format("Failed to get mod block for %s:%s", mod, id));
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -483,12 +482,12 @@ public class WarpDriveConfig {
|
||||||
|
|
||||||
private static ItemStack getModItemStackOrNull(final String mod, final String id, final int meta) {
|
private static ItemStack getModItemStackOrNull(final String mod, final String id, final int meta) {
|
||||||
try {
|
try {
|
||||||
ItemStack item = new ItemStack((Item) Item.itemRegistry.getObject(mod + ":" + id));
|
final ItemStack item = new ItemStack((Item) Item.itemRegistry.getObject(mod + ":" + id));
|
||||||
if (meta != -1) {
|
if (meta != -1) {
|
||||||
item.setItemDamage(meta);
|
item.setItemDamage(meta);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.info(String.format("Failed to get mod item for %s:%s@%d", mod, id, meta));
|
WarpDrive.logger.info(String.format("Failed to get mod item for %s:%s@%d", mod, id, meta));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1057,7 @@ public class WarpDriveConfig {
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerBlockTransformer(final String modId, IBlockTransformer blockTransformer) {
|
public static void registerBlockTransformer(final String modId, final IBlockTransformer blockTransformer) {
|
||||||
blockTransformers.put(modId, blockTransformer);
|
blockTransformers.put(modId, blockTransformer);
|
||||||
WarpDrive.logger.info(modId + " blockTransformer registered");
|
WarpDrive.logger.info(modId + " blockTransformer registered");
|
||||||
}
|
}
|
||||||
|
@ -1130,79 +1129,97 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
isNotEnoughItemsLoaded = Loader.isModLoaded("NotEnoughItems");
|
isNotEnoughItemsLoaded = Loader.isModLoaded("NotEnoughItems");
|
||||||
|
|
||||||
boolean isBotaniaLoaded = Loader.isModLoaded("Botania");
|
final boolean isBotaniaLoaded = Loader.isModLoaded("Botania");
|
||||||
if (isBotaniaLoaded) {
|
if (isBotaniaLoaded) {
|
||||||
CompatBotania.register();
|
CompatBotania.register();
|
||||||
}
|
}
|
||||||
boolean isBiblioCraftLoaded = Loader.isModLoaded("BiblioCraft");
|
|
||||||
|
final boolean isBiblioCraftLoaded = Loader.isModLoaded("BiblioCraft");
|
||||||
if (isBiblioCraftLoaded) {
|
if (isBiblioCraftLoaded) {
|
||||||
CompatBiblioCraft.register();
|
CompatBiblioCraft.register();
|
||||||
}
|
}
|
||||||
boolean isBuildCraftLoaded = Loader.isModLoaded("BuildCraft|Core");
|
|
||||||
|
final boolean isBuildCraftLoaded = Loader.isModLoaded("BuildCraft|Core");
|
||||||
if (isBuildCraftLoaded) {
|
if (isBuildCraftLoaded) {
|
||||||
CompatBuildCraft.register();
|
CompatBuildCraft.register();
|
||||||
}
|
}
|
||||||
boolean isCarpentersBlocksLoaded = Loader.isModLoaded("CarpentersBlocks");
|
|
||||||
|
final boolean isCarpentersBlocksLoaded = Loader.isModLoaded("CarpentersBlocks");
|
||||||
if (isCarpentersBlocksLoaded) {
|
if (isCarpentersBlocksLoaded) {
|
||||||
CompatCarpentersBlocks.register();
|
CompatCarpentersBlocks.register();
|
||||||
}
|
}
|
||||||
boolean isCustomNpcsLoaded = Loader.isModLoaded("customnpcs");
|
|
||||||
|
final boolean isCustomNpcsLoaded = Loader.isModLoaded("customnpcs");
|
||||||
if (isCustomNpcsLoaded) {
|
if (isCustomNpcsLoaded) {
|
||||||
CompatCustomNpcs.register();
|
CompatCustomNpcs.register();
|
||||||
}
|
}
|
||||||
boolean isDraconicEvolutionLoaded = Loader.isModLoaded("DraconicEvolution");
|
|
||||||
|
final boolean isDraconicEvolutionLoaded = Loader.isModLoaded("DraconicEvolution");
|
||||||
if (isDraconicEvolutionLoaded) {
|
if (isDraconicEvolutionLoaded) {
|
||||||
CompatDraconicEvolution.register();
|
CompatDraconicEvolution.register();
|
||||||
}
|
}
|
||||||
boolean isEvilCraftLoaded = Loader.isModLoaded("evilcraft");
|
|
||||||
|
final boolean isEvilCraftLoaded = Loader.isModLoaded("evilcraft");
|
||||||
if (isEvilCraftLoaded) {
|
if (isEvilCraftLoaded) {
|
||||||
CompatEvilCraft.register();
|
CompatEvilCraft.register();
|
||||||
}
|
}
|
||||||
boolean isJABBAloaded = Loader.isModLoaded("JABBA");
|
|
||||||
|
final boolean isJABBAloaded = Loader.isModLoaded("JABBA");
|
||||||
if (isJABBAloaded) {
|
if (isJABBAloaded) {
|
||||||
CompatJABBA.register();
|
CompatJABBA.register();
|
||||||
}
|
}
|
||||||
boolean isMekanismLoaded = Loader.isModLoaded("Mekanism");
|
|
||||||
|
final boolean isMekanismLoaded = Loader.isModLoaded("Mekanism");
|
||||||
if (isMekanismLoaded) {
|
if (isMekanismLoaded) {
|
||||||
CompatMekanism.register();
|
CompatMekanism.register();
|
||||||
}
|
}
|
||||||
boolean isMetallurgyLoaded = Loader.isModLoaded("Metallurgy");
|
|
||||||
|
final boolean isMetallurgyLoaded = Loader.isModLoaded("Metallurgy");
|
||||||
if (isMetallurgyLoaded) {
|
if (isMetallurgyLoaded) {
|
||||||
CompatMetallurgy.register();
|
CompatMetallurgy.register();
|
||||||
}
|
}
|
||||||
boolean isNaturaLoaded = Loader.isModLoaded("Natura");
|
|
||||||
|
final boolean isNaturaLoaded = Loader.isModLoaded("Natura");
|
||||||
if (isNaturaLoaded) {
|
if (isNaturaLoaded) {
|
||||||
CompatNatura.register();
|
CompatNatura.register();
|
||||||
}
|
}
|
||||||
boolean isPneumaticCraftLoaded = Loader.isModLoaded("PneumaticCraft");
|
|
||||||
|
final boolean isPneumaticCraftLoaded = Loader.isModLoaded("PneumaticCraft");
|
||||||
if (isPneumaticCraftLoaded) {
|
if (isPneumaticCraftLoaded) {
|
||||||
CompatPneumaticCraft.register();
|
CompatPneumaticCraft.register();
|
||||||
}
|
}
|
||||||
boolean isRedstonePasteLoaded = Loader.isModLoaded("RedstonePasteMod");
|
|
||||||
|
final boolean isRedstonePasteLoaded = Loader.isModLoaded("RedstonePasteMod");
|
||||||
if (isRedstonePasteLoaded) {
|
if (isRedstonePasteLoaded) {
|
||||||
CompatRedstonePaste.register();
|
CompatRedstonePaste.register();
|
||||||
}
|
}
|
||||||
boolean isSGCraftLoaded = Loader.isModLoaded("SGCraft");
|
|
||||||
|
final boolean isSGCraftLoaded = Loader.isModLoaded("SGCraft");
|
||||||
if (isSGCraftLoaded) {
|
if (isSGCraftLoaded) {
|
||||||
CompatSGCraft.register();
|
CompatSGCraft.register();
|
||||||
}
|
}
|
||||||
boolean isStargateTech2Loaded = Loader.isModLoaded("StargateTech2");
|
|
||||||
|
final boolean isStargateTech2Loaded = Loader.isModLoaded("StargateTech2");
|
||||||
if (isStargateTech2Loaded) {
|
if (isStargateTech2Loaded) {
|
||||||
CompatStargateTech2.register();
|
CompatStargateTech2.register();
|
||||||
}
|
}
|
||||||
boolean isTConstructLoaded = Loader.isModLoaded("TConstruct");
|
|
||||||
|
final boolean isTConstructLoaded = Loader.isModLoaded("TConstruct");
|
||||||
if (isTConstructLoaded) {
|
if (isTConstructLoaded) {
|
||||||
CompatTConstruct.register();
|
CompatTConstruct.register();
|
||||||
}
|
}
|
||||||
boolean isTechgunsLoaded = Loader.isModLoaded("Techguns");
|
|
||||||
|
final boolean isTechgunsLoaded = Loader.isModLoaded("Techguns");
|
||||||
if (isTechgunsLoaded) {
|
if (isTechgunsLoaded) {
|
||||||
CompatTechguns.register();
|
CompatTechguns.register();
|
||||||
}
|
}
|
||||||
boolean isThaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
|
|
||||||
|
final boolean isThaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
|
||||||
if (isThaumcraftLoaded) {
|
if (isThaumcraftLoaded) {
|
||||||
CompatThaumcraft.register();
|
CompatThaumcraft.register();
|
||||||
}
|
}
|
||||||
boolean isThermalDynamicsLoaded = Loader.isModLoaded("ThermalDynamics");
|
|
||||||
|
final boolean isThermalDynamicsLoaded = Loader.isModLoaded("ThermalDynamics");
|
||||||
if (isThermalDynamicsLoaded) {
|
if (isThermalDynamicsLoaded) {
|
||||||
CompatThermalDynamics.register();
|
CompatThermalDynamics.register();
|
||||||
}
|
}
|
||||||
|
@ -1224,7 +1241,7 @@ public class WarpDriveConfig {
|
||||||
|
|
||||||
IC2_rubberWood = getModBlock("IC2", "blockRubWood");
|
IC2_rubberWood = getModBlock("IC2", "blockRubWood");
|
||||||
IC2_Resin = getModItemStack("IC2", "itemHarz", -1);
|
IC2_Resin = getModItemStack("IC2", "itemHarz", -1);
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.error("Error loading IndustrialCraft2 classes");
|
WarpDrive.logger.error("Error loading IndustrialCraft2 classes");
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1237,7 +1254,7 @@ public class WarpDriveConfig {
|
||||||
CCT_Turtle = getModBlock("ComputerCraft", "CC-Turtle");
|
CCT_Turtle = getModBlock("ComputerCraft", "CC-Turtle");
|
||||||
CCT_Expanded = getModBlock("ComputerCraft", "CC-TurtleExpanded");
|
CCT_Expanded = getModBlock("ComputerCraft", "CC-TurtleExpanded");
|
||||||
CCT_Advanced = getModBlock("ComputerCraft", "CC-TurtleAdvanced");
|
CCT_Advanced = getModBlock("ComputerCraft", "CC-TurtleAdvanced");
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.error("Error loading ComputerCraft classes");
|
WarpDrive.logger.error("Error loading ComputerCraft classes");
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1246,9 +1263,9 @@ public class WarpDriveConfig {
|
||||||
public static DocumentBuilder getXmlDocumentBuilder() {
|
public static DocumentBuilder getXmlDocumentBuilder() {
|
||||||
if (xmlDocumentBuilder == null) {
|
if (xmlDocumentBuilder == null) {
|
||||||
|
|
||||||
ErrorHandler xmlErrorHandler = new ErrorHandler() {
|
final ErrorHandler xmlErrorHandler = new ErrorHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void warning(SAXParseException exception) throws SAXException {
|
public void warning(final SAXParseException exception) {
|
||||||
WarpDrive.logger.warn(String.format("XML warning at line %d: %s",
|
WarpDrive.logger.warn(String.format("XML warning at line %d: %s",
|
||||||
exception.getLineNumber(),
|
exception.getLineNumber(),
|
||||||
exception.getLocalizedMessage() ));
|
exception.getLocalizedMessage() ));
|
||||||
|
@ -1256,7 +1273,7 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fatalError(SAXParseException exception) throws SAXException {
|
public void fatalError(final SAXParseException exception) {
|
||||||
WarpDrive.logger.warn(String.format("XML fatal error at line %d: %s",
|
WarpDrive.logger.warn(String.format("XML fatal error at line %d: %s",
|
||||||
exception.getLineNumber(),
|
exception.getLineNumber(),
|
||||||
exception.getLocalizedMessage() ));
|
exception.getLocalizedMessage() ));
|
||||||
|
@ -1264,7 +1281,7 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(SAXParseException exception) throws SAXException {
|
public void error(final SAXParseException exception) {
|
||||||
WarpDrive.logger.warn(String.format("XML error at line %d: %s",
|
WarpDrive.logger.warn(String.format("XML error at line %d: %s",
|
||||||
exception.getLineNumber(),
|
exception.getLineNumber(),
|
||||||
exception.getLocalizedMessage() ));
|
exception.getLocalizedMessage() ));
|
||||||
|
@ -1273,7 +1290,7 @@ public class WarpDriveConfig {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
documentBuilderFactory.setIgnoringComments(false);
|
documentBuilderFactory.setIgnoringComments(false);
|
||||||
documentBuilderFactory.setNamespaceAware(true);
|
documentBuilderFactory.setNamespaceAware(true);
|
||||||
documentBuilderFactory.setValidating(true);
|
documentBuilderFactory.setValidating(true);
|
||||||
|
@ -1281,7 +1298,7 @@ public class WarpDriveConfig {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
xmlDocumentBuilder = documentBuilderFactory.newDocumentBuilder();
|
xmlDocumentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||||
} catch (ParserConfigurationException exception) {
|
} catch (final ParserConfigurationException exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
xmlDocumentBuilder.setErrorHandler(xmlErrorHandler);
|
xmlDocumentBuilder.setErrorHandler(xmlErrorHandler);
|
||||||
|
@ -1295,7 +1312,7 @@ public class WarpDriveConfig {
|
||||||
* Target folder should be already created
|
* Target folder should be already created
|
||||||
**/
|
**/
|
||||||
private static void unpackResourcesToFolder(final String prefix, final String suffix, final String[] filenames, final String resourcePathSource, File folderTarget) {
|
private static void unpackResourcesToFolder(final String prefix, final String suffix, final String[] filenames, final String resourcePathSource, File folderTarget) {
|
||||||
File[] files = configDirectory.listFiles((file_notUsed, name) -> name.startsWith(prefix) && name.endsWith(suffix));
|
final File[] files = configDirectory.listFiles((file_notUsed, name) -> name.startsWith(prefix) && name.endsWith(suffix));
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
throw new RuntimeException(String.format("Critical error accessing configuration directory, searching for %s*%s files: %s", prefix, suffix, configDirectory));
|
throw new RuntimeException(String.format("Critical error accessing configuration directory, searching for %s*%s files: %s", prefix, suffix, configDirectory));
|
||||||
}
|
}
|
||||||
|
@ -1310,16 +1327,16 @@ public class WarpDriveConfig {
|
||||||
* Copy a default configuration file from the mod's resources to the specified configuration folder
|
* Copy a default configuration file from the mod's resources to the specified configuration folder
|
||||||
* Target folder should be already created
|
* Target folder should be already created
|
||||||
**/
|
**/
|
||||||
private static void unpackResourceToFolder(final String filename, final String resourcePathSource, File folderTarget) {
|
private static void unpackResourceToFolder(final String filename, final String resourcePathSource, final File folderTarget) {
|
||||||
String resourceName = resourcePathSource + "/" + filename;
|
final String resourceName = resourcePathSource + "/" + filename;
|
||||||
|
|
||||||
File destination = new File(folderTarget, filename);
|
final File destination = new File(folderTarget, filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = WarpDrive.class.getClassLoader().getResourceAsStream(resourceName);
|
final InputStream inputStream = WarpDrive.class.getClassLoader().getResourceAsStream(resourceName);
|
||||||
BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(destination));
|
final BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(destination));
|
||||||
|
|
||||||
byte[] byteBuffer = new byte[Math.max(8192, inputStream.available())];
|
final byte[] byteBuffer = new byte[Math.max(8192, inputStream.available())];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while ((bytesRead = inputStream.read(byteBuffer)) >= 0) {
|
while ((bytesRead = inputStream.read(byteBuffer)) >= 0) {
|
||||||
outputStream.write(byteBuffer, 0, bytesRead);
|
outputStream.write(byteBuffer, 0, bytesRead);
|
||||||
|
@ -1327,7 +1344,7 @@ public class WarpDriveConfig {
|
||||||
|
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.error("Failed to unpack resource \'" + resourceName + "\' into " + destination);
|
WarpDrive.logger.error("Failed to unpack resource \'" + resourceName + "\' into " + destination);
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JumpBlock(Filler filler, int x, int y, int z) {
|
public JumpBlock(final Filler filler, final int x, final int y, final int z) {
|
||||||
if (filler.block == null) {
|
if (filler.block == null) {
|
||||||
WarpDrive.logger.info("Forcing glass for invalid filler with null block at " + x + " " + y + " " + z);
|
WarpDrive.logger.info("Forcing glass for invalid filler with null block at " + x + " " + y + " " + z);
|
||||||
filler.block = Blocks.glass;
|
filler.block = Blocks.glass;
|
||||||
|
@ -105,7 +105,7 @@ public class JumpBlock {
|
||||||
if (externals == null) {
|
if (externals == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
NBTBase nbtExternal = externals.get(modId);
|
final NBTBase nbtExternal = externals.get(modId);
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
WarpDrive.logger.info("Returning " + modId + " externals at " + x + " " + y + " " + z + " " + nbtExternal);
|
WarpDrive.logger.info("Returning " + modId + " externals at " + x + " " + y + " " + z + " " + nbtExternal);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ public class JumpBlock {
|
||||||
private static final byte[] mrotWoodLog = { 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15 };
|
private static final byte[] mrotWoodLog = { 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15 };
|
||||||
|
|
||||||
// Return updated metadata from rotating a vanilla block
|
// Return updated metadata from rotating a vanilla block
|
||||||
private int getMetadataRotation(NBTTagCompound nbtTileEntity, final byte rotationSteps) {
|
private int getMetadataRotation(final NBTTagCompound nbtTileEntity, final byte rotationSteps) {
|
||||||
if (rotationSteps == 0) {
|
if (rotationSteps == 0) {
|
||||||
return blockMeta;
|
return blockMeta;
|
||||||
}
|
}
|
||||||
|
@ -197,8 +197,8 @@ public class JumpBlock {
|
||||||
} else if (block instanceof BlockLog) {
|
} else if (block instanceof BlockLog) {
|
||||||
mrot = mrotWoodLog;
|
mrot = mrotWoodLog;
|
||||||
} else if (block instanceof BlockSkull) {
|
} else if (block instanceof BlockSkull) {
|
||||||
mrot = mrotNone;
|
// mrot = mrotNone;
|
||||||
short facing = nbtTileEntity.getShort("Rot");
|
final short facing = nbtTileEntity.getShort("Rot");
|
||||||
switch (rotationSteps) {
|
switch (rotationSteps) {
|
||||||
case 1:
|
case 1:
|
||||||
nbtTileEntity.setShort("Rot", mrotSign[facing]);
|
nbtTileEntity.setShort("Rot", mrotSign[facing]);
|
||||||
|
@ -226,19 +226,13 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkCoordinates deploy(World targetWorld, ITransformation transformation) {
|
public ChunkCoordinates deploy(final World targetWorld, final ITransformation transformation) {
|
||||||
try {
|
try {
|
||||||
NBTTagCompound nbtToDeploy = null;
|
final NBTTagCompound nbtToDeploy = getBlockNBT();
|
||||||
if (blockTileEntity != null) {
|
|
||||||
nbtToDeploy = new NBTTagCompound();
|
|
||||||
blockTileEntity.writeToNBT(nbtToDeploy);
|
|
||||||
} else if (blockNBT != null) {
|
|
||||||
nbtToDeploy = (NBTTagCompound) blockNBT.copy();
|
|
||||||
}
|
|
||||||
int newBlockMeta = blockMeta;
|
int newBlockMeta = blockMeta;
|
||||||
if (externals != null) {
|
if (externals != null) {
|
||||||
for (final Entry<String, NBTBase> external : externals.entrySet()) {
|
for (final Entry<String, NBTBase> external : externals.entrySet()) {
|
||||||
IBlockTransformer blockTransformer = WarpDriveConfig.blockTransformers.get(external.getKey());
|
final IBlockTransformer blockTransformer = WarpDriveConfig.blockTransformers.get(external.getKey());
|
||||||
if (blockTransformer != null) {
|
if (blockTransformer != null) {
|
||||||
newBlockMeta = blockTransformer.rotate(block, blockMeta, nbtToDeploy, transformation);
|
newBlockMeta = blockTransformer.rotate(block, blockMeta, nbtToDeploy, transformation);
|
||||||
}
|
}
|
||||||
|
@ -264,24 +258,24 @@ public class JumpBlock {
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
WarpDrive.logger.info(this + " deploy: TileEntity has mainXYZ");
|
WarpDrive.logger.info(this + " deploy: TileEntity has mainXYZ");
|
||||||
}
|
}
|
||||||
ChunkCoordinates mainTarget = transformation.apply(nbtToDeploy.getInteger("mainX"), nbtToDeploy.getInteger("mainY"), nbtToDeploy.getInteger("mainZ"));
|
final ChunkCoordinates mainTarget = transformation.apply(nbtToDeploy.getInteger("mainX"), nbtToDeploy.getInteger("mainY"), nbtToDeploy.getInteger("mainZ"));
|
||||||
nbtToDeploy.setInteger("mainX", mainTarget.posX);
|
nbtToDeploy.setInteger("mainX", mainTarget.posX);
|
||||||
nbtToDeploy.setInteger("mainY", mainTarget.posY);
|
nbtToDeploy.setInteger("mainY", mainTarget.posY);
|
||||||
nbtToDeploy.setInteger("mainZ", mainTarget.posZ);
|
nbtToDeploy.setInteger("mainZ", mainTarget.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbtToDeploy.hasKey("screenData")) {// IC2NuclearControl 2.2.5a
|
if (nbtToDeploy.hasKey("screenData")) {// IC2NuclearControl 2.2.5a
|
||||||
NBTTagCompound nbtScreenData = nbtToDeploy.getCompoundTag("screenData");
|
final NBTTagCompound nbtScreenData = nbtToDeploy.getCompoundTag("screenData");
|
||||||
if ( nbtScreenData.hasKey("minX") && nbtScreenData.hasKey("minY") && nbtScreenData.hasKey("minZ")
|
if ( nbtScreenData.hasKey("minX") && nbtScreenData.hasKey("minY") && nbtScreenData.hasKey("minZ")
|
||||||
&& nbtScreenData.hasKey("maxX") && nbtScreenData.hasKey("maxY") && nbtScreenData.hasKey("maxZ")) {
|
&& nbtScreenData.hasKey("maxX") && nbtScreenData.hasKey("maxY") && nbtScreenData.hasKey("maxZ")) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
WarpDrive.logger.info(this + " deploy: TileEntity has screenData.min/maxXYZ");
|
WarpDrive.logger.info(this + " deploy: TileEntity has screenData.min/maxXYZ");
|
||||||
}
|
}
|
||||||
ChunkCoordinates minTarget = transformation.apply(nbtScreenData.getInteger("minX"), nbtScreenData.getInteger("minY"), nbtScreenData.getInteger("minZ"));
|
final ChunkCoordinates minTarget = transformation.apply(nbtScreenData.getInteger("minX"), nbtScreenData.getInteger("minY"), nbtScreenData.getInteger("minZ"));
|
||||||
nbtScreenData.setInteger("minX", minTarget.posX);
|
nbtScreenData.setInteger("minX", minTarget.posX);
|
||||||
nbtScreenData.setInteger("minY", minTarget.posY);
|
nbtScreenData.setInteger("minY", minTarget.posY);
|
||||||
nbtScreenData.setInteger("minZ", minTarget.posZ);
|
nbtScreenData.setInteger("minZ", minTarget.posZ);
|
||||||
ChunkCoordinates maxTarget = transformation.apply(nbtScreenData.getInteger("maxX"), nbtScreenData.getInteger("maxY"), nbtScreenData.getInteger("maxZ"));
|
final ChunkCoordinates maxTarget = transformation.apply(nbtScreenData.getInteger("maxX"), nbtScreenData.getInteger("maxY"), nbtScreenData.getInteger("maxZ"));
|
||||||
nbtScreenData.setInteger("maxX", maxTarget.posX);
|
nbtScreenData.setInteger("maxX", maxTarget.posX);
|
||||||
nbtScreenData.setInteger("maxY", maxTarget.posY);
|
nbtScreenData.setInteger("maxY", maxTarget.posY);
|
||||||
nbtScreenData.setInteger("maxZ", maxTarget.posZ);
|
nbtScreenData.setInteger("maxZ", maxTarget.posZ);
|
||||||
|
@ -329,12 +323,12 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
|
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
String coordinates;
|
String coordinates;
|
||||||
try {
|
try {
|
||||||
coordinates = " at " + x + " " + y + " " + z + " blockId " + block + ":" + blockMeta;
|
coordinates = " at " + x + " " + y + " " + z + " blockId " + block + ":" + blockMeta;
|
||||||
} catch (Exception dropMe) {
|
} catch (final Exception dropMe) {
|
||||||
coordinates = " (unknown coordinates)";
|
coordinates = " (unknown coordinates)";
|
||||||
}
|
}
|
||||||
WarpDrive.logger.error("moveBlockSimple exception at " + coordinates);
|
WarpDrive.logger.error("moveBlockSimple exception at " + coordinates);
|
||||||
|
@ -342,10 +336,10 @@ public class JumpBlock {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void refreshBlockStateOnClient(World world, int x, int y, int z) {
|
public static void refreshBlockStateOnClient(final World world, final int x, final int y, final int z) {
|
||||||
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
final TileEntity tileEntity = world.getTileEntity(x, y, z);
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
Class<?> teClass = tileEntity.getClass();
|
final Class<?> teClass = tileEntity.getClass();
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
WarpDrive.logger.info(String.format("Refreshing clients @ %s (%d %d %d) with %s derived from %s",
|
WarpDrive.logger.info(String.format("Refreshing clients @ %s (%d %d %d) with %s derived from %s",
|
||||||
world.provider.getDimensionName(),
|
world.provider.getDimensionName(),
|
||||||
|
@ -354,11 +348,11 @@ public class JumpBlock {
|
||||||
teClass.getSuperclass()));
|
teClass.getSuperclass()));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String superClassName = teClass.getSuperclass().getName();
|
final String superClassName = teClass.getSuperclass().getName();
|
||||||
boolean isIC2 = superClassName.contains("ic2.core.block");
|
final boolean isIC2 = superClassName.contains("ic2.core.block");
|
||||||
if (isIC2 || superClassName.contains("advsolar.common.tiles")) {// IC2
|
if (isIC2 || superClassName.contains("advsolar.common.tiles")) {// IC2
|
||||||
Method onUnloaded = teClass.getMethod("onUnloaded");
|
final Method onUnloaded = teClass.getMethod("onUnloaded");
|
||||||
Method onLoaded = teClass.getMethod("onLoaded");
|
final Method onLoaded = teClass.getMethod("onLoaded");
|
||||||
if (onUnloaded != null && onLoaded != null) {
|
if (onUnloaded != null && onLoaded != null) {
|
||||||
onUnloaded.invoke(tileEntity);
|
onUnloaded.invoke(tileEntity);
|
||||||
onLoaded.invoke(tileEntity);
|
onLoaded.invoke(tileEntity);
|
||||||
|
@ -385,17 +379,17 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
} else {// IC2 extensions without network optimization (transferring all fields)
|
} else {// IC2 extensions without network optimization (transferring all fields)
|
||||||
try {
|
try {
|
||||||
Method getNetworkedFields = teClass.getMethod("getNetworkedFields");
|
final Method getNetworkedFields = teClass.getMethod("getNetworkedFields");
|
||||||
List<String> fields = (List<String>) getNetworkedFields.invoke(tileEntity);
|
final List<String> fields = (List<String>) getNetworkedFields.invoke(tileEntity);
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
WarpDrive.logger.info("Tile has " + fields.size() + " networked fields: " + fields);
|
WarpDrive.logger.info("Tile has " + fields.size() + " networked fields: " + fields);
|
||||||
}
|
}
|
||||||
for (final String field : fields) {
|
for (final String field : fields) {
|
||||||
NetworkHelper_updateTileEntityField(tileEntity, field);
|
NetworkHelper_updateTileEntityField(tileEntity, field);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException exception) {
|
} catch (final NoSuchMethodException exception) {
|
||||||
// WarpDrive.logger.info("Tile has no getNetworkedFields method");
|
// WarpDrive.logger.info("Tile has no getNetworkedFields method");
|
||||||
} catch (NoClassDefFoundError exception) {
|
} catch (final NoClassDefFoundError exception) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info("TileEntity " + teClass.getName() + " at " + x + " " + y + " " + z + " is missing a class definition");
|
WarpDrive.logger.info("TileEntity " + teClass.getName() + " at " + x + " " + y + " " + z + " is missing a class definition");
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
|
@ -404,7 +398,7 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.info("Exception involving TileEntity " + teClass.getName() + " at " + x + " " + y + " " + z);
|
WarpDrive.logger.info("Exception involving TileEntity " + teClass.getName() + " at " + x + " " + y + " " + z);
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -421,7 +415,7 @@ public class JumpBlock {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blockMeta = tagCompound.getByte("blockMeta");
|
blockMeta = tagCompound.getByte("blockMeta");
|
||||||
blockTileEntity = null;
|
weakTileEntity = null;
|
||||||
if (tagCompound.hasKey("blockNBT")) {
|
if (tagCompound.hasKey("blockNBT")) {
|
||||||
blockNBT = tagCompound.getCompoundTag("blockNBT");
|
blockNBT = tagCompound.getCompoundTag("blockNBT");
|
||||||
|
|
||||||
|
@ -430,7 +424,7 @@ public class JumpBlock {
|
||||||
blockNBT.removeTag("computerID");
|
blockNBT.removeTag("computerID");
|
||||||
}
|
}
|
||||||
if (blockNBT.hasKey("oc:computer")) {
|
if (blockNBT.hasKey("oc:computer")) {
|
||||||
NBTTagCompound tagComputer = blockNBT.getCompoundTag("oc:computer");
|
final NBTTagCompound tagComputer = blockNBT.getCompoundTag("oc:computer");
|
||||||
tagComputer.removeTag("components");
|
tagComputer.removeTag("components");
|
||||||
tagComputer.removeTag("node");
|
tagComputer.removeTag("node");
|
||||||
blockNBT.setTag("oc:computer", tagComputer);
|
blockNBT.setTag("oc:computer", tagComputer);
|
||||||
|
@ -456,12 +450,9 @@ public class JumpBlock {
|
||||||
public void writeToNBT(final NBTTagCompound tagCompound) {
|
public void writeToNBT(final NBTTagCompound tagCompound) {
|
||||||
tagCompound.setString("block", Block.blockRegistry.getNameForObject(block));
|
tagCompound.setString("block", Block.blockRegistry.getNameForObject(block));
|
||||||
tagCompound.setByte("blockMeta", (byte) blockMeta);
|
tagCompound.setByte("blockMeta", (byte) blockMeta);
|
||||||
if (blockTileEntity != null) {
|
final NBTTagCompound nbtTileEntity = getBlockNBT();
|
||||||
final NBTTagCompound nbtTileEntity = new NBTTagCompound();
|
if (nbtTileEntity != null) {
|
||||||
blockTileEntity.writeToNBT(nbtTileEntity);
|
|
||||||
tagCompound.setTag("blockNBT", nbtTileEntity);
|
tagCompound.setTag("blockNBT", nbtTileEntity);
|
||||||
} else if (blockNBT != null) {
|
|
||||||
tagCompound.setTag("blockNBT", blockNBT);
|
|
||||||
}
|
}
|
||||||
tagCompound.setInteger("x", x);
|
tagCompound.setInteger("x", x);
|
||||||
tagCompound.setInteger("y", y);
|
tagCompound.setInteger("y", y);
|
||||||
|
@ -507,7 +498,7 @@ public class JumpBlock {
|
||||||
|
|
||||||
// OpenComputers case
|
// OpenComputers case
|
||||||
if (tagCompound.hasKey("oc:computer")) {
|
if (tagCompound.hasKey("oc:computer")) {
|
||||||
NBTTagCompound tagComputer = tagCompound.getCompoundTag("oc:computer");
|
final NBTTagCompound tagComputer = tagCompound.getCompoundTag("oc:computer");
|
||||||
tagComputer.removeTag("chunkX");
|
tagComputer.removeTag("chunkX");
|
||||||
tagComputer.removeTag("chunkZ");
|
tagComputer.removeTag("chunkZ");
|
||||||
tagComputer.removeTag("components");
|
tagComputer.removeTag("components");
|
||||||
|
@ -520,11 +511,11 @@ public class JumpBlock {
|
||||||
if (tagCompound.hasKey("oc:items")) {
|
if (tagCompound.hasKey("oc:items")) {
|
||||||
NBTTagList tagListItems = tagCompound.getTagList("oc:items", Constants.NBT.TAG_COMPOUND);
|
NBTTagList tagListItems = tagCompound.getTagList("oc:items", Constants.NBT.TAG_COMPOUND);
|
||||||
for (int indexItemSlot = 0; indexItemSlot < tagListItems.tagCount(); indexItemSlot++) {
|
for (int indexItemSlot = 0; indexItemSlot < tagListItems.tagCount(); indexItemSlot++) {
|
||||||
NBTTagCompound tagCompoundItemSlot = tagListItems.getCompoundTagAt(indexItemSlot);
|
final NBTTagCompound tagCompoundItemSlot = tagListItems.getCompoundTagAt(indexItemSlot);
|
||||||
NBTTagCompound tagCompoundItem = tagCompoundItemSlot.getCompoundTag("item");
|
final NBTTagCompound tagCompoundItem = tagCompoundItemSlot.getCompoundTag("item");
|
||||||
NBTTagCompound tagCompoundTag = tagCompoundItem.getCompoundTag("tag");
|
final NBTTagCompound tagCompoundTag = tagCompoundItem.getCompoundTag("tag");
|
||||||
NBTTagCompound tagCompoundOCData = tagCompoundTag.getCompoundTag("oc:data");
|
final NBTTagCompound tagCompoundOCData = tagCompoundTag.getCompoundTag("oc:data");
|
||||||
NBTTagCompound tagCompoundNode = tagCompoundOCData.getCompoundTag("node");
|
final NBTTagCompound tagCompoundNode = tagCompoundOCData.getCompoundTag("node");
|
||||||
if (tagCompoundNode.hasKey("address")) {
|
if (tagCompoundNode.hasKey("address")) {
|
||||||
tagCompoundNode.removeTag("address");
|
tagCompoundNode.removeTag("address");
|
||||||
}
|
}
|
||||||
|
@ -533,7 +524,7 @@ public class JumpBlock {
|
||||||
|
|
||||||
// OpenComputers keyboard
|
// OpenComputers keyboard
|
||||||
if (tagCompound.hasKey("oc:keyboard")) {
|
if (tagCompound.hasKey("oc:keyboard")) {
|
||||||
NBTTagCompound tagCompoundKeyboard = tagCompound.getCompoundTag("oc:keyboard");
|
final NBTTagCompound tagCompoundKeyboard = tagCompound.getCompoundTag("oc:keyboard");
|
||||||
tagCompoundKeyboard.removeTag("node");
|
tagCompoundKeyboard.removeTag("node");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +547,7 @@ public class JumpBlock {
|
||||||
public static void emptyEnergyStorage(final NBTTagCompound tagCompound) {
|
public static void emptyEnergyStorage(final NBTTagCompound tagCompound) {
|
||||||
// BuildCraft
|
// BuildCraft
|
||||||
if (tagCompound.hasKey("battery", NBT.TAG_COMPOUND)) {
|
if (tagCompound.hasKey("battery", NBT.TAG_COMPOUND)) {
|
||||||
NBTTagCompound tagCompoundBattery = tagCompound.getCompoundTag("battery");
|
final NBTTagCompound tagCompoundBattery = tagCompound.getCompoundTag("battery");
|
||||||
if (tagCompoundBattery.hasKey("energy", NBT.TAG_INT)) {
|
if (tagCompoundBattery.hasKey("energy", NBT.TAG_INT)) {
|
||||||
tagCompoundBattery.setInteger("energy", 0);
|
tagCompoundBattery.setInteger("energy", 0);
|
||||||
}
|
}
|
||||||
|
@ -617,25 +608,25 @@ public class JumpBlock {
|
||||||
WarpDrive.logger.info("Patched IC2 API, new instance is '" + NetworkManager_instance + "'");
|
WarpDrive.logger.info("Patched IC2 API, new instance is '" + NetworkManager_instance + "'");
|
||||||
}
|
}
|
||||||
// IC2 hack ends here
|
// IC2 hack ends here
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
throw new RuntimeException(exception);
|
throw new RuntimeException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void NetworkHelper_updateTileEntityField(TileEntity tileEntity, String field) {
|
private static void NetworkHelper_updateTileEntityField(final TileEntity tileEntity, final String field) {
|
||||||
try {
|
try {
|
||||||
if (NetworkManager_instance == null) {
|
if (NetworkManager_instance == null) {
|
||||||
NetworkHelper_init();
|
NetworkHelper_init();
|
||||||
}
|
}
|
||||||
NetworkManager_updateTileEntityField.invoke(NetworkManager_instance, tileEntity, field);
|
NetworkManager_updateTileEntityField.invoke(NetworkManager_instance, tileEntity, field);
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
throw new RuntimeException(exception);
|
throw new RuntimeException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// IC2 support ends here
|
// IC2 support ends here
|
||||||
|
|
||||||
// This code is a straight copy from Vanilla net.minecraft.world.World.setBlock to remove lighting computations
|
// This code is a straight copy from Vanilla net.minecraft.world.World.setBlock to remove lighting computations
|
||||||
public static boolean setBlockNoLight(World w, int x, int y, int z, Block block, int blockMeta, int par6) {
|
public static boolean setBlockNoLight(final World w, final int x, final int y, final int z, final Block block, final int blockMeta, final int par6) {
|
||||||
// return w.setBlock(x, y, z, block, blockMeta, par6);
|
// return w.setBlock(x, y, z, block, blockMeta, par6);
|
||||||
|
|
||||||
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000) {
|
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000) {
|
||||||
|
@ -644,7 +635,7 @@ public class JumpBlock {
|
||||||
} else if (y >= 256) {
|
} else if (y >= 256) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Chunk chunk = w.getChunkFromChunkCoords(x >> 4, z >> 4);
|
final Chunk chunk = w.getChunkFromChunkCoords(x >> 4, z >> 4);
|
||||||
Block block1 = null;
|
Block block1 = null;
|
||||||
// net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null;
|
// net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null;
|
||||||
|
|
||||||
|
@ -658,7 +649,7 @@ public class JumpBlock {
|
||||||
// w.capturedBlockSnapshots.add(blockSnapshot);
|
// w.capturedBlockSnapshots.add(blockSnapshot);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
boolean flag = myChunkSBIDWMT(chunk, x & 15, y, z & 15, block, blockMeta);
|
final boolean flag = myChunkSBIDWMT(chunk, x & 15, y, z & 15, block, blockMeta);
|
||||||
|
|
||||||
// Disable rollback on item use
|
// Disable rollback on item use
|
||||||
// if (!flag && blockSnapshot != null) {
|
// if (!flag && blockSnapshot != null) {
|
||||||
|
@ -688,8 +679,8 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code is a straight copy from Vanilla net.minecraft.world.Chunk.func_150807_a to remove lighting computations
|
// This code is a straight copy from Vanilla net.minecraft.world.Chunk.func_150807_a to remove lighting computations
|
||||||
private static boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, Block block, int blockMeta) {
|
private static boolean myChunkSBIDWMT(final Chunk c, final int x, final int y, final int z, final Block block, final int blockMeta) {
|
||||||
int i1 = z << 4 | x;
|
final int i1 = z << 4 | x;
|
||||||
|
|
||||||
if (y >= c.precipitationHeightMap[i1] - 1) {
|
if (y >= c.precipitationHeightMap[i1] - 1) {
|
||||||
c.precipitationHeightMap[i1] = -999;
|
c.precipitationHeightMap[i1] = -999;
|
||||||
|
@ -697,13 +688,13 @@ public class JumpBlock {
|
||||||
|
|
||||||
// Removed light recalculations
|
// Removed light recalculations
|
||||||
// int j1 = c.heightMap[i1];
|
// int j1 = c.heightMap[i1];
|
||||||
Block block1 = c.getBlock(x, y, z);
|
final Block block1 = c.getBlock(x, y, z);
|
||||||
int k1 = c.getBlockMetadata(x, y, z);
|
final int k1 = c.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
if (block1 == block && k1 == blockMeta) {
|
if (block1 == block && k1 == blockMeta) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray();
|
final ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray();
|
||||||
ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4];
|
ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4];
|
||||||
// Removed light recalculations
|
// Removed light recalculations
|
||||||
// boolean flag = false;
|
// boolean flag = false;
|
||||||
|
@ -718,8 +709,8 @@ public class JumpBlock {
|
||||||
// flag = y >= j1;
|
// flag = y >= j1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l1 = c.xPosition * 16 + x;
|
final int l1 = c.xPosition * 16 + x;
|
||||||
int i2 = c.zPosition * 16 + z;
|
final int i2 = c.zPosition * 16 + z;
|
||||||
|
|
||||||
// Removed light recalculations
|
// Removed light recalculations
|
||||||
// int k2 = block1.getLightOpacity(c.worldObj, l1, y, i2);
|
// int k2 = block1.getLightOpacity(c.worldObj, l1, y, i2);
|
||||||
|
@ -737,12 +728,12 @@ public class JumpBlock {
|
||||||
if (!c.worldObj.isRemote) {
|
if (!c.worldObj.isRemote) {
|
||||||
block1.breakBlock(c.worldObj, l1, y, i2, block1, k1);
|
block1.breakBlock(c.worldObj, l1, y, i2, block1, k1);
|
||||||
// After breakBlock a phantom TE might have been created with incorrect meta. This attempts to kill that phantom TE so the normal one can be created properly later
|
// After breakBlock a phantom TE might have been created with incorrect meta. This attempts to kill that phantom TE so the normal one can be created properly later
|
||||||
TileEntity te = c.getTileEntityUnsafe(x & 0x0F, y, z & 0x0F);
|
final TileEntity te = c.getTileEntityUnsafe(x & 0x0F, y, z & 0x0F);
|
||||||
if (te != null && te.shouldRefresh(block1, c.getBlock(x & 0x0F, y, z & 0x0F), k1, c.getBlockMetadata(x & 0x0F, y, z & 0x0F), c.worldObj, l1, y, i2)) {
|
if (te != null && te.shouldRefresh(block1, c.getBlock(x & 0x0F, y, z & 0x0F), k1, c.getBlockMetadata(x & 0x0F, y, z & 0x0F), c.worldObj, l1, y, i2)) {
|
||||||
c.removeTileEntity(x & 0x0F, y, z & 0x0F);
|
c.removeTileEntity(x & 0x0F, y, z & 0x0F);
|
||||||
}
|
}
|
||||||
} else if (block1.hasTileEntity(k1)) {
|
} else if (block1.hasTileEntity(k1)) {
|
||||||
TileEntity te = c.getTileEntityUnsafe(x & 0x0F, y, z & 0x0F);
|
final TileEntity te = c.getTileEntityUnsafe(x & 0x0F, y, z & 0x0F);
|
||||||
if (te != null && te.shouldRefresh(block1, block, k1, blockMeta, c.worldObj, l1, y, i2)) {
|
if (te != null && te.shouldRefresh(block1, block, k1, blockMeta, c.worldObj, l1, y, i2)) {
|
||||||
c.worldObj.removeTileEntity(l1, y, i2);
|
c.worldObj.removeTileEntity(l1, y, i2);
|
||||||
}
|
}
|
||||||
|
@ -774,7 +765,7 @@ public class JumpBlock {
|
||||||
}
|
}
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
TileEntity tileentity;
|
final TileEntity tileentity;
|
||||||
|
|
||||||
// Removed onBlockAdded event
|
// Removed onBlockAdded event
|
||||||
// if (!c.worldObj.isRemote) {
|
// if (!c.worldObj.isRemote) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class JumpShip {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JumpShip createFromFile(final String fileName, final StringBuilder reason) {
|
public static JumpShip createFromFile(final String fileName, final StringBuilder reason) {
|
||||||
NBTTagCompound schematic = Commons.readNBTFromFile(WarpDriveConfig.G_SCHEMALOCATION + "/" + fileName + ".schematic");
|
final NBTTagCompound schematic = Commons.readNBTFromFile(WarpDriveConfig.G_SCHEMALOCATION + "/" + fileName + ".schematic");
|
||||||
if (schematic == null) {
|
if (schematic == null) {
|
||||||
reason.append(String.format("Schematic not found or unknown error reading it: '%s'.", fileName));
|
reason.append(String.format("Schematic not found or unknown error reading it: '%s'.", fileName));
|
||||||
return null;
|
return null;
|
||||||
|
@ -233,14 +233,14 @@ public class JumpShip {
|
||||||
coreX, coreY, coreZ);
|
coreX, coreY, coreZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkBorders(StringBuilder reason) {
|
public boolean checkBorders(final StringBuilder reason) {
|
||||||
// Abort jump if blocks with TE are connecting to the ship (avoid crash when splitting multi-blocks)
|
// Abort jump if blocks with TE are connecting to the ship (avoid crash when splitting multi-blocks)
|
||||||
for (int x = minX - 1; x <= maxX + 1; x++) {
|
for (int x = minX - 1; x <= maxX + 1; x++) {
|
||||||
boolean xBorder = (x == minX - 1) || (x == maxX + 1);
|
final boolean xBorder = (x == minX - 1) || (x == maxX + 1);
|
||||||
for (int z = minZ - 1; z <= maxZ + 1; z++) {
|
for (int z = minZ - 1; z <= maxZ + 1; z++) {
|
||||||
boolean zBorder = (z == minZ - 1) || (z == maxZ + 1);
|
final boolean zBorder = (z == minZ - 1) || (z == maxZ + 1);
|
||||||
for (int y = minY - 1; y <= maxY + 1; y++) {
|
for (int y = minY - 1; y <= maxY + 1; y++) {
|
||||||
boolean yBorder = (y == minY - 1) || (y == maxY + 1);
|
final boolean yBorder = (y == minY - 1) || (y == maxY + 1);
|
||||||
if ((y < 0) || (y > 255)) {
|
if ((y < 0) || (y > 255)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ public class JumpShip {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = worldObj.getBlock(x, y, z);
|
final Block block = worldObj.getBlock(x, y, z);
|
||||||
|
|
||||||
// Skipping any air block & ignored blocks
|
// Skipping any air block & ignored blocks
|
||||||
if (worldObj.isAirBlock(x, y, z) || Dictionary.BLOCKS_LEFTBEHIND.contains(block)) {
|
if (worldObj.isAirBlock(x, y, z) || Dictionary.BLOCKS_LEFTBEHIND.contains(block)) {
|
||||||
|
@ -261,7 +261,7 @@ public class JumpShip {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skipping blocks without tile entities
|
// Skipping blocks without tile entities
|
||||||
TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
|
final TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
|
||||||
if (tileEntity == null) {
|
if (tileEntity == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -280,27 +280,27 @@ public class JumpShip {
|
||||||
/**
|
/**
|
||||||
* Saving ship to memory
|
* Saving ship to memory
|
||||||
*/
|
*/
|
||||||
public boolean save(StringBuilder reason) {
|
public boolean save(final StringBuilder reason) {
|
||||||
VectorI vPosition = new VectorI();
|
final VectorI vPosition = new VectorI();
|
||||||
try {
|
try {
|
||||||
int estimatedVolume = (maxX - minX + 1) * (maxY - minY + 1) * (maxZ - minZ + 1);
|
final int estimatedVolume = (maxX - minX + 1) * (maxY - minY + 1) * (maxZ - minZ + 1);
|
||||||
JumpBlock[][] placeTimeJumpBlocks = { new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume] };
|
final JumpBlock[][] placeTimeJumpBlocks = { new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume], new JumpBlock[estimatedVolume] };
|
||||||
int[] placeTimeIndexes = { 0, 0, 0, 0, 0 };
|
final int[] placeTimeIndexes = { 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
int actualVolume = 0;
|
int actualVolume = 0;
|
||||||
int newMass = 0;
|
int newMass = 0;
|
||||||
int xc1 = minX >> 4;
|
final int xc1 = minX >> 4;
|
||||||
int xc2 = maxX >> 4;
|
final int xc2 = maxX >> 4;
|
||||||
int zc1 = minZ >> 4;
|
final int zc1 = minZ >> 4;
|
||||||
int zc2 = maxZ >> 4;
|
final int zc2 = maxZ >> 4;
|
||||||
|
|
||||||
for (int xc = xc1; xc <= xc2; xc++) {
|
for (int xc = xc1; xc <= xc2; xc++) {
|
||||||
int x1 = Math.max(minX, xc << 4);
|
final int x1 = Math.max(minX, xc << 4);
|
||||||
int x2 = Math.min(maxX, (xc << 4) + 15);
|
final int x2 = Math.min(maxX, (xc << 4) + 15);
|
||||||
|
|
||||||
for (int zc = zc1; zc <= zc2; zc++) {
|
for (int zc = zc1; zc <= zc2; zc++) {
|
||||||
int z1 = Math.max(minZ, zc << 4);
|
final int z1 = Math.max(minZ, zc << 4);
|
||||||
int z2 = Math.min(maxZ, (zc << 4) + 15);
|
final int z2 = Math.min(maxZ, (zc << 4) + 15);
|
||||||
|
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; y++) {
|
||||||
vPosition.y = y;
|
vPosition.y = y;
|
||||||
|
@ -308,7 +308,7 @@ public class JumpShip {
|
||||||
vPosition.x = x;
|
vPosition.x = x;
|
||||||
for (int z = z1; z <= z2; z++) {
|
for (int z = z1; z <= z2; z++) {
|
||||||
vPosition.z = z;
|
vPosition.z = z;
|
||||||
Block block = worldObj.getBlock(x, y, z);
|
final Block block = worldObj.getBlock(x, y, z);
|
||||||
|
|
||||||
// Skipping vanilla air & ignored blocks
|
// Skipping vanilla air & ignored blocks
|
||||||
if (block == Blocks.air || Dictionary.BLOCKS_LEFTBEHIND.contains(block)) {
|
if (block == Blocks.air || Dictionary.BLOCKS_LEFTBEHIND.contains(block)) {
|
||||||
|
@ -336,11 +336,11 @@ public class JumpShip {
|
||||||
final TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
|
final TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
|
||||||
final JumpBlock jumpBlock = new JumpBlock(worldObj, x, y, z, block, blockMeta, tileEntity);
|
final JumpBlock jumpBlock = new JumpBlock(worldObj, x, y, z, block, blockMeta, tileEntity);
|
||||||
|
|
||||||
if (jumpBlock.blockTileEntity != null && jumpBlock.externals != null) {
|
if (tileEntity != null && jumpBlock.externals != null) {
|
||||||
for (final Entry<String, NBTBase> external : jumpBlock.externals.entrySet()) {
|
for (final Entry<String, NBTBase> external : jumpBlock.externals.entrySet()) {
|
||||||
IBlockTransformer blockTransformer = WarpDriveConfig.blockTransformers.get(external.getKey());
|
final IBlockTransformer blockTransformer = WarpDriveConfig.blockTransformers.get(external.getKey());
|
||||||
if (blockTransformer != null) {
|
if (blockTransformer != null) {
|
||||||
if (!blockTransformer.isJumpReady(jumpBlock.block, jumpBlock.blockMeta, jumpBlock.blockTileEntity, reason)) {
|
if (!blockTransformer.isJumpReady(jumpBlock.block, jumpBlock.blockMeta, tileEntity, reason)) {
|
||||||
if (reason.length() > 0) {
|
if (reason.length() > 0) {
|
||||||
reason.append("\n");
|
reason.append("\n");
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ public class JumpShip {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actualMass = newMass;
|
actualMass = newMass;
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
final String msg = String.format("Exception while saving ship, probably a corrupted block at (%d %d %d).",
|
final String msg = String.format("Exception while saving ship, probably a corrupted block at (%d %d %d).",
|
||||||
vPosition.x, vPosition.y, vPosition.z);
|
vPosition.x, vPosition.y, vPosition.z);
|
||||||
|
@ -395,7 +395,7 @@ public class JumpShip {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
public void readFromNBT(final NBTTagCompound tagCompound) {
|
||||||
coreX = tagCompound.getInteger("coreX");
|
coreX = tagCompound.getInteger("coreX");
|
||||||
coreY = tagCompound.getInteger("coreY");
|
coreY = tagCompound.getInteger("coreY");
|
||||||
coreZ = tagCompound.getInteger("coreZ");
|
coreZ = tagCompound.getInteger("coreZ");
|
||||||
|
@ -430,7 +430,7 @@ public class JumpShip {
|
||||||
tagCompound.setInteger("minY", minY);
|
tagCompound.setInteger("minY", minY);
|
||||||
tagCompound.setInteger("actualMass", actualMass);
|
tagCompound.setInteger("actualMass", actualMass);
|
||||||
final NBTTagList tagListJumpBlocks = new NBTTagList();
|
final NBTTagList tagListJumpBlocks = new NBTTagList();
|
||||||
for (JumpBlock jumpBlock : jumpBlocks) {
|
for (final JumpBlock jumpBlock : jumpBlocks) {
|
||||||
final NBTTagCompound tagCompoundBlock = new NBTTagCompound();
|
final NBTTagCompound tagCompoundBlock = new NBTTagCompound();
|
||||||
jumpBlock.writeToNBT(tagCompoundBlock);
|
jumpBlock.writeToNBT(tagCompoundBlock);
|
||||||
tagListJumpBlocks.appendTag(tagCompoundBlock);
|
tagListJumpBlocks.appendTag(tagCompoundBlock);
|
||||||
|
|
|
@ -189,7 +189,9 @@ public class StateAir {
|
||||||
public boolean setAirSource(final World world, final ForgeDirection direction, final short pressure) {
|
public boolean setAirSource(final World world, final ForgeDirection direction, final short pressure) {
|
||||||
assert(block != null);
|
assert(block != null);
|
||||||
|
|
||||||
final boolean isPlaceable = (dataAir & BLOCK_MASK) == BLOCK_AIR_PLACEABLE || (dataAir & BLOCK_MASK) == BLOCK_AIR_FLOW || (dataAir & BLOCK_MASK) == BLOCK_AIR_SOURCE;
|
final boolean isPlaceable = (dataAir & BLOCK_MASK) == BLOCK_AIR_PLACEABLE
|
||||||
|
|| (dataAir & BLOCK_MASK) == BLOCK_AIR_FLOW
|
||||||
|
|| (dataAir & BLOCK_MASK) == BLOCK_AIR_SOURCE;
|
||||||
final boolean updateRequired = (block != WarpDrive.blockAirSource)
|
final boolean updateRequired = (block != WarpDrive.blockAirSource)
|
||||||
|| pressureGenerator != pressure
|
|| pressureGenerator != pressure
|
||||||
|| pressureVoid != 0
|
|| pressureVoid != 0
|
||||||
|
@ -202,7 +204,7 @@ public class StateAir {
|
||||||
updateBlockType(world);
|
updateBlockType(world);
|
||||||
try {
|
try {
|
||||||
setGeneratorAndUpdateVoid(world, pressure, direction.getOpposite());
|
setGeneratorAndUpdateVoid(world, pressure, direction.getOpposite());
|
||||||
} catch (ExceptionChunkNotLoaded exceptionChunkNotLoaded) {
|
} catch (final ExceptionChunkNotLoaded exceptionChunkNotLoaded) {
|
||||||
// no operation
|
// no operation
|
||||||
}
|
}
|
||||||
setConcentration(world, (byte) CONCENTRATION_MAX);
|
setConcentration(world, (byte) CONCENTRATION_MAX);
|
||||||
|
@ -512,7 +514,7 @@ public class StateAir {
|
||||||
for (int dy = -1; dy <= 1; dy++) {
|
for (int dy = -1; dy <= 1; dy++) {
|
||||||
for (int dz = -1; dz <= 1; dz++) {
|
for (int dz = -1; dz <= 1; dz++) {
|
||||||
for (int dx = -1; dx <= 1; dx++) {
|
for (int dx = -1; dx <= 1; dx++) {
|
||||||
StateAir stateAir = new StateAir(null);
|
final StateAir stateAir = new StateAir(null);
|
||||||
stateAir.refresh(entityPlayer.worldObj,
|
stateAir.refresh(entityPlayer.worldObj,
|
||||||
MathHelper.floor_double(entityPlayer.posX) + dx,
|
MathHelper.floor_double(entityPlayer.posX) + dx,
|
||||||
MathHelper.floor_double(entityPlayer.posY) + dy,
|
MathHelper.floor_double(entityPlayer.posY) + dy,
|
||||||
|
@ -527,20 +529,20 @@ public class StateAir {
|
||||||
for (int indexZ = 2; indexZ >= 0; indexZ--) {
|
for (int indexZ = 2; indexZ >= 0; indexZ--) {
|
||||||
message.append("\n");
|
message.append("\n");
|
||||||
for (int indexX = 0; indexX <= 2; indexX++) {
|
for (int indexX = 0; indexX <= 2; indexX++) {
|
||||||
StateAir stateAir = stateAirs[indexX][indexY][indexZ];
|
final StateAir stateAir = stateAirs[indexX][indexY][indexZ];
|
||||||
final String stringValue = String.format("%2d", 100 + stateAir.concentration).substring(1);
|
final String stringValue = String.format("%2d", 100 + stateAir.concentration).substring(1);
|
||||||
message.append(String.format("§3%s ", stringValue));
|
message.append(String.format("§3%s ", stringValue));
|
||||||
}
|
}
|
||||||
message.append("§f| ");
|
message.append("§f| ");
|
||||||
for (int indexX = 0; indexX <= 2; indexX++) {
|
for (int indexX = 0; indexX <= 2; indexX++) {
|
||||||
StateAir stateAir = stateAirs[indexX][indexY][indexZ];
|
final StateAir stateAir = stateAirs[indexX][indexY][indexZ];
|
||||||
final String stringValue = String.format("%X", 0x100 + stateAir.pressureGenerator).substring(1);
|
final String stringValue = String.format("%X", 0x100 + stateAir.pressureGenerator).substring(1);
|
||||||
final String stringDirection = directionToChar(stateAir.directionGenerator);
|
final String stringDirection = directionToChar(stateAir.directionGenerator);
|
||||||
message.append(String.format("§e%s §a%s ", stringValue, stringDirection));
|
message.append(String.format("§e%s §a%s ", stringValue, stringDirection));
|
||||||
}
|
}
|
||||||
message.append("§f| ");
|
message.append("§f| ");
|
||||||
for (int indexX = 0; indexX <= 2; indexX++) {
|
for (int indexX = 0; indexX <= 2; indexX++) {
|
||||||
StateAir stateAir = stateAirs[indexX][indexY][indexZ];
|
final StateAir stateAir = stateAirs[indexX][indexY][indexZ];
|
||||||
final String stringValue = String.format("%X", 0x100 + stateAir.pressureVoid).substring(1);
|
final String stringValue = String.format("%X", 0x100 + stateAir.pressureVoid).substring(1);
|
||||||
final String stringDirection = directionToChar(stateAir.directionVoid);
|
final String stringDirection = directionToChar(stateAir.directionVoid);
|
||||||
message.append(String.format("§e%s §d%s ", stringValue, stringDirection));
|
message.append(String.format("§e%s §d%s ", stringValue, stringDirection));
|
||||||
|
@ -551,7 +553,7 @@ public class StateAir {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Commons.addChatMessage(entityPlayer, message.toString());
|
Commons.addChatMessage(entityPlayer, message.toString());
|
||||||
} catch (ExceptionChunkNotLoaded exceptionChunkNotLoaded) {
|
} catch (final ExceptionChunkNotLoaded exceptionChunkNotLoaded) {
|
||||||
// no operation
|
// no operation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable(String reason) {
|
public void disable(final String reason) {
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ship.minY < 0 || ship.maxY > 255) {
|
if (ship.minY < 0 || ship.maxY > 255) {
|
||||||
String msg = "Invalid Y coordinate(s), check ship dimensions...";
|
final String msg = "Invalid Y coordinate(s), check ship dimensions...";
|
||||||
ship.messageToAllPlayersOnShip(msg);
|
ship.messageToAllPlayersOnShip(msg);
|
||||||
disable(msg);
|
disable(msg);
|
||||||
return true;
|
return true;
|
||||||
|
@ -299,7 +299,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
String msg = "Invalid state, aborting jump...";
|
final String msg = "Invalid state, aborting jump...";
|
||||||
ship.messageToAllPlayersOnShip(msg);
|
ship.messageToAllPlayersOnShip(msg);
|
||||||
disable(msg);
|
disable(msg);
|
||||||
return true;
|
return true;
|
||||||
|
@ -307,7 +307,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean forceSourceChunks(StringBuilder reason) {
|
private boolean forceSourceChunks(final StringBuilder reason) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " Forcing source chunks in " + sourceWorld.provider.getDimensionName());
|
WarpDrive.logger.info(this + " Forcing source chunks in " + sourceWorld.provider.getDimensionName());
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean forceTargetChunks(StringBuilder reason) {
|
private boolean forceTargetChunks(final StringBuilder reason) {
|
||||||
LocalProfiler.start("Jump.forceTargetChunks");
|
LocalProfiler.start("Jump.forceTargetChunks");
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " Forcing target chunks in " + targetWorld.provider.getDimensionName());
|
WarpDrive.logger.info(this + " Forcing target chunks in " + targetWorld.provider.getDimensionName());
|
||||||
|
@ -415,10 +415,10 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
protected void state_chunkLoadingSource() {
|
protected void state_chunkLoadingSource() {
|
||||||
LocalProfiler.start("Jump.chunkLoadingSource");
|
LocalProfiler.start("Jump.chunkLoadingSource");
|
||||||
|
|
||||||
StringBuilder reason = new StringBuilder();
|
final StringBuilder reason = new StringBuilder();
|
||||||
|
|
||||||
if (!forceSourceChunks(reason)) {
|
if (!forceSourceChunks(reason)) {
|
||||||
String msg = reason.toString();
|
final String msg = reason.toString();
|
||||||
disable(msg);
|
disable(msg);
|
||||||
ship.messageToAllPlayersOnShip(msg);
|
ship.messageToAllPlayersOnShip(msg);
|
||||||
LocalProfiler.stop();
|
LocalProfiler.stop();
|
||||||
|
@ -479,7 +479,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
final String shipName = ship.shipCore.shipName.replaceAll("[^ -~]", "").replaceAll("[:/\\\\]", "");
|
final String shipName = ship.shipCore.shipName.replaceAll("[^ -~]", "").replaceAll("[:/\\\\]", "");
|
||||||
String schematicFileName;
|
String schematicFileName;
|
||||||
do {
|
do {
|
||||||
Date now = new Date();
|
final Date now = new Date();
|
||||||
schematicFileName = WarpDriveConfig.G_SCHEMALOCATION + "/auto/" + shipName + "_" + sdfDate.format(now) + ".schematic";
|
schematicFileName = WarpDriveConfig.G_SCHEMALOCATION + "/auto/" + shipName + "_" + sdfDate.format(now) + ".schematic";
|
||||||
} while (new File(schematicFileName).exists());
|
} while (new File(schematicFileName).exists());
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP && WarpDrive.isDev) {
|
if (WarpDriveConfig.LOGGING_JUMP && WarpDrive.isDev) {
|
||||||
WarpDrive.logger.info(this + " Ship saved as " + schematicFileName);
|
WarpDrive.logger.info(this + " Ship saved as " + schematicFileName);
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -594,8 +594,8 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not check in long jumps
|
// Do not check in long jumps
|
||||||
int rangeX = Math.abs(moveX) - (ship.maxX - ship.minX);
|
final int rangeX = Math.abs(moveX) - (ship.maxX - ship.minX);
|
||||||
int rangeZ = Math.abs(moveZ) - (ship.maxZ - ship.minZ);
|
final int rangeZ = Math.abs(moveZ) - (ship.maxZ - ship.minZ);
|
||||||
if (Math.max(rangeX, rangeZ) < 256) {
|
if (Math.max(rangeX, rangeZ) < 256) {
|
||||||
firstAdjustmentReason = getPossibleJumpDistance();
|
firstAdjustmentReason = getPossibleJumpDistance();
|
||||||
isPluginCheckDone = true;
|
isPluginCheckDone = true;
|
||||||
|
@ -629,7 +629,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
doCollisionDamage(false);
|
doCollisionDamage(false);
|
||||||
|
|
||||||
// cancel jump
|
// cancel jump
|
||||||
String msg;
|
final String msg;
|
||||||
if (firstAdjustmentReason == null || firstAdjustmentReason.isEmpty()) {
|
if (firstAdjustmentReason == null || firstAdjustmentReason.isEmpty()) {
|
||||||
msg = "Source and target areas are overlapping, jump aborted! Try increasing jump distance...";
|
msg = "Source and target areas are overlapping, jump aborted! Try increasing jump distance...";
|
||||||
} else {
|
} else {
|
||||||
|
@ -642,7 +642,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check world border
|
// Check world border
|
||||||
CelestialObject celestialObjectTarget = CelestialObjectManager.get(targetWorld, (int) aabbTarget.minX, (int) aabbTarget.minZ);
|
final CelestialObject celestialObjectTarget = CelestialObjectManager.get(targetWorld, (int) aabbTarget.minX, (int) aabbTarget.minZ);
|
||||||
if (celestialObjectTarget == null) {
|
if (celestialObjectTarget == null) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.error(String.format("There's no world border defined for dimension %s (%d)",
|
WarpDrive.logger.error(String.format("There's no world border defined for dimension %s (%d)",
|
||||||
|
@ -668,7 +668,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
if (!isPluginCheckDone) {
|
if (!isPluginCheckDone) {
|
||||||
final CheckMovementResult checkMovementResult = checkCollisionAndProtection(transformation, true, "target");
|
final CheckMovementResult checkMovementResult = checkCollisionAndProtection(transformation, true, "target");
|
||||||
if (checkMovementResult != null) {
|
if (checkMovementResult != null) {
|
||||||
String msg = checkMovementResult.reason + "\nJump aborted!";
|
final String msg = checkMovementResult.reason + "\nJump aborted!";
|
||||||
disable(msg);
|
disable(msg);
|
||||||
ship.messageToAllPlayersOnShip(msg);
|
ship.messageToAllPlayersOnShip(msg);
|
||||||
LocalProfiler.stop();
|
LocalProfiler.stop();
|
||||||
|
@ -763,7 +763,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HYPERSPACE_EXITING: {
|
case HYPERSPACE_EXITING: {
|
||||||
CelestialObject celestialObject = CelestialObjectManager.getClosestChild(sourceWorld, ship.coreX, ship.coreZ);
|
final CelestialObject celestialObject = CelestialObjectManager.getClosestChild(sourceWorld, ship.coreX, ship.coreZ);
|
||||||
// anything defined?
|
// anything defined?
|
||||||
if (celestialObject == null) {
|
if (celestialObject == null) {
|
||||||
reason.append(String.format("Unable to reach space from this location!\nThere's no celestial object defined for current dimension %s (%d).",
|
reason.append(String.format("Unable to reach space from this location!\nThere's no celestial object defined for current dimension %s (%d).",
|
||||||
|
@ -774,7 +774,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
// are we clear for transit?
|
// are we clear for transit?
|
||||||
final double distanceSquared = celestialObject.getSquareDistanceInParent(sourceWorld.provider.dimensionId, ship.coreX, ship.coreZ);
|
final double distanceSquared = celestialObject.getSquareDistanceInParent(sourceWorld.provider.dimensionId, ship.coreX, ship.coreZ);
|
||||||
if (distanceSquared > 0.0D) {
|
if (distanceSquared > 0.0D) {
|
||||||
AxisAlignedBB axisAlignedBB = celestialObject.getAreaInParent();
|
final AxisAlignedBB axisAlignedBB = celestialObject.getAreaInParent();
|
||||||
reason.append(String.format(
|
reason.append(String.format(
|
||||||
"Ship is outside any solar system, unable to reach space!\n"
|
"Ship is outside any solar system, unable to reach space!\n"
|
||||||
+ "Closest transition area is ~%d m away (%d %d %d) to (%d %d %d).",
|
+ "Closest transition area is ~%d m away (%d %d %d) to (%d %d %d).",
|
||||||
|
@ -873,7 +873,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
// are we in orbit?
|
// are we in orbit?
|
||||||
final double distanceSquared = celestialObject.getSquareDistanceInParent(sourceWorld.provider.dimensionId, ship.coreX, ship.coreZ);
|
final double distanceSquared = celestialObject.getSquareDistanceInParent(sourceWorld.provider.dimensionId, ship.coreX, ship.coreZ);
|
||||||
if (distanceSquared > 0.0D) {
|
if (distanceSquared > 0.0D) {
|
||||||
AxisAlignedBB axisAlignedBB = celestialObject.getAreaInParent();
|
final AxisAlignedBB axisAlignedBB = celestialObject.getAreaInParent();
|
||||||
reason.append(String.format(
|
reason.append(String.format(
|
||||||
"No planet in range, unable to enter atmosphere!\n"
|
"No planet in range, unable to enter atmosphere!\n"
|
||||||
+ "Closest planet is %d m away (%d %d %d) to (%d %d %d).",
|
+ "Closest planet is %d m away (%d %d %d) to (%d %d %d).",
|
||||||
|
@ -1028,7 +1028,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
|
|
||||||
protected void state_moveExternals() {
|
protected void state_moveExternals() {
|
||||||
LocalProfiler.start("Jump.moveExternals");
|
LocalProfiler.start("Jump.moveExternals");
|
||||||
int blocksToMove = Math.min(blocksPerTick, ship.jumpBlocks.length - actualIndexInShip);
|
final int blocksToMove = Math.min(blocksPerTick, ship.jumpBlocks.length - actualIndexInShip);
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " Moving ship externals from " + actualIndexInShip + " / " + (ship.jumpBlocks.length - 1));
|
WarpDrive.logger.info(this + " Moving ship externals from " + actualIndexInShip + " / " + (ship.jumpBlocks.length - 1));
|
||||||
}
|
}
|
||||||
|
@ -1119,7 +1119,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
|
|
||||||
protected void state_removeBlocks() {
|
protected void state_removeBlocks() {
|
||||||
LocalProfiler.start("Jump.removeBlocks");
|
LocalProfiler.start("Jump.removeBlocks");
|
||||||
int blocksToMove = Math.min(blocksPerTick, ship.jumpBlocks.length - actualIndexInShip);
|
final int blocksToMove = Math.min(blocksPerTick, ship.jumpBlocks.length - actualIndexInShip);
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " Removing ship blocks " + actualIndexInShip + " to " + (actualIndexInShip + blocksToMove - 1) + " / " + (ship.jumpBlocks.length - 1));
|
WarpDrive.logger.info(this + " Removing ship blocks " + actualIndexInShip + " to " + (actualIndexInShip + blocksToMove - 1) + " / " + (ship.jumpBlocks.length - 1));
|
||||||
}
|
}
|
||||||
|
@ -1148,7 +1148,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
JumpBlock.setBlockNoLight(sourceWorld, jumpBlock.x, jumpBlock.y, jumpBlock.z, Blocks.air, 0, 2);
|
JumpBlock.setBlockNoLight(sourceWorld, jumpBlock.x, jumpBlock.y, jumpBlock.z, Blocks.air, 0, 2);
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
WarpDrive.logger.info("Exception while removing " + jumpBlock.block + "@" + jumpBlock.blockMeta + " at " + jumpBlock.x + " " + jumpBlock.y + " " + jumpBlock.z);
|
WarpDrive.logger.info("Exception while removing " + jumpBlock.block + "@" + jumpBlock.blockMeta + " at " + jumpBlock.x + " " + jumpBlock.y + " " + jumpBlock.z);
|
||||||
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
|
@ -1186,7 +1186,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
targetWorld.loadedTileEntityList = removeDuplicates(targetWorld.loadedTileEntityList);
|
targetWorld.loadedTileEntityList = removeDuplicates(targetWorld.loadedTileEntityList);
|
||||||
} catch (Exception exception) {
|
} catch (final Exception exception) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info("TE Duplicates removing exception: " + exception.getMessage());
|
WarpDrive.logger.info("TE Duplicates removing exception: " + exception.getMessage());
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
|
@ -1210,7 +1210,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " Calculating possible jump distance...");
|
WarpDrive.logger.info(this + " Calculating possible jump distance...");
|
||||||
}
|
}
|
||||||
int originalRange = Math.max(Math.abs(moveX), Math.max(Math.abs(moveY), Math.abs(moveZ)));
|
final int originalRange = Math.max(Math.abs(moveX), Math.max(Math.abs(moveY), Math.abs(moveZ)));
|
||||||
int testRange = originalRange;
|
int testRange = originalRange;
|
||||||
int blowPoints = 0;
|
int blowPoints = 0;
|
||||||
collisionDetected = false;
|
collisionDetected = false;
|
||||||
|
@ -1232,7 +1232,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
testRange--;
|
testRange--;
|
||||||
}
|
}
|
||||||
VectorI finalMovement = getMovementVector(testRange / (double)originalRange);
|
final VectorI finalMovement = getMovementVector(testRange / (double)originalRange);
|
||||||
|
|
||||||
if (originalRange != testRange && WarpDriveConfig.LOGGING_JUMP) {
|
if (originalRange != testRange && WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " Jump range adjusted from " + originalRange + " to " + testRange + " after " + blowPoints + " collisions");
|
WarpDrive.logger.info(this + " Jump range adjusted from " + originalRange + " to " + testRange + " after " + blowPoints + " collisions");
|
||||||
|
@ -1251,7 +1251,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
* Wither boom = 5
|
* Wither boom = 5
|
||||||
* Endercrystal = 6
|
* Endercrystal = 6
|
||||||
*/
|
*/
|
||||||
float massCorrection = 0.5F
|
final float massCorrection = 0.5F
|
||||||
+ (float) Math.sqrt(Math.min(1.0D, Math.max(0.0D, ship.shipCore.shipMass - WarpDriveConfig.SHIP_VOLUME_MAX_ON_PLANET_SURFACE)
|
+ (float) Math.sqrt(Math.min(1.0D, Math.max(0.0D, ship.shipCore.shipMass - WarpDriveConfig.SHIP_VOLUME_MAX_ON_PLANET_SURFACE)
|
||||||
/ WarpDriveConfig.SHIP_VOLUME_MIN_FOR_HYPERSPACE));
|
/ WarpDriveConfig.SHIP_VOLUME_MIN_FOR_HYPERSPACE));
|
||||||
collisionDetected = true;
|
collisionDetected = true;
|
||||||
|
@ -1273,17 +1273,17 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
return firstAdjustmentReason;
|
return firstAdjustmentReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doCollisionDamage(boolean atTarget) {
|
private void doCollisionDamage(final boolean atTarget) {
|
||||||
if (!collisionDetected) {
|
if (!collisionDetected) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info(this + " doCollisionDamage No collision detected...");
|
WarpDrive.logger.info(this + " doCollisionDamage No collision detected...");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList<Vector3> collisionPoints = atTarget ? collisionAtTarget : collisionAtSource;
|
final ArrayList<Vector3> collisionPoints = atTarget ? collisionAtTarget : collisionAtSource;
|
||||||
Vector3 min = collisionPoints.get(0).clone();
|
final Vector3 min = collisionPoints.get(0).clone();
|
||||||
Vector3 max = collisionPoints.get(0).clone();
|
final Vector3 max = collisionPoints.get(0).clone();
|
||||||
for (Vector3 v : collisionPoints) {
|
for (final Vector3 v : collisionPoints) {
|
||||||
if (min.x > v.x) {
|
if (min.x > v.x) {
|
||||||
min.x = v.x;
|
min.x = v.x;
|
||||||
} else if (max.x < v.x) {
|
} else if (max.x < v.x) {
|
||||||
|
@ -1305,19 +1305,19 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// inform players on board
|
// inform players on board
|
||||||
double rx = Math.round(min.x + sourceWorld.rand.nextInt(Math.max(1, (int) (max.x - min.x))));
|
final double rx = Math.round(min.x + sourceWorld.rand.nextInt(Math.max(1, (int) (max.x - min.x))));
|
||||||
double ry = Math.round(min.y + sourceWorld.rand.nextInt(Math.max(1, (int) (max.y - min.y))));
|
final double ry = Math.round(min.y + sourceWorld.rand.nextInt(Math.max(1, (int) (max.y - min.y))));
|
||||||
double rz = Math.round(min.z + sourceWorld.rand.nextInt(Math.max(1, (int) (max.z - min.z))));
|
final double rz = Math.round(min.z + sourceWorld.rand.nextInt(Math.max(1, (int) (max.z - min.z))));
|
||||||
ship.messageToAllPlayersOnShip("Ship collision detected around " + (int) rx + ", " + (int) ry + ", " + (int) rz + ". Damage report pending...");
|
ship.messageToAllPlayersOnShip("Ship collision detected around " + (int) rx + ", " + (int) ry + ", " + (int) rz + ". Damage report pending...");
|
||||||
|
|
||||||
// randomize if too many collision points
|
// randomize if too many collision points
|
||||||
int nbExplosions = Math.min(5, collisionPoints.size());
|
final int nbExplosions = Math.min(5, collisionPoints.size());
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info("doCollisionDamage nbExplosions " + nbExplosions + "/" + collisionPoints.size());
|
WarpDrive.logger.info("doCollisionDamage nbExplosions " + nbExplosions + "/" + collisionPoints.size());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nbExplosions; i++) {
|
for (int i = 0; i < nbExplosions; i++) {
|
||||||
// get location
|
// get location
|
||||||
Vector3 current;
|
final Vector3 current;
|
||||||
if (nbExplosions < collisionPoints.size()) {
|
if (nbExplosions < collisionPoints.size()) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.info("doCollisionDamage random #" + i);
|
WarpDrive.logger.info("doCollisionDamage random #" + i);
|
||||||
|
@ -1331,7 +1331,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute explosion strength with a jitter, at least 1 TNT
|
// compute explosion strength with a jitter, at least 1 TNT
|
||||||
float strength = Math.max(4.0F, collisionStrength / nbExplosions - 2.0F + 2.0F * sourceWorld.rand.nextFloat());
|
final float strength = Math.max(4.0F, collisionStrength / nbExplosions - 2.0F + 2.0F * sourceWorld.rand.nextFloat());
|
||||||
|
|
||||||
(atTarget ? targetWorld : sourceWorld).newExplosion(null, current.x, current.y, current.z, strength, atTarget, atTarget);
|
(atTarget ? targetWorld : sourceWorld).newExplosion(null, current.x, current.y, current.z, strength, atTarget, atTarget);
|
||||||
WarpDrive.logger.info("Ship collision caused explosion at " + current.x + " " + current.y + " " + current.z + " with strength " + strength);
|
WarpDrive.logger.info("Ship collision caused explosion at " + current.x + " " + current.y + " " + current.z + " with strength " + strength);
|
||||||
|
@ -1384,7 +1384,9 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
reason = "Unknown reason";
|
reason = "Unknown reason";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(double sx, double sy, double sz, double tx, double ty, double tz, boolean pisCollision, String preason) {
|
public void add(final double sx, final double sy, final double sz,
|
||||||
|
final double tx, final double ty, final double tz,
|
||||||
|
final boolean pisCollision, final String preason) {
|
||||||
atSource.add(new Vector3(sx, sy, sz));
|
atSource.add(new Vector3(sx, sy, sz));
|
||||||
atTarget.add(new Vector3(tx, ty, tz));
|
atTarget.add(new Vector3(tx, ty, tz));
|
||||||
isCollision = isCollision || pisCollision;
|
isCollision = isCollision || pisCollision;
|
||||||
|
@ -1395,13 +1397,13 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckMovementResult checkCollisionAndProtection(ITransformation transformation, final boolean fullCollisionDetails, final String context) {
|
private CheckMovementResult checkCollisionAndProtection(final ITransformation transformation, final boolean fullCollisionDetails, final String context) {
|
||||||
final CheckMovementResult result = new CheckMovementResult();
|
final CheckMovementResult result = new CheckMovementResult();
|
||||||
final VectorI offset = new VectorI((int) Math.signum(moveX), (int) Math.signum(moveY), (int) Math.signum(moveZ));
|
final VectorI offset = new VectorI((int) Math.signum(moveX), (int) Math.signum(moveY), (int) Math.signum(moveZ));
|
||||||
|
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
ChunkCoordinates coordTarget;
|
ChunkCoordinates coordTarget;
|
||||||
ChunkCoordinates coordCoreAtTarget = transformation.apply(ship.coreX, ship.coreY, ship.coreZ);
|
final ChunkCoordinates coordCoreAtTarget = transformation.apply(ship.coreX, ship.coreY, ship.coreZ);
|
||||||
Block blockSource;
|
Block blockSource;
|
||||||
Block blockTarget;
|
Block blockTarget;
|
||||||
for (y = ship.minY; y <= ship.maxY; y++) {
|
for (y = ship.minY; y <= ship.maxY; y++) {
|
||||||
|
@ -1467,8 +1469,8 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private CheckMovementResult checkMovement(final double ratio, final boolean fullCollisionDetails) {
|
private CheckMovementResult checkMovement(final double ratio, final boolean fullCollisionDetails) {
|
||||||
CheckMovementResult result = new CheckMovementResult();
|
final CheckMovementResult result = new CheckMovementResult();
|
||||||
VectorI testMovement = getMovementVector(ratio);
|
final VectorI testMovement = getMovementVector(ratio);
|
||||||
if ((moveY > 0 && ship.maxY + testMovement.y > 255) && !betweenWorlds) {
|
if ((moveY > 0 && ship.maxY + testMovement.y > 255) && !betweenWorlds) {
|
||||||
result.add(ship.coreX, ship.maxY + testMovement.y,
|
result.add(ship.coreX, ship.maxY + testMovement.y,
|
||||||
ship.coreZ, ship.coreX + 0.5D,
|
ship.coreZ, ship.coreX + 0.5D,
|
||||||
|
@ -1487,7 +1489,7 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITransformation testTransformation = new Transformation(ship, targetWorld, testMovement.x, testMovement.y, testMovement.z, rotationSteps);
|
final ITransformation testTransformation = new Transformation(ship, targetWorld, testMovement.x, testMovement.y, testMovement.z, rotationSteps);
|
||||||
return checkCollisionAndProtection(testTransformation, fullCollisionDetails, "ratio " + ratio + " testMovement " + testMovement);
|
return checkCollisionAndProtection(testTransformation, fullCollisionDetails, "ratio " + ratio + " testMovement " + testMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1495,11 +1497,11 @@ public class JumpSequencer extends AbstractSequencer {
|
||||||
return new VectorI((int)Math.round(moveX * ratio), (int)Math.round(moveY * ratio), (int)Math.round(moveZ * ratio));
|
return new VectorI((int)Math.round(moveX * ratio), (int)Math.round(moveY * ratio), (int)Math.round(moveZ * ratio));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<Object> removeDuplicates(List<TileEntity> l) {
|
private static ArrayList<Object> removeDuplicates(final List<TileEntity> l) {
|
||||||
@SuppressWarnings("Convert2Lambda")
|
@SuppressWarnings("Convert2Lambda")
|
||||||
Set<TileEntity> s = new TreeSet<>(new Comparator<TileEntity>() {
|
final Set<TileEntity> s = new TreeSet<>(new Comparator<TileEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(TileEntity o1, TileEntity o2) {
|
public int compare(final TileEntity o1, final TileEntity o2) {
|
||||||
if (o1.xCoord == o2.xCoord && o1.yCoord == o2.yCoord && o1.zCoord == o2.zCoord) {
|
if (o1.xCoord == o2.xCoord && o1.yCoord == o2.yCoord && o1.zCoord == o2.zCoord) {
|
||||||
if (WarpDriveConfig.LOGGING_JUMP) {
|
if (WarpDriveConfig.LOGGING_JUMP) {
|
||||||
WarpDrive.logger.warn(String.format("Removing TE duplicates: detected duplicate in %s @ %d %d %d: %s vs %s",
|
WarpDrive.logger.warn(String.format("Removing TE duplicates: detected duplicate in %s @ %d %d %d: %s vs %s",
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class WorldGenStructure {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateFromFile(final World world, final String filename, final int targetX, final int targetY, final int targetZ, final byte rotationSteps) {
|
public void generateFromFile(final World world, final String filename, final int targetX, final int targetY, final int targetZ, final byte rotationSteps) {
|
||||||
StringBuilder reason = new StringBuilder();
|
final StringBuilder reason = new StringBuilder();
|
||||||
final JumpShip jumpShip = JumpShip.createFromFile(filename, reason);
|
final JumpShip jumpShip = JumpShip.createFromFile(filename, reason);
|
||||||
if (jumpShip == null) {
|
if (jumpShip == null) {
|
||||||
WarpDrive.logger.error(String.format("%s Failed to read schematic %s: %s", this, filename, reason.toString()));
|
WarpDrive.logger.error(String.format("%s Failed to read schematic %s: %s", this, filename, reason.toString()));
|
||||||
|
@ -190,10 +190,10 @@ public class WorldGenStructure {
|
||||||
|
|
||||||
public void deployShip(final World world, final JumpShip jumpShip, final int targetX, final int targetY, final int targetZ, final byte rotationSteps) {
|
public void deployShip(final World world, final JumpShip jumpShip, final int targetX, final int targetY, final int targetZ, final byte rotationSteps) {
|
||||||
|
|
||||||
Transformation transformation = new Transformation(jumpShip, world, targetX - jumpShip.coreX, targetY - jumpShip.coreY, targetZ - jumpShip.coreZ, rotationSteps);
|
final Transformation transformation = new Transformation(jumpShip, world, targetX - jumpShip.coreX, targetY - jumpShip.coreY, targetZ - jumpShip.coreZ, rotationSteps);
|
||||||
for (int index = 0; index < jumpShip.jumpBlocks.length; index++) {
|
for (int index = 0; index < jumpShip.jumpBlocks.length; index++) {
|
||||||
// Deploy single block
|
// Deploy single block
|
||||||
JumpBlock jumpBlock = jumpShip.jumpBlocks[index];
|
final JumpBlock jumpBlock = jumpShip.jumpBlocks[index];
|
||||||
|
|
||||||
if (jumpBlock == null) {
|
if (jumpBlock == null) {
|
||||||
if (WarpDriveConfig.LOGGING_BUILDING) {
|
if (WarpDriveConfig.LOGGING_BUILDING) {
|
||||||
|
@ -213,8 +213,8 @@ public class WorldGenStructure {
|
||||||
WarpDrive.logger.info("At index " + index + ", deploying block " + Block.blockRegistry.getNameForObject(jumpBlock.block) + ":" + jumpBlock.blockMeta
|
WarpDrive.logger.info("At index " + index + ", deploying block " + Block.blockRegistry.getNameForObject(jumpBlock.block) + ":" + jumpBlock.blockMeta
|
||||||
+ " tileEntity " + jumpBlock.blockTileEntity + " NBT " + jumpBlock.blockNBT);
|
+ " tileEntity " + jumpBlock.blockTileEntity + " NBT " + jumpBlock.blockNBT);
|
||||||
}
|
}
|
||||||
ChunkCoordinates targetLocation = transformation.apply(jumpBlock.x, jumpBlock.y, jumpBlock.z);
|
final ChunkCoordinates targetLocation = transformation.apply(jumpBlock.x, jumpBlock.y, jumpBlock.z);
|
||||||
Block blockAtTarget = world.getBlock(targetLocation.posX, targetLocation.posY, targetLocation.posZ);
|
final Block blockAtTarget = world.getBlock(targetLocation.posX, targetLocation.posY, targetLocation.posZ);
|
||||||
if (blockAtTarget == Blocks.air || Dictionary.BLOCKS_EXPANDABLE.contains(blockAtTarget)) {
|
if (blockAtTarget == Blocks.air || Dictionary.BLOCKS_EXPANDABLE.contains(blockAtTarget)) {
|
||||||
jumpBlock.deploy(world, transformation);
|
jumpBlock.deploy(world, transformation);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue