From 57a2c222f12fdd8c842669059106f654ebb02c90 Mon Sep 17 00:00:00 2001 From: Unknown Date: Mon, 22 Apr 2019 12:39:27 +0200 Subject: [PATCH] Code cleanup --- src/main/java/cr0s/warpdrive/Commons.java | 86 ++++--- src/main/java/cr0s/warpdrive/WarpDrive.java | 44 ++-- .../warpdrive/block/BlockAbstractBase.java | 1 + .../block/BlockAbstractContainer.java | 12 +- .../block/ItemBlockAbstractBase.java | 4 +- .../block/TileEntityAbstractBase.java | 3 + .../block/TileEntityAbstractInterfaced.java | 18 +- .../atomic/BlockAbstractAccelerator.java | 2 +- .../block/building/BlockShipScanner.java | 1 + .../block/decoration/BlockDecorative.java | 6 +- .../block/detection/BlockCloakingCore.java | 2 +- .../block/energy/ItemBlockCapacitor.java | 3 +- .../energy/TileEntityEnanReactorCore.java | 6 +- .../forcefield/BlockAbstractForceField.java | 2 +- .../block/forcefield/BlockForceField.java | 2 +- .../forcefield/BlockForceFieldProjector.java | 2 +- .../ItemBlockForceFieldProjector.java | 2 +- .../warpdrive/block/hull/ItemBlockHull.java | 3 +- .../block/hull/ItemBlockHullSlab.java | 17 +- .../block/movement/BlockShipCore.java | 1 + .../movement/ItemBlockTransporterBeacon.java | 18 +- .../warpdrive/block/movement/ShipScanner.java | 8 +- .../TileEntityAbstractShipController.java | 23 +- .../cr0s/warpdrive/client/ClientProxy.java | 6 +- .../warpdrive/command/AbstractCommand.java | 3 +- .../cr0s/warpdrive/command/CommandBed.java | 25 +- .../cr0s/warpdrive/command/CommandEntity.java | 2 +- .../cr0s/warpdrive/command/CommandFind.java | 27 +-- .../warpdrive/command/CommandGenerate.java | 2 +- .../warpdrive/command/CommandInvisible.java | 18 +- .../cr0s/warpdrive/command/CommandReload.java | 16 +- .../cr0s/warpdrive/command/CommandSpace.java | 16 +- .../cr0s/warpdrive/config/Dictionary.java | 16 +- .../java/cr0s/warpdrive/config/Recipes.java | 228 ++++++++++-------- .../cr0s/warpdrive/data/GlobalPosition.java | 2 +- .../cr0s/warpdrive/data/StarMapRegistry.java | 7 +- .../warpdrive/data/StarMapRegistryItem.java | 3 +- .../cr0s/warpdrive/event/ItemHandler.java | 4 +- .../cr0s/warpdrive/event/JumpSequencer.java | 21 +- .../cr0s/warpdrive/event/TooltipHandler.java | 4 +- .../cr0s/warpdrive/item/ItemAbstractBase.java | 2 +- .../cr0s/warpdrive/item/ItemComponent.java | 6 +- .../item/ItemElectromagneticCell.java | 5 +- .../warpdrive/item/ItemForceFieldShape.java | 6 +- .../warpdrive/item/ItemForceFieldUpgrade.java | 2 +- .../cr0s/warpdrive/item/ItemPlasmaTorch.java | 7 +- .../cr0s/warpdrive/item/ItemTuningDriver.java | 8 +- .../cr0s/warpdrive/item/ItemTuningFork.java | 8 +- .../java/cr0s/warpdrive/item/ItemWrench.java | 6 +- 49 files changed, 397 insertions(+), 319 deletions(-) diff --git a/src/main/java/cr0s/warpdrive/Commons.java b/src/main/java/cr0s/warpdrive/Commons.java index 4eede0ff..c4b82bbb 100644 --- a/src/main/java/cr0s/warpdrive/Commons.java +++ b/src/main/java/cr0s/warpdrive/Commons.java @@ -12,6 +12,7 @@ import cr0s.warpdrive.event.ChunkHandler; import cr0s.warpdrive.world.SpaceTeleporter; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; @@ -100,7 +101,8 @@ public class Commons { } @SuppressWarnings("ConstantConditions") // IDE says "§" == CHAR_FORMATTING, execution says otherwise - public static String updateEscapeCodes(final String message) { + @Nonnull + public static String updateEscapeCodes(@Nonnull final String message) { return message .replace("§", CHAR_FORMATTING) .replace("\\n", "\n") @@ -108,7 +110,8 @@ public class Commons { .replaceAll("\u00A0", " "); // u00A0 is 'NO-BREAK SPACE' } - public static String removeFormatting(final String message) { + @Nonnull + public static String removeFormatting(@Nonnull final String message) { return updateEscapeCodes(message) .replaceAll("(" + CHAR_FORMATTING + ".)", ""); } @@ -127,7 +130,8 @@ public class Commons { } // inspired by FontRender.getFormatFromString - private static String getFormatFromString(final String message) { + @Nonnull + private static String getFormatFromString(@Nonnull final String message) { final int indexLastChar = message.length() - 1; StringBuilder result = new StringBuilder(); int indexEscapeCode = -1; @@ -153,22 +157,33 @@ public class Commons { public static Style styleValue = new Style().setColor(TextFormatting.YELLOW); public static Style styleVoltage = new Style().setColor(TextFormatting.DARK_GREEN); - public static WarpDriveText getChatPrefix(final Block block) { + @Nonnull + public static WarpDriveText getChatPrefix(@Nonnull final Block block) { return getChatPrefix(block.getTranslationKey() + ".name"); } - public static WarpDriveText getChatPrefix(final ItemStack itemStack) { + @Nonnull + public static WarpDriveText getChatPrefix(@Nonnull final ItemStack itemStack) { return getChatPrefix(itemStack.getTranslationKey() + ".name"); } - public static WarpDriveText getChatPrefix(final String translationKey) { - return new WarpDriveText(styleHeader, "warpdrive.guide.prefix", new TextComponentTranslation(translationKey)); + @Nonnull + public static WarpDriveText getChatPrefix(@Nonnull final String translationKey) { + return new WarpDriveText(styleHeader, "warpdrive.guide.prefix", + new TextComponentTranslation(translationKey)); } - public static void addChatMessage(final ICommandSender commandSender, final ITextComponent textComponent) { + @Nonnull + public static WarpDriveText getNamedPrefix(@Nonnull final String name) { + return new WarpDriveText(styleHeader, "warpdrive.guide.prefix", + new TextComponentString(name)); + } + + public static void addChatMessage(final ICommandSender commandSender, @Nonnull final ITextComponent textComponent) { final String message = textComponent.getFormattedText(); if (commandSender == null) { - WarpDrive.logger.error(String.format("Unable to send message to NULL sender: %s", message)); + WarpDrive.logger.error(String.format("Unable to send message to NULL sender: %s", + message)); return; } @@ -187,17 +202,17 @@ public class Commons { // add tooltip information with text formatting and line splitting // will ensure it fits on minimum screen width - public static void addTooltip(final List list, final String tooltip) { + public static void addTooltip(final List list, @Nonnull final String tooltip) { // skip empty tooltip if (tooltip.isEmpty()) { return; } // apply requested formatting - final String[] split = updateEscapeCodes(tooltip).split("\n"); + final String[] lines = updateEscapeCodes(tooltip).split("\n"); // add new lines - for (final String line : split) { + for (final String line : lines) { // skip redundant information boolean isExisting = false; final String cleanToAdd = removeFormatting(line).trim().toLowerCase(); @@ -288,6 +303,7 @@ public class Commons { return String.format("%,d", Math.round(value)); } + @Nonnull public static String format(final Object[] arguments) { final StringBuilder result = new StringBuilder(); if (arguments != null && arguments.length > 0) { @@ -305,6 +321,7 @@ public class Commons { return result.toString(); } + @Nonnull public static String format(final World world) { if (world == null) { return "~NULL~"; @@ -360,7 +377,7 @@ public class Commons { x, y, z); } - public static String format(final ItemStack itemStack) { + public static String format(@Nonnull final ItemStack itemStack) { final String stringNBT; if (itemStack.hasTagCompound()) { stringNBT = " " + itemStack.getTagCompound(); @@ -382,7 +399,7 @@ public class Commons { .replace("\\", "."); } - public static ItemStack copyWithSize(final ItemStack itemStack, final int newSize) { + public static ItemStack copyWithSize(@Nonnull final ItemStack itemStack, final int newSize) { final ItemStack ret = itemStack.copy(); ret.setCount(newSize); return ret; @@ -472,8 +489,10 @@ public class Commons { return iterated; } - public static Set getConnectedBlockStatePos(final IBlockAccess blockAccess, final Collection start, final VectorI[] directions, - final Set blockConnecting, final Set blockResults, final int maxRange) { + @Nonnull + public static Set getConnectedBlockStatePos(@Nonnull final IBlockAccess blockAccess, @Nonnull final Collection start, + @Nonnull final VectorI[] directions, @Nonnull final Set blockConnecting, + @Nonnull final Set blockResults, final int maxRange) { Set toIterate = new HashSet<>(start.size() * 4); final Set blockPosIterated = new HashSet<>(64); final Set blockStatePosResults = new HashSet<>(64); @@ -602,7 +621,7 @@ public class Commons { // configurable interpolation - public static double interpolate(final double[] xValues, final double[] yValues, final double xInput) { + public static double interpolate(@Nonnull final double[] xValues, @Nonnull final double[] yValues, final double xInput) { if (WarpDrive.isDev) { assert xValues.length == yValues.length; assert xValues.length > 1; @@ -627,7 +646,7 @@ public class Commons { return yMin + (x - xMin) * (yMax - yMin) / (xMax - xMin); } - public static EnumFacing getHorizontalDirectionFromEntity(final EntityLivingBase entityLiving) { + public static EnumFacing getHorizontalDirectionFromEntity(@Nullable final EntityLivingBase entityLiving) { if (entityLiving != null) { final int direction = Math.round(entityLiving.rotationYaw / 90.0F) & 3; switch (direction) { @@ -645,7 +664,7 @@ public class Commons { return EnumFacing.NORTH; } - public static EnumFacing getFacingFromEntity(final EntityLivingBase entityLivingBase) { + public static EnumFacing getFacingFromEntity(@Nullable final EntityLivingBase entityLivingBase) { if (entityLivingBase != null) { final EnumFacing facing; if (entityLivingBase.rotationPitch > 45) { @@ -715,6 +734,7 @@ public class Commons { WarpDrive.logger.error(stringBuilder.toString()); } + @Nonnull public static String getMethodName(final int depth) { try { final StackTraceElement stackTraceElement = (StackTraceElement) methodThrowable_getStackTraceElement.invoke( @@ -726,7 +746,7 @@ public class Commons { } } - public static void writeNBTToFile(final String fileName, final NBTTagCompound tagCompound) { + public static void writeNBTToFile(@Nonnull final String fileName, @Nonnull final NBTTagCompound tagCompound) { if (WarpDrive.isDev) { WarpDrive.logger.info(String.format("writeNBTToFile %s", fileName)); @@ -749,7 +769,7 @@ public class Commons { } } - public static NBTTagCompound readNBTFromFile(final String fileName) { + public static NBTTagCompound readNBTFromFile(@Nonnull final String fileName) { if (WarpDrive.isDev) { WarpDrive.logger.info(String.format("readNBTFromFile %s", fileName)); } @@ -773,21 +793,21 @@ public class Commons { return null; } - public static BlockPos createBlockPosFromNBT(final NBTTagCompound tagCompound) { + public static BlockPos createBlockPosFromNBT(@Nonnull final NBTTagCompound tagCompound) { final int x = tagCompound.getInteger("x"); final int y = tagCompound.getInteger("y"); final int z = tagCompound.getInteger("z"); return new BlockPos(x, y, z); } - public static NBTTagCompound writeBlockPosToNBT(final BlockPos blockPos, final NBTTagCompound tagCompound) { + public static NBTTagCompound writeBlockPosToNBT(@Nonnull final BlockPos blockPos, @Nonnull final NBTTagCompound tagCompound) { tagCompound.setInteger("x", blockPos.getX()); tagCompound.setInteger("y", blockPos.getY()); tagCompound.setInteger("z", blockPos.getZ()); return tagCompound; } - public static EntityPlayerMP[] getOnlinePlayerByNameOrSelector(final ICommandSender commandSender, final String playerNameOrSelector) { + public static EntityPlayerMP[] getOnlinePlayerByNameOrSelector(@Nonnull final ICommandSender commandSender, final String playerNameOrSelector) { final MinecraftServer server = commandSender.getServer(); assert server != null; final List onlinePlayers = server.getPlayerList().getPlayers(); @@ -834,7 +854,7 @@ public class Commons { } } - public static void messageToAllPlayersInArea(final IStarMapRegistryTileEntity tileEntity, final WarpDriveText textComponent) { + public static void messageToAllPlayersInArea(@Nonnull final IStarMapRegistryTileEntity tileEntity, @Nonnull final WarpDriveText textComponent) { assert tileEntity instanceof TileEntity; final AxisAlignedBB starMapArea = tileEntity.getStarMapArea(); final ITextComponent messageFormatted = Commons.getChatPrefix(tileEntity.getStarMapName()) @@ -851,7 +871,7 @@ public class Commons { } } - public static void moveEntity(final Entity entity, final World worldDestination, final Vector3 v3Destination) { + public static void moveEntity(@Nonnull final Entity entity, @Nonnull final World worldDestination, @Nonnull final Vector3 v3Destination) { if (entity.world.isRemote) { WarpDrive.logger.error(String.format("Skipping remote movement for entity %s destination %s", entity, Commons.format(worldDestination, v3Destination) )); @@ -913,10 +933,10 @@ public class Commons { // server side version of EntityLivingBase.rayTrace private static final double BLOCK_REACH_DISTANCE = 5.0D; // this is a client side hardcoded value, applicable to creative players - public static RayTraceResult getInteractingBlock(final World world, final EntityPlayer entityPlayer) { + public static RayTraceResult getInteractingBlock(@Nonnull final World world, @Nonnull final EntityPlayer entityPlayer) { return getInteractingBlock(world, entityPlayer, BLOCK_REACH_DISTANCE); } - public static RayTraceResult getInteractingBlock(final World world, final EntityPlayer entityPlayer, final double distance) { + public static RayTraceResult getInteractingBlock(@Nonnull final World world, @Nonnull final EntityPlayer entityPlayer, final double distance) { final Vec3d vec3Position = new Vec3d(entityPlayer.posX, entityPlayer.posY + entityPlayer.eyeHeight, entityPlayer.posZ); final Vec3d vec3Look = entityPlayer.getLook(1.0F); final Vec3d vec3Target = vec3Position.add(vec3Look.x * distance, vec3Look.y * distance, vec3Look.z * distance); @@ -929,7 +949,7 @@ public class Commons { // We're remapping it using unlocalized names, since those don't change private static HashMap fluidByBlockName; - public static Fluid fluid_getByBlock(final Block block) { + public static Fluid fluid_getByBlock(@Nonnull final Block block) { // validate context if (!(block instanceof BlockLiquid)) { // if (WarpDrive.isDev) { @@ -964,14 +984,14 @@ public class Commons { return EnumFacing.byIndex(index); } - public static int getOrdinal(final EnumFacing direction) { + public static int getOrdinal(@Nullable final EnumFacing direction) { if (direction == null) { return 6; } return direction.ordinal(); } - public static boolean isValidCamouflage(final IBlockState blockState) { + public static boolean isValidCamouflage(@Nullable final IBlockState blockState) { // fast check if ( blockState == null || blockState == Blocks.AIR @@ -1021,7 +1041,7 @@ public class Commons { return true; } - public static IBlockState getBlockState_noChunkLoading(final IBlockAccess blockAccess, final BlockPos blockPos) { + public static IBlockState getBlockState_noChunkLoading(@Nullable final IBlockAccess blockAccess, @Nonnull final BlockPos blockPos) { // skip unloaded worlds if (blockAccess == null) { return null; @@ -1033,7 +1053,7 @@ public class Commons { return blockAccess.getBlockState(blockPos); } - public static boolean isReplaceableOreGen(final World world, final BlockPos blockPos) { + public static boolean isReplaceableOreGen(@Nonnull final World world, @Nonnull final BlockPos blockPos) { final IBlockState blockStateActual = world.getBlockState(blockPos); final Block blockActual = blockStateActual.getBlock(); return blockActual.isReplaceableOreGen(blockStateActual, world, blockPos, diff --git a/src/main/java/cr0s/warpdrive/WarpDrive.java b/src/main/java/cr0s/warpdrive/WarpDrive.java index 58be3956..c0d2b98c 100644 --- a/src/main/java/cr0s/warpdrive/WarpDrive.java +++ b/src/main/java/cr0s/warpdrive/WarpDrive.java @@ -184,6 +184,7 @@ import org.apache.logging.log4j.Logger; import com.mojang.authlib.GameProfile; +import javax.annotation.Nonnull; import javax.annotation.Nullable; @Mod(modid = WarpDrive.MODID, @@ -288,6 +289,7 @@ public class WarpDrive { public static DamageTeleportation damageTeleportation; public static DamageWarm damageWarm; + // world generation public static Biome biomeSpace; public static DimensionType dimensionTypeSpace; public static DimensionType dimensionTypeHyperSpace; @@ -776,19 +778,19 @@ public class WarpDrive { final public static ArrayList villagerProfessions = new ArrayList<>(10); // Register a Biome. - public static BIOME register(final BIOME biome) { + public static BIOME register(@Nonnull final BIOME biome) { biomes.add(biome); return biome; } // Register a Block with the default ItemBlock class. - public static BLOCK register(final BLOCK block) { + public static BLOCK register(@Nonnull final BLOCK block) { assert block instanceof IBlockBase; return register(block, ((IBlockBase) block).createItemBlock()); } // Register a Block with a custom ItemBlock class. - public static BLOCK register(final BLOCK block, @Nullable final ItemBlock itemBlock) { + public static BLOCK register(@Nonnull final BLOCK block, @Nullable final ItemBlock itemBlock) { final ResourceLocation resourceLocation = block.getRegistryName(); if (resourceLocation == null) { WarpDrive.logger.error(String.format("Missing registry name for block %s, ignoring registration...", @@ -807,34 +809,34 @@ public class WarpDrive { } // Register an Enchantment. - public static ENCHANTMENT register(final ENCHANTMENT enchantment) { + public static ENCHANTMENT register(@Nonnull final ENCHANTMENT enchantment) { enchantments.add(enchantment); return enchantment; } // Register an Item. - public static ITEM register(final ITEM item) { + public static ITEM register(@Nonnull final ITEM item) { items.add(item); return item; } // Register an Potion. - public static POTION register(final POTION potion) { + public static POTION register(@Nonnull final POTION potion) { potions.add(potion); return potion; } // Register an PotionType. - public static POTION_TYPE register(final POTION_TYPE potionType) { + public static POTION_TYPE register(@Nonnull final POTION_TYPE potionType) { potionTypes.add(potionType); return potionType; } // Register a recipe. - public static RECIPE register(final RECIPE recipe) { + public static RECIPE register(@Nonnull final RECIPE recipe) { return register(recipe, ""); } - public static RECIPE register(final RECIPE recipe, final String suffix) { + public static RECIPE register(@Nonnull final RECIPE recipe, final String suffix) { ResourceLocation registryName = recipe.getRegistryName(); if (registryName == null) { final String path; @@ -874,19 +876,19 @@ public class WarpDrive { } // Register a SoundEvent. - public static SOUND_EVENT register(final SOUND_EVENT soundEvent) { + public static SOUND_EVENT register(@Nonnull final SOUND_EVENT soundEvent) { soundEvents.add(soundEvent); return soundEvent; } // Register a VillagerProfession. - public static VILLAGER_PROFESSION register(final VILLAGER_PROFESSION villagerProfession) { + public static VILLAGER_PROFESSION register(@Nonnull final VILLAGER_PROFESSION villagerProfession) { villagerProfessions.add(villagerProfession); return villagerProfession; } @SubscribeEvent - public void onRegisterBiomes(final RegistryEvent.Register event) { + public void onRegisterBiomes(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final Biome biome : biomes) { event.getRegistry().register(biome); @@ -896,7 +898,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterBlocks(final RegistryEvent.Register event) { + public void onRegisterBlocks(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final Block block : blocks) { event.getRegistry().register(block); @@ -936,7 +938,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterEnchantments(final RegistryEvent.Register event) { + public void onRegisterEnchantments(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final Enchantment enchantment : enchantments) { event.getRegistry().register(enchantment); @@ -944,7 +946,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterEntities(final RegistryEvent.Register event) { + public void onRegisterEntities(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); EntityEntry entityEntry; @@ -979,7 +981,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterItems(final RegistryEvent.Register event) { + public void onRegisterItems(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final Item item : items) { event.getRegistry().register(item); @@ -991,7 +993,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterPotions(final RegistryEvent.Register event) { + public void onRegisterPotions(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final Potion potion : potions) { event.getRegistry().register(potion); @@ -999,7 +1001,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterPotionTypes(final RegistryEvent.Register event) { + public void onRegisterPotionTypes(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final PotionType potionType : potionTypes) { event.getRegistry().register(potionType); @@ -1007,7 +1009,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterRecipes(final RegistryEvent.Register event) { + public void onRegisterRecipes(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); Recipes.initOreDictionary(); @@ -1020,7 +1022,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterSoundEvents(final RegistryEvent.Register event) { + public void onRegisterSoundEvents(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); cr0s.warpdrive.data.SoundEvents.registerSounds(); for (final SoundEvent soundEvent : soundEvents) { @@ -1029,7 +1031,7 @@ public class WarpDrive { } @SubscribeEvent - public void onRegisterVillagerProfessions(final RegistryEvent.Register event) { + public void onRegisterVillagerProfessions(@Nonnull final RegistryEvent.Register event) { WarpDrive.logger.debug(String.format("Registering %s", event.getName())); for (final VillagerProfession villagerProfession : villagerProfessions) { event.getRegistry().register(villagerProfession); diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java index 6cc35a14..4ad5baed 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractBase.java @@ -62,6 +62,7 @@ public abstract class BlockAbstractBase extends Block implements IBlockBase { // Force a single model through a custom state mapper final StateMapperBase stateMapperBase = new StateMapperBase() { @Nonnull + @SideOnly(Side.CLIENT) @Override protected ModelResourceLocation getModelResourceLocation(@Nonnull final IBlockState blockState) { return modelResourceLocation; diff --git a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java index 0720bfc1..5424e017 100644 --- a/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java +++ b/src/main/java/cr0s/warpdrive/block/BlockAbstractContainer.java @@ -108,7 +108,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I @Nonnull final EntityLivingBase entityLivingBase, final EnumHand enumHand) { final IBlockState blockState = super.getStateForPlacement(world, blockPos, facing, hitX, hitY, hitZ, metadata, entityLivingBase, enumHand); final boolean isRotating = !ignoreFacingOnPlacement - && blockState.getProperties().containsKey(BlockProperties.FACING); + && blockState.getProperties().containsKey(BlockProperties.FACING); if (isRotating) { if (blockState.isFullBlock()) { final EnumFacing enumFacing = Commons.getFacingFromEntity(entityLivingBase); @@ -153,7 +153,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I } @Override - public void dropBlockAsItemWithChance(final World world, @Nonnull final BlockPos blockPos, @Nonnull final IBlockState blockState, + public void dropBlockAsItemWithChance(@Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final IBlockState blockState, final float chance, final int fortune) { super.dropBlockAsItemWithChance(world, blockPos, blockState, chance, fortune); // calls getDrops() here below if ( !world.isRemote @@ -222,14 +222,14 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I final ResourceLocation registryName = blockNeighbor.getRegistryName(); WarpDrive.logger.error(String.format("Bad multithreading detected from mod %s %s, please report to mod author", registryName == null ? blockNeighbor : registryName.getNamespace(), - Commons.format(blockAccess, blockPosNeighbor) )); + Commons.format(blockAccess, blockPosNeighbor))); new ConcurrentModificationException().printStackTrace(); } return; } final TileEntity tileEntity = blockAccess.getTileEntity(blockPos); - if ( tileEntity == null - || tileEntity.getWorld().isRemote ) { + if (tileEntity == null + || tileEntity.getWorld().isRemote) { return; } if (tileEntity instanceof IBlockUpdateDetector) { @@ -263,7 +263,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I } } - public void onEMP(final World world, final BlockPos blockPos, final float efficiency) { + public void onEMP(@Nonnull final World world, @Nonnull final BlockPos blockPos, final float efficiency) { final TileEntity tileEntity = world.getTileEntity(blockPos); if (tileEntity instanceof TileEntityAbstractEnergy) { final TileEntityAbstractEnergy tileEntityAbstractEnergy = (TileEntityAbstractEnergy) tileEntity; diff --git a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java index 0aece897..ce3b25c7 100644 --- a/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/ItemBlockAbstractBase.java @@ -113,15 +113,15 @@ public class ItemBlockAbstractBase extends ItemBlock implements IItemBase { ClientProxy.modelInitialisation(this); } - @SideOnly(Side.CLIENT) @Nonnull + @SideOnly(Side.CLIENT) @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { return ClientProxy.getModelResourceLocation(itemStack); } - @Override @SideOnly(Side.CLIENT) + @Override public void addInformation(@Nonnull final ItemStack itemStack, @Nullable final World world, @Nonnull final List list, @Nullable final ITooltipFlag advancedItemTooltips) { super.addInformation(itemStack, world, list, advancedItemTooltips); diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java index 4aaeac6a..a5acb608 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractBase.java @@ -242,6 +242,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc } } + @Nonnull protected WarpDriveText getStatusPrefix() { if (world != null) { final Item item = Item.getItemFromBlock(getBlockType()); @@ -253,6 +254,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc return new WarpDriveText(); } + @Nonnull protected WarpDriveText getBeamFrequencyStatus(final int beamFrequency) { if (beamFrequency == -1) { return new WarpDriveText(Commons.styleWarning, "warpdrive.beam_frequency.status_line.undefined"); @@ -263,6 +265,7 @@ public abstract class TileEntityAbstractBase extends TileEntity implements IBloc } } + @Nonnull protected WarpDriveText getVideoChannelStatus(final int videoChannel) { if (videoChannel == -1) { return new WarpDriveText(Commons.styleWarning, "warpdrive.video_channel.status_line.undefined"); diff --git a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java index 2adbab5c..671de594 100644 --- a/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java +++ b/src/main/java/cr0s/warpdrive/block/TileEntityAbstractInterfaced.java @@ -27,6 +27,7 @@ import li.cil.oc.api.network.Node; import li.cil.oc.api.network.Visibility; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -243,7 +244,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas // - block connection when missing the Computer interface upgrade // note: direct API calls remains possible without upgrade, as it's lore dependant @Optional.Method(modid = "opencomputers") - protected Object[] OC_convertArgumentsAndLogCall(final Context context, final Arguments args) { + protected Object[] OC_convertArgumentsAndLogCall(@Nonnull final Context context, @Nonnull final Arguments args) { final Object[] arguments = new Object[args.count()]; int index = 0; for (final Object arg : args) { @@ -341,7 +342,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas return false; } - protected VectorI computer_getVectorI(final VectorI vDefault, final Object[] arguments) { + protected VectorI computer_getVectorI(final VectorI vDefault, @Nonnull final Object[] arguments) { try { if (arguments.length == 3) { final int x = Commons.toInt(arguments[0]); @@ -355,7 +356,10 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas return vDefault; } - protected Object[] computer_getOrSetVector3(final FunctionGet getVector, final FunctionSetVector setVector, final Object[] arguments) { + @Nonnull + protected Object[] computer_getOrSetVector3(@Nonnull final FunctionGet getVector, + @Nonnull final FunctionSetVector setVector, + final Object[] arguments) { if ( arguments != null && arguments.length > 0 && arguments[0] != null ) { @@ -388,7 +392,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas return new Double[] { v3Actual.x, v3Actual.y, v3Actual.z }; } - protected UUID computer_getUUID(final UUID uuidDefault, final Object[] arguments) { + protected UUID computer_getUUID(final UUID uuidDefault, @Nonnull final Object[] arguments) { try { if (arguments.length == 1 && arguments[0] != null) { if (arguments[0] instanceof UUID) { @@ -697,7 +701,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas @Override @Optional.Method(modid = "opencomputers") - public void onConnect(final Node node) { + public void onConnect(@Nonnull final Node node) { if (node.host() instanceof Context) { // Attach our file system to new computers we get connected to. // Note that this is also called for all already present computers @@ -711,7 +715,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas @Override @Optional.Method(modid = "opencomputers") - public void onDisconnect(final Node node) { + public void onDisconnect(@Nonnull final Node node) { if (OC_fileSystem != null) { if (node.host() instanceof Context) { // Disconnecting from a single computer @@ -725,7 +729,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas @Override @Optional.Method(modid = "opencomputers") - public void onMessage(final Message message) { + public void onMessage(@Nonnull final Message message) { // nothing special } } diff --git a/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java b/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java index 90e7ef7c..e32be2ad 100644 --- a/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java +++ b/src/main/java/cr0s/warpdrive/block/atomic/BlockAbstractAccelerator.java @@ -25,7 +25,7 @@ public abstract class BlockAbstractAccelerator extends BlockAbstractBase impleme } @Override - public boolean canCreatureSpawn(@Nonnull IBlockState blockState, @Nonnull IBlockAccess blockAccess, @Nonnull BlockPos blockPos, SpawnPlacementType type) { + public boolean canCreatureSpawn(@Nonnull final IBlockState blockState, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos blockPos, final SpawnPlacementType type) { return false; } } diff --git a/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java index 8d2b8004..0841527a 100644 --- a/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/BlockShipScanner.java @@ -135,6 +135,7 @@ public class BlockShipScanner extends BlockAbstractContainer { || !entityPlayer.isSneaking() ) { Commons.addChatMessage(entityPlayer, ((TileEntityShipScanner) tileEntity).getStatus()); return true; + } else if (blockStateAbove.getBlock() != this) { ((TileEntityShipScanner) tileEntity).blockCamouflage = blockStateAbove.getBlock(); ((TileEntityShipScanner) tileEntity).metadataCamouflage = blockStateAbove.getBlock().getMetaFromState(blockStateAbove); diff --git a/src/main/java/cr0s/warpdrive/block/decoration/BlockDecorative.java b/src/main/java/cr0s/warpdrive/block/decoration/BlockDecorative.java index c95c6672..465ee5db 100644 --- a/src/main/java/cr0s/warpdrive/block/decoration/BlockDecorative.java +++ b/src/main/java/cr0s/warpdrive/block/decoration/BlockDecorative.java @@ -8,6 +8,7 @@ import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; @@ -115,15 +116,16 @@ public class BlockDecorative extends BlockAbstractBase { return blockState.getBlock().getMetaFromState(blockState); } + @Nonnull public static ItemStack getItemStack(final EnumDecorativeType enumDecorativeType) { if (enumDecorativeType != null) { - int damage = enumDecorativeType.ordinal(); + final int damage = enumDecorativeType.ordinal(); if (itemStackCache[damage] == null) { itemStackCache[damage] = new ItemStack(WarpDrive.blockDecorative, 1, damage); } return itemStackCache[damage]; } - return null; + return new ItemStack(Blocks.FIRE); } public static ItemStack getItemStackNoCache(final EnumDecorativeType enumDecorativeType, final int amount) { diff --git a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java index 10689360..a0df46b1 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java +++ b/src/main/java/cr0s/warpdrive/block/detection/BlockCloakingCore.java @@ -48,7 +48,7 @@ public class BlockCloakingCore extends BlockAbstractContainer { } @Override - public int getMetaFromState(final IBlockState blockState) { + public int getMetaFromState(@Nonnull final IBlockState blockState) { return blockState.getValue(BlockProperties.ACTIVE) ? 1 : 0; } diff --git a/src/main/java/cr0s/warpdrive/block/energy/ItemBlockCapacitor.java b/src/main/java/cr0s/warpdrive/block/energy/ItemBlockCapacitor.java index 468b4488..3b27e356 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/ItemBlockCapacitor.java +++ b/src/main/java/cr0s/warpdrive/block/energy/ItemBlockCapacitor.java @@ -19,9 +19,8 @@ public class ItemBlockCapacitor extends ItemBlockAbstractBase { } @Nonnull - @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("deprecation") + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final int damage = itemStack.getItemDamage(); if (damage < 0 || damage > 15) { diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java index 04a9db81..a61d0f4a 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityEnanReactorCore.java @@ -10,6 +10,7 @@ import cr0s.warpdrive.data.Vector3; import cr0s.warpdrive.network.PacketHandler; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.lang.ref.WeakReference; import java.lang.reflect.Array; import java.util.Arrays; @@ -153,7 +154,7 @@ public class TileEntityEnanReactorCore extends TileEntityEnanReactorController { } } - void decreaseInstability(final ReactorFace reactorFace, final int energy) { + void decreaseInstability(@Nonnull final ReactorFace reactorFace, final int energy) { if (reactorFace.indexStability < 0) { return; } @@ -231,7 +232,8 @@ public class TileEntityEnanReactorCore extends TileEntityEnanReactorController { } } - private TileEntityEnanReactorLaser getLaser(final ReactorFace reactorFace) { + @Nullable + private TileEntityEnanReactorLaser getLaser(@Nonnull final ReactorFace reactorFace) { final WeakReference weakTileEntityLaser = weakTileEntityLasers[reactorFace.indexStability]; TileEntityEnanReactorLaser tileEntityEnanReactorLaser; if (weakTileEntityLaser != null) { diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/BlockAbstractForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/BlockAbstractForceField.java index f95c17ff..e989f49e 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/BlockAbstractForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/BlockAbstractForceField.java @@ -35,7 +35,7 @@ public abstract class BlockAbstractForceField extends BlockAbstractContainer { } @Override - public void onEMP(World world, final BlockPos blockPos, final float efficiency) { + public void onEMP(@Nonnull final World world, @Nonnull final BlockPos blockPos, final float efficiency) { super.onEMP(world, blockPos, efficiency * (1.0F - 0.2F * (enumTier.getIndex() - 1))); } } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java index 41bd3021..7990954c 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceField.java @@ -531,7 +531,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR } @Override - public void onEMP(final World world, final BlockPos blockPos, final float efficiency) { + public void onEMP(@Nonnull final World world, @Nonnull final BlockPos blockPos, final float efficiency) { if (efficiency * (1.0F - 0.20F * (enumTier.getIndex() - 1)) > world.rand.nextFloat()) { downgrade(world, blockPos); } diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java index 1be7d646..064525f7 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/BlockForceFieldProjector.java @@ -229,7 +229,7 @@ public class BlockForceFieldProjector extends BlockAbstractForceField { || (enumFacing != blockState.getValue(BlockProperties.FACING) && (!tileEntityForceFieldProjector.isDoubleSided || enumFacing.getOpposite() != blockState.getValue(BlockProperties.FACING))) ) { // find a valid upgrade to dismount if (!tileEntityForceFieldProjector.hasUpgrade(enumForceFieldUpgrade)) { - enumForceFieldUpgrade = (EnumForceFieldUpgrade)tileEntityForceFieldProjector.getFirstUpgradeOfType(EnumForceFieldUpgrade.class, EnumForceFieldUpgrade.NONE); + enumForceFieldUpgrade = (EnumForceFieldUpgrade) tileEntityForceFieldProjector.getFirstUpgradeOfType(EnumForceFieldUpgrade.class, EnumForceFieldUpgrade.NONE); } if (enumForceFieldUpgrade == EnumForceFieldUpgrade.NONE) { diff --git a/src/main/java/cr0s/warpdrive/block/forcefield/ItemBlockForceFieldProjector.java b/src/main/java/cr0s/warpdrive/block/forcefield/ItemBlockForceFieldProjector.java index b68db6ad..53d48cca 100644 --- a/src/main/java/cr0s/warpdrive/block/forcefield/ItemBlockForceFieldProjector.java +++ b/src/main/java/cr0s/warpdrive/block/forcefield/ItemBlockForceFieldProjector.java @@ -19,8 +19,8 @@ public class ItemBlockForceFieldProjector extends ItemBlockAbstractBase { } @Nonnull - @Override @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final ResourceLocation resourceLocation = getRegistryName(); assert resourceLocation != null; diff --git a/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHull.java b/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHull.java index 0f38ca2e..d1374814 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHull.java +++ b/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHull.java @@ -19,9 +19,8 @@ public class ItemBlockHull extends ItemBlockAbstractBase { } @Nonnull - @Override @SideOnly(Side.CLIENT) - @SuppressWarnings("deprecation") + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { if (block instanceof BlockHullStairs) { final ResourceLocation resourceLocation = getRegistryName(); diff --git a/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHullSlab.java b/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHullSlab.java index 60f2fd06..492f4cb0 100644 --- a/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHullSlab.java +++ b/src/main/java/cr0s/warpdrive/block/hull/ItemBlockHullSlab.java @@ -35,11 +35,11 @@ public class ItemBlockHullSlab extends ItemBlockHull { @Nonnull @Override - public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, final World world, @Nonnull final BlockPos blockPos, - @Nonnull final EnumHand enumHand, @Nonnull EnumFacing facing, - final float hitX, final float hitY, final float hitZ) { + public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, + @Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumHand hand, + @Nonnull final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { // get context - final ItemStack itemStackHeld = entityPlayer.getHeldItem(enumHand); + final ItemStack itemStackHeld = entityPlayer.getHeldItem(hand); if (itemStackHeld.isEmpty()) { return EnumActionResult.FAIL; } @@ -65,7 +65,7 @@ public class ItemBlockHullSlab extends ItemBlockHull { if (variantWorld.getFacing() == facing.getOpposite()) { final AxisAlignedBB boundingBox = blockStateWorld.getCollisionBoundingBox(world, blockPos); if (boundingBox != null && world.checkNoEntityCollision(boundingBox)) { - EnumVariant variantNew; + final EnumVariant variantNew; if (variantWorld.getIsPlain()) {// plain variantNew = EnumVariant.PLAIN_FULL; } else { @@ -111,7 +111,7 @@ public class ItemBlockHullSlab extends ItemBlockHull { } // try to place ignoring the existing block - final IBlockState blockStatePlaced = blockSlab.getStateForPlacement(world, blockPosSide, facing, hitX, hitY, hitZ, metadataItem, entityPlayer, enumHand); + final IBlockState blockStatePlaced = blockSlab.getStateForPlacement(world, blockPosSide, facing, hitX, hitY, hitZ, metadataItem, entityPlayer, hand); final EnumFacing enumFacingPlaced = blockStatePlaced.getValue(BlockHullSlab.VARIANT).getFacing().getOpposite(); // try to merge slabs when right-clicking on a side block @@ -152,11 +152,12 @@ public class ItemBlockHullSlab extends ItemBlockHull { } } - return super.onItemUse(entityPlayer, world, blockPos, enumHand, facing, hitX, hitY, hitZ); + return super.onItemUse(entityPlayer, world, blockPos, hand, facing, hitX, hitY, hitZ); } @Override - public boolean canPlaceBlockOnSide(final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumFacing facing, final EntityPlayer entityPlayer, @Nonnull final ItemStack itemStack) { + public boolean canPlaceBlockOnSide(@Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumFacing facing, + @Nonnull final EntityPlayer entityPlayer, @Nonnull final ItemStack itemStack) { // check if clicked block can be interacted with @SuppressWarnings("deprecation") final IBlockState blockStateItem = blockSlab.getStateFromMeta(itemStack.getItemDamage()); diff --git a/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java index 0f66b8f4..1772ccc9 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/BlockShipCore.java @@ -125,6 +125,7 @@ public class BlockShipCore extends BlockAbstractRotatingContainer { } Commons.addChatMessage(entityPlayer, tileEntityShipCore.getBoundingBoxStatus()); return true; + } else if ( !world.isRemote && !entityPlayer.isSneaking() ) { Commons.addChatMessage(entityPlayer, tileEntityShipCore.getStatus()); diff --git a/src/main/java/cr0s/warpdrive/block/movement/ItemBlockTransporterBeacon.java b/src/main/java/cr0s/warpdrive/block/movement/ItemBlockTransporterBeacon.java index 346b715a..5380a60e 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/ItemBlockTransporterBeacon.java +++ b/src/main/java/cr0s/warpdrive/block/movement/ItemBlockTransporterBeacon.java @@ -118,7 +118,7 @@ public class ItemBlockTransporterBeacon extends ItemBlockAbstractBase implements return 0; } - private static ItemStack setEnergy(final ItemStack itemStack, final int energy) { + private static ItemStack setEnergy(@Nonnull final ItemStack itemStack, final int energy) { if (!(itemStack.getItem() instanceof ItemBlockTransporterBeacon)) { return itemStack; } @@ -131,7 +131,7 @@ public class ItemBlockTransporterBeacon extends ItemBlockAbstractBase implements return itemStack; } - private static ItemStack updateDamage(final ItemStack itemStack, final int energy, final boolean isActive) { + private static ItemStack updateDamage(@Nonnull final ItemStack itemStack, final int energy, final boolean isActive) { final int maxDamage = itemStack.getMaxDamage(); final int metadataEnergy = maxDamage - maxDamage * energy / WarpDriveConfig.TRANSPORTER_BEACON_MAX_ENERGY_STORED; final int metadataNew = (metadataEnergy & ~0x3) + (isActive ? 2 : 0); @@ -145,7 +145,7 @@ public class ItemBlockTransporterBeacon extends ItemBlockAbstractBase implements // ITransporterBeacon overrides @Override - public boolean isActive(final ItemStack itemStack) { + public boolean isActive(@Nonnull final ItemStack itemStack) { return getEnergy(itemStack) > WarpDriveConfig.TRANSPORTER_BEACON_ENERGY_PER_TICK; } @@ -212,15 +212,15 @@ public class ItemBlockTransporterBeacon extends ItemBlockAbstractBase implements @Nonnull @Override - public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, final World world, @Nonnull final BlockPos blockPos, - @Nonnull final EnumHand enumHand, @Nonnull final EnumFacing enumFacing, - final float hitX, final float hitY, final float hitZ) { + public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, + @Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumHand hand, + @Nonnull final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { if (world.isRemote) { return EnumActionResult.FAIL; } // get context - final ItemStack itemStackHeld = entityPlayer.getHeldItem(enumHand); + final ItemStack itemStackHeld = entityPlayer.getHeldItem(hand); if (itemStackHeld.isEmpty()) { return EnumActionResult.FAIL; } @@ -230,9 +230,9 @@ public class ItemBlockTransporterBeacon extends ItemBlockAbstractBase implements final TileEntity tileEntity = world.getTileEntity(blockPos); if (!(tileEntity instanceof ITransporterCore)) { - return super.onItemUse(entityPlayer, world, blockPos, enumHand, enumFacing, hitX, hitY, hitZ); + return super.onItemUse(entityPlayer, world, blockPos, hand, facing, hitX, hitY, hitZ); } - if (!entityPlayer.canPlayerEdit(blockPos, enumFacing, itemStackHeld)) { + if (!entityPlayer.canPlayerEdit(blockPos, facing, itemStackHeld)) { return EnumActionResult.FAIL; } diff --git a/src/main/java/cr0s/warpdrive/block/movement/ShipScanner.java b/src/main/java/cr0s/warpdrive/block/movement/ShipScanner.java index ed77cdaf..15c6ae3d 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/ShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/movement/ShipScanner.java @@ -13,15 +13,15 @@ import net.minecraft.world.IBlockAccess; class ShipScanner { // inputs - private IBlockAccess blockAccess; - private int minX, minY, minZ; - private int maxX, maxY, maxZ; + private final IBlockAccess blockAccess; + private final int minX, minY, minZ; + private final int maxX, maxY, maxZ; // execution private int x; private int y; private int z; - private MutableBlockPos mutableBlockPos; + private final MutableBlockPos mutableBlockPos; // output public int mass = 0; diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityAbstractShipController.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityAbstractShipController.java index 1d953218..48b66aae 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityAbstractShipController.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityAbstractShipController.java @@ -31,9 +31,10 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac private int moveUp = 0; private int moveRight = 0; private byte rotationSteps = 0; + protected String nameTarget = ""; + protected EnumShipCommand enumShipCommand = EnumShipCommand.IDLE; protected boolean isCommandConfirmed = false; - protected String nameTarget = ""; public TileEntityAbstractShipController() { super(); @@ -75,9 +76,6 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac public void readFromNBT(final NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); - final boolean isConfirmed = tagCompound.hasKey("commandConfirmed") && tagCompound.getBoolean("commandConfirmed"); - setCommand(tagCompound.getString("commandName"), isConfirmed); - setFront(tagCompound.getInteger("front")); setRight(tagCompound.getInteger("right")); setUp (tagCompound.getInteger("up")); @@ -91,6 +89,9 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac tagCompound.getInteger("moveRight") ); setRotationSteps(tagCompound.getByte("rotationSteps")); nameTarget = tagCompound.getString("nameTarget"); + + final boolean isConfirmed = tagCompound.hasKey("commandConfirmed") && tagCompound.getBoolean("commandConfirmed"); + setCommand(tagCompound.getString("commandName"), isConfirmed); } @Nonnull @@ -98,9 +99,6 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { tagCompound = super.writeToNBT(tagCompound); - tagCompound.setString("commandName", enumShipCommand.getName()); - tagCompound.setBoolean("commandConfirmed", isCommandConfirmed); - tagCompound.setInteger("front", getFront()); tagCompound.setInteger("right", getRight()); tagCompound.setInteger("up", getUp()); @@ -113,6 +111,10 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac tagCompound.setInteger("moveRight", moveRight); tagCompound.setByte("rotationSteps", rotationSteps); tagCompound.setString("nameTarget", nameTarget); + + tagCompound.setString("commandName", enumShipCommand.getName()); + tagCompound.setBoolean("commandConfirmed", isCommandConfirmed); + return tagCompound; } @@ -120,9 +122,6 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac public NBTTagCompound writeItemDropNBT(NBTTagCompound tagCompound) { tagCompound = super.writeItemDropNBT(tagCompound); - tagCompound.removeTag("commandName"); - tagCompound.removeTag("commandConfirmed"); - tagCompound.removeTag("front"); tagCompound.removeTag("right"); tagCompound.removeTag("up"); @@ -135,6 +134,10 @@ public abstract class TileEntityAbstractShipController extends TileEntityAbstrac tagCompound.removeTag("moveRight"); tagCompound.removeTag("rotationSteps"); tagCompound.removeTag("nameTarget"); + + tagCompound.removeTag("commandName"); + tagCompound.removeTag("commandConfirmed"); + return tagCompound; } diff --git a/src/main/java/cr0s/warpdrive/client/ClientProxy.java b/src/main/java/cr0s/warpdrive/client/ClientProxy.java index b47b449f..1cff27a1 100644 --- a/src/main/java/cr0s/warpdrive/client/ClientProxy.java +++ b/src/main/java/cr0s/warpdrive/client/ClientProxy.java @@ -83,7 +83,7 @@ public class ClientProxy extends CommonProxy { } @Nonnull - public static ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { + public static ModelResourceLocation getModelResourceLocation(@Nonnull final ItemStack itemStack) { final Item item = itemStack.getItem(); ResourceLocation resourceLocation = item.getRegistryName(); assert resourceLocation != null; @@ -107,9 +107,9 @@ public class ClientProxy extends CommonProxy { return new ModelResourceLocation(resourceLocation, "inventory"); } - public static void modelInitialisation(final Item item) { + public static void modelInitialisation(@Nonnull final Item item) { if (!(item instanceof IItemBase)) { - throw new RuntimeException(String.format("Unable to item, expecting an IItemBase instance: %s", + throw new RuntimeException(String.format("Unable to initialize item's model, expecting an IItemBase instance: %s", item)); } diff --git a/src/main/java/cr0s/warpdrive/command/AbstractCommand.java b/src/main/java/cr0s/warpdrive/command/AbstractCommand.java index df9e2e72..5de9fbce 100644 --- a/src/main/java/cr0s/warpdrive/command/AbstractCommand.java +++ b/src/main/java/cr0s/warpdrive/command/AbstractCommand.java @@ -9,7 +9,8 @@ import net.minecraft.util.text.TextComponentString; public abstract class AbstractCommand extends CommandBase { public ITextComponent getPrefix() { - return new TextComponentString("/" + getName()).setStyle(Commons.styleHeader).appendSibling(new TextComponentString(" ")); + return new TextComponentString("/" + getName()).setStyle(Commons.styleHeader) + .appendSibling(new TextComponentString(" ")); } } diff --git a/src/main/java/cr0s/warpdrive/command/CommandBed.java b/src/main/java/cr0s/warpdrive/command/CommandBed.java index 388fac59..151ca436 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandBed.java +++ b/src/main/java/cr0s/warpdrive/command/CommandBed.java @@ -15,21 +15,27 @@ import javax.annotation.Nonnull; public class CommandBed extends AbstractCommand { - @Override - public int getRequiredPermissionLevel() { - return 2; - } - @Nonnull @Override public String getName() { return "wbed"; } + @Override + public int getRequiredPermissionLevel() { + return 2; + } + + @Nonnull + @Override + public String getUsage(@Nonnull final ICommandSender commandSender) { + return getName() + " ()" + + "\nplayerName: name of the player home to find. Exact casing is required."; + } + @Override public void execute(@Nonnull final MinecraftServer server, @Nonnull final ICommandSender commandSender, @Nonnull final String[] args) { // parse arguments - //noinspection StatementWithEmptyBody EntityPlayerMP[] entityPlayerMPs = null; if (args.length == 0) { if (commandSender instanceof EntityPlayerMP) { @@ -105,11 +111,4 @@ public class CommandBed extends AbstractCommand { } } } - - @Nonnull - @Override - public String getUsage(@Nonnull final ICommandSender commandSender) { - return getName() + " ()" - + "\nplayerName: name of the player home to find. Exact casing is required."; - } } diff --git a/src/main/java/cr0s/warpdrive/command/CommandEntity.java b/src/main/java/cr0s/warpdrive/command/CommandEntity.java index 2427cc84..0148a898 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandEntity.java +++ b/src/main/java/cr0s/warpdrive/command/CommandEntity.java @@ -97,7 +97,7 @@ public class CommandEntity extends AbstractCommand { WarpDrive.logger.info(String.format("/%s %d '*%s*' %s", getName(), radius, filter, kill)); - List entities; + final List entities; if (radius <= 0) { final World world; if (commandSender instanceof EntityPlayerMP) { diff --git a/src/main/java/cr0s/warpdrive/command/CommandFind.java b/src/main/java/cr0s/warpdrive/command/CommandFind.java index 5aa06843..f50791f9 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandFind.java +++ b/src/main/java/cr0s/warpdrive/command/CommandFind.java @@ -11,22 +11,28 @@ import javax.annotation.Nonnull; public class CommandFind extends AbstractCommand { - @Override - public int getRequiredPermissionLevel() { - return 2; - } - @Nonnull @Override public String getName() { return "wfind"; } + @Override + public int getRequiredPermissionLevel() { + return 2; + } + + @Nonnull + @Override + public String getUsage(@Nonnull final ICommandSender commandSender) { + return getName() + " ()" + + "\nshipName: name of the ship to find. Exact casing is preferred."; + } + @Override public void execute(@Nonnull final MinecraftServer server, @Nonnull final ICommandSender commandSender, @Nonnull final String[] args) { // parse arguments - //noinspection StatementWithEmptyBody - String nameToken; + final String nameToken; if (args.length == 0) { Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender))); return; @@ -51,11 +57,4 @@ public class CommandFind extends AbstractCommand { final String result = WarpDrive.starMap.find(nameToken); Commons.addChatMessage(commandSender, new TextComponentString(result)); } - - @Nonnull - @Override - public String getUsage(@Nonnull final ICommandSender commandSender) { - return getName() + " ()" - + "\nshipName: name of the ship to find. Exact casing is preferred."; - } } diff --git a/src/main/java/cr0s/warpdrive/command/CommandGenerate.java b/src/main/java/cr0s/warpdrive/command/CommandGenerate.java index b1097cb9..31c0f094 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandGenerate.java +++ b/src/main/java/cr0s/warpdrive/command/CommandGenerate.java @@ -36,7 +36,7 @@ public class CommandGenerate extends AbstractCommand { @Nonnull @Override public String getUsage(@Nonnull final ICommandSender commandSender) { - return String.format("/%s []\nStructure groups are ship, station, astfield, %s", + return String.format("/%s ()\nStructure groups are ship, station, astfield, %s", getName(), StructureManager.getGroups().replace("\"", "") ); } diff --git a/src/main/java/cr0s/warpdrive/command/CommandInvisible.java b/src/main/java/cr0s/warpdrive/command/CommandInvisible.java index cff18c42..dc93048d 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandInvisible.java +++ b/src/main/java/cr0s/warpdrive/command/CommandInvisible.java @@ -12,6 +12,12 @@ import net.minecraft.server.MinecraftServer; public class CommandInvisible extends AbstractCommand { + @Nonnull + @Override + public String getName() { + return "invisible"; + } + @Override public int getRequiredPermissionLevel() { return 4; @@ -19,10 +25,10 @@ public class CommandInvisible extends AbstractCommand { @Nonnull @Override - public String getName() { - return "invisible"; + public String getUsage(@Nonnull final ICommandSender commandSender) { + return "/invisible [player]"; } - + @Override public void execute(@Nonnull final MinecraftServer server, @Nonnull final ICommandSender commandSender, @Nonnull final String[] args) { EntityPlayer player = commandSender instanceof EntityPlayer ? (EntityPlayer) commandSender : null; @@ -47,10 +53,4 @@ public class CommandInvisible extends AbstractCommand { // Toggle invisibility player.setInvisible(!player.isInvisible()); } - - @Nonnull - @Override - public String getUsage(@Nonnull final ICommandSender commandSender) { - return "/invisible [player]"; - } } diff --git a/src/main/java/cr0s/warpdrive/command/CommandReload.java b/src/main/java/cr0s/warpdrive/command/CommandReload.java index e3bb4001..040fcf3a 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandReload.java +++ b/src/main/java/cr0s/warpdrive/command/CommandReload.java @@ -11,6 +11,12 @@ import net.minecraft.util.text.TextComponentTranslation; public class CommandReload extends AbstractCommand { + @Nonnull + @Override + public String getName() { + return "wreload"; + } + @Override public int getRequiredPermissionLevel() { return 2; @@ -18,8 +24,8 @@ public class CommandReload extends AbstractCommand { @Nonnull @Override - public String getName() { - return "wreload"; + public String getUsage(@Nonnull final ICommandSender commandSender) { + return "/wreload"; } @Override @@ -28,10 +34,4 @@ public class CommandReload extends AbstractCommand { Commons.addChatMessage(commandSender, new TextComponentTranslation("warpdrive.command.configuration_reloaded").setStyle(Commons.styleCorrect)); Commons.addChatMessage(commandSender, new TextComponentTranslation("warpdrive.command.liability_warning").setStyle(Commons.styleWarning)); } - - @Nonnull - @Override - public String getUsage(@Nonnull final ICommandSender commandSender) { - return "/wreload"; - } } diff --git a/src/main/java/cr0s/warpdrive/command/CommandSpace.java b/src/main/java/cr0s/warpdrive/command/CommandSpace.java index cbb9a98f..cf682994 100644 --- a/src/main/java/cr0s/warpdrive/command/CommandSpace.java +++ b/src/main/java/cr0s/warpdrive/command/CommandSpace.java @@ -23,6 +23,12 @@ import net.minecraft.world.WorldServer; public class CommandSpace extends AbstractCommand { + @Nonnull + @Override + public String getName() { + return "space"; + } + @Override public int getRequiredPermissionLevel() { return 2; @@ -30,8 +36,8 @@ public class CommandSpace extends AbstractCommand { @Nonnull @Override - public String getName() { - return "space"; + public String getUsage(@Nonnull final ICommandSender commandSender) { + return "/space () ([overworld|nether|end|theend|space|hyper|hyperspace|])"; } @Override @@ -207,10 +213,4 @@ public class CommandSpace extends AbstractCommand { Commons.moveEntity(entityPlayerMP, worldTarget, new Vector3(xTarget + 0.5D, yTarget + 0.2D, zTarget + 0.5D)); } } - - @Nonnull - @Override - public String getUsage(@Nonnull final ICommandSender commandSender) { - return "/space () ([overworld|nether|end|theend|space|hyper|hyperspace|])"; - } } diff --git a/src/main/java/cr0s/warpdrive/config/Dictionary.java b/src/main/java/cr0s/warpdrive/config/Dictionary.java index 5a1a7937..27f90ee2 100644 --- a/src/main/java/cr0s/warpdrive/config/Dictionary.java +++ b/src/main/java/cr0s/warpdrive/config/Dictionary.java @@ -8,6 +8,7 @@ import cr0s.warpdrive.block.hull.BlockHullGlass; import cr0s.warpdrive.block.hull.BlockHullSlab; import cr0s.warpdrive.block.hull.BlockHullStairs; +import javax.annotation.Nonnull; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -689,7 +690,8 @@ public class Dictionary { } } - private static String getHashMessage(final HashSet hashSet) { + @Nonnull + private static String getHashMessage(@Nonnull final HashSet hashSet) { final StringBuilder message = new StringBuilder(); for (final Object object : hashSet) { if (message.length() > 0) { @@ -706,7 +708,8 @@ public class Dictionary { return message.toString(); } - private static String getHashMessage(final HashMap hashMap) { + @Nonnull + private static String getHashMessage(@Nonnull final HashMap hashMap) { final StringBuilder message = new StringBuilder(); for (final Entry entry : hashMap.entrySet()) { if (message.length() > 0) { @@ -717,9 +720,9 @@ public class Dictionary { return message.toString(); } - public static NBTBase writeItemsToNBT(final HashSet hashSetItem) { + @Nonnull + public static NBTBase writeItemsToNBT(@Nonnull final HashSet hashSetItem) { final NBTTagList nbtTagList = new NBTTagList(); - assert hashSetItem != null; for (final Item item : hashSetItem) { assert item.getRegistryName() != null; final String registryName = item.getRegistryName().toString(); @@ -728,8 +731,8 @@ public class Dictionary { return nbtTagList; } - public static HashSet readItemsFromNBT(final NBTTagList nbtTagList) { - assert nbtTagList != null; + @Nonnull + public static HashSet readItemsFromNBT(@Nonnull final NBTTagList nbtTagList) { final int size = nbtTagList.tagCount(); final HashSet hashSetItem = new HashSet<>(Math.max(8, size)); @@ -747,6 +750,7 @@ public class Dictionary { return hashSetItem; } + @Nonnull public static String getId(final Entity entity) { final ResourceLocation resourceLocation = EntityList.getKey(entity); return resourceLocation == null ? "-null-" : resourceLocation.toString(); diff --git a/src/main/java/cr0s/warpdrive/config/Recipes.java b/src/main/java/cr0s/warpdrive/config/Recipes.java index 92d00d77..ce2e28c8 100644 --- a/src/main/java/cr0s/warpdrive/config/Recipes.java +++ b/src/main/java/cr0s/warpdrive/config/Recipes.java @@ -212,26 +212,32 @@ public class Recipes { itemStackMotors = new ItemStack[] { itemStackMotorLV, itemStackMotorMV, itemStackMotorHV, itemStackMotorEV }; // integrate with iron bars from all mods - barsIron = WarpDriveConfig.getOreOrItemStack("ore:barsIron", 0, - "minecraft:iron_bars", 0); + barsIron = WarpDriveConfig.getOreOrItemStack( + "ore:barsIron", 0, + "minecraft:iron_bars", 0 ); // integrate with steel and aluminium ingots from all mods - ingotIronOrSteel = WarpDriveConfig.getOreOrItemStack("ore:ingotSteel", 0, - "ore:ingotAluminium", 0, - "ore:ingotAluminum", 0, - "ore:ingotIron", 0); + ingotIronOrSteel = WarpDriveConfig.getOreOrItemStack( + "ore:ingotSteel", 0, + "ore:ingotAluminium", 0, + "ore:ingotAluminum", 0, + "ore:ingotIron", 0 ); // integrate with rubber from all mods - rubber = WarpDriveConfig.getOreOrItemStack("ore:plateRubber", 0, // comes with GregTech - "ore:itemRubber", 0 ); // comes with WarpDrive, IndustrialCraft2, IndustrialForegoing, TechReborn + rubber = WarpDriveConfig.getOreOrItemStack( + "ore:plateRubber", 0, // comes with GregTech + "ore:itemRubber", 0 ); // comes with WarpDrive, IndustrialCraft2, IndustrialForegoing, TechReborn // integrate with circuits from all mods - goldNuggetOrBasicCircuit = WarpDriveConfig.getOreOrItemStack("ore:circuitBasic", 0, // comes with IndustrialCraft2, Mekanism, VoltzEngine - "ore:nuggetGold", 0); - goldIngotOrAdvancedCircuit = WarpDriveConfig.getOreOrItemStack("ore:circuitAdvanced", 0, // comes with IndustrialCraft2, Mekanism, VoltzEngine - "ore:ingotGold", 0); - emeraldOrSuperiorCircuit = WarpDriveConfig.getOreOrItemStack("ore:circuitElite", 0, // comes with Mekanism, VoltzEngine - "ore:gemEmerald", 0); + goldNuggetOrBasicCircuit = WarpDriveConfig.getOreOrItemStack( + "ore:circuitBasic", 0, // comes with IndustrialCraft2, Mekanism, VoltzEngine + "ore:nuggetGold", 0 ); + goldIngotOrAdvancedCircuit = WarpDriveConfig.getOreOrItemStack( + "ore:circuitAdvanced", 0, // comes with IndustrialCraft2, Mekanism, VoltzEngine + "ore:ingotGold", 0 ); + emeraldOrSuperiorCircuit = WarpDriveConfig.getOreOrItemStack( + "ore:circuitElite", 0, // comes with Mekanism, VoltzEngine + "ore:gemEmerald", 0 ); // Iridium block is just that if (WarpDriveConfig.isGregtechLoaded) { @@ -343,10 +349,11 @@ public class Recipes { } // Capacitive crystal is 2 Redstone block, 4 Paper, 1 Regeneration potion, 2 (lithium dust or electrum dust or electrical steel ingot or gold ingot) - final Object lithiumOrElectrum = WarpDriveConfig.getOreOrItemStack("ore:dustLithium", 0, // comes with GregTech, Industrial Craft 2 and Mekanism - "ore:dustElectrum", 0, // comes with ImmersiveEngineering, ThermalFoundation, Metallurgy - "ore:ingotElectricalSteel", 0, // comes with EnderIO - "ore:ingotGold", 0); + final Object lithiumOrElectrum = WarpDriveConfig.getOreOrItemStack( + "ore:dustLithium", 0, // comes with GregTech, Industrial Craft 2 and Mekanism + "ore:dustElectrum", 0, // comes with ImmersiveEngineering, ThermalFoundation, Metallurgy + "ore:ingotElectricalSteel", 0, // comes with EnderIO + "ore:ingotGold", 0 ); // (Lithium is processed from nether quartz) // (IC2 Experimental is 1 Lithium dust from 18 nether quartz) // Regeneration II (ghast tear + glowstone) @@ -356,7 +363,7 @@ public class Recipes { 'R', itemStackStrongRegeneration, 'r', "blockRedstone", 'l', lithiumOrElectrum, - 'p', Items.PAPER)); + 'p', Items.PAPER )); // Diamond crystal WarpDrive.register(new ShapedOreRecipe(groupComponents, @@ -384,17 +391,18 @@ public class Recipes { 'e', Items.ENDER_PEARL, 'B', barsIron, 'r', Items.REDSTONE, - 'g', nuggetGoldOrSilver)); + 'g', nuggetGoldOrSilver )); // Diamond coil is 6 Iron bars, 2 Gold ingots, 1 Diamond crystal, gives 12 - final Object ingotGoldOrSilver = WarpDriveConfig.getOreOrItemStack("ore:ingotElectrum", 0, - "ore:ingotSilver", 0, - "ore:ingotGold", 0); + final Object ingotGoldOrSilver = WarpDriveConfig.getOreOrItemStack( + "ore:ingotElectrum", 0, + "ore:ingotSilver", 0, + "ore:ingotGold", 0 ); WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStackNoCache(EnumComponentType.DIAMOND_COIL, 12), false, "bbg", "bdb", "gbb", 'b', barsIron, 'g', ingotGoldOrSilver, - 'd', ItemComponent.getItemStack(EnumComponentType.DIAMOND_CRYSTAL))); + 'd', ItemComponent.getItemStack(EnumComponentType.DIAMOND_CRYSTAL) )); // Computer interface is 2 Gold ingot, 2 Wired modems (or redstone), 1 Lead/Tin ingot Object redstoneOrModem = Items.REDSTONE; @@ -419,46 +427,51 @@ public class Recipes { 'G', oreCircuitOrHeavyPressurePlate, 'g', "ingotGold", 'r', redstoneOrModem, - 'a', "ingotSolderingAlloy")); + 'a', "ingotSolderingAlloy" )); } + // Computer interface: simple output - final Object slimeOrTinOrLead = WarpDriveConfig.getOreOrItemStack("ore:ingotTin", 0, - "ore:ingotLead", 0, - "ore:slimeball", 0); + final Object slimeOrTinOrLead = WarpDriveConfig.getOreOrItemStack( + "ore:ingotTin", 0, + "ore:ingotLead", 0, + "ore:slimeball", 0 ); WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStackNoCache(EnumComponentType.COMPUTER_INTERFACE, outputFactor), false, " ", "rar", "gGg", 'G', oreCircuitOrHeavyPressurePlate, 'g', "ingotGold", 'r', redstoneOrModem, - 'a', slimeOrTinOrLead)); + 'a', slimeOrTinOrLead )); // *** breathing components // Bone charcoal is smelting 1 Bone GameRegistry.addSmelting(Items.BONE, ItemComponent.getItemStackNoCache(EnumComponentType.BONE_CHARCOAL, 1), 1); // Activated carbon is 3 bone charcoal, 3 leaves, 2 water bottles, 1 sulfur dust or gunpowder - final Object leaves = WarpDriveConfig.getOreOrItemStack("ore:treeLeaves", 0, - "minecraft:leaves", 0); - final Object gunpowderOrSulfur = WarpDriveConfig.getOreOrItemStack("ore:dustSulfur", 0, - "ore:gunpowder", 0, - "minecraft:gunpowder", 0); + final Object leaves = WarpDriveConfig.getOreOrItemStack( + "ore:treeLeaves", 0, + "minecraft:leaves", 0 ); + final Object gunpowderOrSulfur = WarpDriveConfig.getOreOrItemStack( + "ore:dustSulfur", 0, + "ore:gunpowder", 0, + "minecraft:gunpowder", 0 ); final ItemStack itemStackWaterBottle = WarpDriveConfig.getItemStackOrFire("minecraft:potion", 0, "{Potion: \"minecraft:water\"}"); WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStack(EnumComponentType.ACTIVATED_CARBON), false, "lll", "aaa", "wgw", 'l', leaves, 'a', ItemComponent.getItemStack(EnumComponentType.BONE_CHARCOAL), 'w', itemStackWaterBottle, - 'g', gunpowderOrSulfur)); + 'g', gunpowderOrSulfur )); // Air canister is 4 iron bars, 2 rubber, 2 yellow wool, 1 tank - final Object woolPurple = WarpDriveConfig.getOreOrItemStack("ore:blockWoolPurple", 0, - "minecraft:wool", 10); + final Object woolPurple = WarpDriveConfig.getOreOrItemStack( + "ore:blockWoolPurple", 0, + "minecraft:wool", 10 ); WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStackNoCache(EnumComponentType.AIR_CANISTER, 4), false, "iyi", "rgr", "iyi", 'r', rubber, 'g', ItemComponent.getItemStack(EnumComponentType.GLASS_TANK), 'y', woolPurple, - 'i', barsIron)); + 'i', barsIron )); // *** human interface components // Flat screen is 3 Dyes, 1 Glowstone dust, 2 Paper, 3 Glass panes @@ -469,7 +482,7 @@ public class Recipes { 'B', "dyeBlue", 'd', "dustGlowstone", 'g', "paneGlassColorless", - 'p', Items.PAPER)); + 'p', Items.PAPER )); // Holographic projector is 5 Flat screens, 1 Zoom, 1 Emerald crystal, 1 Memory crystal WarpDrive.register(new ShapedOreRecipe(groupComponents, @@ -486,16 +499,16 @@ public class Recipes { WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStackNoCache(EnumComponentType.GLASS_TANK, 4), false, "sgs", "g g", "sgs", 's', "slimeball", - 'g', "blockGlass")); + 'g', "blockGlass" )); // Motor is 2 Gold nuggets (wires), 3 Iron ingots (steel rods), 4 Iron bars (coils) WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStack(EnumComponentType.MOTOR), false, "bbn", "iii", "bbn", 'b', barsIron, 'i', "ingotIron", - 'n', "nuggetGold")); + 'n', "nuggetGold" )); - // Pump is 2 Motor, 1 Iron ingot, 2 Tanks, 4 Rubber, gives 2 + // Pump is 2 Motor, 1 Iron ingot, 2 Tank, 4 Rubber, gives 2 WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStackNoCache(EnumComponentType.PUMP, 2), false, "sst", "mim", "tss", 's', rubber, @@ -534,21 +547,21 @@ public class Recipes { 'd', "gemDiamond")); } - // Zoom is 3 Lenses, 2 Iron ingot, 2 Dyes, 2 Redstone + // Zoom is 3 Lens, 2 Iron ingot, 2 Dyes, 1 Redstone, 1 Basic motor WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStack(EnumComponentType.ZOOM), false, "dir", "lll", "dit", 'r', Items.REDSTONE, 'i', ingotIronOrSteel, 'l', ItemComponent.getItemStack(EnumComponentType.LENS), 't', itemStackMotors[0], - 'd', "dye")); + 'd', "dye" )); - // Diffraction grating is 1 Ghast tear, 3 Iron bars, 3 Glowstone dust + // Diffraction grating is 1 Ghast tear, 3 Iron bar, 3 Glowstone block WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStack(EnumComponentType.DIFFRACTION_GRATING), false, " t ", "iii", "ggg", 't', Items.GHAST_TEAR, 'i', barsIron, - 'g', Blocks.GLOWSTONE)); + 'g', Blocks.GLOWSTONE )); // *** energy components // Power interface is 4 Redstone, 2 Rubber, 3 Gold ingot @@ -559,9 +572,10 @@ public class Recipes { 'r', Items.REDSTONE )); // Superconductor is 1 Ender crystal, 4 Power interface, 4 Cryotheum dust/Lapis block/10k Coolant cell - final Object coolant = WarpDriveConfig.getOreOrItemStack("ore:dustCryotheum", 0, // comes with ThermalFoundation - "ic2:heat_storage", 0, // IC2 Experimental 10k Coolant Cell - "ore:blockLapis", 0); + final Object coolant = WarpDriveConfig.getOreOrItemStack( + "ore:dustCryotheum", 0, // comes with ThermalFoundation + "ic2:heat_storage", 0, // IC2 Experimental 10k Coolant Cell + "ore:blockLapis", 0 ); WarpDrive.register(new ShapedOreRecipe(groupComponents, ItemComponent.getItemStack(EnumComponentType.SUPERCONDUCTOR), false, "pcp", "cec", "pcp", 'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE), @@ -828,14 +842,15 @@ public class Recipes { 'M', "blockElectromagnet3")); // Lower tier coil is iron, copper or coil - final Object ironIngotOrCopperIngotOrCoil = WarpDriveConfig.getOreOrItemStack("gregtech:wire_coil", 0, // GregTech Cupronickel Coil block - "ic2:crafting", 5, // IC2 Coil - "thermalfoundation:material", 513, // ThermalFoundation Redstone reception coil - "immersiveengineering:wirecoil", 1, // ImmersiveEngineering MV wire coil - "enderio:item_power_conduit", 1, // EnderIO Enhanced energy conduit - "ore:ingotCopper", 0, - "ore:ingotSteel", 0, - "minecraft:iron_ingot", 0); + final Object ironIngotOrCopperIngotOrCoil = WarpDriveConfig.getOreOrItemStack( + "gregtech:wire_coil", 0, // GregTech Cupronickel Coil block + "ic2:crafting", 5, // IC2 Coil + "thermalfoundation:material", 513, // ThermalFoundation Redstone reception coil + "immersiveengineering:wirecoil", 1, // ImmersiveEngineering MV wire coil + "enderio:item_power_conduit", 1, // EnderIO Enhanced energy conduit + "ore:ingotCopper", 0, + "ore:ingotSteel", 0, + "minecraft:iron_ingot", 0 ); // Normal electromagnets WarpDrive.register(new ShapedOreRecipe(groupMachines, @@ -943,11 +958,12 @@ public class Recipes { WarpDrive.itemAirTanks[EnumAirTankTier.SUPERIOR.getIndex()]), "_uncrafting"); // Air generator is 1 Power interface, 4 Activated carbon, 1 Motor, 1 MV Machine casing, 2 Glass tanks - final Object bronzeRotorOrIronBars = WarpDriveConfig.getOreOrItemStack("ore:rotorBronze", 0, // GregTech CE Bronze rotor - "ore:plateBronze", 8, // IC2 or ThermalExpansion Bronze plate - "ore:gearIronInfinity", 0, // EnderIO Infinity Bimetal Gear - "ore:barsIron", 0, // Ore dictionary iron bars - "minecraft:iron_bars", 0); // Vanilla iron bars + final Object bronzeRotorOrIronBars = WarpDriveConfig.getOreOrItemStack( + "ore:rotorBronze", 0, // GregTech CE Bronze rotor + "ore:plateBronze", 8, // IC2 or ThermalExpansion Bronze plate + "ore:gearIronInfinity", 0, // EnderIO Infinity Bimetal Gear + "ore:barsIron", 0, // Ore dictionary iron bars + "minecraft:iron_bars", 0 ); WarpDrive.register(new ShapedOreRecipe(groupMachines, new ItemStack(WarpDrive.blockAirGeneratorTiered[EnumTier.BASIC.getIndex()]), false, "aba", "ata", "gmp", 'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE), @@ -1088,15 +1104,17 @@ public class Recipes { private static void initDetection() { // Radar is 1 motor, 4 Titanium plate (diamond), 1 Quarztite rod (nether quartz), 1 Computer interface, 1 HV Machine casing, 1 Power interface - final Object oreCloakingPlate = WarpDriveConfig.getOreOrItemStack("ore:plateTitanium", 0, // GregTech - "ore:plateEnderium", 0, // ThermalExpansion - "ore:ingotVibrantAlloy", 0, // EnderIO - "ore:plateAlloyIridium", 0, // IndustrialCraft2 - "ore:gemQuartz", 0); // vanilla - final Object oreAntenna = WarpDriveConfig.getOreOrItemStack("ore:stickQuartzite", 0, // GregTech - "ore:ingotSignalum", 0, // ThermalExpansion - "ore:nuggetPulsatingIron", 0, // EnderIO - "minecraft:ghast_tear", 0); // vanilla + final Object oreCloakingPlate = WarpDriveConfig.getOreOrItemStack( + "ore:plateTitanium", 0, // GregTech + "ore:plateEnderium", 0, // ThermalExpansion + "ore:ingotVibrantAlloy", 0, // EnderIO + "ore:plateAlloyIridium", 0, // IndustrialCraft2 + "ore:gemQuartz", 0 ); + final Object oreAntenna = WarpDriveConfig.getOreOrItemStack( + "ore:stickQuartzite", 0, // GregTech + "ore:ingotSignalum", 0, // ThermalExpansion + "ore:nuggetPulsatingIron", 0, // EnderIO + "minecraft:ghast_tear", 0 ); WarpDrive.register(new ShapedOreRecipe(groupMachines, new ItemStack(WarpDrive.blockRadar), false, "PAP", "PtP", "pmc", 't', itemStackMotors[2], @@ -1138,24 +1156,27 @@ public class Recipes { 'p', ItemComponent.getItemStack(EnumComponentType.POWER_INTERFACE))); // Cloaking coil is 1 Titanium plate, 4 Reinforced iridium plate, 1 EV Machine casing (Ti) or 1 Beacon, 4 Emerald, 4 Diamond - final Object oreGoldIngotOrCoil = WarpDriveConfig.getOreOrItemStack("gregtech:wire_coil", 3, // GregTech Tungstensteel Coil block - "ic2:crafting", 5, // IC2 Coil - "thermalfoundation:material", 515, // ThermalFoundation Redstone conductance coil - "immersiveengineering:connector", 8, // ImmersiveEngineering HV Transformer (coils wires are too cheap) - "enderio:item_power_conduit", 2, // EnderIO Ender energy conduit - "minecraft:gold_ingot", 0); - final Object oreGoldIngotOrTitaniumPlate = WarpDriveConfig.getOreOrItemStack("ore:plateTitanium", 0, - "advanced_solar_panels:crafting", 0, // ASP Sunnarium - "ore:plateDenseSteel", 0, - "thermalfoundation:glass", 6, // ThermalFoundation Hardened Platinum Glass - "immersiveengineering:metal_device1", 3, // ImmersiveEngineering Thermoelectric Generator - "enderio:item_alloy_ingot", 2, // EnderIO Vibrant alloy (ore:ingotVibrantAlloy) - "minecraft:gold_ingot", 0); - final Object oreEmeraldOrIridiumPlate = WarpDriveConfig.getOreOrItemStack("ore:plateIridium", 0, // GregTech - "ore:plateAlloyIridium", 0, // IndustrialCraft2 - "enderio:item_material", 42, // EnderIO Frank'N'Zombie - "ore:ingotLumium", 0, // ThermalFoundation lumium ingot - "ore:gemEmerald", 0); + final Object oreGoldIngotOrCoil = WarpDriveConfig.getOreOrItemStack( + "gregtech:wire_coil", 3, // GregTech Tungstensteel Coil block + "ic2:crafting", 5, // IC2 Coil + "thermalfoundation:material", 515, // ThermalFoundation Redstone conductance coil + "immersiveengineering:connector", 8, // ImmersiveEngineering HV Transformer (coils wires are too cheap) + "enderio:item_power_conduit", 2, // EnderIO Ender energy conduit + "minecraft:gold_ingot", 0 ); + final Object oreGoldIngotOrTitaniumPlate = WarpDriveConfig.getOreOrItemStack( + "ore:plateTitanium", 0, + "advanced_solar_panels:crafting", 0, // ASP Sunnarium + "ore:plateDenseSteel", 0, + "thermalfoundation:glass", 6, // ThermalFoundation Hardened Platinum Glass + "immersiveengineering:metal_device1", 3, // ImmersiveEngineering Thermoelectric Generator + "enderio:item_alloy_ingot", 2, // EnderIO Vibrant alloy (ore:ingotVibrantAlloy) + "minecraft:gold_ingot", 0 ); + final Object oreEmeraldOrIridiumPlate = WarpDriveConfig.getOreOrItemStack( + "ore:plateIridium", 0, // GregTech + "ore:plateAlloyIridium", 0, // IndustrialCraft2 + "enderio:item_material", 42, // EnderIO Frank'N'Zombie + "ore:ingotLumium", 0, // ThermalFoundation lumium ingot + "ore:gemEmerald", 0 ); WarpDrive.register(new ShapedOreRecipe(groupMachines, new ItemStack(WarpDrive.blockCloakingCoil), false, "iti", "cmc", "iti", 't', oreGoldIngotOrTitaniumPlate, @@ -1515,11 +1536,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 - "minecraft:obsidian", 0); + 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 (final EnumDyeColor enumDyeColor : EnumDyeColor.values()) { final int metadataColor = enumDyeColor.getMetadata(); WarpDrive.register(new ShapedOreRecipe(groupTaintedHulls, @@ -1534,10 +1556,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 - "ore:gemDiamond", 0); + 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 (final EnumDyeColor enumDyeColor : EnumDyeColor.values()) { final int metadataColor = enumDyeColor.getMetadata(); WarpDrive.register(new ShapedOreRecipe(groupTaintedHulls, @@ -1724,10 +1747,11 @@ public class Recipes { 'b', ItemComponent.getItemStack(EnumComponentType.MEMORY_CRYSTAL))); // Laser lift is ... - final Object enderPearlOrMagnetizer = WarpDriveConfig.getOreOrItemStack("gregtech:machine", 420, // Gregtech Basic polarizer - "ic2:te", 37, // IC2 Magnetizer - "ore:ingotPulsatingIron", 0, // EnderIO iron ingot with ender pearl - "minecraft:ender_pearl", 0); + final Object enderPearlOrMagnetizer = WarpDriveConfig.getOreOrItemStack( + "gregtech:machine", 420, // Gregtech Basic polarizer + "ic2:te", 37, // IC2 Magnetizer + "ore:ingotPulsatingIron", 0, // EnderIO iron ingot with ender pearl + "minecraft:ender_pearl", 0 ); WarpDrive.register(new ShapedOreRecipe(groupMachines, new ItemStack(WarpDrive.blockLift), false, "wlw", "per", "glg", 'r', Items.REDSTONE, diff --git a/src/main/java/cr0s/warpdrive/data/GlobalPosition.java b/src/main/java/cr0s/warpdrive/data/GlobalPosition.java index 590ae891..7cbddab5 100644 --- a/src/main/java/cr0s/warpdrive/data/GlobalPosition.java +++ b/src/main/java/cr0s/warpdrive/data/GlobalPosition.java @@ -56,7 +56,7 @@ public class GlobalPosition { if (chunk != null) { isLoaded = !chunk.unloadQueued; } - } catch (NoSuchFieldError exception) { + } catch (final NoSuchFieldError exception) { isLoaded = chunkProviderServer.chunkExists(x >> 4, z >> 4); } // skip unloaded chunks diff --git a/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java b/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java index 6ade8231..fbf16b81 100644 --- a/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java +++ b/src/main/java/cr0s/warpdrive/data/StarMapRegistry.java @@ -8,6 +8,7 @@ import cr0s.warpdrive.block.movement.BlockShipCore; import cr0s.warpdrive.block.movement.TileEntityShipCore; import cr0s.warpdrive.config.WarpDriveConfig; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; @@ -225,7 +226,7 @@ public class StarMapRegistry { return String.format("No ship found with name '%s'", nameShip); } - public StarMapRegistryItem findNearest(final EnumStarMapEntryType enumStarMapEntryType, final World world, final BlockPos blockPos) { + public StarMapRegistryItem findNearest(final EnumStarMapEntryType enumStarMapEntryType, @Nonnull final World world, @Nonnull final BlockPos blockPos) { final CopyOnWriteArraySet setStarMapRegistryItems = registry.get(world.provider.getDimension()); if (setStarMapRegistryItems == null) { return null; @@ -253,7 +254,7 @@ public class StarMapRegistry { return result; } - public void onBlockUpdated(final World world, final BlockPos blockPos, final IBlockState blockState) { + public void onBlockUpdated(@Nonnull final World world, @Nonnull final BlockPos blockPos, final IBlockState blockState) { final CopyOnWriteArraySet setStarMapRegistryItems = registry.get(world.provider.getDimension()); if (setStarMapRegistryItems == null) { return; @@ -435,7 +436,7 @@ public class StarMapRegistry { } } - public boolean isWarpCoreIntersectsWithOthers(final TileEntityShipCore shipCore1) { + public boolean isWarpCoreIntersectsWithOthers(@Nonnull final TileEntityShipCore shipCore1) { cleanup(); if (!shipCore1.isValid()) { diff --git a/src/main/java/cr0s/warpdrive/data/StarMapRegistryItem.java b/src/main/java/cr0s/warpdrive/data/StarMapRegistryItem.java index b2e89ae6..f15c35a2 100644 --- a/src/main/java/cr0s/warpdrive/data/StarMapRegistryItem.java +++ b/src/main/java/cr0s/warpdrive/data/StarMapRegistryItem.java @@ -3,6 +3,7 @@ package cr0s.warpdrive.data; import cr0s.warpdrive.WarpDrive; import cr0s.warpdrive.api.IStarMapRegistryTileEntity; +import javax.annotation.Nonnull; import java.util.UUID; import net.minecraft.nbt.NBTTagCompound; @@ -87,7 +88,7 @@ public class StarMapRegistryItem extends GlobalPosition { name = tileEntity.getStarMapName(); } - public boolean contains(final BlockPos blockPos) { + public boolean contains(@Nonnull final BlockPos blockPos) { return minX <= blockPos.getX() && blockPos.getX() <= maxX && minY <= blockPos.getY() && blockPos.getY() <= maxY && minZ <= blockPos.getZ() && blockPos.getZ() <= maxZ; diff --git a/src/main/java/cr0s/warpdrive/event/ItemHandler.java b/src/main/java/cr0s/warpdrive/event/ItemHandler.java index 6c62fa8a..0f98865e 100644 --- a/src/main/java/cr0s/warpdrive/event/ItemHandler.java +++ b/src/main/java/cr0s/warpdrive/event/ItemHandler.java @@ -2,6 +2,8 @@ package cr0s.warpdrive.event; import cr0s.warpdrive.api.IItemBase; +import javax.annotation.Nonnull; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -11,7 +13,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ItemHandler { @SubscribeEvent - public void onItemExpireEvent(final ItemExpireEvent event) { + public void onItemExpireEvent(@Nonnull final ItemExpireEvent event) { if (event.getEntityItem() == null) { return; } diff --git a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java index fa66e940..fd95c73e 100644 --- a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java +++ b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java @@ -26,6 +26,7 @@ import cr0s.warpdrive.data.Vector3; import cr0s.warpdrive.data.VectorI; import cr0s.warpdrive.network.PacketHandler; +import javax.annotation.Nonnull; import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -95,7 +96,7 @@ public class JumpSequencer extends AbstractSequencer { protected final JumpShip ship; private boolean betweenWorlds; private boolean isPluginCheckDone = false; - private WarpDriveText firstAdjustmentReason = new WarpDriveText(); + private WarpDriveText firstAdjustmentReason = null; private long msCounter = 0; private int ticks = 0; @@ -673,13 +674,15 @@ public class JumpSequencer extends AbstractSequencer { } { - final BlockPos target1 = transformation.apply(ship.minX, ship.minY, ship.minZ); - final BlockPos target2 = transformation.apply(ship.maxX, ship.maxY, ship.maxZ); - final AxisAlignedBB aabbSource = new AxisAlignedBB(ship.minX, ship.minY, ship.minZ, ship.maxX, ship.maxY, ship.maxZ); + final BlockPos blockPosMinAtTarget = transformation.apply(ship.minX, ship.minY, ship.minZ); + final BlockPos blockPosMaxAtTarget = transformation.apply(ship.maxX, ship.maxY, ship.maxZ); + final AxisAlignedBB aabbSource = new AxisAlignedBB( + ship.minX, ship.minY, ship.minZ, + ship.maxX, ship.maxY, ship.maxZ); aabbSource.expand(1.0D, 1.0D, 1.0D); final AxisAlignedBB aabbTarget = new AxisAlignedBB( - Math.min(target1.getX(), target2.getX()), Math.min(target1.getY(), target2.getY()), Math.min(target1.getZ(), target2.getZ()), - Math.max(target1.getX(), target2.getX()), Math.max(target1.getY(), target2.getY()), Math.max(target1.getZ(), target2.getZ())); + blockPosMinAtTarget.getX(), blockPosMinAtTarget.getY(), blockPosMinAtTarget.getZ(), + blockPosMaxAtTarget.getX(), blockPosMaxAtTarget.getY(), blockPosMaxAtTarget.getZ() ); // Validate positions aren't overlapping if ( shipMovementType != EnumShipMovementType.INSTANTIATE && shipMovementType != EnumShipMovementType.RESTORE @@ -824,7 +827,7 @@ public class JumpSequencer extends AbstractSequencer { } } - protected boolean computeTargetWorld(final CelestialObject celestialObjectSource, final EnumShipMovementType shipMovementType, final WarpDriveText reason) { + protected boolean computeTargetWorld(final CelestialObject celestialObjectSource, @Nonnull final EnumShipMovementType shipMovementType, final WarpDriveText reason) { switch (shipMovementType) { case INSTANTIATE: case RESTORE: @@ -1105,7 +1108,7 @@ public class JumpSequencer extends AbstractSequencer { break; case NONE: - break; + // break; } } @@ -1286,7 +1289,6 @@ public class JumpSequencer extends AbstractSequencer { /** * Finishing jump: cleanup, collision effects and delete self **/ - @SuppressWarnings("unchecked") protected void state_finishing() { LocalProfiler.start("Jump.finishing()"); @@ -1663,6 +1665,7 @@ public class JumpSequencer extends AbstractSequencer { WarpDrive.logger.warn(String.format("Second NBT is %s", nbtTagCompound2)); } return 0; + } else { return 1; } diff --git a/src/main/java/cr0s/warpdrive/event/TooltipHandler.java b/src/main/java/cr0s/warpdrive/event/TooltipHandler.java index 55645136..03d0666f 100644 --- a/src/main/java/cr0s/warpdrive/event/TooltipHandler.java +++ b/src/main/java/cr0s/warpdrive/event/TooltipHandler.java @@ -45,7 +45,7 @@ public class TooltipHandler { @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.HIGHEST) - public void onTooltipEvent_first(final ItemTooltipEvent event) { + public void onTooltipEvent_first(@Nonnull final ItemTooltipEvent event) { if (event.getEntityPlayer() == null) { return; } @@ -64,7 +64,7 @@ public class TooltipHandler { @SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.LOWEST) - public void onTooltipEvent_last(final ItemTooltipEvent event) { + public void onTooltipEvent_last(@Nonnull final ItemTooltipEvent event) { if (event.getEntityPlayer() == null) { return; } diff --git a/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java b/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java index 27e07238..59169468 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java +++ b/src/main/java/cr0s/warpdrive/item/ItemAbstractBase.java @@ -46,9 +46,9 @@ public class ItemAbstractBase extends Item implements IItemBase { ClientProxy.modelInitialisation(this); } - @Override @Nonnull @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { return ClientProxy.getModelResourceLocation(itemStack); } diff --git a/src/main/java/cr0s/warpdrive/item/ItemComponent.java b/src/main/java/cr0s/warpdrive/item/ItemComponent.java index 2862c7eb..75e07ade 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemComponent.java +++ b/src/main/java/cr0s/warpdrive/item/ItemComponent.java @@ -13,6 +13,7 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; @@ -34,6 +35,7 @@ public class ItemComponent extends ItemAbstractBase implements IAirContainerItem itemStackCache = new ItemStack[EnumComponentType.length]; } + @Nonnull public static ItemStack getItemStack(final EnumComponentType enumComponentType) { if (enumComponentType != null) { final int damage = enumComponentType.ordinal(); @@ -42,7 +44,7 @@ public class ItemComponent extends ItemAbstractBase implements IAirContainerItem } return itemStackCache[damage]; } - return null; + return new ItemStack(Blocks.FIRE); } public static ItemStack getItemStackNoCache(final EnumComponentType enumComponentType, final int amount) { @@ -70,8 +72,8 @@ public class ItemComponent extends ItemAbstractBase implements IAirContainerItem } @Nonnull - @Override @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final int damage = itemStack.getItemDamage(); ResourceLocation resourceLocation = getRegistryName(); diff --git a/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java b/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java index 41653d7b..7a6d7115 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java +++ b/src/main/java/cr0s/warpdrive/item/ItemElectromagneticCell.java @@ -45,7 +45,7 @@ public class ItemElectromagneticCell extends ItemAbstractBase implements IPartic addPropertyOverride(new ResourceLocation(WarpDrive.MODID, "fill"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) @Override - public float apply(@Nonnull ItemStack itemStack, @Nullable World world, @Nullable EntityLivingBase entity) { + public float apply(@Nonnull final ItemStack itemStack, @Nullable final World world, @Nullable final EntityLivingBase entity) { final ParticleStack particleStack = getParticleStack(itemStack); if (particleStack != null) { return (float) particleStack.getAmount() / getCapacity(itemStack); @@ -56,8 +56,9 @@ public class ItemElectromagneticCell extends ItemAbstractBase implements IPartic } @Nonnull + @SideOnly(Side.CLIENT) @Override - public ModelResourceLocation getModelResourceLocation(ItemStack itemStack) { + public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { String variant = "empty"; final ParticleStack particleStack = getParticleStack(itemStack); if (particleStack != null) { diff --git a/src/main/java/cr0s/warpdrive/item/ItemForceFieldShape.java b/src/main/java/cr0s/warpdrive/item/ItemForceFieldShape.java index 3ffa66fc..915bffe9 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemForceFieldShape.java +++ b/src/main/java/cr0s/warpdrive/item/ItemForceFieldShape.java @@ -15,6 +15,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; @@ -42,6 +43,7 @@ public class ItemForceFieldShape extends ItemAbstractBase { itemStackCache = new ItemStack[EnumForceFieldShape.length]; } + @Nonnull public static ItemStack getItemStack(final EnumForceFieldShape forceFieldShape) { if (forceFieldShape != null) { final int damage = forceFieldShape.ordinal(); @@ -50,7 +52,7 @@ public class ItemForceFieldShape extends ItemAbstractBase { } return itemStackCache[damage]; } - return null; + return new ItemStack(Blocks.FIRE); } public static ItemStack getItemStackNoCache(final EnumForceFieldShape forceFieldShape, final int amount) { @@ -80,8 +82,8 @@ public class ItemForceFieldShape extends ItemAbstractBase { } @Nonnull - @Override @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final int damage = itemStack.getItemDamage(); ResourceLocation resourceLocation = getRegistryName(); diff --git a/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java b/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java index 54e1e611..4cbf5151 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java +++ b/src/main/java/cr0s/warpdrive/item/ItemForceFieldUpgrade.java @@ -79,8 +79,8 @@ public class ItemForceFieldUpgrade extends ItemAbstractBase { } @Nonnull - @Override @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final int damage = itemStack.getItemDamage(); ResourceLocation resourceLocation = getRegistryName(); diff --git a/src/main/java/cr0s/warpdrive/item/ItemPlasmaTorch.java b/src/main/java/cr0s/warpdrive/item/ItemPlasmaTorch.java index 65db457f..fb5c23f1 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemPlasmaTorch.java +++ b/src/main/java/cr0s/warpdrive/item/ItemPlasmaTorch.java @@ -43,7 +43,7 @@ public class ItemPlasmaTorch extends ItemAbstractBase implements IParticleContai addPropertyOverride(new ResourceLocation(WarpDrive.MODID, "fill"), new IItemPropertyGetter() { @SideOnly(Side.CLIENT) @Override - public float apply(@Nonnull ItemStack itemStack, @Nullable World world, @Nullable EntityLivingBase entity) { + public float apply(@Nonnull final ItemStack itemStack, @Nullable final World world, @Nullable final EntityLivingBase entity) { final ParticleStack particleStack = getParticleStack(itemStack); if (particleStack != null) { return (float) particleStack.getAmount() / getCapacity(itemStack); @@ -54,8 +54,9 @@ public class ItemPlasmaTorch extends ItemAbstractBase implements IParticleContai } @Nonnull + @SideOnly(Side.CLIENT) @Override - public ModelResourceLocation getModelResourceLocation(ItemStack itemStack) { + public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { String variant = "empty"; final ParticleStack particleStack = getParticleStack(itemStack); if (particleStack != null) { @@ -175,7 +176,7 @@ public class ItemPlasmaTorch extends ItemAbstractBase implements IParticleContai } @Override - public int getCapacity(ItemStack container) { + public int getCapacity(final ItemStack container) { return WarpDriveConfig.PLASMA_TORCH_CAPACITY_BY_TIER[enumTier.getIndex()]; } diff --git a/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java b/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java index e2d55df1..5bbb29b8 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java +++ b/src/main/java/cr0s/warpdrive/item/ItemTuningDriver.java @@ -67,8 +67,8 @@ public class ItemTuningDriver extends ItemAbstractBase implements IWarpTool { } @Nonnull - @Override @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final int damage = itemStack.getItemDamage(); ResourceLocation resourceLocation = getRegistryName(); @@ -266,9 +266,9 @@ public class ItemTuningDriver extends ItemAbstractBase implements IWarpTool { @Nonnull @Override - public EnumActionResult onItemUse(final EntityPlayer entityPlayer, - final World world, final BlockPos blockPos, final EnumHand hand, - final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { + public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, + @Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumHand hand, + @Nonnull final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { if (world.isRemote) { return EnumActionResult.FAIL; } diff --git a/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java b/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java index 450754c6..d88cbdcd 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java +++ b/src/main/java/cr0s/warpdrive/item/ItemTuningFork.java @@ -59,8 +59,8 @@ public class ItemTuningFork extends ItemAbstractBase implements IWarpTool { } @Nonnull - @Override @SideOnly(Side.CLIENT) + @Override public ModelResourceLocation getModelResourceLocation(final ItemStack itemStack) { final int damage = itemStack.getItemDamage(); ResourceLocation resourceLocation = getRegistryName(); @@ -104,9 +104,9 @@ public class ItemTuningFork extends ItemAbstractBase implements IWarpTool { @Nonnull @Override - public EnumActionResult onItemUse(final EntityPlayer entityPlayer, - final World world, final BlockPos blockPos, final EnumHand hand, - final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { + public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, + @Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumHand hand, + @Nonnull final EnumFacing enumFacing, final float hitX, final float hitY, final float hitZ) { if (world.isRemote) { return EnumActionResult.FAIL; } diff --git a/src/main/java/cr0s/warpdrive/item/ItemWrench.java b/src/main/java/cr0s/warpdrive/item/ItemWrench.java index 001075d6..299475f7 100644 --- a/src/main/java/cr0s/warpdrive/item/ItemWrench.java +++ b/src/main/java/cr0s/warpdrive/item/ItemWrench.java @@ -31,9 +31,9 @@ public class ItemWrench extends ItemAbstractBase implements IWarpTool { @Nonnull @Override - public EnumActionResult onItemUse(final EntityPlayer entityPlayer, - final World world, final BlockPos blockPos, final EnumHand hand, - final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { + public EnumActionResult onItemUse(@Nonnull final EntityPlayer entityPlayer, + @Nonnull final World world, @Nonnull final BlockPos blockPos, @Nonnull final EnumHand hand, + @Nonnull final EnumFacing facing, final float hitX, final float hitY, final float hitZ) { if (world.isRemote) { return EnumActionResult.FAIL; }