From 9fa56c73756a2efc5e07c2a605772bf5b11f69bf Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Fri, 18 Mar 2016 17:51:27 +0100 Subject: [PATCH] Code cleanup --- src/main/java/slimeknights/mantle/Mantle.java | 2 +- .../mantle/block/BlockInventory.java | 5 +- .../slimeknights/mantle/block/EnumBlock.java | 4 +- .../mantle/client/ModelHelper.java | 8 +- .../mantle/client/gui/GuiModule.java | 3 +- .../mantle/client/gui/GuiMultiModule.java | 4 +- .../mantle/client/model/TRSRBakedModel.java | 5 +- .../mantle/item/ItemBlockMeta.java | 13 +- .../slimeknights/mantle/item/ItemEdible.java | 17 +- .../mantle/item/ItemMetaDynamic.java | 20 +- .../mantle/multiblock/IMasterLogic.java | 15 +- .../mantle/multiblock/IMasterNode.java | 8 +- .../mantle/multiblock/IServantLogic.java | 54 ++-- .../mantle/multiblock/MultiServantLogic.java | 281 ++++++++---------- .../network/AbstractPacketThreadsafe.java | 2 - .../mantle/network/NetworkWrapper.java | 1 + .../mantle/tileentity/TileInventory.java | 2 +- .../slimeknights/mantle/util/JeiPlugin.java | 11 +- .../slimeknights/mantle/util/LocUtils.java | 4 +- .../slimeknights/mantle/util/RecipeMatch.java | 1 - .../mantle/util/RecipeMatchRegistry.java | 4 +- .../mantle/util/RecipeRemover.java | 122 ++++---- .../slimeknights/mantle/util/TagHelper.java | 1 + 23 files changed, 276 insertions(+), 311 deletions(-) diff --git a/src/main/java/slimeknights/mantle/Mantle.java b/src/main/java/slimeknights/mantle/Mantle.java index 715843b..4ed13e2 100644 --- a/src/main/java/slimeknights/mantle/Mantle.java +++ b/src/main/java/slimeknights/mantle/Mantle.java @@ -16,7 +16,7 @@ import slimeknights.mantle.common.CommonProxy; * * @author Sunstrike */ -@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.15,)", acceptedMinecraftVersions="[1.8.8,1.8.9]") +@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.15,)", acceptedMinecraftVersions = "[1.8.8,1.8.9]") public class Mantle { public static final String modId = "mantle"; diff --git a/src/main/java/slimeknights/mantle/block/BlockInventory.java b/src/main/java/slimeknights/mantle/block/BlockInventory.java index ac526df..e0fb51a 100644 --- a/src/main/java/slimeknights/mantle/block/BlockInventory.java +++ b/src/main/java/slimeknights/mantle/block/BlockInventory.java @@ -10,9 +10,9 @@ import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; +import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import slimeknights.mantle.tileentity.TileInventory; @@ -86,8 +86,7 @@ public abstract class BlockInventory extends BlockContainer { // BlockContainer sets this to invisible // we need model for standard forge rendering @Override - public EnumBlockRenderType getRenderType(IBlockState state) - { + public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.MODEL; } } diff --git a/src/main/java/slimeknights/mantle/block/EnumBlock.java b/src/main/java/slimeknights/mantle/block/EnumBlock.java index f2acc45..8bab9ef 100644 --- a/src/main/java/slimeknights/mantle/block/EnumBlock.java +++ b/src/main/java/slimeknights/mantle/block/EnumBlock.java @@ -15,6 +15,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; public class EnumBlock & EnumBlock.IEnumMeta & IStringSerializable> extends Block { + public final PropertyEnum prop; private final E[] values; @@ -28,7 +29,7 @@ public class EnumBlock & EnumBlock.IEnumMeta & IStringSerializ @SuppressWarnings("unchecked") private static Material preInit(Material material, PropertyEnum property) { - tmp=property; + tmp = property; return material; } @@ -72,6 +73,7 @@ public class EnumBlock & EnumBlock.IEnumMeta & IStringSerializ } public interface IEnumMeta { + int getMeta(); } } diff --git a/src/main/java/slimeknights/mantle/client/ModelHelper.java b/src/main/java/slimeknights/mantle/client/ModelHelper.java index 110e4cc..c569cc2 100644 --- a/src/main/java/slimeknights/mantle/client/ModelHelper.java +++ b/src/main/java/slimeknights/mantle/client/ModelHelper.java @@ -73,7 +73,8 @@ public class ModelHelper { data[i * 7 + 3] = c; } - return new BakedQuad(data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), quad.getFormat()); + return new BakedQuad(data, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad + .shouldApplyDiffuseLighting(), quad.getFormat()); } public static Map loadTexturesFromJson(ResourceLocation location) throws IOException { @@ -100,8 +101,7 @@ public class ModelHelper { return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath() + ".json"); } - private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s) - { + private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s) { return TRSRTransformation.blockCenterToCorner(new TRSRTransformation( new Vector3f(tx / 16, ty / 16, tz / 16), TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)), @@ -128,7 +128,7 @@ public class ModelHelper { } { BLOCK_THIRD_PERSON_RIGHT = get(0, 2.5f, 0, 75, 45, 0, 0.375f); - BLOCK_THIRD_PERSON_LEFT = get(0, 0, 0, 0, 255, 0, 0.4f); + BLOCK_THIRD_PERSON_LEFT = get(0, 0, 0, 0, 255, 0, 0.4f); } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java index 4711993..8774dca 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java @@ -6,9 +6,8 @@ import net.minecraft.inventory.Slot; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import java.awt.Rectangle; +import java.awt.*; import java.io.IOException; -import java.util.List; // a sub-gui. Mostly the same as a separate GuiContainer, but doesn't do the calls that affect the game as if this were the only gui @SideOnly(Side.CLIENT) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java index 5327cac..a6249af 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java @@ -58,7 +58,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler { public List getModuleAreas() { List areas = new ArrayList(modules.size()); - for (GuiModule module : modules) { + for(GuiModule module : modules) { areas.add(module.getArea()); } return areas; @@ -98,7 +98,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { drawContainerName(); drawPlayerInventoryName(); - + for(GuiModule module : modules) { // set correct state for the module GlStateManager.pushMatrix(); diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java index aa78e55..54ac8e6 100644 --- a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -1,8 +1,6 @@ package slimeknights.mantle.client.model; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.block.model.BakedQuad; @@ -21,7 +19,6 @@ import net.minecraftforge.client.model.TRSRTransformation; import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; import net.minecraftforge.client.model.pipeline.VertexTransformer; -import java.util.EnumMap; import java.util.List; import javax.vecmath.Matrix3f; @@ -161,7 +158,7 @@ public class TRSRBakedModel implements IBakedModel { } public UnpackedBakedQuad build() { - return ((UnpackedBakedQuad.Builder)parent).build(); + return ((UnpackedBakedQuad.Builder) parent).build(); } } } diff --git a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java index 99ff4d3..1d539e1 100644 --- a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java +++ b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java @@ -8,8 +8,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemColored; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.TextFormatting; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.translation.I18n; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameData; @@ -32,7 +32,9 @@ public class ItemBlockMeta extends ItemColored { @Override public String getUnlocalizedName(ItemStack stack) { - if(mappingProperty == null) return super.getUnlocalizedName(stack); + if(mappingProperty == null) { + return super.getUnlocalizedName(stack); + } IBlockState state = block.getStateFromMeta(stack.getMetadata()); String name = state.getValue(mappingProperty).toString().toLowerCase(Locale.US); @@ -40,7 +42,7 @@ public class ItemBlockMeta extends ItemColored { } public static void setMappingProperty(Block block, IProperty property) { - ((ItemBlockMeta)Item.getItemFromBlock(block)).mappingProperty = property; + ((ItemBlockMeta) Item.getItemFromBlock(block)).mappingProperty = property; } @Override @@ -62,11 +64,12 @@ public class ItemBlockMeta extends ItemColored { final ResourceLocation loc = GameData.getBlockRegistry().getNameForObject(block); - for(Comparable o : (Collection)mappingProperty.getAllowedValues()) { + for(Comparable o : (Collection) mappingProperty.getAllowedValues()) { int meta = block.getMetaFromState(block.getDefaultState().withProperty(mappingProperty, o)); String name = mappingProperty.getName(o); - ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(loc, mappingProperty.getName() + "=" + name)); + ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(loc, mappingProperty + .getName() + "=" + name)); } } } diff --git a/src/main/java/slimeknights/mantle/item/ItemEdible.java b/src/main/java/slimeknights/mantle/item/ItemEdible.java index ab12e0e..eee7e4b 100644 --- a/src/main/java/slimeknights/mantle/item/ItemEdible.java +++ b/src/main/java/slimeknights/mantle/item/ItemEdible.java @@ -37,11 +37,12 @@ public class ItemEdible extends ItemFood { /** * Add a new food type! - * @param meta Metadata to use, has to be free - * @param food How much food it restores on eating - * @param saturation Saturation multiplier on the food - * @param name Unlocalized postfix - * @param effects PotionEffects that will be applied on eating. The PotionEffect passed will be directly applied + * + * @param meta Metadata to use, has to be free + * @param food How much food it restores on eating + * @param saturation Saturation multiplier on the food + * @param name Unlocalized postfix + * @param effects PotionEffects that will be applied on eating. The PotionEffect passed will be directly applied * @return Itemstack containing the registered item */ public ItemStack addFood(int meta, int food, float saturation, String name, PotionEffect... effects) { @@ -67,10 +68,10 @@ public class ItemEdible extends ItemFood { @Override protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { - if (!worldIn.isRemote) - { + if(!worldIn.isRemote) { for(PotionEffect potion : potionEffects.get(stack.getMetadata())) { - player.addPotionEffect(new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier(), potion.getIsAmbient(), potion.doesShowParticles())); + player.addPotionEffect(new PotionEffect(potion.getPotion(), potion.getDuration(), potion.getAmplifier(), potion + .getIsAmbient(), potion.doesShowParticles())); } } } diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index b184c10..700b92a 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -41,20 +41,24 @@ public class ItemMetaDynamic extends Item { /** * Add a valid metadata. - * @param meta The metadata value - * @param name The name used for registering the itemmodel as well as the unlocalized name of the meta. The unlocalized name will be lowercased and stripped of whitespaces. + * + * @param meta The metadata value + * @param name The name used for registering the itemmodel as well as the unlocalized name of the meta. The unlocalized name will be lowercased and stripped of whitespaces. * @return An itemstack representing the Item-Meta combination. */ public ItemStack addMeta(int meta, String name) { if(meta > MAX) { - throw new IllegalArgumentException(String.format("Metadata for %s too high, highest supported value is %d. Meta was %d", name, MAX, meta)); + throw new IllegalArgumentException(String + .format("Metadata for %s too high, highest supported value is %d. Meta was %d", name, MAX, meta)); } else if(isValid(meta)) { - throw new IllegalArgumentException(String.format("Metadata for %s is already taken. Meta %d is %s", name, meta, names.get(meta))); + throw new IllegalArgumentException(String + .format("Metadata for %s is already taken. Meta %d is %s", name, meta, names + .get(meta))); } while(meta >= availabilityMask.length) { - availabilityMask = Arrays.copyOf(availabilityMask, availabilityMask.length*2); + availabilityMask = Arrays.copyOf(availabilityMask, availabilityMask.length * 2); } setValid(meta); names.put(meta, name); @@ -64,10 +68,12 @@ public class ItemMetaDynamic extends Item { @Override public String getUnlocalizedName(ItemStack stack) { int meta = stack.getMetadata(); // should call getMetadata below - if(isValid(meta)) + if(isValid(meta)) { return super.getUnlocalizedName(stack) + "." + LocUtils.makeLocString(names.get(meta)); - else + } + else { return super.getUnlocalizedName(stack); + } } @Override diff --git a/src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java b/src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java index 866bcf8..28a719b 100644 --- a/src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java @@ -2,11 +2,12 @@ package slimeknights.mantle.multiblock; import net.minecraft.util.math.BlockPos; -public interface IMasterLogic -{ - /** Called when servants change their state - * - * @param pos servant position - */ - void notifyChange(IServantLogic servant, BlockPos pos); +public interface IMasterLogic { + + /** + * Called when servants change their state + * + * @param pos servant position + */ + void notifyChange(IServantLogic servant, BlockPos pos); } diff --git a/src/main/java/slimeknights/mantle/multiblock/IMasterNode.java b/src/main/java/slimeknights/mantle/multiblock/IMasterNode.java index 6571b56..af67c99 100644 --- a/src/main/java/slimeknights/mantle/multiblock/IMasterNode.java +++ b/src/main/java/slimeknights/mantle/multiblock/IMasterNode.java @@ -1,8 +1,8 @@ package slimeknights.mantle.multiblock; -public interface IMasterNode extends IMasterLogic, IServantLogic -{ - boolean isCurrentlyMaster(); +public interface IMasterNode extends IMasterLogic, IServantLogic { - boolean isEquivalentMaster(IMasterLogic master); + boolean isCurrentlyMaster(); + + boolean isEquivalentMaster(IMasterLogic master); } diff --git a/src/main/java/slimeknights/mantle/multiblock/IServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/IServantLogic.java index 030f786..8277d21 100644 --- a/src/main/java/slimeknights/mantle/multiblock/IServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/IServantLogic.java @@ -3,39 +3,37 @@ package slimeknights.mantle.multiblock; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public interface IServantLogic -{ - BlockPos getMasterPosition(); +public interface IServantLogic { - /** The block should already have a valid master */ - void notifyMasterOfChange(); + BlockPos getMasterPosition(); - /** Checks if this block can be tied to this master - * - * @param master - * @param world the world of master - * @param pos position of master - * @return whether the servant can be tied to this master - */ + /** The block should already have a valid master */ + void notifyMasterOfChange(); - boolean setPotentialMaster(IMasterLogic master, World world, BlockPos pos); + /** + * Checks if this block can be tied to this master + * + * @param world the world of master + * @param pos position of master + * @return whether the servant can be tied to this master + */ - /** Used to set and verify that this is the block's master - * - * @param master - * @param world - * @param pos position of master - * @return Is this block tied to this master? - */ + boolean setPotentialMaster(IMasterLogic master, World world, BlockPos pos); - boolean verifyMaster(IMasterLogic master, World world, BlockPos pos); + /** + * Used to set and verify that this is the block's master + * + * @param pos position of master + * @return Is this block tied to this master? + */ - /** Exactly what it says on the tin - * - * @param master - * @param world - * @param pos position of master - */ + boolean verifyMaster(IMasterLogic master, World world, BlockPos pos); - void invalidateMaster(IMasterLogic master, World world, BlockPos pos); + /** + * Exactly what it says on the tin + * + * @param pos position of master + */ + + void invalidateMaster(IMasterLogic master, World world, BlockPos pos); } diff --git a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java index d37b6c9..657f607 100644 --- a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java @@ -7,191 +7,166 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameData; -public class MultiServantLogic extends TileEntity implements IServantLogic -{ - boolean hasMaster; +public class MultiServantLogic extends TileEntity implements IServantLogic { - BlockPos master; + boolean hasMaster; - Block masterBlock; + BlockPos master; - IBlockState state; + Block masterBlock; - public boolean canUpdate() - { - return false; + IBlockState state; + + public boolean canUpdate() { + return false; + } + + public boolean getHasMaster() { + return this.hasMaster; + } + + public boolean hasValidMaster() { + if(!this.hasMaster) { + return false; } - public boolean getHasMaster() - { - return this.hasMaster; + if(this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj + .getBlockState(this.master) == this.state) { + return true; } - - public boolean hasValidMaster() - { - if (!this.hasMaster) - { - return false; - } - - if (this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj.getBlockState(this.master) == this.state) - { - return true; - } - else - { - this.hasMaster = false; - this.master = null; - return false; - } + else { + this.hasMaster = false; + this.master = null; + return false; } + } - @Override - public BlockPos getMasterPosition() - { - return this.master; - } + @Override + public BlockPos getMasterPosition() { + return this.master; + } - public void overrideMaster(BlockPos pos) - { - this.hasMaster = true; - this.master = pos; - this.state = this.worldObj.getBlockState(this.master); - this.masterBlock = this.state.getBlock(); - } + public void overrideMaster(BlockPos pos) { + this.hasMaster = true; + this.master = pos; + this.state = this.worldObj.getBlockState(this.master); + this.masterBlock = this.state.getBlock(); + } - public void removeMaster() - { - this.hasMaster = false; - this.master = null; - this.masterBlock = null; - this.state = null; - } + public void removeMaster() { + this.hasMaster = false; + this.master = null; + this.masterBlock = null; + this.state = null; + } - @Override - public boolean setPotentialMaster(IMasterLogic master, World w, BlockPos pos) - { - return !this.hasMaster; - } + @Override + public boolean setPotentialMaster(IMasterLogic master, World w, BlockPos pos) { + return !this.hasMaster; + } - @Deprecated - public boolean verifyMaster(IMasterLogic logic, BlockPos pos) - { - return this.master.equals(pos) && this.worldObj.getBlockState(pos) == this.state && this.worldObj.getBlockState(pos).getBlock() == this.masterBlock; - } + @Deprecated + public boolean verifyMaster(IMasterLogic logic, BlockPos pos) { + return this.master.equals(pos) && this.worldObj.getBlockState(pos) == this.state && this.worldObj.getBlockState(pos) + .getBlock() == this.masterBlock; + } - @Override - public boolean verifyMaster(IMasterLogic logic, World world, BlockPos pos) - { - if (this.hasMaster) - { - return this.hasValidMaster(); - } - else - { - this.overrideMaster(pos); - return true; - } + @Override + public boolean verifyMaster(IMasterLogic logic, World world, BlockPos pos) { + if(this.hasMaster) { + return this.hasValidMaster(); } + else { + this.overrideMaster(pos); + return true; + } + } - @Override - public void invalidateMaster(IMasterLogic master, World w, BlockPos pos) - { - this.hasMaster = false; - master = null; - } + @Override + public void invalidateMaster(IMasterLogic master, World w, BlockPos pos) { + this.hasMaster = false; + master = null; + } - @Override - public void notifyMasterOfChange() - { - if (this.hasValidMaster()) - { - IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master); - logic.notifyChange(this, this.pos); - } + @Override + public void notifyMasterOfChange() { + if(this.hasValidMaster()) { + IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master); + logic.notifyChange(this, this.pos); } + } - public void readCustomNBT(NBTTagCompound tags) - { - this.hasMaster = tags.getBoolean("hasMaster"); - if (this.hasMaster) - { - int xCenter = tags.getInteger("xCenter"); - int yCenter = tags.getInteger("yCenter"); - int zCenter = tags.getInteger("zCenter"); - this.master = new BlockPos(xCenter, yCenter, zCenter); - this.masterBlock = GameData.getBlockRegistry().getObject(new ResourceLocation(tags.getString("MasterBlockName"))); - this.state = Block.getStateById(tags.getInteger("masterState")); - } + public void readCustomNBT(NBTTagCompound tags) { + this.hasMaster = tags.getBoolean("hasMaster"); + if(this.hasMaster) { + int xCenter = tags.getInteger("xCenter"); + int yCenter = tags.getInteger("yCenter"); + int zCenter = tags.getInteger("zCenter"); + this.master = new BlockPos(xCenter, yCenter, zCenter); + this.masterBlock = GameData.getBlockRegistry().getObject(new ResourceLocation(tags.getString("MasterBlockName"))); + this.state = Block.getStateById(tags.getInteger("masterState")); } + } - public void writeCustomNBT(NBTTagCompound tags) - { - tags.setBoolean("hasMaster", this.hasMaster); - if (this.hasMaster) - { - tags.setInteger("xCenter", this.master.getX()); - tags.setInteger("yCenter", this.master.getY()); - tags.setInteger("zCenter", this.master.getZ()); - tags.setString("MasterBlockName", GameData.getBlockRegistry().getNameForObject(this.masterBlock).toString()); - tags.setInteger("masterState", Block.getStateId(this.state)); - } + public void writeCustomNBT(NBTTagCompound tags) { + tags.setBoolean("hasMaster", this.hasMaster); + if(this.hasMaster) { + tags.setInteger("xCenter", this.master.getX()); + tags.setInteger("yCenter", this.master.getY()); + tags.setInteger("zCenter", this.master.getZ()); + tags.setString("MasterBlockName", GameData.getBlockRegistry().getNameForObject(this.masterBlock).toString()); + tags.setInteger("masterState", Block.getStateId(this.state)); } + } - @Override - public void readFromNBT(NBTTagCompound tags) - { - super.readFromNBT(tags); - this.readCustomNBT(tags); - } + @Override + public void readFromNBT(NBTTagCompound tags) { + super.readFromNBT(tags); + this.readCustomNBT(tags); + } - @Override - public void writeToNBT(NBTTagCompound tags) - { - super.writeToNBT(tags); - this.writeCustomNBT(tags); - } + @Override + public void writeToNBT(NBTTagCompound tags) { + super.writeToNBT(tags); + this.writeCustomNBT(tags); + } - /* Packets */ - @Override - public Packet getDescriptionPacket() - { - NBTTagCompound tag = new NBTTagCompound(); - this.writeCustomNBT(tag); - return new SPacketUpdateTileEntity(this.pos, 1, tag); - } + /* Packets */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + this.writeCustomNBT(tag); + return new SPacketUpdateTileEntity(this.pos, 1, tag); + } - @Override - public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) - { - this.readCustomNBT(packet.getNbtCompound()); - this.worldObj.notifyLightSet(this.pos); - this.worldObj.notifyBlockUpdate(this.pos, state, state, 3); - } + @Override + public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { + this.readCustomNBT(packet.getNbtCompound()); + this.worldObj.notifyLightSet(this.pos); + this.worldObj.notifyBlockUpdate(this.pos, state, state, 3); + } - @Override - public World getWorld() - { - return this.worldObj; - } + @Override + public World getWorld() { + return this.worldObj; + } - @Deprecated - public boolean setMaster(BlockPos pos) - { - if (!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj.getBlockState(this.master).getBlock() != this.masterBlock)) - { - this.overrideMaster(pos); - return true; - } - else - { - return false; - } + @Deprecated + public boolean setMaster(BlockPos pos) { + if(!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj + .getBlockState(this.master) + .getBlock() != this.masterBlock)) { + this.overrideMaster(pos); + return true; } + else { + return false; + } + } } diff --git a/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java b/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java index b7460bc..08c0c4e 100644 --- a/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java +++ b/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java @@ -3,8 +3,6 @@ package slimeknights.mantle.network; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.server.MinecraftServer; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; /** diff --git a/src/main/java/slimeknights/mantle/network/NetworkWrapper.java b/src/main/java/slimeknights/mantle/network/NetworkWrapper.java index cfa3ea3..5dcc3c9 100644 --- a/src/main/java/slimeknights/mantle/network/NetworkWrapper.java +++ b/src/main/java/slimeknights/mantle/network/NetworkWrapper.java @@ -49,6 +49,7 @@ public class NetworkWrapper { } public static class AbstactPacketHandler implements IMessageHandler { + @Override public IMessage onMessage(AbstractPacket packet, MessageContext ctx) { if(ctx.side == Side.SERVER) { diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index 6b50aee..1caab1e 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -7,9 +7,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.ITextComponent; import java.util.Arrays; diff --git a/src/main/java/slimeknights/mantle/util/JeiPlugin.java b/src/main/java/slimeknights/mantle/util/JeiPlugin.java index 7219496..276b122 100644 --- a/src/main/java/slimeknights/mantle/util/JeiPlugin.java +++ b/src/main/java/slimeknights/mantle/util/JeiPlugin.java @@ -1,16 +1,14 @@ package slimeknights.mantle.util; +import java.awt.*; +import java.util.List; + import javax.annotation.Nonnull; import javax.annotation.Nullable; -import java.awt.Rectangle; -import java.util.List; -import mezz.jei.api.IItemRegistry; -import mezz.jei.api.IJeiHelpers; import mezz.jei.api.IJeiRuntime; import mezz.jei.api.IModPlugin; import mezz.jei.api.IModRegistry; -import mezz.jei.api.IRecipeRegistry; import mezz.jei.api.JEIPlugin; import mezz.jei.api.gui.IAdvancedGuiHandler; import slimeknights.mantle.client.gui.GuiMultiModule; @@ -36,5 +34,6 @@ public class JeiPlugin implements IModPlugin { } @Override - public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {} + public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { + } } diff --git a/src/main/java/slimeknights/mantle/util/LocUtils.java b/src/main/java/slimeknights/mantle/util/LocUtils.java index e9a289e..2049011 100644 --- a/src/main/java/slimeknights/mantle/util/LocUtils.java +++ b/src/main/java/slimeknights/mantle/util/LocUtils.java @@ -6,7 +6,9 @@ import java.util.Locale; // localization utils public abstract class LocUtils { - private LocUtils() {} + + private LocUtils() { + } /** * Removes all whitespaces from the string and makes it lowercase. diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index f6651ba..5b9e5e2 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -5,7 +5,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java b/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java index 701840e..b5dd7ce 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java @@ -1,7 +1,6 @@ package slimeknights.mantle.util; import com.google.common.collect.Lists; -import com.google.common.collect.Queues; import net.minecraft.block.Block; import net.minecraft.item.Item; @@ -137,7 +136,8 @@ public class RecipeMatchRegistry { public static RecipeComparator INSTANCE = new RecipeComparator(); - private RecipeComparator() {} + private RecipeComparator() { + } @Override public int compare(RecipeMatch o1, RecipeMatch o2) { diff --git a/src/main/java/slimeknights/mantle/util/RecipeRemover.java b/src/main/java/slimeknights/mantle/util/RecipeRemover.java index eef31cd..d36172e 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeRemover.java +++ b/src/main/java/slimeknights/mantle/util/RecipeRemover.java @@ -12,83 +12,67 @@ import java.util.List; import java.util.Map; @SuppressWarnings("unchecked") -public class RecipeRemover -{ - public static void removeShapedRecipes(List removelist) - { - for (ItemStack stack : removelist) - { - removeShapedRecipe(stack); +public class RecipeRemover { + + public static void removeShapedRecipes(List removelist) { + for(ItemStack stack : removelist) { + removeShapedRecipe(stack); + } + } + + public static void removeAnyRecipe(ItemStack resultItem) { + List recipes = CraftingManager.getInstance().getRecipeList(); + for(int i = 0; i < recipes.size(); i++) { + IRecipe tmpRecipe = recipes.get(i); + ItemStack recipeResult = tmpRecipe.getRecipeOutput(); + if(ItemStack.areItemStacksEqual(resultItem, recipeResult)) { + recipes.remove(i--); + } + } + } + + public static void removeShapedRecipe(ItemStack resultItem) { + List recipes = CraftingManager.getInstance().getRecipeList(); + for(int i = 0; i < recipes.size(); i++) { + IRecipe tmpRecipe = recipes.get(i); + if(tmpRecipe instanceof ShapedRecipes) { + ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if(ItemStack.areItemStacksEqual(resultItem, recipeResult)) { + recipes.remove(i--); } + } } + } - public static void removeAnyRecipe(ItemStack resultItem) - { - List recipes = CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < recipes.size(); i++) - { - IRecipe tmpRecipe = recipes.get(i); - ItemStack recipeResult = tmpRecipe.getRecipeOutput(); - if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) - { - recipes.remove(i--); - } + public static void removeShapelessRecipe(ItemStack resultItem) { + List recipes = CraftingManager.getInstance().getRecipeList(); + for(int i = 0; i < recipes.size(); i++) { + IRecipe tmpRecipe = recipes.get(i); + if(tmpRecipe instanceof ShapelessRecipes) { + ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe; + ItemStack recipeResult = recipe.getRecipeOutput(); + + if(ItemStack.areItemStacksEqual(resultItem, recipeResult)) { + recipes.remove(i--); } + } } + } - public static void removeShapedRecipe(ItemStack resultItem) - { - List recipes = CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < recipes.size(); i++) - { - IRecipe tmpRecipe = recipes.get(i); - if (tmpRecipe instanceof ShapedRecipes) - { - ShapedRecipes recipe = (ShapedRecipes) tmpRecipe; - ItemStack recipeResult = recipe.getRecipeOutput(); + public static void removeFurnaceRecipe(ItemStack resultItem) { + Map recipes = FurnaceRecipes.instance().getSmeltingList(); + recipes.remove(resultItem); + } - if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) - { - recipes.remove(i--); - } - } - } - } + public static void removeFurnaceRecipe(Item i, int metadata) { + removeFurnaceRecipe(new ItemStack(i, 1, metadata)); + } - public static void removeShapelessRecipe(ItemStack resultItem) - { - List recipes = CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < recipes.size(); i++) - { - IRecipe tmpRecipe = recipes.get(i); - if (tmpRecipe instanceof ShapelessRecipes) - { - ShapelessRecipes recipe = (ShapelessRecipes) tmpRecipe; - ItemStack recipeResult = recipe.getRecipeOutput(); - - if (ItemStack.areItemStacksEqual(resultItem, recipeResult)) - { - recipes.remove(i--); - } - } - } - } - - public static void removeFurnaceRecipe(ItemStack resultItem) - { - Map recipes = FurnaceRecipes.instance().getSmeltingList(); - recipes.remove(resultItem); - } - - public static void removeFurnaceRecipe(Item i, int metadata) - { - removeFurnaceRecipe(new ItemStack(i, 1, metadata)); - } - - public static void removeFurnaceRecipe(Item i) - { - removeFurnaceRecipe(new ItemStack(i, 1, 32767)); - } + public static void removeFurnaceRecipe(Item i) { + removeFurnaceRecipe(new ItemStack(i, 1, 32767)); + } /* // todo: 1.9 //removes from all vanilla worldgen chests :D diff --git a/src/main/java/slimeknights/mantle/util/TagHelper.java b/src/main/java/slimeknights/mantle/util/TagHelper.java index 3151e53..a4ed21e 100644 --- a/src/main/java/slimeknights/mantle/util/TagHelper.java +++ b/src/main/java/slimeknights/mantle/util/TagHelper.java @@ -6,6 +6,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; public class TagHelper { + public static int TAG_TYPE_STRING = (new NBTTagString()).getId(); public static int TAG_TYPE_COMPOUND = (new NBTTagCompound()).getId();