Code cleanup

This commit is contained in:
Unknown 2018-12-18 13:08:42 +01:00 committed by unknown
parent 636fc2396a
commit ec0b631620
9 changed files with 42 additions and 48 deletions

View file

@ -358,9 +358,9 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractMachine
}
// ThermalExpansion IEnergyHandler interface
// RedstoneFlux IEnergyReceiver interface
@Override
@Optional.Method(modid = "redstoneflux") /* IEnergyReceiver */
@Optional.Method(modid = "redstoneflux")
public int receiveEnergy(final EnumFacing from, final int maxReceive_RF, final boolean simulate) {
if (WarpDriveConfig.LOGGING_ENERGY) {
WarpDrive.logger.info(this + " [RF]receiveEnergy from " + from + " maxReceive_RF " + maxReceive_RF + " simulate " + simulate);
@ -386,8 +386,9 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractMachine
return toAdd_RF;
}
// RedstoneFlux IEnergyProvider interface
@Override
@Optional.Method(modid = "redstoneflux") /* IEnergyProvider */
@Optional.Method(modid = "redstoneflux")
public int extractEnergy(final EnumFacing from, final int maxExtract_RF, final boolean simulate) {
if (WarpDriveConfig.LOGGING_ENERGY) {
WarpDrive.logger.info(this + " [RF]extractEnergy from " + from + " maxExtract_RF " + maxExtract_RF + " simulate " + simulate);
@ -404,20 +405,22 @@ public abstract class TileEntityAbstractEnergy extends TileEntityAbstractMachine
return convertInternalToRF_floor(energyExtracted_internal);
}
// RedstoneFlux IEnergyConnection interface
@Override
@Optional.Method(modid = "redstoneflux") /* IEnergyConnection */
@Optional.Method(modid = "redstoneflux")
public boolean canConnectEnergy(final EnumFacing from) {
return (energy_getMaxStorage() != 0) && (energy_canInput(from) || energy_canOutput(from)); // Warning: deadlock risk depending on child implementation
}
// RedstoneFlux IEnergyHandler interface
@Override
@Optional.Method(modid = "redstoneflux") /* IEnergyReceiver and IEnergyProvider */
@Optional.Method(modid = "redstoneflux")
public int getEnergyStored(final EnumFacing from) {
return canConnectEnergy(from) ? convertInternalToRF_floor(energy_getEnergyStored()) : 0;
}
@Override
@Optional.Method(modid = "redstoneflux") /* IEnergyReceiver and IEnergyProvider */
@Optional.Method(modid = "redstoneflux")
public int getMaxEnergyStored(final EnumFacing from) {
return canConnectEnergy(from) ? convertInternalToRF_floor(energy_getMaxStorage()) : 0;
}

View file

@ -155,7 +155,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
// Forge overrides
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
public void readFromNBT(final NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
setBounds(tagCompound.getInteger("radiusXneg"), tagCompound.getInteger("radiusXpos"),
@ -192,6 +192,7 @@ public class TileEntityChunkLoader extends TileEntityAbstractChunkLoading {
return new Object[] { radiusXneg, radiusXpos, radiusZneg, radiusZpos };
}
@Override
public Object[] getEnergyRequired() {
return new Object[] { calculateEnergyRequired() };
}

View file

@ -392,7 +392,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
carryPlaceSpeed = floatPlaceSpeed - countMaxPlaced;
// evaluate force field block metadata
IBlockState blockStateForceField;
final IBlockState blockStateForceField;
if (forceFieldSetup.getCamouflageBlockState() == null) {
blockStateForceField = WarpDrive.blockForceFields[enumTier.getIndex()].getStateFromMeta(
Math.min(15, (beamFrequency * 16) / IBeamFrequency.BEAM_FREQUENCY_MAX));

View file

@ -57,7 +57,7 @@ public class BlockShipCore extends BlockAbstractRotatingContainer {
@Nonnull final IBlockState blockState, final int fortune) {
final TileEntity tileEntity = blockAccess.getTileEntity(blockPos);
if (tileEntity instanceof TileEntityShipCore) {
if (((TileEntityShipCore)tileEntity).jumpCount == 0) {
if (((TileEntityShipCore) tileEntity).jumpCount == 0) {
super.getDrops(itemStacks, blockAccess, blockPos, blockState, fortune);
return;
}

View file

@ -116,9 +116,6 @@ public class Dictionary {
config.get("block_tags", "minecraft:portal" , "Anchor StopMining").getString();
config.get("block_tags", "minecraft:repeating_command_block" , "Anchor StopMining").getString();
config.get("block_tags", "minecraft:structure_block" , "Anchor StopMining").getString();
// config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor StopMining NoBlink").getString();
// config.get("block_tags", "Artifacts:anti_anti_builder_stone" , "Anchor StopMining").getString();
// config.get("block_tags", "Artifacts:anti_builder" , "Anchor StopMining").getString();
config.get("block_tags", "computercraft:command_computer" , "Anchor SkipMining").getString();
// @TODO MC1.12 config.get("block_tags", "ic2:blockPersonal" , "Anchor SkipMining").getString(); // IC2 personal chest, need property filtering
// @TODO MC1.12 config.get("block_tags", "malisisdoors:null" , "Anchor").getString(); // improper registration of block causing NPE
@ -182,7 +179,6 @@ public class Dictionary {
config.get("block_tags", "chisel:cloud" , "LeftBehind Expandable").getString();
config.get("block_tags", "railcraft:residual.heat" , "LeftBehind Expandable").getString();
config.get("block_tags", "warpdrive:gas" , "LeftBehind Expandable").getString();
// config.get("block_tags", "InvisibLights:blockLightSource" , "NoMass Expandable").getString();
config.get("block_tags", "warpdrive:air_flow" , "NoMass Expandable PlaceLatest").getString();
config.get("block_tags", "warpdrive:air_source" , "NoMass Expandable PlaceLatest").getString();
config.get("block_tags", "buildcraftcore:marker_path" , "NoMass LeftBehind Expandable").getString(); // depends on an unsupported separate cache
@ -210,8 +206,6 @@ public class Dictionary {
config.get("block_tags", "thermalexpansion:cache" , "NoCamouflage").getString();
config.get("block_tags", "thermalexpansion:device" , "NoCamouflage").getString();
config.get("block_tags", "thermalexpansion:machine" , "NoCamouflage").getString();
// config.get("block_tags", "thermalexpansion:Sponge" , "NoCamouflage").getString(); // not found
// config.get("block_tags", "witchery:leechchest" , "NoCamouflage").getString();
taggedBlocksName = categoryBlockTags.getValues().keySet().toArray(new String[0]);
}

View file

@ -40,13 +40,13 @@ import net.minecraftforge.registries.ForgeRegistry;
*/
public class Recipes {
private static ResourceLocation groupComponents = new ResourceLocation("components");
private static ResourceLocation groupDecorations = new ResourceLocation("decoration");
private static ResourceLocation groupMachines = new ResourceLocation("machines");
private static ResourceLocation groupTools = new ResourceLocation("tools");
private static final ResourceLocation groupComponents = new ResourceLocation("components");
private static final ResourceLocation groupDecorations = new ResourceLocation("decoration");
private static final ResourceLocation groupMachines = new ResourceLocation("machines");
private static final ResourceLocation groupTools = new ResourceLocation("tools");
private static ResourceLocation groupHulls = new ResourceLocation("hulls");
private static ResourceLocation groupTaintedHulls = new ResourceLocation("tainted_hulls");
private static final ResourceLocation groupHulls = new ResourceLocation("hulls");
private static final ResourceLocation groupTaintedHulls = new ResourceLocation("tainted_hulls");
public static final HashMap<EnumDyeColor, String> oreDyes = new HashMap<>(16);
static {
@ -98,7 +98,7 @@ public class Recipes {
registerOreDictionary("blockVoidShell", new ItemStack(WarpDrive.blockVoidShellPlain, 1));
registerOreDictionary("blockVoidShell", new ItemStack(WarpDrive.blockVoidShellGlass, 1));
for (int tier = 1; tier <= 3; tier++) {
int index = tier - 1;
final int index = tier - 1;
registerOreDictionary("blockElectromagnet" + tier, new ItemStack(WarpDrive.blockElectromagnets_plain[index], 1));
registerOreDictionary("blockElectromagnet" + tier, new ItemStack(WarpDrive.blockElectromagnets_glass[index], 1));
}
@ -141,10 +141,10 @@ public class Recipes {
private static void initIngredients() {
// Get the machine casing to use
ItemStack itemStackMachineCasingLV;
ItemStack itemStackMachineCasingMV;
ItemStack itemStackMachineCasingHV;
ItemStack itemStackMachineCasingEV;
final ItemStack itemStackMachineCasingLV;
final ItemStack itemStackMachineCasingMV;
final ItemStack itemStackMachineCasingHV;
final ItemStack itemStackMachineCasingEV;
ItemStack itemStackMotorLV = ItemComponent.getItemStack(EnumComponentType.MOTOR);
ItemStack itemStackMotorMV = ItemComponent.getItemStack(EnumComponentType.MOTOR);
ItemStack itemStackMotorHV = ItemComponent.getItemStack(EnumComponentType.MOTOR);
@ -1502,12 +1502,12 @@ public class Recipes {
}
// Tier 2 = 4 Tier 1, 4 GregTech 5 TungstenSteel reinforced block, IC2 Carbon plate, DarkSteel ingots or Obsidian, gives 4
final Object oreObsidianTungstenSteelPlate = WarpDriveConfig.getOreOrItemStack("ore:plateTungstenSteel", 0, // GregTech CE TungstenSteel Plate
"ic2:crafting", 15, // IC2 Carbon plate
"thermalfoundation:glass", 3, // ThermalFoundation Hardened glass
"ore:ingotDarkSteel", 0, // EnderIO DarkSteel ingot
final Object oreObsidianTungstenSteelPlate = WarpDriveConfig.getOreOrItemStack("ore:plateTungstenSteel", 0, // GregTech CE TungstenSteel Plate
"ic2:crafting", 15, // IC2 Carbon plate
"thermalfoundation:glass", 3, // ThermalFoundation Hardened glass
"ore:ingotDarkSteel", 0, // EnderIO DarkSteel ingot
"minecraft:obsidian", 0);
for (EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
for (final EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
final int metadataColor = enumDyeColor.getMetadata();
WarpDrive.register(new ShapedOreRecipe(groupTaintedHulls,
new ItemStack(WarpDrive.blockHulls_plain[EnumTier.ADVANCED.getIndex()][0], 4, metadataColor), false, "cbc", "b b", "cbc",
@ -1521,11 +1521,11 @@ public class Recipes {
}
// Tier 3 = 4 Tier 2, 1 GregTech Naquadah plate, IC2 Iridium plate, EnderIO Pulsating crystal or Diamond, gives 4
final Object oreDiamondOrNaquadahPlate = WarpDriveConfig.getOreOrItemStack("ore:plateNaquadah", 0, // GregTech CE Naquadah plate
"ore:plateAlloyIridium", 0, // IC2 Iridium alloy
"ore:itemPulsatingCrystal", 0, // EnderIO Pulsating crystal
final Object oreDiamondOrNaquadahPlate = WarpDriveConfig.getOreOrItemStack("ore:plateNaquadah", 0, // GregTech CE Naquadah plate
"ore:plateAlloyIridium", 0, // IC2 Iridium alloy
"ore:itemPulsatingCrystal", 0, // EnderIO Pulsating crystal
"ore:gemDiamond", 0);
for (EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
for (final EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
final int metadataColor = enumDyeColor.getMetadata();
WarpDrive.register(new ShapedOreRecipe(groupTaintedHulls,
new ItemStack(WarpDrive.blockHulls_plain[EnumTier.SUPERIOR.getIndex()][0], 4, metadataColor), false, " b ", "bcb", " b ",
@ -1540,8 +1540,8 @@ public class Recipes {
// Hull blocks variation
for (final EnumTier enumTier : EnumTier.nonCreative()) {
int index = enumTier.getIndex();
for (EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
final int index = enumTier.getIndex();
for (final EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
final int metadataColor = enumDyeColor.getMetadata();
// crafting glass

View file

@ -128,15 +128,12 @@ public class WarpDriveConfig {
* The variables which store whether or not individual mods are loaded
*/
public static boolean isAdvancedRepulsionSystemLoaded = false;
public static boolean isAdvancedSolarPanelLoaded = false;
public static boolean isRedstoneFluxLoaded = false;
public static boolean isComputerCraftLoaded = false;
public static boolean isDefenseTechLoaded = false;
public static boolean isEnderIOLoaded = false;
public static boolean isForgeMultipartLoaded = false;
public static boolean isGregTechLoaded = false;
public static boolean isICBMClassicLoaded = false;
public static boolean isImmersiveEngineeringLoaded = false;
public static boolean isIndustrialCraft2Loaded = false;
public static boolean isNotEnoughItemsLoaded = false;
public static boolean isOpenComputersLoaded = false;
@ -658,7 +655,6 @@ public class WarpDriveConfig {
isRedstoneFluxLoaded = Loader.isModLoaded("redstoneflux");
isComputerCraftLoaded = Loader.isModLoaded("computercraft");
isEnderIOLoaded = Loader.isModLoaded("enderio");
isDefenseTechLoaded = Loader.isModLoaded("DefenseTech");
isGregTechLoaded = Loader.isModLoaded("gregtech");
isIndustrialCraft2Loaded = Loader.isModLoaded("ic2");
isOpenComputersLoaded = Loader.isModLoaded("opencomputers");
@ -1191,11 +1187,9 @@ public class WarpDriveConfig {
// read non-explicit mod dependencies
isAdvancedRepulsionSystemLoaded = Loader.isModLoaded("AdvancedRepulsionSystems");
isAdvancedSolarPanelLoaded = Loader.isModLoaded("AdvancedSolarPanel");
isForgeMultipartLoaded = Loader.isModLoaded("forgemultipartcbe");
isICBMClassicLoaded = Loader.isModLoaded("icbmclassic");
isNotEnoughItemsLoaded = Loader.isModLoaded("NotEnoughItems");
isImmersiveEngineeringLoaded = Loader.isModLoaded("immersiveengineering");
isThermalExpansionLoaded = Loader.isModLoaded("thermalexpansion");
isThermalFoundationLoaded = Loader.isModLoaded("thermalfoundation");
@ -1227,6 +1221,7 @@ public class WarpDriveConfig {
isForgeMultipartLoaded = CompatForgeMultipart.register();
}
final boolean isImmersiveEngineeringLoaded = Loader.isModLoaded("immersiveengineering");
if (isImmersiveEngineeringLoaded) {
CompatImmersiveEngineering.register();
}

View file

@ -304,7 +304,7 @@ public class JumpBlock {
if (nbtToDeploy.hasKey("screenData")) {// IC2NuclearControl 2.2.5a
final NBTTagCompound nbtScreenData = nbtToDeploy.getCompoundTag("screenData");
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) {
WarpDrive.logger.info(String.format("%s deploy: TileEntity has screenData.min/maxXYZ", this));
}
@ -327,10 +327,11 @@ public class JumpBlock {
TileEntity newTileEntity = null;
boolean isForgeMultipart = false;
if (WarpDriveConfig.isForgeMultipartLoaded && nbtToDeploy.hasKey("id") && nbtToDeploy.getString("id").equals("savedMultipart")) {
if ( WarpDriveConfig.isForgeMultipartLoaded
&& nbtToDeploy.hasKey("id")
&& nbtToDeploy.getString("id").equals("savedMultipart") ) {
isForgeMultipart = true;
newTileEntity = (TileEntity) CompatForgeMultipart.methodMultipartHelper_createTileFromNBT.invoke(null, targetWorld, nbtToDeploy);
}
if (newTileEntity == null) {

View file

@ -110,8 +110,8 @@ public class MessageSpawnParticle implements IMessage, IMessageHandler<MessageSp
private void handle(final World world) {
// Directly spawn particle as per RenderGlobal.doSpawnParticle, bypassing range check
// adjust color as needed
Minecraft mc = Minecraft.getMinecraft();
Entity entity = mc.getRenderViewEntity();
final Minecraft mc = Minecraft.getMinecraft();
final Entity entity = mc.getRenderViewEntity();
if (entity == null || mc.effectRenderer == null) {
return;
}