From f824777c441a61c817a990f954bf3286455d3e89 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Tue, 2 Dec 2014 14:57:14 -0500 Subject: [PATCH 01/91] start porting to 1.8 this initial pass just fixes FML imports and moves some things to blockpos --- build.properties | 7 +- src/mantle/Mantle.java | 24 +-- src/mantle/blocks/MantleBlock.java | 1 - .../abstracts/AdaptiveInventoryLogic.java | 5 +- .../abstracts/ExpandableInventoryLogic.java | 5 +- .../blocks/abstracts/InventoryBlock.java | 35 ++-- .../blocks/abstracts/InventoryLogic.java | 4 +- .../blocks/abstracts/InventorySlab.java | 23 +-- .../blocks/abstracts/MultiServantLogic.java | 15 +- src/mantle/blocks/iface/IFacingLogic.java | 1 + src/mantle/blocks/iface/IServantLogic.java | 18 +- src/mantle/books/BookData.java | 6 +- src/mantle/books/external/ZipLoader.java | 22 +-- src/mantle/client/RenderItemCopy.java | 28 ++- src/mantle/client/SmallFontRenderer.java | 14 +- src/mantle/client/gui/GuiManual.java | 4 +- src/mantle/client/gui/TurnPageButton.java | 1 - src/mantle/client/pages/PicturePage.java | 1 - src/mantle/common/ComparisonHelper.java | 3 +- src/mantle/common/MProxyCommon.java | 2 +- src/mantle/crash/CallableSuppConfig.java | 2 +- src/mantle/crash/CallableUnsuppConfig.java | 2 +- src/mantle/debug/LogIdentifier.java | 56 ------ src/mantle/event/ManualOpenEvent.java | 2 +- src/mantle/event/Migration.java | 8 +- src/mantle/items/ItemUtils.java | 4 +- src/mantle/items/Manual.java | 4 +- src/mantle/items/abstracts/CraftingItem.java | 4 +- src/mantle/lib/CoreConfig.java | 3 - .../lib/environment/EnvironmentChecks.java | 4 +- src/mantle/math/Dozenal.java | 4 +- src/mantle/module/ILoadableModule.java | 26 --- src/mantle/module/ModuleController.java | 180 ------------------ src/mantle/utils/ItemMetaWrapper.java | 3 +- src/mantle/utils/ItemStackWrapper.java | 3 +- src/mantle/world/CoordTuple.java | 175 ----------------- src/mantle/world/CoordTuplePair.java | 12 +- src/mantle/world/CoordTupleSort.java | 31 --- src/mantle/world/DimensionCoordPair.java | 5 +- src/mantle/world/DimensionCoordTuple.java | 5 +- 40 files changed, 131 insertions(+), 621 deletions(-) delete mode 100644 src/mantle/debug/LogIdentifier.java delete mode 100644 src/mantle/module/ILoadableModule.java delete mode 100644 src/mantle/module/ModuleController.java delete mode 100644 src/mantle/world/CoordTuple.java delete mode 100644 src/mantle/world/CoordTupleSort.java diff --git a/build.properties b/build.properties index c3092ab..20501d3 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,4 @@ -mod_version=0.3.2 -minecraft_version=1.7.10 -forge_version=10.13.0.1187 +mod_version=0.4 +minecraft_version=1.8 +forge_version=11.14.0.1251-1.8 + diff --git a/src/mantle/Mantle.java b/src/mantle/Mantle.java index 91509a0..3c929a4 100644 --- a/src/mantle/Mantle.java +++ b/src/mantle/Mantle.java @@ -8,21 +8,20 @@ import mantle.books.BookData; import mantle.books.BookDataStore; import mantle.common.IDDumps; import mantle.common.MProxyCommon; -import mantle.debug.LogIdentifier; import mantle.items.Manual; import mantle.lib.CoreConfig; import mantle.lib.CoreRepo; import mantle.lib.environment.EnvironmentChecks; import mantle.module.ModuleController; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.registry.GameRegistry; import java.io.File; @@ -44,7 +43,6 @@ public class Mantle public static MProxyCommon proxy; public static Manual mantleBook; - public static LogIdentifier logID; /** * Constructor * @@ -69,10 +67,6 @@ public class Mantle logger.info("Entering preinitialization phase."); CoreConfig.loadConfiguration(evt.getModConfigurationDirectory()); - if (CoreConfig.identifyLogs) { - logID = new LogIdentifier(); - logID.preinit(); - } NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); mantleBook = (Manual) new Manual().setUnlocalizedName("mantle.manual"); diff --git a/src/mantle/blocks/MantleBlock.java b/src/mantle/blocks/MantleBlock.java index fe43726..f8e9ffe 100644 --- a/src/mantle/blocks/MantleBlock.java +++ b/src/mantle/blocks/MantleBlock.java @@ -7,7 +7,6 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.FMLCommonHandler; diff --git a/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java b/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java index 96162ab..c6436bb 100644 --- a/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java +++ b/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java @@ -6,7 +6,6 @@ import mantle.blocks.iface.IFacingLogic; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import cpw.mods.fml.common.FMLCommonHandler; public abstract class AdaptiveInventoryLogic extends InventoryLogic implements IFacingLogic { @@ -75,8 +74,8 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I } stack.stackSize -= itemSize; - EntityItem entityitem = new EntityItem(worldObj, (double) ((float) xCoord + jumpX + offsetX), (double) ((float) yCoord + jumpY), - (double) ((float) zCoord + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage())); + EntityItem entityitem = new EntityItem(worldObj, (double) ((float) pos.getX() + jumpX + offsetX), (double) ((float) pos.getY() + jumpY), + (double) ((float) pos.getZ() + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage())); if (stack.hasTagCompound()) { diff --git a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java b/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java index de97a44..8cca62d 100644 --- a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java +++ b/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java @@ -5,6 +5,7 @@ import net.minecraft.entity.player.*; import net.minecraft.inventory.*; import net.minecraft.item.ItemStack; import net.minecraft.nbt.*; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; public abstract class ExpandableInventoryLogic extends InventoryLogic implements IInventory @@ -105,11 +106,11 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements @Override public boolean isUseableByPlayer (EntityPlayer entityplayer) { - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) + if (worldObj.getTileEntity(pos) != this) return false; else - return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + return entityplayer.getDistance((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64D; } diff --git a/src/mantle/blocks/abstracts/InventoryBlock.java b/src/mantle/blocks/abstracts/InventoryBlock.java index 5fbeb01..273e47a 100644 --- a/src/mantle/blocks/abstracts/InventoryBlock.java +++ b/src/mantle/blocks/abstracts/InventoryBlock.java @@ -2,8 +2,8 @@ package mantle.blocks.abstracts; import java.util.Random; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; import mantle.blocks.iface.IActiveLogic; import mantle.blocks.iface.IFacingLogic; import mantle.debug.DebugHelper; @@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; +import net.minecraft.util.BlockPos; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; @@ -48,12 +49,12 @@ public abstract class InventoryBlock extends BlockContainer public abstract Object getModInstance (); @Override - public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + public boolean onBlockActivated (World world, BlockPos pos, EntityPlayer player, int side, float clickX, float clickY, float clickZ) { if (player.isSneaking()) return false; - Integer integer = getGui(world, x, y, z, player); + Integer integer = getGui(world, pos, player); if (integer == null || integer == -1) { return false; @@ -61,16 +62,16 @@ public abstract class InventoryBlock extends BlockContainer else { if (!world.isRemote) - player.openGui(getModInstance(), integer, world, x, y, z); + player.openGui(getModInstance(), integer, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } /* Inventory */ @Override - public void breakBlock (World par1World, int x, int y, int z, Block blockID, int meta) + public void breakBlock (World par1World, BlockPos pos, Block blockID, int meta) { - TileEntity te = par1World.getTileEntity(x, y, z); + TileEntity te = par1World.getTileEntity(pos); if (te != null && te instanceof InventoryLogic) { @@ -96,7 +97,7 @@ public abstract class InventoryBlock extends BlockContainer } stack.stackSize -= itemSize; - EntityItem entityitem = new EntityItem(par1World, (double) ((float) x + jumpX), (double) ((float) y + jumpY), (double) ((float) z + jumpZ), new ItemStack(stack.getItem(), + EntityItem entityitem = new EntityItem(par1World, (double) ((float) pos.getX() + jumpX), (double) ((float) pos.getY() + jumpY), (double) ((float) pos.getZ() + jumpZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage())); if (stack.hasTagCompound()) @@ -114,7 +115,7 @@ public abstract class InventoryBlock extends BlockContainer } } - super.breakBlock(par1World, x, y, z, blockID, meta); + super.breakBlock(par1World, pos, blockID, meta); } /* Placement */ @@ -123,7 +124,7 @@ public abstract class InventoryBlock extends BlockContainer //This class does not have an actual block placed in the world @Override - public int onBlockPlaced (World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) + public int onBlockPlaced (World world, BlockPos pos, int side, float hitX, float hitY, float hitZ, int meta) { this.side = side; return meta; @@ -131,9 +132,9 @@ public abstract class InventoryBlock extends BlockContainer @Override @SuppressWarnings("deprecation") // TODO: Remove this when setDirection calls updated. - public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack stack) + public void onBlockPlacedBy (World world, BlockPos pos, EntityLivingBase entityliving, ItemStack stack) { - TileEntity logic = world.getTileEntity(x, y, z); + TileEntity logic = world.getTileEntity(pos); if (logic instanceof IFacingLogic) { IFacingLogic direction = (IFacingLogic) logic; @@ -165,9 +166,9 @@ public abstract class InventoryBlock extends BlockContainer } @SuppressWarnings("unused") - public static boolean isActive (IBlockAccess world, int x, int y, int z) + public static boolean isActive (IBlockAccess world, BlockPos pos) { - TileEntity logic = world.getTileEntity(x, y, z); + TileEntity logic = world.getTileEntity(pos); if (logic instanceof IActiveLogic) { return ((IActiveLogic) logic).getActive(); @@ -201,17 +202,17 @@ public abstract class InventoryBlock extends BlockContainer /* IDebuggable */ @Override - public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player) + public void onBlockClicked (World world, BlockPos pos, EntityPlayer player) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && player.getHeldItem().getItem() != null && player.getHeldItem().getItem() == Items.stick) { - TileEntity te = world.getTileEntity(x, y, z); + TileEntity te = world.getTileEntity(pos); if (te instanceof IDebuggable) { DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player)); } } - super.onBlockClicked(world, x, y, z, player); + super.onBlockClicked(world, pos, player); } } \ No newline at end of file diff --git a/src/mantle/blocks/abstracts/InventoryLogic.java b/src/mantle/blocks/abstracts/InventoryLogic.java index f7620b4..dc0a6e0 100644 --- a/src/mantle/blocks/abstracts/InventoryLogic.java +++ b/src/mantle/blocks/abstracts/InventoryLogic.java @@ -103,11 +103,11 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I @Override public boolean isUseableByPlayer (EntityPlayer entityplayer) { - if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) + if (worldObj.getTileEntity(pos) != this) return false; else - return entityplayer.getDistance((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; + return entityplayer.getDistance((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64D; } diff --git a/src/mantle/blocks/abstracts/InventorySlab.java b/src/mantle/blocks/abstracts/InventorySlab.java index 449b00e..b5d4b0f 100644 --- a/src/mantle/blocks/abstracts/InventorySlab.java +++ b/src/mantle/blocks/abstracts/InventorySlab.java @@ -3,8 +3,10 @@ package mantle.blocks.abstracts; import java.util.List; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -22,50 +24,45 @@ public abstract class InventorySlab extends InventoryBlock /* Rendering */ @Override - //TODO: renderAsNormalBlock() public boolean renderAsNormalBlock () { return false; } - //TODO: isOpaqueCube() @Override public boolean isOpaqueCube () { return false; } - //TODO shouldSideBeRendered @Override - public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, int side) + public boolean shouldSideBeRendered (IBlockAccess world, BlockPos pos, int side) { if (side > 1) - return super.shouldSideBeRendered(world, x, y, z, side); + return super.shouldSideBeRendered(world, pos, side); - int meta = world.getBlockMetadata(x, y, z); + int meta = world.getBlockMetadata(pos); boolean top = (meta | 8) == 1; if ((top && side == 0) || (!top && side == 1)) return true; - return super.shouldSideBeRendered(world, x, y, z, side); + return super.shouldSideBeRendered(world, pos, side); } - //TODO: addCollisionBoxesToList() @Override @SuppressWarnings("rawtypes") - public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) + public void addCollisionBoxesToList (World world, BlockPos pos, IBlockState state, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) { - setBlockBoundsBasedOnState(world, x, y, z); - super.addCollisionBoxesToList(world, x, y, z, axisalignedbb, arraylist, entity); + setBlockBoundsBasedOnState(world, pos); + super.addCollisionBoxesToList(world,pos ,state, axisalignedbb, arraylist, entity); } public void setBlockBoundsForItemRender () { - //TODO: setBlockBounds setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } - public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) + public void setBlockBoundsBasedOnState (IBlockAccess world, BlockPos pos, IBlockState state) { int meta = world.getBlockMetadata(x, y, z) / 8; float minY = meta == 1 ? 0.5F : 0.0F; diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/mantle/blocks/abstracts/MultiServantLogic.java index 7f639d1..6d5847e 100644 --- a/src/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/mantle/blocks/abstracts/MultiServantLogic.java @@ -13,15 +13,15 @@ import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import cpw.mods.fml.common.registry.GameRegistry; public class MultiServantLogic extends TileEntity implements IServantLogic, IDebuggable { boolean hasMaster; - CoordTuple master; + BlockPos master; Block masterBlock; - byte masterMeat; //Typo, it stays! + byte masterMeat; //TODO rename this! public boolean canUpdate () { @@ -38,7 +38,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb if (!hasMaster) return false; - if (worldObj.getBlock(master.x, master.y, master.z) == masterBlock && worldObj.getBlockMetadata(master.x, master.y, master.z) == masterMeat) + if (worldObj.getBlock(master) == masterBlock && worldObj.getBlockMetadata(master) == masterMeat) return true; else @@ -49,7 +49,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb } } - public CoordTuple getMasterPosition () + public BlockPos getMasterPosition () { return master; } @@ -79,10 +79,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb @Deprecated public boolean verifyMaster (IMasterLogic logic, int x, int y, int z) { - if (master.equalCoords(x, y, z) && worldObj.getBlock(x, y, z) == masterBlock && worldObj.getBlockMetadata(x, y, z) == masterMeat) - return true; - else - return false; + return master.equalCoords(x, y, z) && worldObj.getBlock(x, y, z) == masterBlock && worldObj.getBlockMetadata(x, y, z) == masterMeat; } @Override diff --git a/src/mantle/blocks/iface/IFacingLogic.java b/src/mantle/blocks/iface/IFacingLogic.java index a7d4b03..2dd620d 100644 --- a/src/mantle/blocks/iface/IFacingLogic.java +++ b/src/mantle/blocks/iface/IFacingLogic.java @@ -21,6 +21,7 @@ public interface IFacingLogic @Deprecated public void setDirection (float yaw, float pitch, EntityLivingBase player); + //TODO 1.8 \/ /** This will be added next version * public void setDirection(int side, float yaw, float pitch, EntityLivingBase player); */ diff --git a/src/mantle/blocks/iface/IServantLogic.java b/src/mantle/blocks/iface/IServantLogic.java index 3794d20..33ad243 100644 --- a/src/mantle/blocks/iface/IServantLogic.java +++ b/src/mantle/blocks/iface/IServantLogic.java @@ -14,9 +14,9 @@ public interface IServantLogic * * @param master * @param world the world of master - * @param x xCoord of master - * @param y yCoord of master - * @param z zCoord of master + * @param xMaster xCoord of master + * @param yMaster yCoord of master + * @param zMaster zCoord of master * @return whether the servant can be tied to this master */ @@ -26,9 +26,9 @@ public interface IServantLogic * * @param master * @param world - * @param x xCoord of master - * @param y yCoord of master - * @param z zCoord of master + * @param xMaster xCoord of master + * @param yMaster yCoord of master + * @param zMaster zCoord of master * @return Is this block tied to this master? */ @@ -38,9 +38,9 @@ public interface IServantLogic * * @param master * @param world - * @param x xCoord of master - * @param y yCoord of master - * @param z zCoord of master + * @param xMaster xCoord of master + * @param yMaster yCoord of master + * @param zMaster zCoord of master */ public void invalidateMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); diff --git a/src/mantle/books/BookData.java b/src/mantle/books/BookData.java index 61752cf..c0daaeb 100644 --- a/src/mantle/books/BookData.java +++ b/src/mantle/books/BookData.java @@ -7,9 +7,9 @@ import org.w3c.dom.Document; public class BookData { - public String unlocalizedName = new String(); - public String toolTip = new String(); - public String modID = new String(); + public String unlocalizedName = ""; + public String toolTip = ""; + public String modID = ""; public ResourceLocation leftImage = new ResourceLocation("mantle", "textures/gui/bookleft.png"); public ResourceLocation rightImage = new ResourceLocation("mantle", "textures/gui/bookright.png"); public ResourceLocation itemImage = new ResourceLocation("mantle", "textures/items/mantlebook_blue.png"); diff --git a/src/mantle/books/external/ZipLoader.java b/src/mantle/books/external/ZipLoader.java index c54a263..652973b 100644 --- a/src/mantle/books/external/ZipLoader.java +++ b/src/mantle/books/external/ZipLoader.java @@ -33,8 +33,8 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; public class ZipLoader { @@ -43,13 +43,13 @@ public class ZipLoader public static BookData loadZip (File f) { BookLoad bl; - String flName = new String(); - String flExt = new String(); - String lImg = new String(); - String rImg = new String(); - String bIcon = new String(); - String unlocName = new String(); - String toolTip = new String(); + String flName = ""; + String flExt = ""; + String lImg = ""; + String rImg = ""; + String bIcon = ""; + String unlocName = ""; + String toolTip = ""; Boolean translatable = false; BookData b = new BookData(); boolean isClient = FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT; @@ -228,9 +228,7 @@ public class ZipLoader public static boolean isImage (String ext) { - if (ext.equalsIgnoreCase("png")) - return true; - return false; + return ext.equalsIgnoreCase("png"); } public static ItemStack[] getISArray (JsonArray a) diff --git a/src/mantle/client/RenderItemCopy.java b/src/mantle/client/RenderItemCopy.java index 31f677f..9850f9b 100644 --- a/src/mantle/client/RenderItemCopy.java +++ b/src/mantle/client/RenderItemCopy.java @@ -23,8 +23,8 @@ import net.minecraftforge.client.ForgeHooksClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderItemCopy extends Render @@ -75,7 +75,7 @@ public class RenderItemCopy extends Render if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, new RenderBlocks(), 000)) // TODO what goes here not 000 { - ; + } else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType())) { @@ -111,7 +111,6 @@ public class RenderItemCopy extends Render } f5 = 1.0F; - //TODO renderBlockAsItem this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5); GL11.glPopMatrix(); } @@ -363,7 +362,6 @@ public class RenderItemCopy extends Render float f2; Block block = Block.getBlockFromItem(k); - //TODO renderItemIn3d if (block != null && par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(block.getRenderType())) { par2TextureManager.bindTexture(TextureMap.locationBlocksTexture); @@ -532,11 +530,11 @@ public class RenderItemCopy extends Render } tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); + tessellator.addVertexWithUV((double) (par2), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); - tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); - tessellator.addVertexWithUV((double) (par2 + 0), (double) (par3 + 0), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); + tessellator.addVertexWithUV((double) (par2), (double) (par3), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); tessellator.draw(); } } @@ -593,10 +591,10 @@ public class RenderItemCopy extends Render { par1Tessellator.startDrawingQuads(); par1Tessellator.setColorOpaque_I(par6); - par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + 0), 0.0D); - par1Tessellator.addVertex((double) (par2 + 0), (double) (par3 + par5), 0.0D); + par1Tessellator.addVertex((double) (par2), (double) (par3), 0.0D); + par1Tessellator.addVertex((double) (par2), (double) (par3 + par5), 0.0D); par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); - par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + 0), 0.0D); + par1Tessellator.addVertex((double) (par2 + par4), (double) (par3), 0.0D); par1Tessellator.draw(); } @@ -604,10 +602,10 @@ public class RenderItemCopy extends Render { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); + tessellator.addVertexWithUV((double) (par1), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); - tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); - tessellator.addVertexWithUV((double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); + tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); + tessellator.addVertexWithUV((double) (par1), (double) (par2), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); tessellator.draw(); } @@ -662,7 +660,7 @@ public class RenderItemCopy extends Render /** * Allows for a subclass to override how many rendered items appear in a * "mini item 3d stack" - * @param stack + * @param stack the ItemStack * @return */ public byte getMiniItemCount (ItemStack stack) diff --git a/src/mantle/client/SmallFontRenderer.java b/src/mantle/client/SmallFontRenderer.java index 22aad49..ce57090 100644 --- a/src/mantle/client/SmallFontRenderer.java +++ b/src/mantle/client/SmallFontRenderer.java @@ -24,8 +24,8 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class SmallFontRenderer implements IResourceManagerReloadListener @@ -270,7 +270,7 @@ public class SmallFontRenderer implements IResourceManagerReloadListener { if (unicodePageLocations[par1] == null) { - unicodePageLocations[par1] = new ResourceLocation("minecraft", String.format("textures/font/unicode_page_%02x.png", new Object[] { Integer.valueOf(par1) })); + unicodePageLocations[par1] = new ResourceLocation("minecraft", String.format("textures/font/unicode_page_%02x.png", new Object[] { par1 })); } return unicodePageLocations[par1]; } @@ -526,7 +526,7 @@ public class SmallFontRenderer implements IResourceManagerReloadListener else { j = ' '; - for (char c : ChatAllowedCharacters.allowedCharacters) + for (char c : ChatAllowedCharacters.allowedCharactersArray) { if (c == c0) { @@ -539,7 +539,7 @@ public class SmallFontRenderer implements IResourceManagerReloadListener { do { - k = this.fontRandom.nextInt(ChatAllowedCharacters.allowedCharacters.length); + k = this.fontRandom.nextInt(ChatAllowedCharacters.allowedCharactersArray.length); } while (this.charWidth[j + 32] != this.charWidth[k + 32]); j = k; @@ -587,7 +587,7 @@ public class SmallFontRenderer implements IResourceManagerReloadListener if (this.strikethroughStyle) { - tessellator = Tessellator.instance; + tessellator = Tessellator.getInstance(); GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); @@ -600,7 +600,7 @@ public class SmallFontRenderer implements IResourceManagerReloadListener if (this.underlineStyle) { - tessellator = Tessellator.instance; + tessellator = Tessellator.getInstance(); GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; diff --git a/src/mantle/client/gui/GuiManual.java b/src/mantle/client/gui/GuiManual.java index a07492f..4881388 100644 --- a/src/mantle/client/gui/GuiManual.java +++ b/src/mantle/client/gui/GuiManual.java @@ -17,8 +17,8 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiManual extends GuiScreen diff --git a/src/mantle/client/gui/TurnPageButton.java b/src/mantle/client/gui/TurnPageButton.java index 82f0ffd..0cb5410 100644 --- a/src/mantle/client/gui/TurnPageButton.java +++ b/src/mantle/client/gui/TurnPageButton.java @@ -1,6 +1,5 @@ package mantle.client.gui; -import static mantle.lib.CoreRepo.logger; import mantle.books.BookData; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; diff --git a/src/mantle/client/pages/PicturePage.java b/src/mantle/client/pages/PicturePage.java index 7d3af30..eeda9fc 100644 --- a/src/mantle/client/pages/PicturePage.java +++ b/src/mantle/client/pages/PicturePage.java @@ -1,6 +1,5 @@ package mantle.client.pages; -import mantle.lib.client.MantleClientRegistry; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import static mantle.lib.CoreRepo.logger; diff --git a/src/mantle/common/ComparisonHelper.java b/src/mantle/common/ComparisonHelper.java index 642bfc1..0a89577 100644 --- a/src/mantle/common/ComparisonHelper.java +++ b/src/mantle/common/ComparisonHelper.java @@ -18,9 +18,10 @@ public class ComparisonHelper public static boolean areEquivalent (Item item1, Item item2) { - return item1.equals(item2); + return item1 == item2; } + //@TODO make this a more verbose comparison public static boolean areEquivalent (ItemStack is1, ItemStack is2) { return is1.getItem() == is2.getItem(); diff --git a/src/mantle/common/MProxyCommon.java b/src/mantle/common/MProxyCommon.java index 17a63bf..cfccaf9 100644 --- a/src/mantle/common/MProxyCommon.java +++ b/src/mantle/common/MProxyCommon.java @@ -2,7 +2,7 @@ package mantle.common; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import cpw.mods.fml.common.network.IGuiHandler; +import net.minecraftforge.fml.common.network.IGuiHandler; public class MProxyCommon implements IGuiHandler { diff --git a/src/mantle/crash/CallableSuppConfig.java b/src/mantle/crash/CallableSuppConfig.java index bee7045..94819cc 100644 --- a/src/mantle/crash/CallableSuppConfig.java +++ b/src/mantle/crash/CallableSuppConfig.java @@ -1,6 +1,6 @@ package mantle.crash; -import cpw.mods.fml.common.ICrashCallable; +import net.minecraftforge.fml.common.ICrashCallable; /** * Crash Callable for supported environments. diff --git a/src/mantle/crash/CallableUnsuppConfig.java b/src/mantle/crash/CallableUnsuppConfig.java index f764c5f..036fb01 100644 --- a/src/mantle/crash/CallableUnsuppConfig.java +++ b/src/mantle/crash/CallableUnsuppConfig.java @@ -2,7 +2,7 @@ package mantle.crash; import java.util.List; -import cpw.mods.fml.common.ICrashCallable; +import net.minecraftforge.fml.common.ICrashCallable; // Crash handler for when an unsupported mod is running alongside us public class CallableUnsuppConfig implements ICrashCallable diff --git a/src/mantle/debug/LogIdentifier.java b/src/mantle/debug/LogIdentifier.java deleted file mode 100644 index 8a73b01..0000000 --- a/src/mantle/debug/LogIdentifier.java +++ /dev/null @@ -1,56 +0,0 @@ -package mantle.debug; - -import java.io.PrintStream; -import static mantle.lib.CoreRepo.logger; - -import cpw.mods.fml.common.Loader; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class LogIdentifier -{ - private Logger outLogger = LogManager.getLogger("Mantle-STDOUT"); - private Logger errLogger = LogManager.getLogger("Mantle-STDERR"); - - public void preinit () - { - if(!Loader.isModLoaded("Artemis"))//this is completely useless if artemis is installed - { - logger.info("Inserting TracingPrintStream..."); - System.setOut(new TracingPrintStream(outLogger, "STDOUT", System.out)); - System.setErr(new TracingPrintStream(errLogger, "STDERR", System.err)); - logger.info("TracingPrintStream inserted on STDOUT/STDERR. These will now be redirected to the Mantle-STDOUT/Mantle-STDERR loggers."); - System.out.println("Mantle redirect test-out"); - System.err.println("Mantle redirect test-err");//intended behavior to be able to ensure the integrity of the redirector - //logger.info("Forcing Java.util.Logger logging into log4j2"); - //JavaLoggingRedirector.activate(); - // logger.info("Successfully redirected java.util.logging"); - } - } - -} - -class TracingPrintStream extends PrintStream -{ - static Logger log; - - public TracingPrintStream(Logger l, String Stream, PrintStream original) - { - super(original); - log = l; - } - - @Override - public void println (String x) - { - x = (x == null ? " " : x); - StackTraceElement[] stack = Thread.currentThread().getStackTrace(); - // stack(2) is calling object. - String name = stack[2].getClassName(); - if (name != null) - log.info("[" + name + "]: " + x); - else - log.info("[null|" + Thread.currentThread().getName() + "]: " + x); - } - -} diff --git a/src/mantle/event/ManualOpenEvent.java b/src/mantle/event/ManualOpenEvent.java index de2931a..04d8667 100644 --- a/src/mantle/event/ManualOpenEvent.java +++ b/src/mantle/event/ManualOpenEvent.java @@ -1,6 +1,6 @@ package mantle.event; -import cpw.mods.fml.common.eventhandler.Event; +import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/mantle/event/Migration.java b/src/mantle/event/Migration.java index 39fad77..6a3c689 100644 --- a/src/mantle/event/Migration.java +++ b/src/mantle/event/Migration.java @@ -2,9 +2,9 @@ package mantle.event; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.event.FMLMissingMappingsEvent; -import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; +import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping; import net.minecraft.block.Block; import net.minecraft.item.Item; import static mantle.lib.CoreRepo.logger; @@ -56,7 +56,7 @@ public abstract class Migration public void addRemoval (String id) { ignore.add(modID + ":" + id); - }; + } /* * This must be called from your mod's main class as it requires @EventHandler notation diff --git a/src/mantle/items/ItemUtils.java b/src/mantle/items/ItemUtils.java index e863b71..f359e98 100644 --- a/src/mantle/items/ItemUtils.java +++ b/src/mantle/items/ItemUtils.java @@ -1,13 +1,13 @@ package mantle.items; import net.minecraft.item.Item; -import cpw.mods.fml.common.registry.GameData; +import net.minecraftforge.fml.common.registry.GameData; public class ItemUtils { public static String getUniqueName (Item item) { - return GameData.getItemRegistry().getNameForObject(item); + return (String)GameData.getItemRegistry().getNameForObject(item); } public static Item getItemFromUniqueName (String uniqueName) { diff --git a/src/mantle/items/Manual.java b/src/mantle/items/Manual.java index 514501c..d09da98 100644 --- a/src/mantle/items/Manual.java +++ b/src/mantle/items/Manual.java @@ -15,8 +15,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class Manual extends CraftingItem { diff --git a/src/mantle/items/abstracts/CraftingItem.java b/src/mantle/items/abstracts/CraftingItem.java index 890be76..7df21de 100644 --- a/src/mantle/items/abstracts/CraftingItem.java +++ b/src/mantle/items/abstracts/CraftingItem.java @@ -8,8 +8,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; public class CraftingItem extends Item { diff --git a/src/mantle/lib/CoreConfig.java b/src/mantle/lib/CoreConfig.java index 17dc9ba..d17030b 100644 --- a/src/mantle/lib/CoreConfig.java +++ b/src/mantle/lib/CoreConfig.java @@ -54,8 +54,6 @@ public class CoreConfig dumpPotionIDs = config.get("DebugHelpers", "Dump POTION ID's in log", dumpPotionIDs).getBoolean(dumpPotionIDs); dumpEnchantIDs = config.get("DebugHelpers", "Dump ENCHANT ID's in log", dumpEnchantIDs).getBoolean(dumpEnchantIDs); - identifyLogs = config.get("DebugHelpers", "Force all unidentified logging entries (STDOUT/STDERR) through log4j2", identifyLogs).getBoolean(identifyLogs); - //check for debugging overrides in system environment checkSysOverrides(); config.save(); @@ -98,7 +96,6 @@ public class CoreConfig public static boolean dumpBiomeIDs = false; public static boolean dumpPotionIDs = false; public static boolean dumpEnchantIDs = false; - public static boolean identifyLogs = false; } diff --git a/src/mantle/lib/environment/EnvironmentChecks.java b/src/mantle/lib/environment/EnvironmentChecks.java index 53738d6..1c19663 100644 --- a/src/mantle/lib/environment/EnvironmentChecks.java +++ b/src/mantle/lib/environment/EnvironmentChecks.java @@ -3,9 +3,9 @@ package mantle.lib.environment; import static mantle.lib.CoreRepo.logger; import static mantle.lib.CoreRepo.modId; -import java.util.ArrayList; import java.util.List; +import com.google.common.collect.Lists; import mantle.crash.CallableSuppConfig; import mantle.crash.CallableUnsuppConfig; import mantle.lib.CoreConfig; @@ -39,7 +39,7 @@ public class EnvironmentChecks @SuppressWarnings("rawtypes") public static void verifyEnvironmentSanity () { - List modIds = new ArrayList(); + List modIds = Lists.newArrayList(); if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine() || Loader.isModLoaded("optifine")) { diff --git a/src/mantle/math/Dozenal.java b/src/mantle/math/Dozenal.java index 482e375..883fa15 100644 --- a/src/mantle/math/Dozenal.java +++ b/src/mantle/math/Dozenal.java @@ -8,6 +8,8 @@ package mantle.math; * @author mDiyo */ +import com.google.common.collect.Lists; + import java.util.LinkedList; public class Dozenal @@ -34,7 +36,7 @@ public class Dozenal public static String convertDecimal (int i) { int num = i; - LinkedList list = new LinkedList(); + LinkedList list = Lists.newLinkedList(); while (num > 0) { list.add(getDozenalCharacter(num % 12)); diff --git a/src/mantle/module/ILoadableModule.java b/src/mantle/module/ILoadableModule.java deleted file mode 100644 index 94e0032..0000000 --- a/src/mantle/module/ILoadableModule.java +++ /dev/null @@ -1,26 +0,0 @@ -package mantle.module; - -/** - * Interface for modules for dealing with other mods. - * - * Note that all ILoadableModule's should have a static String field "modId" which contains the mod ID of the mod it supports. - * This is accessed by reflection because Java is dumb and has no statics in interfaces. - * - * @author Arkan - */ -@Deprecated //See Pulsar package for replacement -public interface ILoadableModule { - - // Example modId field - //public static String modId = "ExampleMod"; - - // Called during PreInit - public abstract void preInit(); - - // Called during Init - public abstract void init(); - - // Called during PostInit - public abstract void postInit(); - -} \ No newline at end of file diff --git a/src/mantle/module/ModuleController.java b/src/mantle/module/ModuleController.java deleted file mode 100644 index a387b19..0000000 --- a/src/mantle/module/ModuleController.java +++ /dev/null @@ -1,180 +0,0 @@ -package mantle.module; - -import cpw.mods.fml.common.Loader; -import net.minecraftforge.common.config.Configuration; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.util.ArrayList; - -/** - * Controller for mod compat modules. - * - * @author Sunstrike - * @author Arkan Emberwalker - */ -@Deprecated //See PulseManager for replacement -public class ModuleController { - - private enum State { - WAITING, PREINIT, INIT, POSTINIT, DONE - } - - private ArrayList modules = new ArrayList(); - private State currentState = State.WAITING; - private Logger logger; - private Configuration config; - - /** - * Constructor for a config-less plugin loader - * - * @param modName The human-readable name of the invoking mod. Used for logger construction. - */ - @SuppressWarnings("unused") - public ModuleController(String modName) { - this.logger = LogManager.getLogger(modName + "-ModuleController"); - this.config = null; - } - - /** - * Constructor for a config-using plugin loader - * - * @param confName The name for the configuration file (should end in .cfg) - * @param modName The human-readable name of the invoking mod. Used for logger construction. - */ - public ModuleController(String confName, String modName) { - this.logger = LogManager.getLogger(modName + "-ModuleController"); - this.config = new Configuration(new File(Loader.instance().getConfigDir().toString() + File.separator + confName)); - } - - /** - * The host mod should invoke this when it receives the FML PreInitialization event. - */ - public void preInit() { - currentState = State.PREINIT; - for (ILoadableModule m : modules) m.preInit(); - } - - /** - * The host mod should invoke this when it receives the FML Initialization event. - */ - public void init() { - currentState = State.INIT; - for (ILoadableModule m : modules) m.init(); - } - - /** - * The host mod should invoke this when it receives the FML PostInitialization event. - */ - public void postInit() { - currentState = State.POSTINIT; - for (ILoadableModule m : modules) m.postInit(); - currentState = State.DONE; - } - - /** - * Main registration point for modules. - * - * This version will always check the configuration, if one is defined, before attempting to load a plugin. This is - * the preferred entry point. To bypass the config test, use registerUncheckedModule(). - * - * @param mod The module to attempt to register. - * @return True on success, false on error or rejection. - */ - @SuppressWarnings("unused") - public boolean registerModule(Class mod) { - String mID = getModId(mod); - if (mID == null) return false; - - boolean allowedByConf = true; - if (config != null) { - config.load(); - allowedByConf = config.get("Modules", mID, true).getBoolean(true); - config.save(); - } - - if (!allowedByConf || !Loader.isModLoaded(mID)) return false; - - return doSetup(mod, mID); - } - - /** - * Unchecked handler for registering a module forcefully. - * - * This version bypasses any config test; use registerModule where possible. This is only intended for modules - * the user is not allowed to configure (e.g. Mystcraft blacklist plugins). - * - * @param mod The module to attempt to register. - * @return True on success, false on error. - */ - @SuppressWarnings("unused") - public boolean registerUncheckedModule(Class mod) { - String mID = getModId(mod); - if (mID == null || !Loader.isModLoaded(mID)) return false; - - return doSetup(mod, mID); - } - - private String getModId(Class mod) { - String mID; - try { - mID = (String)mod.getField("modId").get(null); - } catch (Exception e) { - logger.error("Module loading failed for class " + mod + "; modId field may be missing."); - return null; - } catch (NoClassDefFoundError ncdf) { // NOTE: Catching Errors is usually bad practice, but we need to here. - logger.error("Module loading failed for class " + mod + "; a referenced class is missing."); - return null; - } - return mID; - } - - /** - * Internal handler which actually does the heavy lifting with loading. - * - * @param mod Module class to setup - * @return True on success, else false. - */ - private boolean doSetup(Class mod, String mID) { - ILoadableModule module; - try { - module = mod.newInstance(); - modules.add(module); - } catch (Exception e) { - logger.error("Could not construct module for " + mID); - logger.error(e.getMessage()); - logger.error(e.getStackTrace()); - return false; - } - - logger.info("Module for " + mID + " loaded successfully."); - - boolean caughtUp = false; - switch (currentState) { - case DONE: - case POSTINIT: - module.preInit(); - module.init(); - module.postInit(); - caughtUp = true; - break; - case INIT: - module.preInit(); - module.init(); - caughtUp = true; - break; - case PREINIT: - module.preInit(); - caughtUp = true; - break; - default: - break; - } - - if (caughtUp) logger.info("Completed catch-up for " + mID + " module."); - - return true; - } - -} \ No newline at end of file diff --git a/src/mantle/utils/ItemMetaWrapper.java b/src/mantle/utils/ItemMetaWrapper.java index e9aaaae..e44c59c 100644 --- a/src/mantle/utils/ItemMetaWrapper.java +++ b/src/mantle/utils/ItemMetaWrapper.java @@ -26,9 +26,8 @@ public class ItemMetaWrapper { ItemMetaWrapper itemMeta = (ItemMetaWrapper) o; if (item != null ? !(item == itemMeta.item) : itemMeta.item != null) return false; - if (meta != null ? !meta.equals(itemMeta.meta) : itemMeta.meta != null) return false; + return !(meta != null ? !meta.equals(itemMeta.meta) : itemMeta.meta != null); - return true; } @Override diff --git a/src/mantle/utils/ItemStackWrapper.java b/src/mantle/utils/ItemStackWrapper.java index 65678e8..261762f 100644 --- a/src/mantle/utils/ItemStackWrapper.java +++ b/src/mantle/utils/ItemStackWrapper.java @@ -24,9 +24,8 @@ public class ItemStackWrapper extends ItemMetaWrapper { ItemStackWrapper that = (ItemStackWrapper) o; - if (stacksize != null ? !stacksize.equals(that.stacksize) : that.stacksize != null) return false; + return !(stacksize != null ? !stacksize.equals(that.stacksize) : that.stacksize != null); - return true; } @Override diff --git a/src/mantle/world/CoordTuple.java b/src/mantle/world/CoordTuple.java deleted file mode 100644 index b09a516..0000000 --- a/src/mantle/world/CoordTuple.java +++ /dev/null @@ -1,175 +0,0 @@ -package mantle.world; - -/** - * CoordTuple - * - * @author mDiyo - */ -@SuppressWarnings("rawtypes") -public class CoordTuple implements Comparable -{ - public final int x; - public final int y; - public final int z; - - public CoordTuple(double posX, double posY, double posZ) - { - x = (int) Math.floor(posX); - y = (int) Math.floor(posY); - z = (int) Math.floor(posZ); - } - - public boolean equalCoords (int posX, int posY, int posZ) - { - if (this.x == posX && this.y == posY && this.z == posZ) - return true; - else - return false; - } - - public boolean equals (Object obj) { - if (!(obj instanceof CoordTuple)) { - return false; - } - - CoordTuple that = (CoordTuple)obj; - return this.x == that.x && this.y == that.y && this.z == that.z; - } - - @Override - public int hashCode () - { - final int prime = 31; - int result = 1; - result = prime * result + x; - result = prime * result + y; - result = prime * result + z; - return result; - } - - public String toString () - { - return "X: " + x + ", Y: " + y + ", Z: " + z; - } - - @Override - public int compareTo (Object o) - { - if (o == null) - throw new NullPointerException("Object cannot be null"); - - CoordTuple coord = (CoordTuple) o; - - if (x < coord.x) - { - return -1; - } - if (x > coord.x) - { - return 1; - } - if (y < coord.y) - { - return -1; - } - if (y > coord.y) - { - return 1; - } - if (z < coord.z) - { - return -1; - } - if (z > coord.z) - { - return 1; - } - - return 0; - } - - public static CoordTuple up (int x, int y, int z) - { - return new CoordTuple(x, y + 1, z); - } - - public static CoordTuple down (int x, int y, int z) - { - return new CoordTuple(x, y - 1, z); - } - - public static CoordTuple north (int x, int y, int z) - { - return new CoordTuple(x, y, z - 1); - } - - public static CoordTuple south (int x, int y, int z) - { - return new CoordTuple(x, y, z + 1); - } - - public static CoordTuple east (int x, int y, int z) - { - return new CoordTuple(x + 1, y, z); - } - - public static CoordTuple west (int x, int y, int z) - { - return new CoordTuple(x - 1, y, z); - } - - public static CoordTuple inFront (int x, int y, int z, int meta) - { - switch (meta) - { - case 0: - return down(x, y, z); - case 1: - return up(x, y, z); - case 2: - return north(x, y, z); - case 3: - return south(x, y, z); - case 4: - return west(x, y, z); - case 5: - return east(x, y, z); - default: - return new CoordTuple(x, y, z); - } - } - - public static CoordTuple behind (int x, int y, int z, int meta) - { - switch (meta) - { - case 1: - return down(x, y, z); - case 0: - return up(x, y, z); - case 3: - return north(x, y, z); - case 2: - return south(x, y, z); - case 5: - return west(x, y, z); - case 4: - return east(x, y, z); - default: - return new CoordTuple(x, y, z); - } - } - - public int getDistanceFrom (CoordTuple tuple) - { - return getDistanceFrom(tuple.x, tuple.y, tuple.z); - } - - public int getDistanceFrom (int x1, int y1, int z1) - { - int xPos = x - x1; - int yPos = y - y1; - int zPos = z - z1; - return xPos * xPos + yPos * yPos + zPos * zPos; - } -} diff --git a/src/mantle/world/CoordTuplePair.java b/src/mantle/world/CoordTuplePair.java index 67b3547..2bee4f4 100644 --- a/src/mantle/world/CoordTuplePair.java +++ b/src/mantle/world/CoordTuplePair.java @@ -1,5 +1,7 @@ package mantle.world; +import net.minecraft.util.BlockPos; + /** * CoordTuplePair * @@ -7,10 +9,10 @@ package mantle.world; */ public class CoordTuplePair { - public CoordTuple a; - public CoordTuple b; + public BlockPos a; + public BlockPos b; - public CoordTuplePair(CoordTuple a, CoordTuple b) + public CoordTuplePair(BlockPos a, BlockPos b) { this.a = a; this.b = b; @@ -18,7 +20,7 @@ public class CoordTuplePair public CoordTuplePair(int aX, int aY, int aZ, int bX, int bY, int bZ) { - this.a = new CoordTuple(aX, aY, aZ); - this.b = new CoordTuple(bX, bY, bZ); + this.a = new BlockPos(aX, aY, aZ); + this.b = new BlockPos(bX, bY, bZ); } } \ No newline at end of file diff --git a/src/mantle/world/CoordTupleSort.java b/src/mantle/world/CoordTupleSort.java deleted file mode 100644 index 2ce1aea..0000000 --- a/src/mantle/world/CoordTupleSort.java +++ /dev/null @@ -1,31 +0,0 @@ -package mantle.world; - -import java.util.Comparator; - -/** - * CoordTupleSort - * - * @author mDiyo - */ -@SuppressWarnings("rawtypes") -public class CoordTupleSort implements Comparator -{ - @Override - public int compare (Object o1, Object o2) - { - CoordTuple c1 = (CoordTuple) o1; - CoordTuple c2 = (CoordTuple) o2; - - //Sort by y, then x, then z - if (c1.y != c2.y) - return c1.y - c2.y; - - if (c1.x != c2.x) - return c1.x - c2.x; - - if (c1.z != c2.z) - return c1.z - c2.z; - - return 0; - } -} diff --git a/src/mantle/world/DimensionCoordPair.java b/src/mantle/world/DimensionCoordPair.java index c186674..660b3c5 100644 --- a/src/mantle/world/DimensionCoordPair.java +++ b/src/mantle/world/DimensionCoordPair.java @@ -20,10 +20,7 @@ public class DimensionCoordPair public boolean equalCoords (int worldID, int posX, int posZ) { - if (this.dim == posX && this.x == posX && this.z == posZ) - return true; - else - return false; + return this.dim == posX && this.x == posX && this.z == posZ; } @Override diff --git a/src/mantle/world/DimensionCoordTuple.java b/src/mantle/world/DimensionCoordTuple.java index f3428f9..8ee1bdd 100644 --- a/src/mantle/world/DimensionCoordTuple.java +++ b/src/mantle/world/DimensionCoordTuple.java @@ -23,10 +23,7 @@ public class DimensionCoordTuple public boolean equalCoords (int worldID, int posX, int posY, int posZ) { - if (this.dim == worldID && this.x == posX && this.y == posY && this.z == posZ) - return true; - else - return false; + return this.dim == worldID && this.x == posX && this.y == posY && this.z == posZ; } @Override From 00d99031a6fcca267aacdf5cecf5236a3d731c63 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Tue, 2 Dec 2014 15:00:45 -0500 Subject: [PATCH 02/91] partial cleanup to world utils --- src/mantle/world/DirectionUtils.java | 10 +++++----- src/mantle/world/WorldHelper.java | 21 +++++++-------------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/mantle/world/DirectionUtils.java b/src/mantle/world/DirectionUtils.java index 7c2d20d..3d1fbd4 100644 --- a/src/mantle/world/DirectionUtils.java +++ b/src/mantle/world/DirectionUtils.java @@ -1,6 +1,6 @@ package mantle.world; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; /** * Helper functions for dealing with ForgeDirection @@ -16,14 +16,14 @@ public class DirectionUtils // No instantiation } - public static boolean isRightAngles (ForgeDirection a, ForgeDirection b) + public static boolean isRightAngles (EnumFacing a, EnumFacing b) { - return a != b && a != b.getOpposite() && a != ForgeDirection.UNKNOWN && b != ForgeDirection.UNKNOWN; + return a != b && a != b.getOpposite(); } - public static boolean isHorizontal (ForgeDirection a) + public static boolean isHorizontal (EnumFacing a) { - return a == ForgeDirection.EAST || a == ForgeDirection.NORTH || a == ForgeDirection.SOUTH || a == ForgeDirection.WEST; + return a == EnumFacing.EAST || a == EnumFacing.NORTH || a == EnumFacing.SOUTH || a == EnumFacing.WEST; } } diff --git a/src/mantle/world/WorldHelper.java b/src/mantle/world/WorldHelper.java index 0b63340..d006991 100644 --- a/src/mantle/world/WorldHelper.java +++ b/src/mantle/world/WorldHelper.java @@ -1,31 +1,24 @@ package mantle.world; -import mantle.common.ComparisonHelper; -import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class WorldHelper { - @Deprecated - public static boolean setBlockToAirBool (World w, int x, int y, int z) + public static boolean setBlockToAir (World w, BlockPos pos) { - return setBlockToAir(w, x, y, z); + return w.setBlockToAir(pos); } - public static boolean setBlockToAir (World w, int x, int y, int z) + public static boolean isAirBlock (IBlockAccess access, BlockPos pos) { - return w.setBlockToAir(x, y, z); + return access.getBlock(pos).isAir(access, pos); } - public static boolean isAirBlock (IBlockAccess access, int x, int y, int z) + public static boolean isAirBlock (World access, BlockPos pos) { - return access.getBlock(x,y,z).isAir(access, x,y,z); - } - - public static boolean isAirBlock (World access, int x, int y, int z) - { - return access.isAirBlock(x,y,z); + return access.isAirBlock(pos); } } From 3d0b65f6424a21be72e5e59aea026f3b675fd3a7 Mon Sep 17 00:00:00 2001 From: alexbegt Date: Wed, 3 Dec 2014 21:22:52 -0500 Subject: [PATCH 03/91] Doing some code cleanup, fixing FML locations (Please be right github account) --- src/mantle/blocks/iface/IFacingLogic.java | 4 ++-- src/mantle/blocks/iface/IServantLogic.java | 4 ++-- src/mantle/books/external/ZipLoader.java | 2 +- src/mantle/common/network/PacketUpdateTE.java | 3 ++- src/mantle/lib/environment/EnvironmentChecks.java | 10 +++++----- src/mantle/pulsar/config/ForgeCFG.java | 2 +- src/mantle/pulsar/control/PulseManager.java | 10 +++++----- src/mantle/pulsar/internal/Configuration.java | 2 +- src/mantle/pulsar/pulse/IPulse.java | 6 +++--- src/mantle/utils/RecipeRemover.java | 2 +- 10 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/mantle/blocks/iface/IFacingLogic.java b/src/mantle/blocks/iface/IFacingLogic.java index 2dd620d..12299b8 100644 --- a/src/mantle/blocks/iface/IFacingLogic.java +++ b/src/mantle/blocks/iface/IFacingLogic.java @@ -1,7 +1,7 @@ package mantle.blocks.iface; import net.minecraft.entity.EntityLivingBase; -import net.minecraftforge.common.util.ForgeDirection; +import net.minecraft.util.EnumFacing; /** * Logic for blocks which have a specific direction facing. @@ -13,7 +13,7 @@ public interface IFacingLogic public byte getRenderDirection (); - public ForgeDirection getForgeDirection (); + public EnumFacing getForgeDirection (); @Deprecated public void setDirection (int side); diff --git a/src/mantle/blocks/iface/IServantLogic.java b/src/mantle/blocks/iface/IServantLogic.java index 33ad243..82ef3a9 100644 --- a/src/mantle/blocks/iface/IServantLogic.java +++ b/src/mantle/blocks/iface/IServantLogic.java @@ -1,11 +1,11 @@ package mantle.blocks.iface; -import mantle.world.CoordTuple; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; public interface IServantLogic { - public CoordTuple getMasterPosition (); + public BlockPos getMasterPosition (); /** The block should already have a valid master */ public void notifyMasterOfChange (); diff --git a/src/mantle/books/external/ZipLoader.java b/src/mantle/books/external/ZipLoader.java index 652973b..13c79a1 100644 --- a/src/mantle/books/external/ZipLoader.java +++ b/src/mantle/books/external/ZipLoader.java @@ -114,7 +114,7 @@ public class ZipLoader { try { - is.stackTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(bis.tags); + is.setTagCompound(JsonToNBT.func_180713_a(bis.tags)); } catch (Exception e1) { diff --git a/src/mantle/common/network/PacketUpdateTE.java b/src/mantle/common/network/PacketUpdateTE.java index 2ba216a..7af4de7 100644 --- a/src/mantle/common/network/PacketUpdateTE.java +++ b/src/mantle/common/network/PacketUpdateTE.java @@ -6,6 +6,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; public class PacketUpdateTE extends AbstractPacket { @@ -62,7 +63,7 @@ public class PacketUpdateTE extends AbstractPacket @Override public void handleClientSide (EntityPlayer player) { - TileEntity te = player.worldObj.getTileEntity(x, y, z); + TileEntity te = player.worldObj.getTileEntity(new BlockPos(x, y, z)); if (te != null) { diff --git a/src/mantle/lib/environment/EnvironmentChecks.java b/src/mantle/lib/environment/EnvironmentChecks.java index 1c19663..a238b30 100644 --- a/src/mantle/lib/environment/EnvironmentChecks.java +++ b/src/mantle/lib/environment/EnvironmentChecks.java @@ -9,11 +9,11 @@ import com.google.common.collect.Lists; import mantle.crash.CallableSuppConfig; import mantle.crash.CallableUnsuppConfig; import mantle.lib.CoreConfig; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.ICrashCallable; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.relauncher.Side; +import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.ICrashCallable; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.relauncher.Side; /** * Environment Checks diff --git a/src/mantle/pulsar/config/ForgeCFG.java b/src/mantle/pulsar/config/ForgeCFG.java index ac3f5a1..948bfb0 100644 --- a/src/mantle/pulsar/config/ForgeCFG.java +++ b/src/mantle/pulsar/config/ForgeCFG.java @@ -1,6 +1,6 @@ package mantle.pulsar.config; -import cpw.mods.fml.common.Loader; +import net.minecraftforge.fml.common.Loader; import mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.common.config.Configuration; diff --git a/src/mantle/pulsar/control/PulseManager.java b/src/mantle/pulsar/control/PulseManager.java index 6f1fa67..5f3a199 100644 --- a/src/mantle/pulsar/control/PulseManager.java +++ b/src/mantle/pulsar/control/PulseManager.java @@ -4,11 +4,11 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.*; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import mantle.pulsar.config.IConfiguration; import mantle.pulsar.internal.Configuration; import mantle.pulsar.pulse.PulseMeta; diff --git a/src/mantle/pulsar/internal/Configuration.java b/src/mantle/pulsar/internal/Configuration.java index 5b243fb..19ee523 100644 --- a/src/mantle/pulsar/internal/Configuration.java +++ b/src/mantle/pulsar/internal/Configuration.java @@ -8,7 +8,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import cpw.mods.fml.common.Loader; +import net.minecraftforge.fml.common.Loader; import mantle.pulsar.config.IConfiguration; import mantle.pulsar.internal.logging.ILogger; import mantle.pulsar.pulse.PulseMeta; diff --git a/src/mantle/pulsar/pulse/IPulse.java b/src/mantle/pulsar/pulse/IPulse.java index cb4febd..5aaf66e 100644 --- a/src/mantle/pulsar/pulse/IPulse.java +++ b/src/mantle/pulsar/pulse/IPulse.java @@ -1,8 +1,8 @@ package mantle.pulsar.pulse; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; /** * Base interface for all Pulsar modules ("pulses"). diff --git a/src/mantle/utils/RecipeRemover.java b/src/mantle/utils/RecipeRemover.java index 5f281be..3ddbef9 100644 --- a/src/mantle/utils/RecipeRemover.java +++ b/src/mantle/utils/RecipeRemover.java @@ -75,7 +75,7 @@ public class RecipeRemover public static void removeFurnaceRecipe (ItemStack resultItem) { - Map recipes = FurnaceRecipes.smelting().getSmeltingList(); + Map recipes = FurnaceRecipes.instance().getSmeltingList(); recipes.remove(resultItem); } From 1153da11388e8eccd5f0101a88ba89c8f67f3127 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Thu, 4 Dec 2014 06:03:09 -0500 Subject: [PATCH 04/91] few minor fixes --- src/mantle/world/ChunkCoord.java | 6 +++--- src/mantle/world/WorldHelper.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mantle/world/ChunkCoord.java b/src/mantle/world/ChunkCoord.java index f629024..e6154e2 100644 --- a/src/mantle/world/ChunkCoord.java +++ b/src/mantle/world/ChunkCoord.java @@ -2,7 +2,7 @@ package mantle.world; import java.io.Serializable; -import mantle.world.CoordTuple; +import net.minecraft.util.BlockPos; import net.minecraft.world.chunk.Chunk; /** @@ -24,10 +24,10 @@ public final class ChunkCoord implements Comparable, Serializable this.chunkZ = chunk.zPosition; } - public ChunkCoord(CoordTuple c) + public ChunkCoord(BlockPos pos) { - this(c.x >> 4, c.z >> 4); + this(pos.getX() >> 4, pos.getZ() >> 4); } public ChunkCoord(int x, int z) diff --git a/src/mantle/world/WorldHelper.java b/src/mantle/world/WorldHelper.java index d006991..38ed4fa 100644 --- a/src/mantle/world/WorldHelper.java +++ b/src/mantle/world/WorldHelper.java @@ -13,7 +13,7 @@ public class WorldHelper public static boolean isAirBlock (IBlockAccess access, BlockPos pos) { - return access.getBlock(pos).isAir(access, pos); + return access.getBlockState(pos).getBlock().isAir(access, pos); } public static boolean isAirBlock (World access, BlockPos pos) From e7341ff77ff7d4460518a8b56b28307767d0400e Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Thu, 4 Dec 2014 06:52:03 -0500 Subject: [PATCH 05/91] move more utils to blockpos, small rendering fixes --- src/mantle/blocks/BlockUtils.java | 4 +- src/mantle/blocks/MantleBlock.java | 11 +-- .../abstracts/ExpandableInventoryLogic.java | 4 +- .../blocks/abstracts/InventoryBlock.java | 25 ++++--- .../blocks/abstracts/InventorySlab.java | 5 +- .../blocks/abstracts/MultiServantLogic.java | 51 +++++++------- src/mantle/blocks/iface/IFacingLogic.java | 9 +-- src/mantle/blocks/iface/IMasterLogic.java | 8 +-- src/mantle/blocks/iface/IServantLogic.java | 18 ++--- src/mantle/client/RenderItemCopy.java | 70 ++++++++++--------- src/mantle/client/SmallFontRenderer.java | 25 ++++--- src/mantle/common/network/PacketUpdateTE.java | 20 +++--- .../lib/environment/EnvironmentChecks.java | 2 +- 13 files changed, 126 insertions(+), 126 deletions(-) diff --git a/src/mantle/blocks/BlockUtils.java b/src/mantle/blocks/BlockUtils.java index e01a9ed..28a1d95 100644 --- a/src/mantle/blocks/BlockUtils.java +++ b/src/mantle/blocks/BlockUtils.java @@ -3,7 +3,7 @@ package mantle.blocks; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.registry.GameData; +import net.minecraftforge.fml.common.registry.GameData; public class BlockUtils { @@ -20,7 +20,7 @@ public class BlockUtils public static String getUniqueName (Block block) { - return GameData.getBlockRegistry().getNameForObject(block); + return GameData.getBlockRegistry().getNameForObject(block).toString(); } public static Block getBlockFromUniqueName (String uniqueName) diff --git a/src/mantle/blocks/MantleBlock.java b/src/mantle/blocks/MantleBlock.java index f8e9ffe..9b33e86 100644 --- a/src/mantle/blocks/MantleBlock.java +++ b/src/mantle/blocks/MantleBlock.java @@ -8,9 +8,10 @@ import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; /** * Root class for inheriting the Minecraft Block. @@ -27,16 +28,16 @@ public abstract class MantleBlock extends Block // IDebuggable support - Uses a stick for debug purposes. @Override - public void onBlockClicked (World world, int x, int y, int z, EntityPlayer player) + public void onBlockClicked (World world, BlockPos pos, EntityPlayer player) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && (player.getHeldItem().getItem() == Items.stick || player.getHeldItem().getItem() instanceof IDebugItem)) { - TileEntity te = world.getTileEntity(x, y, z); + TileEntity te = world.getTileEntity(pos); if (te instanceof IDebuggable) DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player)); } - super.onBlockClicked(world, x, y, z, player); + super.onBlockClicked(world, pos, player); } } diff --git a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java b/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java index 8cca62d..62ffa6f 100644 --- a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java +++ b/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java @@ -1,6 +1,8 @@ package mantle.blocks.abstracts; import java.util.*; + +import com.google.common.collect.Lists; import net.minecraft.entity.player.*; import net.minecraft.inventory.*; import net.minecraft.item.ItemStack; @@ -16,7 +18,7 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements super(0); } - protected ArrayList inventory = new ArrayList(); + protected ArrayList inventory = Lists.newArrayList(); protected String invName; @Override diff --git a/src/mantle/blocks/abstracts/InventoryBlock.java b/src/mantle/blocks/abstracts/InventoryBlock.java index 273e47a..7b9f35f 100644 --- a/src/mantle/blocks/abstracts/InventoryBlock.java +++ b/src/mantle/blocks/abstracts/InventoryBlock.java @@ -2,6 +2,9 @@ package mantle.blocks.abstracts; import java.util.Random; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.EnumFaceDirection; +import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; import mantle.blocks.iface.IActiveLogic; @@ -49,12 +52,12 @@ public abstract class InventoryBlock extends BlockContainer public abstract Object getModInstance (); @Override - public boolean onBlockActivated (World world, BlockPos pos, EntityPlayer player, int side, float clickX, float clickY, float clickZ) + public boolean onBlockActivated (World world, BlockPos pos, EntityPlayer player, EnumFacing side, float clickX, float clickY, float clickZ) { if (player.isSneaking()) return false; - Integer integer = getGui(world, pos, player); + Integer integer = getGui(world, pos.getX(), pos.getY(), pos.getZ(), player); if (integer == null || integer == -1) { return false; @@ -69,7 +72,7 @@ public abstract class InventoryBlock extends BlockContainer /* Inventory */ @Override - public void breakBlock (World par1World, BlockPos pos, Block blockID, int meta) + public void breakBlock (World par1World, BlockPos pos, IBlockState meta) { TileEntity te = par1World.getTileEntity(pos); @@ -115,16 +118,16 @@ public abstract class InventoryBlock extends BlockContainer } } - super.breakBlock(par1World, pos, blockID, meta); + super.breakBlock(par1World, pos, meta); } /* Placement */ - int side = -1; + EnumFacing side; //This class does not have an actual block placed in the world @Override - public int onBlockPlaced (World world, BlockPos pos, int side, float hitX, float hitY, float hitZ, int meta) + public IBlockState onBlockPlaced (World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState meta) { this.side = side; return meta; @@ -139,18 +142,18 @@ public abstract class InventoryBlock extends BlockContainer { IFacingLogic direction = (IFacingLogic) logic; // TODO: Convert all setDirection calls to modern invokation, when that's ready. - if (side != -1) + if (side != null) { - direction.setDirection(side); - side = -1; + direction.setDirection(side, 0F, 0F, null); + side = null; } if (entityliving == null) { - direction.setDirection(0F, 0F, null); + direction.setDirection(null, 0F, 0F, null); } else { - direction.setDirection(entityliving.rotationYaw * 4F, entityliving.rotationPitch, entityliving); + direction.setDirection(null, entityliving.rotationYaw * 4F, entityliving.rotationPitch, entityliving); } } diff --git a/src/mantle/blocks/abstracts/InventorySlab.java b/src/mantle/blocks/abstracts/InventorySlab.java index b5d4b0f..b422a46 100644 --- a/src/mantle/blocks/abstracts/InventorySlab.java +++ b/src/mantle/blocks/abstracts/InventorySlab.java @@ -7,6 +7,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -36,7 +37,7 @@ public abstract class InventorySlab extends InventoryBlock } @Override - public boolean shouldSideBeRendered (IBlockAccess world, BlockPos pos, int side) + public boolean shouldSideBeRendered (IBlockAccess world, BlockPos pos, EnumFacing side) { if (side > 1) return super.shouldSideBeRendered(world, pos, side); @@ -64,7 +65,7 @@ public abstract class InventorySlab extends InventoryBlock public void setBlockBoundsBasedOnState (IBlockAccess world, BlockPos pos, IBlockState state) { - int meta = world.getBlockMetadata(x, y, z) / 8; + int meta = world.getBlockState(pos) / 8; float minY = meta == 1 ? 0.5F : 0.0F; float maxY = meta == 1 ? 1.0F : 0.5F; setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/mantle/blocks/abstracts/MultiServantLogic.java index 6d5847e..97f87d6 100644 --- a/src/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/mantle/blocks/abstracts/MultiServantLogic.java @@ -7,6 +7,7 @@ import mantle.debug.DebugData; import mantle.debug.IDebuggable; import mantle.world.CoordTuple; import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -21,7 +22,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb boolean hasMaster; BlockPos master; Block masterBlock; - byte masterMeat; //TODO rename this! + IBlockState state; public boolean canUpdate () { @@ -38,7 +39,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb if (!hasMaster) return false; - if (worldObj.getBlock(master) == masterBlock && worldObj.getBlockMetadata(master) == masterMeat) + if (worldObj.getBlockState(master).getBlock() == masterBlock && worldObj.getBlockState(master) == state) return true; else @@ -57,9 +58,9 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb public void overrideMaster (int x, int y, int z) { hasMaster = true; - master = new CoordTuple(x, y, z); - masterBlock = worldObj.getBlock(x, y, z); - masterMeat = (byte) worldObj.getBlockMetadata(x, y, z); + master = new BlockPos(x, y, z); + state = worldObj.getBlockState(master); + masterBlock = state.getBlock(); } public void removeMaster () @@ -67,19 +68,19 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb hasMaster = false; master = null; masterBlock = null; - masterMeat = 0; + state = null; } @Override - public boolean setPotentialMaster (IMasterLogic master, World w, int x, int y, int z) + public boolean setPotentialMaster (IMasterLogic master, World w, BlockPos pos) { return !hasMaster; } @Deprecated - public boolean verifyMaster (IMasterLogic logic, int x, int y, int z) + public boolean verifyMaster (IMasterLogic logic, BlockPos pos) { - return master.equalCoords(x, y, z) && worldObj.getBlock(x, y, z) == masterBlock && worldObj.getBlockMetadata(x, y, z) == masterMeat; + return master.equals(pos) && worldObj.getBlockState(pos) == state && worldObj.getBlockState(pos).getBlock() == masterBlock; } @Override @@ -107,8 +108,8 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb { if (hasValidMaster()) { - IMasterLogic logic = (IMasterLogic) worldObj.getTileEntity(master.x, master.y, master.z); - logic.notifyChange(this, xCoord, yCoord, zCoord); + IMasterLogic logic = (IMasterLogic) worldObj.getTileEntity(pos); + logic.notifyChange(this, pos); } } @@ -120,9 +121,9 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb int xCenter = tags.getInteger("xCenter"); int yCenter = tags.getInteger("yCenter"); int zCenter = tags.getInteger("zCenter"); - master = new CoordTuple(xCenter, yCenter, zCenter); + master = new BlockPos(xCenter, yCenter, zCenter); masterBlock = BlockUtils.getBlockFromUniqueName(tags.getString("MasterBlockName")); - masterMeat = tags.getByte("masterMeat"); + state = tags.getByte("masterMeat"); } } @@ -131,11 +132,11 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb tags.setBoolean("TiedToMaster", hasMaster); if (hasMaster) { - tags.setInteger("xCenter", master.x); - tags.setInteger("yCenter", master.y); - tags.setInteger("zCenter", master.z); + tags.setInteger("xCenter", master.getX()); + tags.setInteger("yCenter", master.getY()); + tags.setInteger("zCenter", master.getZ()); tags.setString("MasterBlockName", BlockUtils.getUniqueName(masterBlock)); - tags.setByte("masterMeat", masterMeat); + tags.setByte("masterMeat", state); } } @@ -159,15 +160,15 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb { NBTTagCompound tag = new NBTTagCompound(); writeCustomNBT(tag); - return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); + return new S35PacketUpdateTileEntity(pos, 1, tag); } @Override public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) { - readCustomNBT(packet.func_148857_g()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + readCustomNBT(packet.getNbtCompound()); + worldObj.markBlockForRenderUpdate(pos); + worldObj.markBlockForUpdate(pos); } /* IDebuggable */ @@ -175,10 +176,10 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb public DebugData getDebugInfo (EntityPlayer player) { String[] strs = new String[2]; - strs[0] = "Location: x" + xCoord + ", y" + yCoord + ", z" + zCoord; + strs[0] = "Location: x" + pos.getX() + ", y" + pos.getY() + ", z" + pos.getZ(); if (hasMaster) { - strs[1] = "masterBlock: " + masterBlock.toString() + ", masterMeat: " + masterMeat; + strs[1] = "masterBlock: " + masterBlock.toString() + ", masterMeat: " + state.toString(); } else { @@ -189,13 +190,13 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb public World getWorld () { - return this.getWorldObj(); + return worldObj; } @Deprecated public boolean setMaster (int x, int y, int z) { - if (!hasMaster || worldObj.getBlock(master.x, master.y, master.z) != masterBlock || (worldObj.getBlockMetadata(master.x, master.y, master.z) != masterMeat)) + if (!hasMaster || worldObj.getBlockState(master) != state || (worldObj.getBlockState(master) != masterBlock)) { overrideMaster(x, y, z); return true; diff --git a/src/mantle/blocks/iface/IFacingLogic.java b/src/mantle/blocks/iface/IFacingLogic.java index 12299b8..a9667ed 100644 --- a/src/mantle/blocks/iface/IFacingLogic.java +++ b/src/mantle/blocks/iface/IFacingLogic.java @@ -15,14 +15,7 @@ public interface IFacingLogic public EnumFacing getForgeDirection (); - @Deprecated - public void setDirection (int side); - @Deprecated - public void setDirection (float yaw, float pitch, EntityLivingBase player); - - //TODO 1.8 \/ - /** This will be added next version - * public void setDirection(int side, float yaw, float pitch, EntityLivingBase player); */ + public void setDirection(EnumFacing facing, float yaw, float pitch, EntityLivingBase player); } diff --git a/src/mantle/blocks/iface/IMasterLogic.java b/src/mantle/blocks/iface/IMasterLogic.java index 8788ed3..cd3acca 100644 --- a/src/mantle/blocks/iface/IMasterLogic.java +++ b/src/mantle/blocks/iface/IMasterLogic.java @@ -1,12 +1,12 @@ package mantle.blocks.iface; +import net.minecraft.util.BlockPos; + public interface IMasterLogic { /** Called when servants change their state * - * @param x Servant X - * @param y Servant Y - * @param z Servant Z + * @param pos servant position */ - public void notifyChange (IServantLogic servant, int x, int y, int z); + public void notifyChange (IServantLogic servant, BlockPos pos); } diff --git a/src/mantle/blocks/iface/IServantLogic.java b/src/mantle/blocks/iface/IServantLogic.java index 82ef3a9..4ca6e86 100644 --- a/src/mantle/blocks/iface/IServantLogic.java +++ b/src/mantle/blocks/iface/IServantLogic.java @@ -14,34 +14,28 @@ public interface IServantLogic * * @param master * @param world the world of master - * @param xMaster xCoord of master - * @param yMaster yCoord of master - * @param zMaster zCoord of master + * @param pos position of master * @return whether the servant can be tied to this master */ - public boolean setPotentialMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); + public boolean setPotentialMaster (IMasterLogic master, World world, BlockPos pos); /** Used to set and verify that this is the block's master * * @param master * @param world - * @param xMaster xCoord of master - * @param yMaster yCoord of master - * @param zMaster zCoord of master + * @param pos position of master * @return Is this block tied to this master? */ - public boolean verifyMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); + public boolean verifyMaster (IMasterLogic master, World world, BlockPos pos); /** Exactly what it says on the tin * * @param master * @param world - * @param xMaster xCoord of master - * @param yMaster yCoord of master - * @param zMaster zCoord of master + * @param pos position of master */ - public void invalidateMaster (IMasterLogic master, World world, int xMaster, int yMaster, int zMaster); + public void invalidateMaster (IMasterLogic master, World world, BlockPos pos); } diff --git a/src/mantle/client/RenderItemCopy.java b/src/mantle/client/RenderItemCopy.java index 9850f9b..c0fa466 100644 --- a/src/mantle/client/RenderItemCopy.java +++ b/src/mantle/client/RenderItemCopy.java @@ -5,9 +5,11 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.entity.Render; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; @@ -40,8 +42,9 @@ public class RenderItemCopy extends Render public float zLevel; public static boolean renderInFrame; - public RenderItemCopy() + protected RenderItemCopy(RenderManager mgr) { + super(mgr); this.shadowSize = 0.15F; this.shadowOpaque = 0.75F; } @@ -202,7 +205,8 @@ public class RenderItemCopy extends Render private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) { - Tessellator tessellator = Tessellator.instance; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); if (par2Icon == null) { @@ -322,12 +326,12 @@ public class RenderItemCopy extends Render } GL11.glColor4f(par5, par6, par7, 1.0F); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - tessellator.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7); - tessellator.addVertexWithUV((double) (f8 - f9), (double) (0.0F - f10), 0.0D, (double) f5, (double) f7); - tessellator.addVertexWithUV((double) (f8 - f9), (double) (1.0F - f10), 0.0D, (double) f5, (double) f6); - tessellator.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6); + worldRenderer.startDrawingQuads(); + worldRenderer.setNormal(0.0F, 1.0F, 0.0F); + worldRenderer.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7); + worldRenderer.addVertexWithUV((double) (f8 - f9), (double) (0.0F - f10), 0.0D, (double) f5, (double) f7); + worldRenderer.addVertexWithUV((double) (f8 - f9), (double) (1.0F - f10), 0.0D, (double) f5, (double) f6); + worldRenderer.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6); tessellator.draw(); GL11.glPopMatrix(); } @@ -521,20 +525,20 @@ public class RenderItemCopy extends Render float f1 = 0.00390625F; float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; float f3 = 0.0F; - Tessellator tessellator = Tessellator.instance; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); float f4 = 4.0F; if (j1 == 1) { f4 = -1.0F; } - - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double) (par2), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); - tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), + worldRenderer.startDrawingQuads(); + worldRenderer.addVertexWithUV((double) (par2), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); + worldRenderer.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); - tessellator.addVertexWithUV((double) (par2 + par4), (double) (par3), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); - tessellator.addVertexWithUV((double) (par2), (double) (par3), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); + worldRenderer.addVertexWithUV((double) (par2 + par4), (double) (par3), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); + worldRenderer.addVertexWithUV((double) (par2), (double) (par3), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); tessellator.draw(); } } @@ -569,7 +573,7 @@ public class RenderItemCopy extends Render GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); - Tessellator tessellator = Tessellator.instance; + Tessellator tessellator = Tessellator.getInstance(); int i1 = 255 - l << 16 | l << 8; int j1 = (255 - l) / 4 << 16 | 16128; this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); @@ -587,26 +591,28 @@ public class RenderItemCopy extends Render * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: * tessellator, x, y, width, height, color */ - private void renderQuad (Tessellator par1Tessellator, int par2, int par3, int par4, int par5, int par6) + private void renderQuad (Tessellator tessellator, int par2, int par3, int par4, int par5, int par6) { - par1Tessellator.startDrawingQuads(); - par1Tessellator.setColorOpaque_I(par6); - par1Tessellator.addVertex((double) (par2), (double) (par3), 0.0D); - par1Tessellator.addVertex((double) (par2), (double) (par3 + par5), 0.0D); - par1Tessellator.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); - par1Tessellator.addVertex((double) (par2 + par4), (double) (par3), 0.0D); - par1Tessellator.draw(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.startDrawingQuads(); + worldRenderer.setColorOpaque_I(par6); + worldRenderer.addVertex((double) (par2), (double) (par3), 0.0D); + worldRenderer.addVertex((double) (par2), (double) (par3 + par5), 0.0D); + worldRenderer.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); + worldRenderer.addVertex((double) (par2 + par4), (double) (par3), 0.0D); + worldRenderer.draw(); } public void renderIcon (int par1, int par2, IIcon par3Icon, int par4, int par5) { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double) (par1), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); - tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); - tessellator.addVertexWithUV((double) (par1 + par4), (double) (par2), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); - tessellator.addVertexWithUV((double) (par1), (double) (par2), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); - tessellator.draw(); + WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); + worldRenderer.startDrawingQuads(); + + worldRenderer.addVertexWithUV((double) (par1), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); + worldRenderer.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); + worldRenderer.addVertexWithUV((double) (par1 + par4), (double) (par2), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); + worldRenderer.addVertexWithUV((double) (par1), (double) (par2), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); + worldRenderer.draw(); } protected ResourceLocation getEntityTexture (Entity par1Entity) diff --git a/src/mantle/client/SmallFontRenderer.java b/src/mantle/client/SmallFontRenderer.java index ce57090..39f3f37 100644 --- a/src/mantle/client/SmallFontRenderer.java +++ b/src/mantle/client/SmallFontRenderer.java @@ -15,6 +15,7 @@ import javax.imageio.ImageIO; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.IResourceManager; import net.minecraft.client.resources.IResourceManagerReloadListener; @@ -584,16 +585,17 @@ public class SmallFontRenderer implements IResourceManagerReloadListener } Tessellator tessellator; - + WorldRenderer worldRenderer; if (this.strikethroughStyle) { tessellator = Tessellator.getInstance(); + worldRenderer = tessellator.getWorldRenderer(); GL11.glDisable(GL11.GL_TEXTURE_2D); - tessellator.startDrawingQuads(); - tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); - tessellator.addVertex((double) (this.posX + f1), (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); - tessellator.addVertex((double) (this.posX + f1), (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D); - tessellator.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D); + worldRenderer.startDrawingQuads(); + worldRenderer.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); + worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); + worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D); + worldRenderer.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } @@ -601,13 +603,14 @@ public class SmallFontRenderer implements IResourceManagerReloadListener if (this.underlineStyle) { tessellator = Tessellator.getInstance(); + worldRenderer = tessellator.getWorldRenderer(); GL11.glDisable(GL11.GL_TEXTURE_2D); - tessellator.startDrawingQuads(); + worldRenderer.startDrawingQuads(); int l = this.underlineStyle ? -1 : 0; - tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D); - tessellator.addVertex((double) (this.posX + f1), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D); - tessellator.addVertex((double) (this.posX + f1), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D); - tessellator.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D); + worldRenderer.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D); + worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D); + worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D); + worldRenderer.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } diff --git a/src/mantle/common/network/PacketUpdateTE.java b/src/mantle/common/network/PacketUpdateTE.java index 7af4de7..d351403 100644 --- a/src/mantle/common/network/PacketUpdateTE.java +++ b/src/mantle/common/network/PacketUpdateTE.java @@ -10,7 +10,7 @@ import net.minecraft.util.BlockPos; public class PacketUpdateTE extends AbstractPacket { - private int x, y, z; + private BlockPos pos; private NBTTagCompound data; public PacketUpdateTE() @@ -18,11 +18,9 @@ public class PacketUpdateTE extends AbstractPacket } - public PacketUpdateTE(int x, int y, int z, NBTTagCompound data) + public PacketUpdateTE(BlockPos pos, NBTTagCompound data) { - this.x = x; - this.y = y; - this.z = z; + this.pos = pos; this.data = data; } @@ -30,9 +28,9 @@ public class PacketUpdateTE extends AbstractPacket public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer) { PacketBuffer pbuff = new PacketBuffer(buffer); - pbuff.writeInt(x); - pbuff.writeShort(y); - pbuff.writeInt(z); + pbuff.writeInt(pos.getX()); + pbuff.writeShort(pos.getY()); + pbuff.writeInt(pos.getZ()); try { pbuff.writeNBTTagCompoundToBuffer(data); @@ -47,9 +45,7 @@ public class PacketUpdateTE extends AbstractPacket public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer) { PacketBuffer pbuff = new PacketBuffer(buffer); - x = pbuff.readInt(); - y = pbuff.readShort(); - z = pbuff.readInt(); + pos = new BlockPos(pbuff.readInt(), pbuff.readShort(), pbuff.readInt()); try { data = pbuff.readNBTTagCompoundFromBuffer(); @@ -63,7 +59,7 @@ public class PacketUpdateTE extends AbstractPacket @Override public void handleClientSide (EntityPlayer player) { - TileEntity te = player.worldObj.getTileEntity(new BlockPos(x, y, z)); + TileEntity te = player.worldObj.getTileEntity(pos); if (te != null) { diff --git a/src/mantle/lib/environment/EnvironmentChecks.java b/src/mantle/lib/environment/EnvironmentChecks.java index a238b30..94c072f 100644 --- a/src/mantle/lib/environment/EnvironmentChecks.java +++ b/src/mantle/lib/environment/EnvironmentChecks.java @@ -55,7 +55,7 @@ public class EnvironmentChecks if (cl != null) { if (!CoreConfig.silenceEnvChecks) - logger.error("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and Cauldron(MCPC+)."); + logger.error("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and spigot. Please try Sponge instead"); modIds.add("bukkit"); } } From cb0e12a3784dd0cc9028245cf599bdb45f61e74f Mon Sep 17 00:00:00 2001 From: alexbegt Date: Thu, 4 Dec 2014 08:56:46 -0500 Subject: [PATCH 06/91] Fixes some more errors. --- src/mantle/blocks/abstracts/InventoryBlock.java | 8 ++++---- src/mantle/blocks/abstracts/InventorySlab.java | 12 +++++++----- src/mantle/blocks/abstracts/MultiServantLogic.java | 9 ++++----- src/mantle/client/gui/TurnPageButton.java | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/mantle/blocks/abstracts/InventoryBlock.java b/src/mantle/blocks/abstracts/InventoryBlock.java index 7b9f35f..2f88a80 100644 --- a/src/mantle/blocks/abstracts/InventoryBlock.java +++ b/src/mantle/blocks/abstracts/InventoryBlock.java @@ -52,7 +52,7 @@ public abstract class InventoryBlock extends BlockContainer public abstract Object getModInstance (); @Override - public boolean onBlockActivated (World world, BlockPos pos, EntityPlayer player, EnumFacing side, float clickX, float clickY, float clickZ) + public boolean onBlockActivated (World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float clickX, float clickY, float clickZ) { if (player.isSneaking()) return false; @@ -127,15 +127,15 @@ public abstract class InventoryBlock extends BlockContainer //This class does not have an actual block placed in the world @Override - public IBlockState onBlockPlaced (World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState meta) + public IBlockState onBlockPlaced (World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { this.side = side; - return meta; + return world.getBlockState(pos).getBlock().getStateFromMeta(meta); } @Override @SuppressWarnings("deprecation") // TODO: Remove this when setDirection calls updated. - public void onBlockPlacedBy (World world, BlockPos pos, EntityLivingBase entityliving, ItemStack stack) + public void onBlockPlacedBy (World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, ItemStack stack) { TileEntity logic = world.getTileEntity(pos); if (logic instanceof IFacingLogic) diff --git a/src/mantle/blocks/abstracts/InventorySlab.java b/src/mantle/blocks/abstracts/InventorySlab.java index b422a46..bd39aa8 100644 --- a/src/mantle/blocks/abstracts/InventorySlab.java +++ b/src/mantle/blocks/abstracts/InventorySlab.java @@ -25,7 +25,7 @@ public abstract class InventorySlab extends InventoryBlock /* Rendering */ @Override - public boolean renderAsNormalBlock () + public boolean isFullCube () { return false; } @@ -39,12 +39,13 @@ public abstract class InventorySlab extends InventoryBlock @Override public boolean shouldSideBeRendered (IBlockAccess world, BlockPos pos, EnumFacing side) { - if (side > 1) + if (side.getHorizontalIndex() > 1) return super.shouldSideBeRendered(world, pos, side); - int meta = world.getBlockMetadata(pos); + IBlockState iblockstate = world.getBlockState(pos); + int meta = iblockstate.getBlock().getMetaFromState(iblockstate); boolean top = (meta | 8) == 1; - if ((top && side == 0) || (!top && side == 1)) + if ((top && side == side.DOWN) || (!top && side == side.UP)) return true; return super.shouldSideBeRendered(world, pos, side); @@ -65,7 +66,8 @@ public abstract class InventorySlab extends InventoryBlock public void setBlockBoundsBasedOnState (IBlockAccess world, BlockPos pos, IBlockState state) { - int meta = world.getBlockState(pos) / 8; + IBlockState iblockstate = world.getBlockState(pos); + int meta = iblockstate.getBlock().getMetaFromState(iblockstate) / 8; float minY = meta == 1 ? 0.5F : 0.0F; float maxY = meta == 1 ? 1.0F : 0.5F; setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/mantle/blocks/abstracts/MultiServantLogic.java index 97f87d6..5f76641 100644 --- a/src/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/mantle/blocks/abstracts/MultiServantLogic.java @@ -5,7 +5,6 @@ import mantle.blocks.iface.IMasterLogic; import mantle.blocks.iface.IServantLogic; import mantle.debug.DebugData; import mantle.debug.IDebuggable; -import mantle.world.CoordTuple; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; @@ -84,7 +83,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb } @Override - public boolean verifyMaster (IMasterLogic logic, World world, int x, int y, int z) + public boolean verifyMaster (IMasterLogic logic, World world, BlockPos pos) { if (hasMaster) { @@ -92,13 +91,13 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb } else { - overrideMaster(x, y, z); + overrideMaster(pos.getX(), pos.getY(), pos.getZ()); return true; } } @Override - public void invalidateMaster (IMasterLogic master, World w, int x, int y, int z) + public void invalidateMaster (IMasterLogic master, World w, BlockPos pos) { hasMaster = false; master = null; @@ -167,7 +166,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) { readCustomNBT(packet.getNbtCompound()); - worldObj.markBlockForRenderUpdate(pos); + worldObj.notifyLightSet(pos); worldObj.markBlockForUpdate(pos); } diff --git a/src/mantle/client/gui/TurnPageButton.java b/src/mantle/client/gui/TurnPageButton.java index 0cb5410..2aa2844 100644 --- a/src/mantle/client/gui/TurnPageButton.java +++ b/src/mantle/client/gui/TurnPageButton.java @@ -7,8 +7,8 @@ import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TurnPageButton extends GuiButton From a03a0f9025d727e6e9cf4454c04a91ed4773ee61 Mon Sep 17 00:00:00 2001 From: alexbegt Date: Thu, 4 Dec 2014 20:34:35 -0500 Subject: [PATCH 07/91] Fixes some more issues. --- .../assets/mantle/models/item/mantleBook.json | 18 + src/mantle/Mantle.java | 1 - .../blocks/abstracts/InventoryBlock.java | 21 - src/mantle/books/BookData.java | 4 +- src/mantle/client/MProxyClient.java | 10 +- src/mantle/client/ModelHelper.java | 34 + src/mantle/client/RenderItemCopy.java | 683 ----------- src/mantle/client/SmallFontRenderer.java | 1067 ----------------- src/mantle/client/gui/GuiManual.java | 8 +- .../client/pages/ContentsTablePage.java | 2 +- src/mantle/client/pages/CraftingPage.java | 12 +- src/mantle/client/pages/FurnacePage.java | 8 +- src/mantle/client/pages/SidebarPage.java | 2 +- src/mantle/items/abstracts/CraftingItem.java | 25 - 14 files changed, 72 insertions(+), 1823 deletions(-) create mode 100644 resources/assets/mantle/models/item/mantleBook.json create mode 100644 src/mantle/client/ModelHelper.java delete mode 100644 src/mantle/client/RenderItemCopy.java delete mode 100644 src/mantle/client/SmallFontRenderer.java diff --git a/resources/assets/mantle/models/item/mantleBook.json b/resources/assets/mantle/models/item/mantleBook.json new file mode 100644 index 0000000..83eecc5 --- /dev/null +++ b/resources/assets/mantle/models/item/mantleBook.json @@ -0,0 +1,18 @@ +{ + "parent": "builtin/generated", + "textures": { + "layer0": "mantle:items/mantlebook_blue" + }, + "display": { + "thirdperson": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 1, -3 ], + "scale": [ 0.55, 0.55, 0.55 ] + }, + "firstperson": { + "rotation": [ 0, -135, 25 ], + "translation": [ 0, 4, 2 ], + "scale": [ 1.7, 1.7, 1.7 ] + } + } +} diff --git a/src/mantle/Mantle.java b/src/mantle/Mantle.java index 3c929a4..9c96a3d 100644 --- a/src/mantle/Mantle.java +++ b/src/mantle/Mantle.java @@ -12,7 +12,6 @@ import mantle.items.Manual; import mantle.lib.CoreConfig; import mantle.lib.CoreRepo; import mantle.lib.environment.EnvironmentChecks; -import mantle.module.ModuleController; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; diff --git a/src/mantle/blocks/abstracts/InventoryBlock.java b/src/mantle/blocks/abstracts/InventoryBlock.java index 2f88a80..9edc40c 100644 --- a/src/mantle/blocks/abstracts/InventoryBlock.java +++ b/src/mantle/blocks/abstracts/InventoryBlock.java @@ -14,7 +14,6 @@ import mantle.debug.IDebuggable; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -25,7 +24,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; -import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -184,25 +182,6 @@ public abstract class InventoryBlock extends BlockContainer return meta; } - /* Textures */ - public IIcon[] icons; - - public abstract String[] getTextureNames (); - - public abstract String getTextureDomain (int textureNameIndex); - - @Override - public void registerBlockIcons (IIconRegister iconRegister) - { - String[] textureNames = getTextureNames(); - this.icons = new IIcon[textureNames.length]; - - for (int i = 0; i < this.icons.length; ++i) - { - this.icons[i] = iconRegister.registerIcon(getTextureDomain(i) + ":" + textureNames[i]); - } - } - /* IDebuggable */ @Override public void onBlockClicked (World world, BlockPos pos, EntityPlayer player) diff --git a/src/mantle/books/BookData.java b/src/mantle/books/BookData.java index c0daaeb..4fd63f4 100644 --- a/src/mantle/books/BookData.java +++ b/src/mantle/books/BookData.java @@ -1,6 +1,6 @@ package mantle.books; -import mantle.client.SmallFontRenderer; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.ResourceLocation; import org.w3c.dom.Document; @@ -15,7 +15,7 @@ public class BookData public ResourceLocation itemImage = new ResourceLocation("mantle", "textures/items/mantlebook_blue.png"); public Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml"); //font can be left null if so, the default from mantle will be used - public SmallFontRenderer font; + public FontRenderer font; public Boolean isTranslatable = false; public boolean isFromZip = false; diff --git a/src/mantle/client/MProxyClient.java b/src/mantle/client/MProxyClient.java index 922c385..e0d1635 100644 --- a/src/mantle/client/MProxyClient.java +++ b/src/mantle/client/MProxyClient.java @@ -5,6 +5,7 @@ import static mantle.lib.CoreRepo.logger; import java.util.HashMap; import java.util.Map; +import mantle.Mantle; import mantle.books.BookData; import mantle.books.BookDataStore; import mantle.client.gui.GuiManual; @@ -30,17 +31,10 @@ public class MProxyClient extends MProxyCommon public static final String MINECRAFT_ASCII_PATH = "minecraft:textures/font/ascii.png"; - public static SmallFontRenderer smallFontRenderer; - /* Registers any rendering code. */ public void registerRenderer () { - Minecraft mc = Minecraft.getMinecraft(); - if (mc.getTextureManager() == null) - logger.error("Vanilla texture manager is null!"); - if (mc.renderEngine == null) - logger.error("Vanilla render engine is null!"); - smallFontRenderer = new SmallFontRenderer(mc.gameSettings, new ResourceLocation(MINECRAFT_ASCII_PATH), mc.renderEngine, false); + ModelHelper.registerItem(Mantle.mantleBook, "mantleBook"); } public static Map> pageClasses = new HashMap>(); diff --git a/src/mantle/client/ModelHelper.java b/src/mantle/client/ModelHelper.java new file mode 100644 index 0000000..d8c031f --- /dev/null +++ b/src/mantle/client/ModelHelper.java @@ -0,0 +1,34 @@ +package mantle.client; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemModelMesher; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelHelper +{ + public static void registerItem(Item item, int metadata, String itemName) + { + ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); + mesher.register(item, metadata, new ModelResourceLocation(itemName, "inventory")); + } + + public static void registerBlock(Block block, int metadata, String blockName) + { + registerItem(Item.getItemFromBlock(block), metadata, blockName); + } + + public static void registerBlock(Block block, String blockName) + { + registerBlock(block, 0, blockName); + } + + public static void registerItem(Item item, String itemName) + { + registerItem(item, 0, itemName); + } +} \ No newline at end of file diff --git a/src/mantle/client/RenderItemCopy.java b/src/mantle/client/RenderItemCopy.java deleted file mode 100644 index c0fa466..0000000 --- a/src/mantle/client/RenderItemCopy.java +++ /dev/null @@ -1,683 +0,0 @@ -package mantle.client; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.block.model.ModelBlock; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.ForgeHooksClient; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class RenderItemCopy extends Render -{ - private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - private RenderBlocks itemRenderBlocks = new RenderBlocks(); - - /** The RNG used in RenderItem (for bobbing itemstacks on the ground) */ - private Random random = new Random(); - public boolean renderWithColor = true; - - /** Defines the zLevel of rendering of item on GUI. */ - public float zLevel; - public static boolean renderInFrame; - - protected RenderItemCopy(RenderManager mgr) - { - super(mgr); - this.shadowSize = 0.15F; - this.shadowOpaque = 0.75F; - } - - /** - * Renders the item - */ - public void doRenderItem (EntityItem par1EntityItem, double par2, double par4, double par6, float par8, float par9) - { - this.bindEntityTexture(par1EntityItem); - this.random.setSeed(187L); - ItemStack itemstack = par1EntityItem.getEntityItem(); - - if (itemstack.getItem() != null) - { - GL11.glPushMatrix(); - float f2 = shouldBob() ? MathHelper.sin(((float) par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F; - float f3 = (((float) par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI); - byte b0 = getMiniBlockCount(itemstack); - - GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - float f4; - float f5; - float f6; - int i; - - Block block = null; - - block = Block.getBlockFromItem(itemstack.getItem()); - - if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, new RenderBlocks(), 000)) // TODO what goes here not 000 - { - - } - else if (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d(block.getRenderType())) - { - GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); - - if (renderInFrame) - { - GL11.glScalef(1.25F, 1.25F, 1.25F); - GL11.glTranslatef(0.0F, 0.05F, 0.0F); - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - } - - float f7 = 0.25F; - int j = block.getRenderType(); - - if (j == 1 || j == 19 || j == 12 || j == 2) - { - f7 = 0.5F; - } - - GL11.glScalef(f7, f7, f7); - - for (i = 0; i < b0; ++i) - { - GL11.glPushMatrix(); - - if (i > 0) - { - f5 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; - f4 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; - f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / f7; - GL11.glTranslatef(f5, f4, f6); - } - - f5 = 1.0F; - this.itemRenderBlocks.renderBlockAsItem(block, itemstack.getItemDamage(), f5); - GL11.glPopMatrix(); - } - } - else - { - float f8; - - if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses()) - { - if (renderInFrame) - { - GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); - GL11.glTranslatef(0.0F, -0.05F, 0.0F); - } - else - { - GL11.glScalef(0.5F, 0.5F, 0.5F); - } - - for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) - { - this.random.setSeed(187L); - IIcon icon = itemstack.getItem().getIcon(itemstack, k); - f8 = 1.0F; - - if (this.renderWithColor) - { - i = itemstack.getItem().getColorFromItemStack(itemstack, k); - f5 = (float) (i >> 16 & 255) / 255.0F; - f4 = (float) (i >> 8 & 255) / 255.0F; - f6 = (float) (i & 255) / 255.0F; - GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F); - this.renderDroppedItem(par1EntityItem, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8, k); - } - else - { - this.renderDroppedItem(par1EntityItem, icon, b0, par9, 1.0F, 1.0F, 1.0F, k); - } - } - } - else - { - if (renderInFrame) - { - GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F); - GL11.glTranslatef(0.0F, -0.05F, 0.0F); - } - else - { - GL11.glScalef(0.5F, 0.5F, 0.5F); - } - - IIcon icon1 = itemstack.getIconIndex(); - - if (this.renderWithColor) - { - int l = itemstack.getItem().getColorFromItemStack(itemstack, 0); - f8 = (float) (l >> 16 & 255) / 255.0F; - float f9 = (float) (l >> 8 & 255) / 255.0F; - f5 = (float) (l & 255) / 255.0F; - f4 = 1.0F; - this.renderDroppedItem(par1EntityItem, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4); - } - else - { - this.renderDroppedItem(par1EntityItem, icon1, b0, par9, 1.0F, 1.0F, 1.0F); - } - } - } - - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); - } - } - - protected ResourceLocation func_110796_a (EntityItem par1EntityItem) - { - return this.renderManager.renderEngine.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber()); - } - - /** - * Renders a dropped item - */ - private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7) - { - renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0); - } - - private void renderDroppedItem (EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass) - { - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - - if (par2Icon == null) - { - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - ResourceLocation resourcelocation = texturemanager.getResourceLocation(par1EntityItem.getEntityItem().getItemSpriteNumber()); - par2Icon = ((TextureMap) texturemanager.getTexture(resourcelocation)).getAtlasSprite("missingno"); - } - - float f4 = par2Icon.getMinU(); - float f5 = par2Icon.getMaxU(); - float f6 = par2Icon.getMinV(); - float f7 = par2Icon.getMaxV(); - float f8 = 1.0F; - float f9 = 0.5F; - float f10 = 0.25F; - float f11; - - if (this.renderManager.options.fancyGraphics) - { - GL11.glPushMatrix(); - - if (renderInFrame) - { - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - } - else - { - GL11.glRotatef((((float) par1EntityItem.age + par4) / 20.0F + par1EntityItem.hoverStart) * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F); - } - - float f12 = 0.0625F; - f11 = 0.021875F; - ItemStack itemstack = par1EntityItem.getEntityItem(); - int j = itemstack.stackSize; - byte b0 = getMiniItemCount(itemstack); - - GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F)); - - for (int k = 0; k < b0; ++k) - { - // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug... - if (k > 0 && shouldSpreadItems()) - { - float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; - float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; - float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F; - GL11.glTranslatef(x, y, f12 + f11); - } - else - { - GL11.glTranslatef(0f, 0f, f12 + f11); - } - - if (itemstack.getItemSpriteNumber() == 0) - { - this.bindTexture(TextureMap.locationBlocksTexture); - } - else - { - this.bindTexture(TextureMap.locationItemsTexture); - } - - GL11.glColor4f(par5, par6, par7, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12); - - if (itemstack.hasEffect(pass)) - { - GL11.glDepthFunc(GL11.GL_EQUAL); - GL11.glDisable(GL11.GL_LIGHTING); - this.renderManager.renderEngine.bindTexture(RES_ITEM_GLINT); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - float f13 = 0.76F; - GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F); - GL11.glMatrixMode(GL11.GL_TEXTURE); - GL11.glPushMatrix(); - float f14 = 0.125F; - GL11.glScalef(f14, f14, f14); - float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; - GL11.glTranslatef(f15, 0.0F, 0.0F); - GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glScalef(f14, f14, f14); - f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; - GL11.glTranslatef(-f15, 0.0F, 0.0F); - GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); - ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, f12); - GL11.glPopMatrix(); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_LEQUAL); - } - } - - GL11.glPopMatrix(); - } - else - { - for (int l = 0; l < par3; ++l) - { - GL11.glPushMatrix(); - - if (l > 0) - { - f11 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; - float f16 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; - float f17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F; - GL11.glTranslatef(f11, f16, f17); - } - - if (!renderInFrame) - { - GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); - } - - GL11.glColor4f(par5, par6, par7, 1.0F); - worldRenderer.startDrawingQuads(); - worldRenderer.setNormal(0.0F, 1.0F, 0.0F); - worldRenderer.addVertexWithUV((double) (0.0F - f9), (double) (0.0F - f10), 0.0D, (double) f4, (double) f7); - worldRenderer.addVertexWithUV((double) (f8 - f9), (double) (0.0F - f10), 0.0D, (double) f5, (double) f7); - worldRenderer.addVertexWithUV((double) (f8 - f9), (double) (1.0F - f10), 0.0D, (double) f5, (double) f6); - worldRenderer.addVertexWithUV((double) (0.0F - f9), (double) (1.0F - f10), 0.0D, (double) f4, (double) f6); - tessellator.draw(); - GL11.glPopMatrix(); - } - } - } - - /** - * Renders the item's icon or block into the UI at the specified position. - */ - public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) - { - renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false); - } - - public void renderItemIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect) - { - Item k = par3ItemStack.getItem(); - int l; - if(k == null) - { - k = Items.iron_pickaxe; - l = 0; - } - else - { - l = par3ItemStack.getItemDamage(); - } - Object object = par3ItemStack.getItem() == null ? null : par3ItemStack.getIconIndex(); - float f; - int i1; - float f1; - float f2; - - Block block = Block.getBlockFromItem(k); - if (block != null && par3ItemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(block.getRenderType())) - { - par2TextureManager.bindTexture(TextureMap.locationBlocksTexture); - GL11.glPushMatrix(); - GL11.glTranslatef((float) (par4 - 2), (float) (par5 + 3), -3.0F + this.zLevel); - GL11.glScalef(10.0F, 10.0F, 10.0F); - GL11.glTranslatef(1.0F, 0.5F, 1.0F); - GL11.glScalef(1.0F, 1.0F, -1.0F); - GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F); - i1 = par3ItemStack.getItem().getColorFromItemStack(par3ItemStack, 0); - f = (float) (i1 >> 16 & 255) / 255.0F; - f1 = (float) (i1 >> 8 & 255) / 255.0F; - f2 = (float) (i1 & 255) / 255.0F; - - if (this.renderWithColor) - { - GL11.glColor4f(f, f1, f2, 1.0F); - } - - GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - //TODO FIX THESE - //this.itemRenderBlocks.useInventoryTint = this.renderWithColor; - this.itemRenderBlocks.renderBlockAsItem(block, l, 1.0F); - //TODO FIX THESE - //this.itemRenderBlocks.useInventoryTint = true; - GL11.glPopMatrix(); - } - else if (k != null && k.requiresMultipleRenderPasses()) - { - GL11.glDisable(GL11.GL_LIGHTING); - - for (int j1 = 0; j1 < k.getRenderPasses(l); ++j1) - { - par2TextureManager.bindTexture(par3ItemStack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture); - IIcon icon = k.getIcon(par3ItemStack, j1); - int k1 = k.getColorFromItemStack(par3ItemStack, j1); - f1 = (float) (k1 >> 16 & 255) / 255.0F; - f2 = (float) (k1 >> 8 & 255) / 255.0F; - float f3 = (float) (k1 & 255) / 255.0F; - - if (this.renderWithColor) - { - GL11.glColor4f(f1, f2, f3, 1.0F); - } - - this.renderIcon(par4, par5, icon, 16, 16); - - if (par3ItemStack.hasEffect(j1)) - { - renderEffect(par2TextureManager, par4, par5); - } - } - - GL11.glEnable(GL11.GL_LIGHTING); - } - else - { - GL11.glDisable(GL11.GL_LIGHTING); - ResourceLocation resourcelocation = par2TextureManager.getResourceLocation(par3ItemStack.getItemSpriteNumber()); - par2TextureManager.bindTexture(resourcelocation); - - if (object == null) - { - object = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); - } - - i1 = k.getColorFromItemStack(par3ItemStack, 0); - f = (float) (i1 >> 16 & 255) / 255.0F; - f1 = (float) (i1 >> 8 & 255) / 255.0F; - f2 = (float) (i1 & 255) / 255.0F; - - if (this.renderWithColor) - { - GL11.glColor4f(f, f1, f2, 1.0F); - } - - this.renderIcon(par4, par5, (IIcon) object, 16, 16); - GL11.glEnable(GL11.GL_LIGHTING); - - if (par3ItemStack.hasEffect(0)) - { - renderEffect(par2TextureManager, par4, par5); - } - } - - GL11.glEnable(GL11.GL_CULL_FACE); - } - - private void renderEffect (TextureManager manager, int x, int y) - { - GL11.glDepthFunc(GL11.GL_GREATER); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDepthMask(false); - manager.bindTexture(RES_ITEM_GLINT); - this.zLevel -= 50.0F; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); - GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); - this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - this.zLevel += 50.0F; - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_LEQUAL); - } - - /** - * Render the item's icon or block into the GUI, including the glint effect. - */ - public void renderItemAndEffectIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) - { - if (par3ItemStack != null) - { - if (!ForgeHooksClient.renderInventoryItem(new RenderBlocks(), par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float) par4, (float) par5)) - { - this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true); - } - - /* Modders must handle this themselves if they use custom renderers! - if (par3ItemStack.hasEffect()) - { - GL11.glDepthFunc(GL11.GL_GREATER); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDepthMask(false); - par2TextureManager.bindTexture(RES_ITEM_GLINT); - this.zLevel -= 50.0F; - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR); - GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); - this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20); - GL11.glDisable(GL11.GL_BLEND); - GL11.glDepthMask(true); - this.zLevel += 50.0F; - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthFunc(GL11.GL_LEQUAL); - } - */ - } - } - - private void renderGlint (int par1, int par2, int par3, int par4, int par5) - { - for (int j1 = 0; j1 < 2; ++j1) - { - if (j1 == 0) - { - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - } - - if (j1 == 1) - { - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - } - - float f = 0.00390625F; - float f1 = 0.00390625F; - float f2 = (float) (Minecraft.getSystemTime() % (long) (3000 + j1 * 1873)) / (3000.0F + (float) (j1 * 1873)) * 256.0F; - float f3 = 0.0F; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - float f4 = 4.0F; - - if (j1 == 1) - { - f4 = -1.0F; - } - worldRenderer.startDrawingQuads(); - worldRenderer.addVertexWithUV((double) (par2), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par5 * f4) * f), (double) ((f3 + (float) par5) * f1)); - worldRenderer.addVertexWithUV((double) (par2 + par4), (double) (par3 + par5), (double) this.zLevel, (double) ((f2 + (float) par4 + (float) par5 * f4) * f), - (double) ((f3 + (float) par5) * f1)); - worldRenderer.addVertexWithUV((double) (par2 + par4), (double) (par3), (double) this.zLevel, (double) ((f2 + (float) par4) * f), (double) ((f3 + 0.0F) * f1)); - worldRenderer.addVertexWithUV((double) (par2), (double) (par3), (double) this.zLevel, (double) ((f2 + 0.0F) * f), (double) ((f3 + 0.0F) * f1)); - tessellator.draw(); - } - } - - /** - * Renders the item's overlay information. Examples being stack count or damage on top of the item's image at the - * specified position. - */ - public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5) - { - this.renderItemOverlayIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, (String) null); - } - - public void renderItemOverlayIntoGUI (SmallFontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, String par6Str) - { - if (par3ItemStack != null) - { - if (par3ItemStack.stackSize > 1 || par6Str != null) - { - String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - par1FontRenderer.drawStringWithShadow(s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - } - - if (par3ItemStack.isItemDamaged()) - { - int k = (int) Math.round(13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage()); - int l = (int) Math.round(255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage()); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - Tessellator tessellator = Tessellator.getInstance(); - int i1 = 255 - l << 16 | l << 8; - int j1 = (255 - l) / 4 << 16 | 16128; - this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); - this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); - this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - } - } - - /** - * Adds a quad to the tesselator at the specified position with the set width and height and color. Args: - * tessellator, x, y, width, height, color - */ - private void renderQuad (Tessellator tessellator, int par2, int par3, int par4, int par5, int par6) - { - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.startDrawingQuads(); - worldRenderer.setColorOpaque_I(par6); - worldRenderer.addVertex((double) (par2), (double) (par3), 0.0D); - worldRenderer.addVertex((double) (par2), (double) (par3 + par5), 0.0D); - worldRenderer.addVertex((double) (par2 + par4), (double) (par3 + par5), 0.0D); - worldRenderer.addVertex((double) (par2 + par4), (double) (par3), 0.0D); - worldRenderer.draw(); - } - - public void renderIcon (int par1, int par2, IIcon par3Icon, int par4, int par5) - { - WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); - worldRenderer.startDrawingQuads(); - - worldRenderer.addVertexWithUV((double) (par1), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMaxV()); - worldRenderer.addVertexWithUV((double) (par1 + par4), (double) (par2 + par5), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMaxV()); - worldRenderer.addVertexWithUV((double) (par1 + par4), (double) (par2), (double) this.zLevel, (double) par3Icon.getMaxU(), (double) par3Icon.getMinV()); - worldRenderer.addVertexWithUV((double) (par1), (double) (par2), (double) this.zLevel, (double) par3Icon.getMinU(), (double) par3Icon.getMinV()); - worldRenderer.draw(); - } - - protected ResourceLocation getEntityTexture (Entity par1Entity) - { - return this.func_110796_a((EntityItem) par1Entity); - } - - /** - * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then - * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic - * (Render 1) - ret = 2; - if (stack.stackSize > 5) - ret = 3; - if (stack.stackSize > 20) - ret = 4; - if (stack.stackSize > 40) - ret = 5; - return ret; - } - - /** - * Allows for a subclass to override how many rendered items appear in a - * "mini item 3d stack" - * @param stack the ItemStack - * @return - */ - public byte getMiniItemCount (ItemStack stack) - { - byte ret = 1; - if (stack.stackSize > 1) - ret = 2; - if (stack.stackSize > 15) - ret = 3; - if (stack.stackSize > 31) - ret = 4; - return ret; - } -} diff --git a/src/mantle/client/SmallFontRenderer.java b/src/mantle/client/SmallFontRenderer.java deleted file mode 100644 index 39f3f37..0000000 --- a/src/mantle/client/SmallFontRenderer.java +++ /dev/null @@ -1,1067 +0,0 @@ -package mantle.client; - -import static mantle.lib.CoreRepo.logger; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; -import java.text.Bidi; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Random; - -import javax.imageio.ImageIO; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.util.ChatAllowedCharacters; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class SmallFontRenderer implements IResourceManagerReloadListener -{ - private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256]; - - /** Array of width of all the characters in default.png */ - private int[] charWidth = new int[256]; - - /** the height in pixels of default text */ - public int FONT_HEIGHT = 9; - public Random fontRandom = new Random(); - - /** - * Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory. - */ - private byte[] glyphWidth = new byte[65536]; - - /** - * Array of RGB triplets defining the 16 standard chat colors followed by 16 darker version of the same colors for - * drop shadows. - */ - private int[] colorCode = new int[32]; - private final ResourceLocation locationFontTexture; - - /** The RenderEngine used to load and setup glyph textures. */ - private TextureManager renderEngine; - - /** Current X coordinate at which to draw the next character. */ - private float posX; - - /** Current Y coordinate at which to draw the next character. */ - private float posY; - - /** - * If true, strings should be rendered with Unicode fonts instead of the default.png font - */ - private boolean unicodeFlag; - - /** - * If true, the Unicode Bidirectional Algorithm should be run before rendering any string. - */ - private boolean bidiFlag; - - /** Used to specify new red value for the current color. */ - private float red; - - /** Used to specify new blue value for the current color. */ - private float blue; - - /** Used to specify new green value for the current color. */ - private float green; - - /** Used to speify new alpha value for the current color. */ - private float alpha; - - /** Text color of the currently rendering string. */ - private int textColor; - - /** Set if the "k" style (random) is active in currently rendering string */ - private boolean randomStyle; - - /** Set if the "l" style (bold) is active in currently rendering string */ - private boolean boldStyle; - - /** Set if the "o" style (italic) is active in currently rendering string */ - private boolean italicStyle; - - /** - * Set if the "n" style (underlined) is active in currently rendering string - */ - private boolean underlineStyle; - - /** - * Set if the "m" style (strikethrough) is active in currently rendering string - */ - private boolean strikethroughStyle; - - public SmallFontRenderer(GameSettings par1GameSettings, ResourceLocation par2ResourceLocation, TextureManager par3TextureManager, boolean par4) - { - this.locationFontTexture = par2ResourceLocation; - //logger.error(this.locationFontTexture.toString() + " " + this.locationFontTexture.getResourcePath()); - this.renderEngine = par3TextureManager; - this.unicodeFlag = true; - if (this.renderEngine != null) - this.renderEngine.bindTexture(par2ResourceLocation); - if (this.renderEngine == null) - logger.error("renderEngine is null"); - //Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("Minecraft", "textures/font/ascii.png")); - for (int i = 0; i < 32; ++i) - { - int j = (i >> 3 & 1) * 85; - int k = (i >> 2 & 1) * 170 + j; - int l = (i >> 1 & 1) * 170 + j; - int i1 = (i >> 0 & 1) * 170 + j; - - if (i == 6) - { - k += 85; - } - - if (par1GameSettings.anaglyph) - { - int j1 = (k * 30 + l * 59 + i1 * 11) / 100; - int k1 = (k * 30 + l * 70) / 100; - int l1 = (k * 30 + i1 * 70) / 100; - k = j1; - l = k1; - i1 = l1; - } - - if (i >= 16) - { - k /= 4; - l /= 4; - i1 /= 4; - } - - this.colorCode[i] = (k & 255) << 16 | (l & 255) << 8 | i1 & 255; - } - - this.readGlyphSizes(); - } - - public void onResourceManagerReload (IResourceManager par1ResourceManager) - { - this.readFontTexture(); - } - - private void readFontTexture () - { - BufferedImage bufferedimage; - - try - { - bufferedimage = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(this.locationFontTexture).getInputStream()); - } - catch (IOException ioexception) - { - throw new RuntimeException(ioexception); - } - - int i = bufferedimage.getWidth(); - int j = bufferedimage.getHeight(); - int[] aint = new int[i * j]; - bufferedimage.getRGB(0, 0, i, j, aint, 0, i); - int k = j / 16; - int l = i / 16; - byte b0 = 1; - float f = 8.0F / (float) l; - int i1 = 0; - - while (i1 < 256) - { - int j1 = i1 % 16; - int k1 = i1 / 16; - - if (i1 == 32) - { - this.charWidth[i1] = 3 + b0; - } - - int l1 = l - 1; - - while (true) - { - if (l1 >= 0) - { - int i2 = j1 * l + l1; - boolean flag = true; - - for (int j2 = 0; j2 < k && flag; ++j2) - { - int k2 = (k1 * l + j2) * i; - - if ((aint[i2 + k2] >> 24 & 255) != 0) - { - flag = false; - } - } - - if (flag) - { - --l1; - continue; - } - } - - ++l1; - this.charWidth[i1] = (int) (0.5D + (double) ((float) l1 * f)) + b0; - ++i1; - break; - } - } - } - - private void readGlyphSizes () - { - try - { - InputStream inputstream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("font/glyph_sizes.bin")).getInputStream(); - inputstream.read(this.glyphWidth); - } - catch (IOException ioexception) - { - throw new RuntimeException(ioexception); - } - } - - /** - * Pick how to render a single character and return the width used. - */ - private float renderCharAtPos (int par1, char par2, boolean par3) - { - return par2 == 32 ? 4.0F : (par1 > 0 && !this.unicodeFlag ? this.renderDefaultChar(par1 + 32, par3) : this.renderUnicodeChar(par2, par3)); - } - - /** - * Render a single character with the default.png font at current (posX,posY) location... - */ - private float renderDefaultChar (int par1, boolean par2) - { - float f = (float) (par1 % 16 * 8); - float f1 = (float) (par1 / 16 * 8); - float f2 = par2 ? 1.0F : 0.0F; - this.renderEngine.bindTexture(this.locationFontTexture); - float f3 = (float) this.charWidth[par1] - 0.01F; - GL11.glBegin(GL11.GL_TRIANGLE_STRIP); - GL11.glTexCoord2f(f / 128.0F, f1 / 128.0F); - GL11.glVertex3f(this.posX + f2, this.posY, 0.0F); - GL11.glTexCoord2f(f / 128.0F, (f1 + 7.99F) / 128.0F); - GL11.glVertex3f(this.posX - f2, this.posY + 7.99F, 0.0F); - GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, f1 / 128.0F); - GL11.glVertex3f(this.posX + f3 - 1.0F + f2, this.posY, 0.0F); - GL11.glTexCoord2f((f + f3 - 1.0F) / 128.0F, (f1 + 7.99F) / 128.0F); - GL11.glVertex3f(this.posX + f3 - 1.0F - f2, this.posY + 7.99F, 0.0F); - GL11.glEnd(); - return (float) this.charWidth[par1]; - } - - private ResourceLocation getUnicodePageLocation (int par1) - { - if (unicodePageLocations[par1] == null) - { - unicodePageLocations[par1] = new ResourceLocation("minecraft", String.format("textures/font/unicode_page_%02x.png", new Object[] { par1 })); - } - return unicodePageLocations[par1]; - } - - /** - * Load one of the /font/glyph_XX.png into a new GL texture and store the texture ID in glyphTextureName array. - */ - private void loadGlyphTexture (int par1) - { - this.renderEngine.bindTexture(this.getUnicodePageLocation(par1)); - } - - /** - * Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files... - */ - private float renderUnicodeChar (char par1, boolean par2) - { - if (this.glyphWidth[par1] == 0) - { - return 0.0F; - } - else - { - int i = par1 / 256; - this.loadGlyphTexture(i); - int j = this.glyphWidth[par1] >>> 4; - int k = this.glyphWidth[par1] & 15; - float f = (float) j; - float f1 = (float) (k + 1); - float f2 = (float) (par1 % 16 * 16) + f; - float f3 = (float) ((par1 & 255) / 16 * 16); - float f4 = f1 - f - 0.02F; - float f5 = par2 ? 1.0F : 0.0F; - GL11.glBegin(GL11.GL_TRIANGLE_STRIP); - GL11.glTexCoord2f(f2 / 256.0F, f3 / 256.0F); - GL11.glVertex3f(this.posX + f5, this.posY, 0.0F); - GL11.glTexCoord2f(f2 / 256.0F, (f3 + 15.98F) / 256.0F); - GL11.glVertex3f(this.posX - f5, this.posY + 7.99F, 0.0F); - GL11.glTexCoord2f((f2 + f4) / 256.0F, f3 / 256.0F); - GL11.glVertex3f(this.posX + f4 / 2.0F + f5, this.posY, 0.0F); - GL11.glTexCoord2f((f2 + f4) / 256.0F, (f3 + 15.98F) / 256.0F); - GL11.glVertex3f(this.posX + f4 / 2.0F - f5, this.posY + 7.99F, 0.0F); - GL11.glEnd(); - return (f1 - f) / 2.0F + 1.0F; - } - } - - /** - * Draws the specified string with a shadow. - */ - public int drawStringWithShadow (String par1Str, int par2, int par3, int par4) - { - return this.drawString(par1Str, par2, par3, par4, true); - } - - /** - * Draws the specified string. - */ - public int drawString (String par1Str, int par2, int par3, int par4) - { - return this.drawString(par1Str, par2, par3, par4, false); - } - - /** - * Draws the specified string. Args: string, x, y, color, dropShadow - */ - public int drawString (String par1Str, int par2, int par3, int par4, boolean par5) - { - this.resetStyles(); - - if (this.bidiFlag) - { - par1Str = this.bidiReorder(par1Str); - } - - int l; - - if (par5) - { - l = this.renderString(par1Str, par2 + 1, par3 + 1, par4, true); - l = Math.max(l, this.renderString(par1Str, par2, par3, par4, false)); - } - else - { - l = this.renderString(par1Str, par2, par3, par4, false); - } - - return l; - } - - /** - * Apply Unicode Bidirectional Algorithm to string and return a new possibly reordered string for visual rendering. - */ - private String bidiReorder (String par1Str) - { - if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length())) - { - Bidi bidi = new Bidi(par1Str, -2); - byte[] abyte = new byte[bidi.getRunCount()]; - String[] astring = new String[abyte.length]; - int i; - - for (int j = 0; j < abyte.length; ++j) - { - int k = bidi.getRunStart(j); - i = bidi.getRunLimit(j); - int l = bidi.getRunLevel(j); - String s1 = par1Str.substring(k, i); - abyte[j] = (byte) l; - astring[j] = s1; - } - - String[] astring1 = astring.clone(); - Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length); - StringBuilder stringbuilder = new StringBuilder(); - i = 0; - - while (i < astring.length) - { - byte b0 = abyte[i]; - int i1 = 0; - - while (true) - { - if (i1 < astring1.length) - { - if (!astring1[i1].equals(astring[i])) - { - ++i1; - continue; - } - - b0 = abyte[i1]; - } - - if ((b0 & 1) == 0) - { - stringbuilder.append(astring[i]); - } - else - { - for (i1 = astring[i].length() - 1; i1 >= 0; --i1) - { - char c0 = astring[i].charAt(i1); - - if (c0 == 40) - { - c0 = 41; - } - else if (c0 == 41) - { - c0 = 40; - } - - stringbuilder.append(c0); - } - } - - ++i; - break; - } - } - - return stringbuilder.toString(); - } - else - { - return par1Str; - } - } - - /** - * Reset all style flag fields in the class to false; called at the start of string rendering - */ - private void resetStyles () - { - this.randomStyle = false; - this.boldStyle = false; - this.italicStyle = false; - this.underlineStyle = false; - this.strikethroughStyle = false; - } - - /** - * Render a single line string at the current (posX,posY) and update posX - */ - private void renderStringAtPos (String par1Str, boolean par2) - { - for (int i = 0; i < par1Str.length(); ++i) - { - char c0 = par1Str.charAt(i); - int j; - int k; - - if (c0 == 167 && i + 1 < par1Str.length()) - { - j = "0123456789abcdefklmnor".indexOf(par1Str.toLowerCase().charAt(i + 1)); - - if (j < 16) - { - this.randomStyle = false; - this.boldStyle = false; - this.strikethroughStyle = false; - this.underlineStyle = false; - this.italicStyle = false; - - if (j < 0 || j > 15) - { - j = 15; - } - - if (par2) - { - j += 16; - } - - k = this.colorCode[j]; - this.textColor = k; - GL11.glColor4f((float) (k >> 16) / 255.0F, (float) (k >> 8 & 255) / 255.0F, (float) (k & 255) / 255.0F, this.alpha); - } - else if (j == 16) - { - this.randomStyle = true; - } - else if (j == 17) - { - this.boldStyle = true; - } - else if (j == 18) - { - this.strikethroughStyle = true; - } - else if (j == 19) - { - this.underlineStyle = true; - } - else if (j == 20) - { - this.italicStyle = true; - } - else if (j == 21) - { - this.randomStyle = false; - this.boldStyle = false; - this.strikethroughStyle = false; - this.underlineStyle = false; - this.italicStyle = false; - GL11.glColor4f(this.red, this.blue, this.green, this.alpha); - } - - ++i; - } - else - { - j = ' '; - for (char c : ChatAllowedCharacters.allowedCharactersArray) - { - if (c == c0) - { - j = c0; - break; - } - } - - if (this.randomStyle && j > 0) - { - do - { - k = this.fontRandom.nextInt(ChatAllowedCharacters.allowedCharactersArray.length); - } while (this.charWidth[j + 32] != this.charWidth[k + 32]); - - j = k; - } - - float f = this.unicodeFlag ? 0.5F : 1.0F; - boolean flag1 = (j <= 0 || this.unicodeFlag) && par2; - - if (flag1) - { - this.posX -= f; - this.posY -= f; - } - float f1 = this.renderCharAtPos(j, c0, this.italicStyle); - - if (flag1) - { - this.posX += f; - this.posY += f; - } - - if (this.boldStyle) - { - this.posX += f; - - if (flag1) - { - this.posX -= f; - this.posY -= f; - } - - this.renderCharAtPos(j, c0, this.italicStyle); - this.posX -= f; - - if (flag1) - { - this.posX += f; - this.posY += f; - } - - ++f1; - } - - Tessellator tessellator; - WorldRenderer worldRenderer; - if (this.strikethroughStyle) - { - tessellator = Tessellator.getInstance(); - worldRenderer = tessellator.getWorldRenderer(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - worldRenderer.startDrawingQuads(); - worldRenderer.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); - worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) (this.FONT_HEIGHT / 2)), 0.0D); - worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D); - worldRenderer.addVertex((double) this.posX, (double) (this.posY + (float) (this.FONT_HEIGHT / 2) - 1.0F), 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - if (this.underlineStyle) - { - tessellator = Tessellator.getInstance(); - worldRenderer = tessellator.getWorldRenderer(); - GL11.glDisable(GL11.GL_TEXTURE_2D); - worldRenderer.startDrawingQuads(); - int l = this.underlineStyle ? -1 : 0; - worldRenderer.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D); - worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) this.FONT_HEIGHT), 0.0D); - worldRenderer.addVertex((double) (this.posX + f1), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D); - worldRenderer.addVertex((double) (this.posX + (float) l), (double) (this.posY + (float) this.FONT_HEIGHT - 1.0F), 0.0D); - tessellator.draw(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - this.posX += (float) ((int) f1); - } - } - } - - /** - * Render string either left or right aligned depending on bidiFlag - */ - private int renderStringAligned (String par1Str, int par2, int par3, int par4, int par5, boolean par6) - { - if (this.bidiFlag) - { - par1Str = this.bidiReorder(par1Str); - int i1 = this.getStringWidth(par1Str); - par2 = par2 + par4 - i1; - } - - return this.renderString(par1Str, par2, par3, par5, par6); - } - - /** - * Render single line string by setting GL color, current (posX,posY), and calling renderStringAtPos() - */ - private int renderString (String par1Str, int par2, int par3, int par4, boolean par5) - { - if (par1Str == null) - { - return 0; - } - else - { - if ((par4 & -67108864) == 0) - { - par4 |= -16777216; - } - - if (par5) - { - par4 = (par4 & 16579836) >> 2 | par4 & -16777216; - } - - this.red = (float) (par4 >> 16 & 255) / 255.0F; - this.blue = (float) (par4 >> 8 & 255) / 255.0F; - this.green = (float) (par4 & 255) / 255.0F; - this.alpha = (float) (par4 >> 24 & 255) / 255.0F; - GL11.glColor4f(this.red, this.blue, this.green, this.alpha); - this.posX = (float) par2; - this.posY = (float) par3; - this.renderStringAtPos(par1Str, par5); - return (int) this.posX; - } - } - - /** - * Returns the width of this string. Equivalent of FontMetrics.stringWidth(String s). - */ - public int getStringWidth (String par1Str) - { - if (par1Str == null) - { - return 0; - } - else - { - int i = 0; - boolean flag = false; - - for (int j = 0; j < par1Str.length(); ++j) - { - char c0 = par1Str.charAt(j); - int k = this.getCharWidth(c0); - - if (k < 0 && j < par1Str.length() - 1) - { - ++j; - c0 = par1Str.charAt(j); - - if (c0 != 108 && c0 != 76) - { - if (c0 == 114 || c0 == 82) - { - flag = false; - } - } - else - { - flag = true; - } - - k = 0; - } - - i += k; - - if (flag) - { - ++i; - } - } - - return i; - } - } - - /** - * Returns the width of this character as rendered. - */ - public int getCharWidth (char par1) - { - if (par1 == 167) - { - return -1; - } - else if (par1 == 32) - { - return 4; - } - else - { - int i; - if (ChatAllowedCharacters.isAllowedCharacter(par1)) - i = par1; - else - { - i = 69; - logger.error("dont send bad chat characters to my font renderer!"); - } - - if (i >= 0 && !this.unicodeFlag) - { - return this.charWidth[i + 32]; - } - else if (this.glyphWidth[par1] != 0) - { - int j = this.glyphWidth[par1] >>> 4; - int k = this.glyphWidth[par1] & 15; - - if (k > 7) - { - k = 15; - j = 0; - } - - ++k; - return (k - j) / 2 + 1; - } - else - { - return 0; - } - } - } - - /** - * Trims a string to fit a specified Width. - */ - public String trimStringToWidth (String par1Str, int par2) - { - return this.trimStringToWidth(par1Str, par2, false); - } - - /** - * Trims a string to a specified width, and will reverse it if par3 is set. - */ - public String trimStringToWidth (String par1Str, int par2, boolean par3) - { - StringBuilder stringbuilder = new StringBuilder(); - int j = 0; - int k = par3 ? par1Str.length() - 1 : 0; - int l = par3 ? -1 : 1; - boolean flag1 = false; - boolean flag2 = false; - - for (int i1 = k; i1 >= 0 && i1 < par1Str.length() && j < par2; i1 += l) - { - char c0 = par1Str.charAt(i1); - int j1 = this.getCharWidth(c0); - - if (flag1) - { - flag1 = false; - - if (c0 != 108 && c0 != 76) - { - if (c0 == 114 || c0 == 82) - { - flag2 = false; - } - } - else - { - flag2 = true; - } - } - else if (j1 < 0) - { - flag1 = true; - } - else - { - j += j1; - - if (flag2) - { - ++j; - } - } - - if (j > par2) - { - break; - } - - if (par3) - { - stringbuilder.insert(0, c0); - } - else - { - stringbuilder.append(c0); - } - } - - return stringbuilder.toString(); - } - - /** - * Remove all newline characters from the end of the string - */ - private String trimStringNewline (String par1Str) - { - while (par1Str != null && par1Str.endsWith("\n")) - { - par1Str = par1Str.substring(0, par1Str.length() - 1); - } - - return par1Str; - } - - /** - * Splits and draws a String with wordwrap (maximum length is parameter k) - */ - public void drawSplitString (String par1Str, int par2, int par3, int par4, int par5) - { - this.resetStyles(); - this.textColor = par5; - par1Str = this.trimStringNewline(par1Str); - this.renderSplitString(par1Str, par2, par3, par4, false); - } - - /** - * Perform actual work of rendering a multi-line string with wordwrap and with darker drop shadow color if flag is - * set - */ - @SuppressWarnings("raw") - private void renderSplitString (String par1Str, int par2, int par3, int par4, boolean par5) - { - List list = this.listFormattedStringToWidth(par1Str, par4); - - for (Iterator iterator = list.iterator(); iterator.hasNext(); par3 += this.FONT_HEIGHT) - { - String s1 = iterator.next(); - this.renderStringAligned(s1, par2, par3, par4, this.textColor, par5); - } - } - - /** - * Returns the width of the wordwrapped String (maximum length is parameter k) - */ - public int splitStringWidth (String par1Str, int par2) - { - return this.FONT_HEIGHT * this.listFormattedStringToWidth(par1Str, par2).size(); - } - - /** - * Set unicodeFlag controlling whether strings should be rendered with Unicode fonts instead of the default.png - * font. - */ - public void setUnicodeFlag (boolean par1) - { - this.unicodeFlag = par1; - } - - /** - * Get unicodeFlag controlling whether strings should be rendered with Unicode fonts instead of the default.png - * font. - */ - public boolean getUnicodeFlag () - { - return this.unicodeFlag; - } - - /** - * Set bidiFlag to control if the Unicode Bidirectional Algorithm should be run before rendering any string. - */ - public void setBidiFlag (boolean par1) - { - this.bidiFlag = par1; - } - - /** - * Breaks a string into a list of pieces that will fit a specified width. - */ - public List listFormattedStringToWidth (String par1Str, int par2) - { - return Arrays.asList(this.wrapFormattedStringToWidth(par1Str, par2).split("\n")); - } - - /** - * Inserts newline and formatting into a string to wrap it within the specified width. - */ - String wrapFormattedStringToWidth (String par1Str, int par2) - { - int j = this.sizeStringToWidth(par1Str, par2); - - if (par1Str.length() <= j) - { - return par1Str; - } - else - { - String s1 = par1Str.substring(0, j); - char c0 = par1Str.charAt(j); - boolean flag = c0 == 32 || c0 == 10; - String s2 = getFormatFromString(s1) + par1Str.substring(j + (flag ? 1 : 0)); - return s1 + "\n" + this.wrapFormattedStringToWidth(s2, par2); - } - } - - /** - * Determines how many characters from the string will fit into the specified width. - */ - @SuppressWarnings("fallthrough") - private int sizeStringToWidth (String par1Str, int par2) - { - int j = par1Str.length(); - int k = 0; - int l = 0; - int i1 = -1; - - for (boolean flag = false; l < j; ++l) - { - char c0 = par1Str.charAt(l); - - switch (c0) - { - case 10: - --l; - break; - case 167: - if (l < j - 1) - { - ++l; - char c1 = par1Str.charAt(l); - - if (c1 != 108 && c1 != 76) - { - if (c1 == 114 || c1 == 82 || isFormatColor(c1)) - { - flag = false; - } - } - else - { - flag = true; - } - } - - break; - case 32: - i1 = l; - default: - k += this.getCharWidth(c0); - - if (flag) - { - ++k; - } - } - - if (c0 == 10) - { - ++l; - i1 = l; - break; - } - - if (k > par2) - { - break; - } - } - - return l != j && i1 != -1 && i1 < l ? i1 : l; - } - - /** - * Checks if the char code is a hexadecimal character, used to set colour. - */ - private static boolean isFormatColor (char par0) - { - return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70; - } - - /** - * Checks if the char code is O-K...lLrRk-o... used to set special formatting. - */ - private static boolean isFormatSpecial (char par0) - { - return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82; - } - - /** - * Digests a string for nonprinting formatting characters then returns a string containing only that formatting. - */ - private static String getFormatFromString (String par0Str) - { - String s1 = ""; - int i = -1; - int j = par0Str.length(); - - while ((i = par0Str.indexOf(167, i + 1)) != -1) - { - if (i < j - 1) - { - char c0 = par0Str.charAt(i + 1); - - if (isFormatColor(c0)) - { - s1 = "\u00a7" + c0; - } - else if (isFormatSpecial(c0)) - { - s1 = s1 + "\u00a7" + c0; - } - } - } - - return s1; - } - - /** - * Get bidiFlag that controls if the Unicode Bidirectional Algorithm should be run before rendering any string - */ - public boolean getBidiFlag () - { - return this.bidiFlag; - } - -} diff --git a/src/mantle/client/gui/GuiManual.java b/src/mantle/client/gui/GuiManual.java index 4881388..d6a4214 100644 --- a/src/mantle/client/gui/GuiManual.java +++ b/src/mantle/client/gui/GuiManual.java @@ -2,12 +2,12 @@ package mantle.client.gui; import mantle.books.BookData; import mantle.client.MProxyClient; -import mantle.client.RenderItemCopy; -import mantle.client.SmallFontRenderer; import mantle.client.pages.BookPage; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -25,7 +25,7 @@ public class GuiManual extends GuiScreen { ItemStack itemstackBook; Document manual; - public RenderItemCopy renderitem = new RenderItemCopy(); + public RenderItem renderitem = Minecraft.getMinecraft().getRenderItem(); int bookImageWidth = 206; int bookImageHeight = 200; int bookTotalPages = 1; @@ -41,7 +41,7 @@ public class GuiManual extends GuiScreen BookPage pageLeft; BookPage pageRight; - public SmallFontRenderer fonts = MProxyClient.smallFontRenderer; + public FontRenderer fonts = Minecraft.getMinecraft().fontRendererObj; public GuiManual(ItemStack stack, BookData data) { diff --git a/src/mantle/client/pages/ContentsTablePage.java b/src/mantle/client/pages/ContentsTablePage.java index 62a0bec..154490b 100644 --- a/src/mantle/client/pages/ContentsTablePage.java +++ b/src/mantle/client/pages/ContentsTablePage.java @@ -48,7 +48,7 @@ public class ContentsTablePage extends BookPage manual.renderitem.zLevel = 100; for (int i = 0; i < icons.length; i++) { - manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 16, localHeight + 18 * i + 18); + manual.renderitem.func_175042_a(icons[i], localWidth + 16, localHeight + 18 * i + 18); int yOffset = 18; if (isTranslatable) iconText[i] = StatCollector.translateToLocal(iconText[i]); diff --git a/src/mantle/client/pages/CraftingPage.java b/src/mantle/client/pages/CraftingPage.java index 4c62aa2..b3ac31f 100644 --- a/src/mantle/client/pages/CraftingPage.java +++ b/src/mantle/client/pages/CraftingPage.java @@ -56,25 +56,25 @@ public class CraftingPage extends BookPage if (recipeSize == 2) { - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); + manual.renderitem.func_180450_b(icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); if (icons[0].stackSize > 1) - manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + manual.renderitem.func_180453_a(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); for (int i = 0; i < icons.length - 1; i++) { if (icons[i + 1] != null) - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); + manual.renderitem.func_180450_b(icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); } } if (recipeSize == 3) { - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); + manual.renderitem.func_180450_b(icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); if (icons[0].stackSize > 1) - manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + manual.renderitem.func_180453_a(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); for (int i = 0; i < icons.length - 1; i++) { if (icons[i + 1] != null) - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); + manual.renderitem.func_180450_b(icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); } } diff --git a/src/mantle/client/pages/FurnacePage.java b/src/mantle/client/pages/FurnacePage.java index 5cbba2f..082f5db 100644 --- a/src/mantle/client/pages/FurnacePage.java +++ b/src/mantle/client/pages/FurnacePage.java @@ -42,12 +42,12 @@ public class FurnacePage extends BookPage RenderHelper.enableGUIStandardItemLighting(); manual.renderitem.zLevel = 100; - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); - manual.renderitem.renderItemAndEffectIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); + manual.renderitem.func_180450_b(MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); + manual.renderitem.func_180450_b(icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); + manual.renderitem.func_180450_b(icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); if (icons[0].stackSize > 1) - manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); + manual.renderitem.func_180453_a(manual.fonts, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); manual.renderitem.zLevel = 0; GL11.glScalef(0.5F, 0.5F, 0.5F); diff --git a/src/mantle/client/pages/SidebarPage.java b/src/mantle/client/pages/SidebarPage.java index 13605d8..008fe29 100644 --- a/src/mantle/client/pages/SidebarPage.java +++ b/src/mantle/client/pages/SidebarPage.java @@ -52,7 +52,7 @@ public class SidebarPage extends BookPage { iconText[i] = StatCollector.translateToLocal(iconText[i]); } - manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 8, localHeight + 18 * i + offset); + manual.renderitem.func_175042_a(icons[i], localWidth + 8, localHeight + 18 * i + offset); int yOffset = 39; if (iconText[i].length() > 40) yOffset = 34; diff --git a/src/mantle/items/abstracts/CraftingItem.java b/src/mantle/items/abstracts/CraftingItem.java index 7df21de..e7ae7aa 100644 --- a/src/mantle/items/abstracts/CraftingItem.java +++ b/src/mantle/items/abstracts/CraftingItem.java @@ -2,11 +2,9 @@ package mantle.items.abstracts; import java.util.List; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -17,7 +15,6 @@ public class CraftingItem extends Item public String[] textureNames; public String[] unlocalizedNames; public String folder; - public IIcon[] icons; public CraftingItem(String[] names, String[] tex, String folder, String modTexturePrefix, CreativeTabs tab) { @@ -42,28 +39,6 @@ public class CraftingItem extends Item this.folder = folder; } - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage (int meta) - { - int arr = MathHelper.clamp_int(meta, 0, unlocalizedNames.length); - if(arr > icons.length) - return icons[0]; - return icons[arr]; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons (IIconRegister iconRegister) - { - this.icons = new IIcon[textureNames.length]; - - for (int i = 0; i < this.icons.length; ++i) - { - if (!(textureNames[i].equals(""))) - this.icons[i] = iconRegister.registerIcon(modTexPrefix + ":" + folder + textureNames[i]); - } - } - public String getUnlocalizedName (ItemStack stack) { int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length); From 0a4697845973cf510e82b9c18cc474d34b5f1bd2 Mon Sep 17 00:00:00 2001 From: alexbegt Date: Thu, 4 Dec 2014 21:41:45 -0500 Subject: [PATCH 08/91] Fixing the last issue. --- src/mantle/blocks/abstracts/MultiServantLogic.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/mantle/blocks/abstracts/MultiServantLogic.java index 5f76641..bfd4781 100644 --- a/src/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/mantle/blocks/abstracts/MultiServantLogic.java @@ -122,7 +122,8 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb int zCenter = tags.getInteger("zCenter"); master = new BlockPos(xCenter, yCenter, zCenter); masterBlock = BlockUtils.getBlockFromUniqueName(tags.getString("MasterBlockName")); - state = tags.getByte("masterMeat"); + // TODO: Make this a byte. + state = Block.getStateById(tags.getInteger("masterState")); } } @@ -135,7 +136,8 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb tags.setInteger("yCenter", master.getY()); tags.setInteger("zCenter", master.getZ()); tags.setString("MasterBlockName", BlockUtils.getUniqueName(masterBlock)); - tags.setByte("masterMeat", state); + // TODO: Make this a byte. + tags.setInteger("masterState", Block.getStateId(state)); } } @@ -195,7 +197,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb @Deprecated public boolean setMaster (int x, int y, int z) { - if (!hasMaster || worldObj.getBlockState(master) != state || (worldObj.getBlockState(master) != masterBlock)) + if (!hasMaster || worldObj.getBlockState(master) != state || (worldObj.getBlockState(master).getBlock() != masterBlock)) { overrideMaster(x, y, z); return true; From f246f789ff42bd0d5556a98dfaa53d9e13291197 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Sun, 4 Jan 2015 14:37:09 -0500 Subject: [PATCH 09/91] some minor cleanup, require java 7 for 1.8 slime knights mods --- build.gradle | 2 ++ .../blocks/abstracts/MultiServantLogic.java | 10 ++++---- src/mantle/world/WorldHelper.java | 24 ------------------- 3 files changed, 7 insertions(+), 29 deletions(-) delete mode 100644 src/mantle/world/WorldHelper.java diff --git a/build.gradle b/build.gradle index e0e61ab..9f059d8 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,8 @@ repositories { apply plugin: 'forge' group = 'mantle' +sourceCompatibility = 1.7 +targetCompatibility = 1.7 // Define properties file ext.configFile = file "build.properties" diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/mantle/blocks/abstracts/MultiServantLogic.java index bfd4781..92de706 100644 --- a/src/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/mantle/blocks/abstracts/MultiServantLogic.java @@ -54,10 +54,10 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb return master; } - public void overrideMaster (int x, int y, int z) + public void overrideMaster (BlockPos pos) { hasMaster = true; - master = new BlockPos(x, y, z); + master = pos; state = worldObj.getBlockState(master); masterBlock = state.getBlock(); } @@ -91,7 +91,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb } else { - overrideMaster(pos.getX(), pos.getY(), pos.getZ()); + overrideMaster(pos); return true; } } @@ -195,11 +195,11 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb } @Deprecated - public boolean setMaster (int x, int y, int z) + public boolean setMaster (BlockPos pos) { if (!hasMaster || worldObj.getBlockState(master) != state || (worldObj.getBlockState(master).getBlock() != masterBlock)) { - overrideMaster(x, y, z); + overrideMaster(pos); return true; } else diff --git a/src/mantle/world/WorldHelper.java b/src/mantle/world/WorldHelper.java deleted file mode 100644 index 38ed4fa..0000000 --- a/src/mantle/world/WorldHelper.java +++ /dev/null @@ -1,24 +0,0 @@ -package mantle.world; - -import net.minecraft.util.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public class WorldHelper -{ - public static boolean setBlockToAir (World w, BlockPos pos) - { - return w.setBlockToAir(pos); - } - - public static boolean isAirBlock (IBlockAccess access, BlockPos pos) - { - return access.getBlockState(pos).getBlock().isAir(access, pos); - } - - public static boolean isAirBlock (World access, BlockPos pos) - { - return access.isAirBlock(pos); - } - -} From f0bfe7ce9be01f5311cb49b7255e36593dc45526 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Wed, 11 Mar 2015 16:23:19 -0400 Subject: [PATCH 10/91] update mappings version, and forge build --- build.gradle | 1 + build.properties | 3 ++- src/mantle/Mantle.java | 3 ++- src/mantle/books/external/ZipLoader.java | 2 +- src/mantle/client/pages/ContentsTablePage.java | 2 +- src/mantle/client/pages/CraftingPage.java | 12 ++++++------ src/mantle/client/pages/FurnacePage.java | 8 ++++---- src/mantle/client/pages/SidebarPage.java | 2 +- src/mantle/common/IDDumps.java | 2 +- 9 files changed, 19 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 9f059d8..6991104 100644 --- a/build.gradle +++ b/build.gradle @@ -78,6 +78,7 @@ version = "${config.minecraft_version}-${artifact_version}" minecraft { version = config.minecraft_version + "-" + config.forge_version + mappings = config.mappings runDir = 'run' replace '${version}', project.version } diff --git a/build.properties b/build.properties index 20501d3..d58ff29 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.0.1251-1.8 +forge_version=11.14.1.1334 +mappings=snapshot_20150310 diff --git a/src/mantle/Mantle.java b/src/mantle/Mantle.java index 9c96a3d..2e2b766 100644 --- a/src/mantle/Mantle.java +++ b/src/mantle/Mantle.java @@ -4,6 +4,8 @@ import static mantle.lib.CoreRepo.logger; import static mantle.lib.CoreRepo.modId; import static mantle.lib.CoreRepo.modName; import static mantle.lib.CoreRepo.modVersion; + +import LZMA.LzmaInputStream; import mantle.books.BookData; import mantle.books.BookDataStore; import mantle.common.IDDumps; @@ -67,7 +69,6 @@ public class Mantle CoreConfig.loadConfiguration(evt.getModConfigurationDirectory()); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); - mantleBook = (Manual) new Manual().setUnlocalizedName("mantle.manual"); GameRegistry.registerItem(mantleBook, "mantleBook"); diff --git a/src/mantle/books/external/ZipLoader.java b/src/mantle/books/external/ZipLoader.java index 13c79a1..97c663c 100644 --- a/src/mantle/books/external/ZipLoader.java +++ b/src/mantle/books/external/ZipLoader.java @@ -114,7 +114,7 @@ public class ZipLoader { try { - is.setTagCompound(JsonToNBT.func_180713_a(bis.tags)); + is.setTagCompound(JsonToNBT.getTagFromJson(bis.tags)); } catch (Exception e1) { diff --git a/src/mantle/client/pages/ContentsTablePage.java b/src/mantle/client/pages/ContentsTablePage.java index 154490b..f36f414 100644 --- a/src/mantle/client/pages/ContentsTablePage.java +++ b/src/mantle/client/pages/ContentsTablePage.java @@ -48,7 +48,7 @@ public class ContentsTablePage extends BookPage manual.renderitem.zLevel = 100; for (int i = 0; i < icons.length; i++) { - manual.renderitem.func_175042_a(icons[i], localWidth + 16, localHeight + 18 * i + 18); + manual.renderitem.renderItemIntoGUI(icons[i], localWidth + 16, localHeight + 18 * i + 18); int yOffset = 18; if (isTranslatable) iconText[i] = StatCollector.translateToLocal(iconText[i]); diff --git a/src/mantle/client/pages/CraftingPage.java b/src/mantle/client/pages/CraftingPage.java index b3ac31f..ba28944 100644 --- a/src/mantle/client/pages/CraftingPage.java +++ b/src/mantle/client/pages/CraftingPage.java @@ -56,25 +56,25 @@ public class CraftingPage extends BookPage if (recipeSize == 2) { - manual.renderitem.func_180450_b(icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); if (icons[0].stackSize > 1) - manual.renderitem.func_180453_a(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); for (int i = 0; i < icons.length - 1; i++) { if (icons[i + 1] != null) - manual.renderitem.func_180450_b(icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); } } if (recipeSize == 3) { - manual.renderitem.func_180450_b(icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); if (icons[0].stackSize > 1) - manual.renderitem.func_180453_a(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); for (int i = 0; i < icons.length - 1; i++) { if (icons[i + 1] != null) - manual.renderitem.func_180450_b(icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); } } diff --git a/src/mantle/client/pages/FurnacePage.java b/src/mantle/client/pages/FurnacePage.java index 082f5db..601a7d8 100644 --- a/src/mantle/client/pages/FurnacePage.java +++ b/src/mantle/client/pages/FurnacePage.java @@ -42,12 +42,12 @@ public class FurnacePage extends BookPage RenderHelper.enableGUIStandardItemLighting(); manual.renderitem.zLevel = 100; - manual.renderitem.func_180450_b(MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); - manual.renderitem.func_180450_b(icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); - manual.renderitem.func_180450_b(icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); + manual.renderitem.renderItemAndEffectIntoGUI(icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); if (icons[0].stackSize > 1) - manual.renderitem.func_180453_a(manual.fonts, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); + manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); manual.renderitem.zLevel = 0; GL11.glScalef(0.5F, 0.5F, 0.5F); diff --git a/src/mantle/client/pages/SidebarPage.java b/src/mantle/client/pages/SidebarPage.java index 008fe29..cda297f 100644 --- a/src/mantle/client/pages/SidebarPage.java +++ b/src/mantle/client/pages/SidebarPage.java @@ -52,7 +52,7 @@ public class SidebarPage extends BookPage { iconText[i] = StatCollector.translateToLocal(iconText[i]); } - manual.renderitem.func_175042_a(icons[i], localWidth + 8, localHeight + 18 * i + offset); + manual.renderitem.renderItemIntoGUI(icons[i], localWidth + 8, localHeight + 18 * i + offset); int yOffset = 39; if (iconText[i].length() > 40) yOffset = 34; diff --git a/src/mantle/common/IDDumps.java b/src/mantle/common/IDDumps.java index de437b3..7d65fe5 100644 --- a/src/mantle/common/IDDumps.java +++ b/src/mantle/common/IDDumps.java @@ -32,7 +32,7 @@ public class IDDumps } if (CoreConfig.dumpEnchantIDs) { - for (Enchantment e : Enchantment.enchantmentsList) + for (Enchantment e : Enchantment.enchantmentsBookList) { if (e != null && e.getName() != null) { From ff9c8291e26a4039efe1d14b8409c9b242b05d55 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Thu, 12 Mar 2015 17:53:57 -0400 Subject: [PATCH 11/91] move ICrop over from natura --- src/mantle/blocks/iface/ICrop.java | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/mantle/blocks/iface/ICrop.java diff --git a/src/mantle/blocks/iface/ICrop.java b/src/mantle/blocks/iface/ICrop.java new file mode 100644 index 0000000..da0b3fb --- /dev/null +++ b/src/mantle/blocks/iface/ICrop.java @@ -0,0 +1,34 @@ +package mantle.blocks.iface; + + +import java.util.Collections; +import java.util.List; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.BlockPos; +import net.minecraft.world.IBlockAccess; + +public interface ICrop +{ + public enum HarvestType + { + BREAK, USE, MACHINE + } + + public static final List NO_YIELD = Collections.emptyList(); + + /** + * + * @param world + * @param pos + * @param type + * @return A list of items harvested. If no items are returned, NO_YIELD should be passed. + */ + public List harvestCrop (IBlockAccess world, BlockPos pos, HarvestType type); + + public boolean isFullyGrown (IBlockAccess world, BlockPos pos); + + public boolean hasYield (IBlockAccess world, BlockPos pos); + + public void growthTick (IBlockAccess world, BlockPos pos); +} From 3b1b56b41ab328fd298d99266d381202da571d4c Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 28 Mar 2015 20:48:32 -0400 Subject: [PATCH 12/91] Going to put this in Mantle and not Natura. It helps with deal with Metadata (Different Variants). --- .../blocks/abstracts/ItemBlockVariants.java | 33 +++++++++++ src/mantle/blocks/iface/IBlockVariant.java | 8 +++ .../blocks/iface/IBlockWithVariants.java | 8 +++ src/mantle/client/ModelVariant.java | 58 +++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 src/mantle/blocks/abstracts/ItemBlockVariants.java create mode 100644 src/mantle/blocks/iface/IBlockVariant.java create mode 100644 src/mantle/blocks/iface/IBlockWithVariants.java create mode 100644 src/mantle/client/ModelVariant.java diff --git a/src/mantle/blocks/abstracts/ItemBlockVariants.java b/src/mantle/blocks/abstracts/ItemBlockVariants.java new file mode 100644 index 0000000..e7ff237 --- /dev/null +++ b/src/mantle/blocks/abstracts/ItemBlockVariants.java @@ -0,0 +1,33 @@ +package mantle.blocks.abstracts; + +import mantle.blocks.iface.IBlockWithVariants; +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class ItemBlockVariants extends ItemBlock +{ + private final IBlockWithVariants variantBlock; + + public ItemBlockVariants(Block block) + { + super(block); + + this.variantBlock = (IBlockWithVariants) block; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + @Override + public int getMetadata(int damage) + { + return damage; + } + + @Override + public String getUnlocalizedName(ItemStack stack) + { + return super.getUnlocalizedName() + "." + this.variantBlock.getVariantNameFromStack(stack); + } + +} diff --git a/src/mantle/blocks/iface/IBlockVariant.java b/src/mantle/blocks/iface/IBlockVariant.java new file mode 100644 index 0000000..beeae8d --- /dev/null +++ b/src/mantle/blocks/iface/IBlockVariant.java @@ -0,0 +1,8 @@ +package mantle.blocks.iface; + +import net.minecraft.util.IStringSerializable; + +public interface IBlockVariant extends IStringSerializable +{ + int getMetadata(); +} diff --git a/src/mantle/blocks/iface/IBlockWithVariants.java b/src/mantle/blocks/iface/IBlockWithVariants.java new file mode 100644 index 0000000..9ff0b13 --- /dev/null +++ b/src/mantle/blocks/iface/IBlockWithVariants.java @@ -0,0 +1,8 @@ +package mantle.blocks.iface; + +import net.minecraft.item.ItemStack; + +public interface IBlockWithVariants +{ + String getVariantNameFromStack(ItemStack stack); +} diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java new file mode 100644 index 0000000..df25ee8 --- /dev/null +++ b/src/mantle/client/ModelVariant.java @@ -0,0 +1,58 @@ +package mantle.client; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import mantle.blocks.iface.IBlockVariant; + +@SideOnly(Side.CLIENT) +public class ModelVariant +{ + private String modID; + + public ModelVariant(String modId) + { + this.modID = modId; + } + + public void registerItemRenderer(Block block, IBlockVariant[] variants) + { + String[] names = new String[variants.length]; + + for (int i = 0; i < variants.length; ++i) + { + IBlockVariant subtype = variants[i]; + names[i] = (this.modID + ":") + subtype.getName(); + + this.registerItemRenderer(names[i], Item.getItemFromBlock(block), subtype.getMetadata()); + } + + ModelBakery.addVariantName(Item.getItemFromBlock(block), names); + } + + public void registerItemRenderer(Block block, int meta) + { + this.registerItemRenderer(Item.getItemFromBlock(block), meta); + } + + public void registerItemRenderer(Item item, int meta) + { + String name = (this.modID + ":") + item.getUnlocalizedName().substring(5); + + this.registerItemRenderer(name, item, meta); + } + + public void registerItemRenderer(String name, Block block, int meta) + { + this.registerItemRenderer(name, Item.getItemFromBlock(block), meta); + } + + public static void registerItemRenderer(String name, Item item, int meta) + { + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(name, "inventory")); + } +} From d7b6343353c8a9de2dc628a7edaba0efd0b9b4a2 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Mon, 30 Mar 2015 20:40:37 -0400 Subject: [PATCH 13/91] update to latest pulsar closes #30 --- src/mantle/pulsar/config/IConfiguration.java | 0 src/mantle/pulsar/control/PulseManager.java | 250 +++++++++--------- src/mantle/pulsar/debug/EventSpy.java | 25 ++ src/mantle/pulsar/internal/Configuration.java | 2 +- src/mantle/pulsar/internal/CrashHandler.java | 49 ++++ .../pulsar/internal/logging/ILogger.java | 0 .../pulsar/internal/logging/JULLogger.java | 0 .../pulsar/internal/logging/Log4jLogger.java | 0 .../pulsar/internal/logging/LogManager.java | 0 src/mantle/pulsar/pulse/Handler.java | 14 - src/mantle/pulsar/pulse/IPulse.java | 38 --- src/mantle/pulsar/pulse/Pulse.java | 3 + src/mantle/pulsar/pulse/PulseMeta.java | 9 +- src/mantle/pulsar/pulse/PulseProxy.java | 28 -- 14 files changed, 205 insertions(+), 213 deletions(-) mode change 100644 => 100755 src/mantle/pulsar/config/IConfiguration.java mode change 100644 => 100755 src/mantle/pulsar/control/PulseManager.java create mode 100755 src/mantle/pulsar/debug/EventSpy.java mode change 100644 => 100755 src/mantle/pulsar/internal/Configuration.java create mode 100755 src/mantle/pulsar/internal/CrashHandler.java mode change 100644 => 100755 src/mantle/pulsar/internal/logging/ILogger.java mode change 100644 => 100755 src/mantle/pulsar/internal/logging/JULLogger.java mode change 100644 => 100755 src/mantle/pulsar/internal/logging/Log4jLogger.java mode change 100644 => 100755 src/mantle/pulsar/internal/logging/LogManager.java delete mode 100644 src/mantle/pulsar/pulse/Handler.java delete mode 100644 src/mantle/pulsar/pulse/IPulse.java mode change 100644 => 100755 src/mantle/pulsar/pulse/Pulse.java mode change 100644 => 100755 src/mantle/pulsar/pulse/PulseMeta.java delete mode 100644 src/mantle/pulsar/pulse/PulseProxy.java diff --git a/src/mantle/pulsar/config/IConfiguration.java b/src/mantle/pulsar/config/IConfiguration.java old mode 100644 new mode 100755 diff --git a/src/mantle/pulsar/control/PulseManager.java b/src/mantle/pulsar/control/PulseManager.java old mode 100644 new mode 100755 index 5f3a199..557aa53 --- a/src/mantle/pulsar/control/PulseManager.java +++ b/src/mantle/pulsar/control/PulseManager.java @@ -1,35 +1,44 @@ package mantle.pulsar.control; import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; +import com.google.common.eventbus.SubscriberExceptionContext; +import com.google.common.eventbus.SubscriberExceptionHandler; import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.FMLModContainer; import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.event.FMLEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + import mantle.pulsar.config.IConfiguration; import mantle.pulsar.internal.Configuration; +import mantle.pulsar.internal.CrashHandler; import mantle.pulsar.pulse.PulseMeta; import mantle.pulsar.internal.logging.ILogger; import mantle.pulsar.internal.logging.LogManager; -import mantle.pulsar.pulse.Handler; -import mantle.pulsar.pulse.IPulse; import mantle.pulsar.pulse.Pulse; -import mantle.pulsar.pulse.PulseProxy; /** * Manager class for a given mods Pulses. * + * This MUST be constructed by a mod BEFORE preinit as it registers on to the mod event bus - a static block would serve + * for this. No more Pulses can be registered after preinit has been caught, so assume preinit is too late to register + * new Pulses. + * * Each Pulsar-enabled mod should create one and only one of these to manage its Pulses. * * @author Arkan */ -@SuppressWarnings({"unused", "deprecated"}) +@SuppressWarnings("unused") public class PulseManager { - private final ILogger log; + private ILogger log; private final boolean useConfig; private final LinkedHashMap pulses = new LinkedHashMap(); @@ -37,31 +46,18 @@ public class PulseManager { private boolean blockNewRegistrations = false; private boolean configLoaded = false; private IConfiguration conf; - - /** - * Configuration-less constructor. - * - * PulseManagers created this way ignore configurability on child Pulses. This is not recommended. - * - * @param modId The parents ModID. - */ - @Deprecated - public PulseManager(String modId) { - log = LogManager.getLogger("PulseManager-" + modId); - useConfig = false; - conf = null; - } + private EventBus bus; + private String id; /** * Configuration-using constructor. * - * This form creates a PulseManager that supports configuration of Pulses by file. Recommended approach. + * This form creates a PulseManager that supports configuration of Pulses by file. * - * @param modId The parents ModID. * @param configName The config file name. */ - public PulseManager(String modId, String configName) { - log = LogManager.getLogger("PulseManager-" + modId); + public PulseManager(String configName) { + init(); useConfig = true; conf = new Configuration(configName, log); } @@ -72,15 +68,27 @@ public class PulseManager { * Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star. * Whatever really. See {@link mantle.pulsar.config.IConfiguration}. * - * @param modId The parents ModID. * @param config Configuration handler. */ - public PulseManager(String modId, IConfiguration config) { - log = LogManager.getLogger("PulseManager-" + modId); + public PulseManager(IConfiguration config) { + init(); useConfig = true; conf = config; } + /** + * Shared initialiser code between all the constructors. + */ + private void init() { + String modId = Loader.instance().activeModContainer().getModId(); + this.id = modId; + log = LogManager.getLogger("Pulsar-" + modId); + FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this)); + // Attach us to the mods FML bus and setup our own bus + bus = new EventBus(new BusExceptionHandler(modId)); + attachToContainerEventBus(this); + } + /** * Register a new Pulse with the manager. * @@ -97,7 +105,7 @@ public class PulseManager { } String id, description, deps; - boolean forced, enabled, missingDeps = false; + boolean forced, enabled, defaultEnabled, missingDeps = false; try { Pulse p = pulse.getClass().getAnnotation(Pulse.class); @@ -106,6 +114,7 @@ public class PulseManager { deps = p.modsRequired(); forced = p.forced(); enabled = p.defaultEnable(); + defaultEnabled = p.defaultEnable(); } catch (NullPointerException ex) { throw new RuntimeException("Could not parse @Pulse annotation for Pulse: " + pulse); } @@ -125,120 +134,65 @@ public class PulseManager { } } - PulseMeta meta = new PulseMeta(id, description, forced, enabled); + PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); meta.setEnabled(!missingDeps && getEnabledFromConfig(meta)); if (meta.isEnabled()) { - parseAndAddProxies(pulse); pulses.put(pulse, meta); + // Attach Pulse to internal event bus + bus.register(pulse); } } + /** + * Helper to attach a given object to the modcontainer event bus. + * + * @param obj Object to register. + */ + private void attachToContainerEventBus(Object obj) { + ModContainer cnt = Loader.instance().activeModContainer(); + log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); + try { + FMLModContainer mc = (FMLModContainer)cnt; + Field ebf = mc.getClass().getDeclaredField("eventBus"); + + boolean access = ebf.isAccessible(); + ebf.setAccessible(true); + EventBus eb = (EventBus)ebf.get(mc); + ebf.setAccessible(access); + + eb.register(obj); + } catch (NoSuchFieldException nsfe) { + throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?"); + } catch (IllegalAccessException iae) { + throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue."); + } catch (ClassCastException cce) { + throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage()); + } + } + + /** + * Internal (but public for EventBus use) handler for events. + * + * DO NOT CALL THIS DIRECTLY! Let EventBus handle it. + * + * @param evt An event object. + */ + @Subscribe + public void propagateEvent(FMLEvent evt) { + if (evt instanceof FMLPreInitializationEvent) preInit((FMLPreInitializationEvent) evt); + bus.post(evt); + } + private boolean getEnabledFromConfig(PulseMeta meta) { if (meta.isForced() || !useConfig) return true; // Forced or no config set. return conf.isModuleEnabled(meta); } - /** - * @deprecated FML handles proxies now. - * - * @param pulse Pulse to parse for proxy annotations. - */ - @Deprecated - private void parseAndAddProxies(Object pulse) { - try { - for (Field f : pulse.getClass().getDeclaredFields()) { - log.debug("Parsing field: " + f); - PulseProxy p = f.getAnnotation(PulseProxy.class); - if (p != null) { // Support for deprecated PulseProxy annotation - log.warn("Pulse " + pulse + " used the deprecated PulseProxy annotation. As of Pulsar 0.1.0, it's now preferred to use FML's SidedProxy annotation."); - log.warn("The old PulseProxy parsing will be removed in the next breaking update (Pulsar 1.x)."); - setProxyField(pulse, f, p.clientSide(), p.serverSide()); - } - } - } catch (Exception ex) { - throw new RuntimeException("Pulse annotation parsing failed for Pulse " + pulse + "; " + ex); - } - } - - @Deprecated - private void setProxyField(Object pulse, Field f, String client, String server) throws Exception { - boolean accessible = f.isAccessible(); - f.setAccessible(true); - switch (FMLCommonHandler.instance().getSide()) { - case CLIENT: - f.set(pulse, Class.forName(client).newInstance()); - break; - default: - f.set(pulse, Class.forName(server).newInstance()); - } - f.setAccessible(accessible); - } - public void preInit(FMLPreInitializationEvent evt) { if (!blockNewRegistrations) conf.flush(); // First preInit call, so flush config blockNewRegistrations = true; - - for (Map.Entry e : pulses.entrySet()) { - if(hasRequiredPulses(e)) { - log.debug("Preinitialising Pulse " + e.getValue().getId() + "..."); - if (e.getKey() instanceof IPulse) { // Deprecated IPulse handling - IPulse ip = (IPulse)e.getKey(); - ip.preInit(evt); - } else findAndInvokeHandlers(e.getKey(), evt); - } - } - } - - public void init(FMLInitializationEvent evt) { - for (Map.Entry e : pulses.entrySet()) { - log.debug("Initialising Pulse " + e.getValue().getId() + "..."); - - if (e.getKey() instanceof IPulse) { // Deprecated IPulse handling - IPulse ip = (IPulse)e.getKey(); - ip.init(evt); - log.warn("Pulse " + e.getValue().getId() + " is using the deprecated IPulse interface."); - log.warn("This will be removed in the next major version (Pulsar 1.x) - Please switch to @Handler!"); - } else findAndInvokeHandlers(e.getKey(), evt); - } - } - - public void postInit(FMLPostInitializationEvent evt) { - for (Map.Entry e : pulses.entrySet()) { - log.debug("Postinitialising Pulse " + e.getValue().getId() + "..."); - - if (e.getKey() instanceof IPulse) { // Deprecated IPulse handling - IPulse ip = (IPulse)e.getKey(); - ip.postInit(evt); - } else findAndInvokeHandlers(e.getKey(), evt); - } - } - - /** - * Parse an object for a matching handler for the given object. - * - * @param pulse Object to inspect for Handlers - * @param evt The event object - */ - @SuppressWarnings("unchecked") - private void findAndInvokeHandlers(Object pulse, Object evt) { - for (Method m : pulse.getClass().getDeclaredMethods()) { - try { - if (m.getAnnotation(Handler.class) == null) continue; // Ignore non-@Handler methods - - Class[] pTypes = m.getParameterTypes(); - if (pTypes.length != 1) continue; - - Class pt = pTypes[0]; - if (pt.isAssignableFrom(evt.getClass())) { - m.invoke(pulse, evt); - } - } catch (Exception ex) { - log.warn("Caught exception in findAndInvokeHandlers: " + ex); - ex.printStackTrace(); - } - } } private boolean hasRequiredPulses(Map.Entry entry) { @@ -255,12 +209,48 @@ public class PulseManager { return true; } + /** + * Check if a given Pulse ID is loaded in this manager. + * + * @param pulseId The ID to check. + * @return Whether the ID was present. + */ public boolean isPulseLoaded(String pulseId) { for(Map.Entry entry : pulses.entrySet()) { - if(entry.getValue().getId().equals(pulseId)) { + if (entry.getValue().getId().equals(pulseId)) { return true; } } return false; } + + public Collection getAllPulseMetadata() { + return pulses.values(); + } + + /** + * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) + */ + private class BusExceptionHandler implements SubscriberExceptionHandler { + private final String id; + + /** + * @param id Mod ID to include in exception raises. + */ + public BusExceptionHandler(String id) { + this.id = id; + } + + @Override + public void handleException(Throwable exception, SubscriberExceptionContext ctx) { + FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + id + " >> Exception uncaught in [" + + ctx.getSubscriber().getClass().getName() + ":" + ctx.getSubscriberMethod().getName() + + "] for event [" + ctx.getEvent().getClass().getSimpleName() + "]", true); + } + } + + @Override + public String toString() { + return "PulseManager[" + id + "]"; + } } diff --git a/src/mantle/pulsar/debug/EventSpy.java b/src/mantle/pulsar/debug/EventSpy.java new file mode 100755 index 0000000..6fa6bb5 --- /dev/null +++ b/src/mantle/pulsar/debug/EventSpy.java @@ -0,0 +1,25 @@ +package mantle.pulsar.debug; + +import com.google.common.eventbus.Subscribe; +import mantle.pulsar.internal.logging.ILogger; +import mantle.pulsar.internal.logging.LogManager; +import mantle.pulsar.pulse.Pulse; +import net.minecraftforge.fml.common.Loader; + +/** + * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. + * + * @author Arkan + */ +@SuppressWarnings("unused") +@Pulse(id="EventSpy", description="we iz in ur buses, monitorin ur eventz", forced=true) +public class EventSpy { + + private final ILogger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); + + @Subscribe + public void receive(Object evt) { + log.info("Received event: " + evt); + } + +} diff --git a/src/mantle/pulsar/internal/Configuration.java b/src/mantle/pulsar/internal/Configuration.java old mode 100644 new mode 100755 index 19ee523..ab5ba54 --- a/src/mantle/pulsar/internal/Configuration.java +++ b/src/mantle/pulsar/internal/Configuration.java @@ -50,7 +50,7 @@ public class Configuration implements IConfiguration { public boolean isModuleEnabled(PulseMeta meta) { ConfigEntry entry = modules.get(meta.getId()); if (entry == null) { - modules.put(meta.getId(), new ConfigEntry(meta.isEnabled(), meta.getDescription())); + modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); return meta.isEnabled(); } else { return entry.getEnabled(); diff --git a/src/mantle/pulsar/internal/CrashHandler.java b/src/mantle/pulsar/internal/CrashHandler.java new file mode 100755 index 0000000..30a4603 --- /dev/null +++ b/src/mantle/pulsar/internal/CrashHandler.java @@ -0,0 +1,49 @@ +package mantle.pulsar.internal; + +import net.minecraftforge.fml.common.ICrashCallable; +import mantle.pulsar.control.PulseManager; +import mantle.pulsar.pulse.PulseMeta; + +/** + * FML crash callable for Pulse Managers; dumps a list of loaded pulses to the error log. + * + * @author Arkan + */ +public class CrashHandler implements ICrashCallable { + + private String id; + private PulseManager manager; + + public CrashHandler(String modId, PulseManager manager) { + this.id = "Pulsar/" + modId + " loaded Pulses"; + this.manager = manager; + } + + @Override + public String getLabel() { + return id; + } + + @Override + public String call() throws Exception { + String out = "\n"; + for (PulseMeta meta : manager.getAllPulseMetadata()) { + String state = getStateFromMeta(meta); + out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... + } + return out; + } + + private static String getStateFromMeta(PulseMeta meta) { + if (meta.isForced()) { + return "Enabled/Forced"; + } else { + if (meta.isEnabled()) { + return "Enabled/Not Forced"; + } else { + return "Disabled/Not Forced"; + } + } + } + +} diff --git a/src/mantle/pulsar/internal/logging/ILogger.java b/src/mantle/pulsar/internal/logging/ILogger.java old mode 100644 new mode 100755 diff --git a/src/mantle/pulsar/internal/logging/JULLogger.java b/src/mantle/pulsar/internal/logging/JULLogger.java old mode 100644 new mode 100755 diff --git a/src/mantle/pulsar/internal/logging/Log4jLogger.java b/src/mantle/pulsar/internal/logging/Log4jLogger.java old mode 100644 new mode 100755 diff --git a/src/mantle/pulsar/internal/logging/LogManager.java b/src/mantle/pulsar/internal/logging/LogManager.java old mode 100644 new mode 100755 diff --git a/src/mantle/pulsar/pulse/Handler.java b/src/mantle/pulsar/pulse/Handler.java deleted file mode 100644 index 547648d..0000000 --- a/src/mantle/pulsar/pulse/Handler.java +++ /dev/null @@ -1,14 +0,0 @@ -package mantle.pulsar.pulse; - -import java.lang.annotation.*; - -/** - * Annotates methods to be used for event handling. - * - * @author Arkan - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD}) -public @interface Handler -{} diff --git a/src/mantle/pulsar/pulse/IPulse.java b/src/mantle/pulsar/pulse/IPulse.java deleted file mode 100644 index 5aaf66e..0000000 --- a/src/mantle/pulsar/pulse/IPulse.java +++ /dev/null @@ -1,38 +0,0 @@ -package mantle.pulsar.pulse; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -/** - * Base interface for all Pulsar modules ("pulses"). - * - * @deprecated Use the new {@link Handler} annotation. - * - * @author Arkan - */ -@Deprecated -public interface IPulse { - - /** - * FML preinit from the parent mod. - * - * @param evt The FML event inherited from this Pulses parent. - */ - public void preInit(FMLPreInitializationEvent evt); - - /** - * FML init from the parent mod. - * - * @param evt The FML event inherited from this Pulses parent. - */ - public void init(FMLInitializationEvent evt); - - /** - * FML postinit from the parent mod. - * - * @param evt The FML event inherited from this Pulses parent. - */ - public void postInit(FMLPostInitializationEvent evt); - -} diff --git a/src/mantle/pulsar/pulse/Pulse.java b/src/mantle/pulsar/pulse/Pulse.java old mode 100644 new mode 100755 index 8d4f17c..9ebce64 --- a/src/mantle/pulsar/pulse/Pulse.java +++ b/src/mantle/pulsar/pulse/Pulse.java @@ -5,6 +5,9 @@ import java.lang.annotation.*; /** * Metadata annotation for IPulse implementations. * + * Pulses should use the standard Google Event Bus @Subscribe annotation to catch FML events, which are forwarded from + * the current mod container (including Pre/Init/Post events). + * * @author Arkan */ @Retention(RetentionPolicy.RUNTIME) diff --git a/src/mantle/pulsar/pulse/PulseMeta.java b/src/mantle/pulsar/pulse/PulseMeta.java old mode 100644 new mode 100755 index a493638..7059a9e --- a/src/mantle/pulsar/pulse/PulseMeta.java +++ b/src/mantle/pulsar/pulse/PulseMeta.java @@ -8,13 +8,14 @@ package mantle.pulsar.pulse; public class PulseMeta { private String id, description; - private boolean forced, enabled; + private boolean forced, enabled, defaultEnabled; - public PulseMeta(String id, String description, boolean forced, boolean enabled) { + public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) { this.id = id; this.description = description; this.forced = forced; this.enabled = enabled; + this.defaultEnabled = defaultEnabled; } public String getId() { @@ -36,4 +37,8 @@ public class PulseMeta { public void setEnabled(boolean enabled) { this.enabled = enabled; } + + public boolean isDefaultEnabled() { + return defaultEnabled; + } } diff --git a/src/mantle/pulsar/pulse/PulseProxy.java b/src/mantle/pulsar/pulse/PulseProxy.java deleted file mode 100644 index b8089bb..0000000 --- a/src/mantle/pulsar/pulse/PulseProxy.java +++ /dev/null @@ -1,28 +0,0 @@ -package mantle.pulsar.pulse; - -import java.lang.annotation.*; - -/** - * Annotation to denote a field that should be populated by a side-specific proxy. - * - * @deprecated Use FML's @SidedProxy instead. - * - * @author Arkan - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -@Documented -@Deprecated -public @interface PulseProxy { - - /** - * @return The FQCN of the client proxy. - */ - public String clientSide(); - - /** - * @return The FQCN of the server proxy. - */ - public String serverSide(); - -} From b700b10949dccacd11bafa9c3281c43101c6a27c Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 4 Apr 2015 13:23:23 -0400 Subject: [PATCH 14/91] Updated version's of forge and mappings. --- build.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index d58ff29..ca0113d 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.1.1334 -mappings=snapshot_20150310 +forge_version=11.14.1.1353 +mappings=snapshot_20150404 From 952c9e26163714f2d6462c24306eb1c5c33acb56 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 4 Apr 2015 14:10:30 -0400 Subject: [PATCH 15/91] Rewriting the variants for a better way. --- .../blocks/abstracts/ItemBlockVariants.java | 2 +- src/mantle/blocks/iface/IBlockVariant.java | 8 --- src/mantle/blocks/util/BlockVariant.java | 30 +++++++++ .../{iface => util}/IBlockWithVariants.java | 4 +- src/mantle/blocks/util/PropertyVariant.java | 65 +++++++++++++++++++ src/mantle/client/ModelVariant.java | 20 +++--- 6 files changed, 110 insertions(+), 19 deletions(-) delete mode 100644 src/mantle/blocks/iface/IBlockVariant.java create mode 100644 src/mantle/blocks/util/BlockVariant.java rename src/mantle/blocks/{iface => util}/IBlockWithVariants.java (80%) create mode 100644 src/mantle/blocks/util/PropertyVariant.java diff --git a/src/mantle/blocks/abstracts/ItemBlockVariants.java b/src/mantle/blocks/abstracts/ItemBlockVariants.java index e7ff237..e295195 100644 --- a/src/mantle/blocks/abstracts/ItemBlockVariants.java +++ b/src/mantle/blocks/abstracts/ItemBlockVariants.java @@ -1,6 +1,6 @@ package mantle.blocks.abstracts; -import mantle.blocks.iface.IBlockWithVariants; +import mantle.blocks.util.IBlockWithVariants; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; diff --git a/src/mantle/blocks/iface/IBlockVariant.java b/src/mantle/blocks/iface/IBlockVariant.java deleted file mode 100644 index beeae8d..0000000 --- a/src/mantle/blocks/iface/IBlockVariant.java +++ /dev/null @@ -1,8 +0,0 @@ -package mantle.blocks.iface; - -import net.minecraft.util.IStringSerializable; - -public interface IBlockVariant extends IStringSerializable -{ - int getMetadata(); -} diff --git a/src/mantle/blocks/util/BlockVariant.java b/src/mantle/blocks/util/BlockVariant.java new file mode 100644 index 0000000..390c1b6 --- /dev/null +++ b/src/mantle/blocks/util/BlockVariant.java @@ -0,0 +1,30 @@ +package mantle.blocks.util; + +public class BlockVariant implements Comparable +{ + private int meta; + + private String name; + + public BlockVariant(int meta, String name) + { + this.meta = meta; + this.name = name; + } + + public int getMeta() + { + return this.meta; + } + + public String getName() + { + return this.name; + } + + @Override + public int compareTo(BlockVariant o) + { + return this.meta; + } +} \ No newline at end of file diff --git a/src/mantle/blocks/iface/IBlockWithVariants.java b/src/mantle/blocks/util/IBlockWithVariants.java similarity index 80% rename from src/mantle/blocks/iface/IBlockWithVariants.java rename to src/mantle/blocks/util/IBlockWithVariants.java index 9ff0b13..dc9458f 100644 --- a/src/mantle/blocks/iface/IBlockWithVariants.java +++ b/src/mantle/blocks/util/IBlockWithVariants.java @@ -1,8 +1,8 @@ -package mantle.blocks.iface; +package mantle.blocks.util; import net.minecraft.item.ItemStack; public interface IBlockWithVariants { String getVariantNameFromStack(ItemStack stack); -} +} \ No newline at end of file diff --git a/src/mantle/blocks/util/PropertyVariant.java b/src/mantle/blocks/util/PropertyVariant.java new file mode 100644 index 0000000..769ebb8 --- /dev/null +++ b/src/mantle/blocks/util/PropertyVariant.java @@ -0,0 +1,65 @@ +package mantle.blocks.util; + +import java.util.Collection; +import java.util.HashMap; + +import net.minecraft.block.properties.IProperty; + +import com.google.common.collect.ImmutableSet; + +public class PropertyVariant implements IProperty +{ + private String name; + + private ImmutableSet valuesSet; + + private HashMap metaMap; + + protected PropertyVariant(String name, BlockVariant... variants) + { + this.name = name; + this.valuesSet = ImmutableSet.copyOf(variants); + this.metaMap = new HashMap(); + + for (BlockVariant variant : variants) + { + this.metaMap.put(variant.getMeta(), variant); + } + } + + public static PropertyVariant create(String name, BlockVariant... variants) + { + return new PropertyVariant(name, variants); + } + + @Override + public String getName() + { + return this.name; + } + + @Override + public Collection getAllowedValues() + { + return this.valuesSet; + } + + @Override + public Class getValueClass() + { + return BlockVariant.class; + } + + @SuppressWarnings("rawtypes") + @Override + public String getName(Comparable value) + { + return ((BlockVariant) value).getName(); + } + + public BlockVariant getVariantFromMeta(int meta) + { + return this.metaMap.get(meta); + } + +} \ No newline at end of file diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index df25ee8..bfffd49 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -1,5 +1,9 @@ package mantle.client; +import java.util.Collection; +import java.util.Iterator; + +import mantle.blocks.util.BlockVariant; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; @@ -7,7 +11,6 @@ import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import mantle.blocks.iface.IBlockVariant; @SideOnly(Side.CLIENT) public class ModelVariant @@ -19,16 +22,17 @@ public class ModelVariant this.modID = modId; } - public void registerItemRenderer(Block block, IBlockVariant[] variants) + public void registerItemRenderer(Block block, Collection variants) { - String[] names = new String[variants.length]; + String[] names = new String[variants.size()]; - for (int i = 0; i < variants.length; ++i) + Iterator iterator = variants.iterator(); + for (int i = 0; iterator.hasNext(); i++) { - IBlockVariant subtype = variants[i]; - names[i] = (this.modID + ":") + subtype.getName(); + BlockVariant variant = iterator.next(); + names[i] = (this.modID + ":") + variant.getName(); - this.registerItemRenderer(names[i], Item.getItemFromBlock(block), subtype.getMetadata()); + this.registerItemRenderer(names[i], Item.getItemFromBlock(block), variant.getMeta()); } ModelBakery.addVariantName(Item.getItemFromBlock(block), names); @@ -51,7 +55,7 @@ public class ModelVariant this.registerItemRenderer(name, Item.getItemFromBlock(block), meta); } - public static void registerItemRenderer(String name, Item item, int meta) + public void registerItemRenderer(String name, Item item, int meta) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(name, "inventory")); } From 23dde7d5b7bcd4ac8343af3cc798740165b26387 Mon Sep 17 00:00:00 2001 From: alexbegt Date: Sun, 5 Apr 2015 16:38:48 -0400 Subject: [PATCH 16/91] Making the mod ID lowercase. --- resources/mcmod.info | 2 +- src/mantle/Mantle.java | 2 +- src/mantle/lib/CoreRepo.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/mcmod.info b/resources/mcmod.info index de04bf5..3ff46cc 100644 --- a/resources/mcmod.info +++ b/resources/mcmod.info @@ -1,5 +1,5 @@ [{ - "modid": "Mantle", + "modid": "mantle", "name": "Mantle", "description": "Shared code for Slime Knights mods and others.", "version": "${version}", diff --git a/src/mantle/Mantle.java b/src/mantle/Mantle.java index 2e2b766..7a9e6de 100644 --- a/src/mantle/Mantle.java +++ b/src/mantle/Mantle.java @@ -37,7 +37,7 @@ import java.io.File; public class Mantle { /* Instance of this mod, used for grabbing prototype fields */ - @Instance("Mantle") + @Instance("mantle") public static Mantle instance; /* Proxies for sides, used for graphics processing */ @SidedProxy(clientSide = "mantle.client.MProxyClient", serverSide = "mantle.common.MProxyCommon") diff --git a/src/mantle/lib/CoreRepo.java b/src/mantle/lib/CoreRepo.java index ab6a379..45fb33e 100644 --- a/src/mantle/lib/CoreRepo.java +++ b/src/mantle/lib/CoreRepo.java @@ -13,7 +13,7 @@ import org.apache.logging.log4j.Logger; public final class CoreRepo { - public static final String modId = "Mantle"; + public static final String modId = "mantle"; public static final String modName = "Mantle"; public static final String modVersion = "${version}"; From bb20f6d4c69d09dc09a2926647aca3b16b5584ab Mon Sep 17 00:00:00 2001 From: Alexander Date: Tue, 7 Apr 2015 23:12:45 -0400 Subject: [PATCH 17/91] Add a new method to register more then one item at once. --- src/mantle/client/ModelVariant.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index bfffd49..283c129 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -50,6 +50,14 @@ public class ModelVariant this.registerItemRenderer(name, item, meta); } + public void registerItemRenderers(int meta, Item... items) + { + for (Item item : items) + { + this.registerItemRenderer(item, meta); + } + } + public void registerItemRenderer(String name, Block block, int meta) { this.registerItemRenderer(name, Item.getItemFromBlock(block), meta); From 406630ac8eec1bf03f2f61fb286220a1f5091850 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 8 Apr 2015 00:02:15 -0400 Subject: [PATCH 18/91] Should of added this before. --- src/mantle/client/ModelVariant.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 283c129..952be18 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -38,6 +38,14 @@ public class ModelVariant ModelBakery.addVariantName(Item.getItemFromBlock(block), names); } + public void registerBlockRenderers(int meta, Block... blocks) + { + for (Block block : blocks) + { + this.registerItemRenderer(block, meta); + } + } + public void registerItemRenderer(Block block, int meta) { this.registerItemRenderer(Item.getItemFromBlock(block), meta); From b23dd0dce04b111e6d0dcf75b7fbdec1866ee619 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 8 Apr 2015 00:45:51 -0400 Subject: [PATCH 19/91] I broke the item textures. --- src/mantle/client/ModelVariant.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 952be18..1171af0 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -38,31 +38,31 @@ public class ModelVariant ModelBakery.addVariantName(Item.getItemFromBlock(block), names); } - public void registerBlockRenderers(int meta, Block... blocks) + public void registerBlockRenderers(boolean addModId, int meta, Block... blocks) { for (Block block : blocks) { - this.registerItemRenderer(block, meta); + this.registerItemRenderer(addModId, block, meta); } } - public void registerItemRenderer(Block block, int meta) + public void registerItemRenderer(boolean addModId, Block block, int meta) { - this.registerItemRenderer(Item.getItemFromBlock(block), meta); + this.registerItemRenderer(addModId, Item.getItemFromBlock(block), meta); } - public void registerItemRenderer(Item item, int meta) + public void registerItemRenderer(boolean addModId, Item item, int meta) { String name = (this.modID + ":") + item.getUnlocalizedName().substring(5); this.registerItemRenderer(name, item, meta); } - public void registerItemRenderers(int meta, Item... items) + public void registerItemRenderers(boolean addModId, int meta, Item... items) { for (Item item : items) { - this.registerItemRenderer(item, meta); + this.registerItemRenderer(addModId, item, meta); } } From 8bbd3713aa6346ce95361e447250697dbf95dd58 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 8 Apr 2015 00:51:25 -0400 Subject: [PATCH 20/91] I am really tired, lets try this... --- src/mantle/client/ModelVariant.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 1171af0..0a11661 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -38,31 +38,31 @@ public class ModelVariant ModelBakery.addVariantName(Item.getItemFromBlock(block), names); } - public void registerBlockRenderers(boolean addModId, int meta, Block... blocks) + public void registerBlockRenderers(int meta, Block... blocks) { for (Block block : blocks) { - this.registerItemRenderer(addModId, block, meta); + this.registerItemRenderer(block, meta); } } - public void registerItemRenderer(boolean addModId, Block block, int meta) + public void registerItemRenderer(Block block, int meta) { - this.registerItemRenderer(addModId, Item.getItemFromBlock(block), meta); + this.registerItemRenderer(Item.getItemFromBlock(block), meta); } - public void registerItemRenderer(boolean addModId, Item item, int meta) + public void registerItemRenderer(Item item, int meta) { - String name = (this.modID + ":") + item.getUnlocalizedName().substring(5); + String name = (this.modID + ":") + item.getUnlocalizedName().substring(5).replace(this.modID + ".", ""); this.registerItemRenderer(name, item, meta); } - public void registerItemRenderers(boolean addModId, int meta, Item... items) + public void registerItemRenderers(int meta, Item... items) { for (Item item : items) { - this.registerItemRenderer(addModId, item, meta); + this.registerItemRenderer(item, meta); } } From ed84ba3b87e6fd37841e99864e1853b1a2d6d7c7 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 8 Apr 2015 01:00:57 -0400 Subject: [PATCH 21/91] It works... Good. --- src/mantle/client/ModelVariant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 0a11661..1e72dbf 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -53,7 +53,7 @@ public class ModelVariant public void registerItemRenderer(Item item, int meta) { - String name = (this.modID + ":") + item.getUnlocalizedName().substring(5).replace(this.modID + ".", ""); + String name = (this.modID + ":") + item.getUnlocalizedName().substring(5).replace(this.modID.toLowerCase() + ".", ""); this.registerItemRenderer(name, item, meta); } From f21ac4145befc1a0fe074ae88133710240679ac9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 24 Apr 2015 14:19:53 -0400 Subject: [PATCH 22/91] Did some changes to the model code natura uses. --- src/mantle/blocks/util/BlockVariant.java | 48 ++++++----- src/mantle/blocks/util/PropertyVariant.java | 90 ++++++++++----------- src/mantle/client/ModelVariant.java | 88 +++++++++----------- 3 files changed, 108 insertions(+), 118 deletions(-) diff --git a/src/mantle/blocks/util/BlockVariant.java b/src/mantle/blocks/util/BlockVariant.java index 390c1b6..beff5df 100644 --- a/src/mantle/blocks/util/BlockVariant.java +++ b/src/mantle/blocks/util/BlockVariant.java @@ -2,29 +2,35 @@ package mantle.blocks.util; public class BlockVariant implements Comparable { - private int meta; + private int meta; - private String name; + private String name; - public BlockVariant(int meta, String name) - { - this.meta = meta; - this.name = name; - } + public BlockVariant(int meta, String name) + { + this.meta = meta; + this.name = name; + } - public int getMeta() - { - return this.meta; - } + public int getMeta() + { + return this.meta; + } - public String getName() - { - return this.name; - } + public String getName() + { + return this.name; + } - @Override - public int compareTo(BlockVariant o) - { - return this.meta; - } -} \ No newline at end of file + @Override + public int compareTo(BlockVariant o) + { + return this.meta; + } + + @Override + public String toString() + { + return this.getName(); + } +} diff --git a/src/mantle/blocks/util/PropertyVariant.java b/src/mantle/blocks/util/PropertyVariant.java index 769ebb8..386fa23 100644 --- a/src/mantle/blocks/util/PropertyVariant.java +++ b/src/mantle/blocks/util/PropertyVariant.java @@ -1,65 +1,65 @@ package mantle.blocks.util; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import net.minecraft.block.properties.IProperty; -import com.google.common.collect.ImmutableSet; - public class PropertyVariant implements IProperty { - private String name; + private String name; - private ImmutableSet valuesSet; + private ArrayList values; - private HashMap metaMap; + private HashMap metaMap; - protected PropertyVariant(String name, BlockVariant... variants) - { - this.name = name; - this.valuesSet = ImmutableSet.copyOf(variants); - this.metaMap = new HashMap(); + protected PropertyVariant(String name, BlockVariant... variants) + { + this.name = name; + this.values = new ArrayList(Arrays.asList(variants)); + this.metaMap = new HashMap(); - for (BlockVariant variant : variants) - { - this.metaMap.put(variant.getMeta(), variant); - } - } + for (BlockVariant variant : variants) + { + this.metaMap.put(variant.getMeta(), variant); + } + } - public static PropertyVariant create(String name, BlockVariant... variants) - { - return new PropertyVariant(name, variants); - } + public static PropertyVariant create(String name, BlockVariant... variants) + { + return new PropertyVariant(name, variants); + } - @Override - public String getName() - { - return this.name; - } + @Override + public String getName() + { + return this.name; + } - @Override - public Collection getAllowedValues() - { - return this.valuesSet; - } + @Override + public Collection getAllowedValues() + { + return this.values; + } - @Override - public Class getValueClass() - { - return BlockVariant.class; - } + @Override + public Class getValueClass() + { + return BlockVariant.class; + } - @SuppressWarnings("rawtypes") - @Override - public String getName(Comparable value) - { - return ((BlockVariant) value).getName(); - } + @Override + @SuppressWarnings("rawtypes") + public String getName(Comparable value) + { + return ((BlockVariant) value).getName(); + } - public BlockVariant getVariantFromMeta(int meta) - { - return this.metaMap.get(meta); - } + public BlockVariant getVariantFromMeta(int meta) + { + return this.metaMap.get(meta); + } -} \ No newline at end of file +} diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 1e72dbf..c9835d2 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -1,7 +1,6 @@ package mantle.client; import java.util.Collection; -import java.util.Iterator; import mantle.blocks.util.BlockVariant; import net.minecraft.block.Block; @@ -15,64 +14,49 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class ModelVariant { - private String modID; + private String MOD_ID; - public ModelVariant(String modId) - { - this.modID = modId; - } + private Minecraft mc; - public void registerItemRenderer(Block block, Collection variants) - { - String[] names = new String[variants.size()]; + public ModelVariant(String modId, Minecraft mc) + { + this.MOD_ID = modId; + this.mc = mc; + } - Iterator iterator = variants.iterator(); - for (int i = 0; iterator.hasNext(); i++) - { - BlockVariant variant = iterator.next(); - names[i] = (this.modID + ":") + variant.getName(); + public void registerBlockModelVariants(Block block, Collection variants) + { + for (BlockVariant variant : variants) + { + Item item = Item.getItemFromBlock(block); - this.registerItemRenderer(names[i], Item.getItemFromBlock(block), variant.getMeta()); - } + this.registerItemModel(item, variant.getName(), variant.getMeta()); + ModelBakery.addVariantName(item, (MOD_ID + ":") + variant.getName()); + } + } - ModelBakery.addVariantName(Item.getItemFromBlock(block), names); - } + public void registerBlockModel(Block block) + { + this.registerBlockModel(block, block.getUnlocalizedName().substring(5), 0); + } - public void registerBlockRenderers(int meta, Block... blocks) - { - for (Block block : blocks) - { - this.registerItemRenderer(block, meta); - } - } + public void registerBlockModel(Block block, String name, int meta) + { + this.registerItemModel(Item.getItemFromBlock(block), name, meta); + } - public void registerItemRenderer(Block block, int meta) - { - this.registerItemRenderer(Item.getItemFromBlock(block), meta); - } + public void registerItemModel(Item item) + { + this.registerItemModel(item, item.getUnlocalizedName().substring(5), 0); + } - public void registerItemRenderer(Item item, int meta) - { - String name = (this.modID + ":") + item.getUnlocalizedName().substring(5).replace(this.modID.toLowerCase() + ".", ""); + public void registerItemModel(Item item, String name, int meta) + { + this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(name, "inventory")); + } - this.registerItemRenderer(name, item, meta); - } - - public void registerItemRenderers(int meta, Item... items) - { - for (Item item : items) - { - this.registerItemRenderer(item, meta); - } - } - - public void registerItemRenderer(String name, Block block, int meta) - { - this.registerItemRenderer(name, Item.getItemFromBlock(block), meta); - } - - public void registerItemRenderer(String name, Item item, int meta) - { - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(name, "inventory")); - } + private ModelResourceLocation getModelResource(String name, String type) + { + return new ModelResourceLocation((MOD_ID + ":") + name, type); + } } From 244c26dd7b031b509866bd3543496d3c55c55f50 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 24 Apr 2015 14:45:22 -0400 Subject: [PATCH 23/91] Fixes broken item textures. --- src/mantle/client/ModelVariant.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index c9835d2..bee1882 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -52,7 +52,8 @@ public class ModelVariant public void registerItemModel(Item item, String name, int meta) { - this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(name, "inventory")); + String NAME = name.replace(this.MOD_ID + ".", ""); + this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(NAME, "inventory")); } private ModelResourceLocation getModelResource(String name, String type) From 073817b0202dd5dfbf0ac777d01de8976c114df9 Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 24 Apr 2015 19:55:07 -0400 Subject: [PATCH 24/91] I failed, and somehow formated Mantle... --- build.properties | 4 +- src/mantle/Mantle.java | 14 +- src/mantle/blocks/BlockUtils.java | 8 +- src/mantle/blocks/MantleBlock.java | 4 +- .../abstracts/AdaptiveInventoryLogic.java | 47 ++-- .../abstracts/ExpandableInventoryLogic.java | 160 +++++++------ .../blocks/abstracts/InventoryBlock.java | 71 +++--- .../blocks/abstracts/InventoryLogic.java | 184 ++++++++------- .../blocks/abstracts/InventorySlab.java | 36 +-- .../blocks/abstracts/ItemBlockVariants.java | 36 +-- .../blocks/abstracts/MultiItemBlock.java | 33 ++- .../blocks/abstracts/MultiServantLogic.java | 149 ++++++------ src/mantle/blocks/iface/IActiveLogic.java | 4 +- src/mantle/blocks/iface/ICrop.java | 9 +- src/mantle/blocks/iface/IFacingLogic.java | 7 +- src/mantle/blocks/iface/IMasterLogic.java | 4 +- src/mantle/blocks/iface/IMasterNode.java | 4 +- src/mantle/blocks/iface/IServantLogic.java | 20 +- .../blocks/util/IBlockWithVariants.java | 4 +- src/mantle/books/BookData.java | 13 +- src/mantle/books/BookDataStore.java | 28 ++- src/mantle/books/ManualReader.java | 5 +- src/mantle/books/client/BookImage.java | 8 +- src/mantle/books/external/BookIS.java | 4 +- src/mantle/books/external/BookLoad.java | 31 ++- src/mantle/books/external/ZipLoader.java | 19 +- src/mantle/client/MProxyClient.java | 26 ++- src/mantle/client/ModelHelper.java | 4 +- src/mantle/client/ModelVariant.java | 4 +- src/mantle/client/gui/GuiManual.java | 133 +++++++---- src/mantle/client/gui/TurnPageButton.java | 9 +- src/mantle/client/pages/BlankPage.java | 4 +- src/mantle/client/pages/BookPage.java | 9 +- .../client/pages/ContentsTablePage.java | 44 ++-- src/mantle/client/pages/CraftingPage.java | 91 +++++--- src/mantle/client/pages/FurnacePage.java | 44 ++-- src/mantle/client/pages/PicturePage.java | 52 +++-- src/mantle/client/pages/SectionPage.java | 21 +- src/mantle/client/pages/SidebarPage.java | 40 ++-- src/mantle/client/pages/TextPage.java | 14 +- src/mantle/client/pages/TitlePage.java | 14 +- src/mantle/common/ComparisonHelper.java | 10 +- src/mantle/common/IDDumps.java | 3 +- src/mantle/common/MProxyCommon.java | 10 +- src/mantle/common/network/AbstractPacket.java | 18 +- src/mantle/common/network/PacketUpdateTE.java | 25 +- src/mantle/crash/CallableSuppConfig.java | 6 +- src/mantle/crash/CallableUnsuppConfig.java | 11 +- src/mantle/debug/DebugData.java | 5 +- src/mantle/debug/DebugHelper.java | 10 +- src/mantle/debug/IDebuggable.java | 2 +- src/mantle/event/ManualOpenEvent.java | 43 ++-- src/mantle/event/Migration.java | 78 ++++--- src/mantle/items/ItemUtils.java | 7 +- src/mantle/items/Manual.java | 30 +-- src/mantle/items/abstracts/CraftingItem.java | 27 ++- src/mantle/lib/CoreConfig.java | 22 +- src/mantle/lib/CoreRepo.java | 2 + src/mantle/lib/TabTools.java | 16 +- .../lib/client/MantleClientRegistry.java | 22 +- .../lib/environment/EnvironmentChecks.java | 9 +- src/mantle/math/Dozenal.java | 16 +- src/mantle/player/PlayerUtils.java | 6 +- src/mantle/pulsar/config/ForgeCFG.java | 31 ++- src/mantle/pulsar/config/IConfiguration.java | 3 +- src/mantle/pulsar/control/PulseManager.java | 214 +++++++++++------- src/mantle/pulsar/debug/EventSpy.java | 13 +- src/mantle/pulsar/internal/Configuration.java | 201 ++++++++++------ src/mantle/pulsar/internal/CrashHandler.java | 37 ++- .../pulsar/internal/logging/ILogger.java | 3 +- .../pulsar/internal/logging/JULLogger.java | 38 ++-- .../pulsar/internal/logging/Log4jLogger.java | 38 ++-- .../pulsar/internal/logging/LogManager.java | 32 ++- src/mantle/pulsar/pulse/Pulse.java | 11 +- src/mantle/pulsar/pulse/PulseMeta.java | 35 +-- src/mantle/utils/ItemMetaWrapper.java | 34 ++- src/mantle/utils/ItemStackNBTWrapper.java | 30 ++- src/mantle/utils/ItemStackWrapper.java | 34 ++- src/mantle/utils/RecipeRemover.java | 18 +- src/mantle/world/ChunkCoord.java | 21 +- src/mantle/world/CoordTuplePair.java | 3 +- src/mantle/world/DimensionCoordPair.java | 31 ++- src/mantle/world/DimensionCoordTuple.java | 36 +-- src/mantle/world/DirectionUtils.java | 4 +- 84 files changed, 1577 insertions(+), 1083 deletions(-) diff --git a/build.properties b/build.properties index ca0113d..43e5f71 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.1.1353 -mappings=snapshot_20150404 +forge_version=11.14.1.1392 +mappings=snapshot_20150424 diff --git a/src/mantle/Mantle.java b/src/mantle/Mantle.java index 7a9e6de..34ab38f 100644 --- a/src/mantle/Mantle.java +++ b/src/mantle/Mantle.java @@ -4,8 +4,6 @@ import static mantle.lib.CoreRepo.logger; import static mantle.lib.CoreRepo.modId; import static mantle.lib.CoreRepo.modName; import static mantle.lib.CoreRepo.modVersion; - -import LZMA.LzmaInputStream; import mantle.books.BookData; import mantle.books.BookDataStore; import mantle.common.IDDumps; @@ -24,8 +22,6 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; -import java.io.File; - /** * Mantle * @@ -39,11 +35,13 @@ public class Mantle /* Instance of this mod, used for grabbing prototype fields */ @Instance("mantle") public static Mantle instance; + /* Proxies for sides, used for graphics processing */ @SidedProxy(clientSide = "mantle.client.MProxyClient", serverSide = "mantle.common.MProxyCommon") - public static MProxyCommon proxy; + public static Manual mantleBook; + /** * Constructor * @@ -62,7 +60,7 @@ public class Mantle * @param evt The FMLPreInitializationEvent from FML */ @EventHandler - public void preInit (FMLPreInitializationEvent evt) + public void preInit(FMLPreInitializationEvent evt) { logger.info("Mantle (" + modVersion + ") -- Preparing for launch."); logger.info("Entering preinitialization phase."); @@ -82,7 +80,7 @@ public class Mantle * @param evt The FMLInitializationEvent from FML */ @EventHandler - public void Init (FMLInitializationEvent evt) + public void Init(FMLInitializationEvent evt) { logger.info("Entering initialization phase."); proxy.registerRenderer(); @@ -96,7 +94,7 @@ public class Mantle * @param evt The FMLPostInitializationEvent from FML */ @EventHandler - public void postInit (FMLPostInitializationEvent evt) + public void postInit(FMLPostInitializationEvent evt) { logger.info("Entering postinitialization phase."); proxy.readManuals(); diff --git a/src/mantle/blocks/BlockUtils.java b/src/mantle/blocks/BlockUtils.java index 28a1d95..b6c0523 100644 --- a/src/mantle/blocks/BlockUtils.java +++ b/src/mantle/blocks/BlockUtils.java @@ -7,23 +7,23 @@ import net.minecraftforge.fml.common.registry.GameData; public class BlockUtils { - public static Block getBlockFromItem (Item item) + public static Block getBlockFromItem(Item item) { return Block.getBlockFromItem(item); } @SuppressWarnings("unused") - public static Block getBlockFromItemStack (ItemStack itemStack) + public static Block getBlockFromItemStack(ItemStack itemStack) { return getBlockFromItem(itemStack.getItem()); } - public static String getUniqueName (Block block) + public static String getUniqueName(Block block) { return GameData.getBlockRegistry().getNameForObject(block).toString(); } - public static Block getBlockFromUniqueName (String uniqueName) + public static Block getBlockFromUniqueName(String uniqueName) { return GameData.getBlockRegistry().getObject(uniqueName); } diff --git a/src/mantle/blocks/MantleBlock.java b/src/mantle/blocks/MantleBlock.java index 9b33e86..552909e 100644 --- a/src/mantle/blocks/MantleBlock.java +++ b/src/mantle/blocks/MantleBlock.java @@ -28,14 +28,16 @@ public abstract class MantleBlock extends Block // IDebuggable support - Uses a stick for debug purposes. @Override - public void onBlockClicked (World world, BlockPos pos, EntityPlayer player) + public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && (player.getHeldItem().getItem() == Items.stick || player.getHeldItem().getItem() instanceof IDebugItem)) { TileEntity te = world.getTileEntity(pos); if (te instanceof IDebuggable) + { DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player)); + } } super.onBlockClicked(world, pos, player); } diff --git a/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java b/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java index c6436bb..3f91f76 100644 --- a/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java +++ b/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java @@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound; public abstract class AdaptiveInventoryLogic extends InventoryLogic implements IFacingLogic { Random random = new Random(); + protected int inventorySize; public AdaptiveInventoryLogic() @@ -17,32 +18,32 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I super(0); } - protected void adjustInventory (int size, boolean forceAdjust) + protected void adjustInventory(int size, boolean forceAdjust) { - if (size != inventorySize || forceAdjust) + if (size != this.inventorySize || forceAdjust) { - inventorySize = size; + this.inventorySize = size; - ItemStack[] tempInv = inventory; - inventory = new ItemStack[size]; - int invLength = tempInv.length > inventory.length ? inventory.length : tempInv.length; - System.arraycopy(tempInv, 0, inventory, 0, invLength); + ItemStack[] tempInv = this.inventory; + this.inventory = new ItemStack[size]; + int invLength = tempInv.length > this.inventory.length ? this.inventory.length : tempInv.length; + System.arraycopy(tempInv, 0, this.inventory, 0, invLength); - if (tempInv.length > inventory.length) + if (tempInv.length > this.inventory.length) { - for (int i = inventory.length; i < tempInv.length; i++) + for (int i = this.inventory.length; i < tempInv.length; i++) { ItemStack stack = tempInv[i]; if (stack != null) { - float jumpX = random.nextFloat() * 0.8F + 0.1F; - float jumpY = random.nextFloat() * 0.8F + 0.1F; - float jumpZ = random.nextFloat() * 0.8F + 0.1F; + float jumpX = this.random.nextFloat() * 0.8F + 0.1F; + float jumpY = this.random.nextFloat() * 0.8F + 0.1F; + float jumpZ = this.random.nextFloat() * 0.8F + 0.1F; int offsetX = 0; int offsetY = 0; int offsetZ = 0; - switch (getTossDirection()) + switch (this.getTossDirection()) { case 0: // -y offsetY--; @@ -66,7 +67,7 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I while (stack.stackSize > 0) { - int itemSize = random.nextInt(21) + 10; + int itemSize = this.random.nextInt(21) + 10; if (itemSize > stack.stackSize) { @@ -74,8 +75,8 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I } stack.stackSize -= itemSize; - EntityItem entityitem = new EntityItem(worldObj, (double) ((float) pos.getX() + jumpX + offsetX), (double) ((float) pos.getY() + jumpY), - (double) ((float) pos.getZ() + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage())); + EntityItem entityitem = new EntityItem(this.worldObj, (double) ((float) this.pos.getX() + jumpX + offsetX), (double) ((float) this.pos.getY() + jumpY), + (double) ((float) this.pos.getZ() + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage())); if (stack.hasTagCompound()) { @@ -83,10 +84,10 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I } float offset = 0.05F; - entityitem.motionX = (double) ((float) random.nextGaussian() * offset); - entityitem.motionY = (double) ((float) random.nextGaussian() * offset + 0.2F); - entityitem.motionZ = (double) ((float) random.nextGaussian() * offset); - worldObj.spawnEntityInWorld(entityitem); + entityitem.motionX = (double) ((float) this.random.nextGaussian() * offset); + entityitem.motionY = (double) ((float) this.random.nextGaussian() * offset + 0.2F); + entityitem.motionZ = (double) ((float) this.random.nextGaussian() * offset); + this.worldObj.spawnEntityInWorld(entityitem); } } } @@ -94,8 +95,8 @@ public abstract class AdaptiveInventoryLogic extends InventoryLogic implements I } } - public int getTossDirection () + public int getTossDirection() { - return getRenderDirection(); + return this.getRenderDirection(); } -} \ No newline at end of file +} diff --git a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java b/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java index 62ffa6f..33e46db 100644 --- a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java +++ b/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java @@ -1,14 +1,18 @@ package mantle.blocks.abstracts; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.World; import com.google.common.collect.Lists; -import net.minecraft.entity.player.*; -import net.minecraft.inventory.*; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.*; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; public abstract class ExpandableInventoryLogic extends InventoryLogic implements IInventory { @@ -19,82 +23,85 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements } protected ArrayList inventory = Lists.newArrayList(); + protected String invName; @Override - public ItemStack getStackInSlot (int slot) + public ItemStack getStackInSlot(int slot) { - return slot < inventory.size() ? inventory.get(slot) : null; - } - - public boolean isStackInSlot (int slot) - { - return slot < inventory.size() && inventory.get(slot) != null; + return slot < this.inventory.size() ? this.inventory.get(slot) : null; } @Override - public int getSizeInventory () + public boolean isStackInSlot(int slot) { - return inventory.size(); + return slot < this.inventory.size() && this.inventory.get(slot) != null; } - public int getMaxSize () + @Override + public int getSizeInventory() + { + return this.inventory.size(); + } + + public int getMaxSize() { return 64; } @Override - public int getInventoryStackLimit () + public int getInventoryStackLimit() { return 64; } - public boolean canDropInventorySlot (int slot) + @Override + public boolean canDropInventorySlot(int slot) { return true; } @Override - public void setInventorySlotContents (int slot, ItemStack itemstack) + public void setInventorySlotContents(int slot, ItemStack itemstack) { - if (slot < inventory.size()) + if (slot < this.inventory.size()) { - inventory.set(slot, itemstack); + this.inventory.set(slot, itemstack); } - else if (slot == inventory.size()) + else if (slot == this.inventory.size()) { - inventory.add(itemstack); + this.inventory.add(itemstack); } - else if (slot < getMaxSize()) + else if (slot < this.getMaxSize()) { - inventory.ensureCapacity(slot); - inventory.set(slot, itemstack); + this.inventory.ensureCapacity(slot); + this.inventory.set(slot, itemstack); } else { return; } - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.stackSize = this.getInventoryStackLimit(); } } @Override - public ItemStack decrStackSize (int slot, int quantity) + public ItemStack decrStackSize(int slot, int quantity) { - if (slot < inventory.size() && inventory.get(slot) != null) + if (slot < this.inventory.size() && this.inventory.get(slot) != null) { - if (inventory.get(slot).stackSize <= quantity) + if (this.inventory.get(slot).stackSize <= quantity) { - ItemStack stack = inventory.get(slot); - inventory.set(slot, null); + ItemStack stack = this.inventory.get(slot); + this.inventory.set(slot, null); return stack; } - ItemStack split = inventory.get(slot).splitStack(quantity); - if (inventory.get(slot).stackSize == 0) + ItemStack split = this.inventory.get(slot).splitStack(quantity); + if (this.inventory.get(slot).stackSize == 0) { - inventory.set(slot, null); + this.inventory.set(slot, null); } return split; } @@ -106,52 +113,58 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements /* Supporting methods */ @Override - public boolean isUseableByPlayer (EntityPlayer entityplayer) + public boolean isUseableByPlayer(EntityPlayer entityplayer) { - if (worldObj.getTileEntity(pos) != this) + if (this.worldObj.getTileEntity(this.pos) != this) + { return false; - + } else - return entityplayer.getDistance((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64D; + { + return entityplayer.getDistance((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64D; + } } - public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z); + @Override + public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z); /* NBT */ @Override - public void readFromNBT (NBTTagCompound tags) + public void readFromNBT(NBTTagCompound tags) { super.readFromNBT(tags); this.invName = tags.getString("InvName"); NBTTagList nbttaglist = tags.getTagList("Items", 9); - inventory = new ArrayList(); - inventory.ensureCapacity(nbttaglist.tagCount() > getMaxSize() ? getMaxSize() : nbttaglist.tagCount()); + this.inventory = new ArrayList(); + this.inventory.ensureCapacity(nbttaglist.tagCount() > this.getMaxSize() ? this.getMaxSize() : nbttaglist.tagCount()); for (int iter = 0; iter < nbttaglist.tagCount(); iter++) { NBTTagCompound tagList = nbttaglist.getCompoundTagAt(iter); byte slotID = tagList.getByte("Slot"); - if (slotID >= 0 && slotID < inventory.size()) + if (slotID >= 0 && slotID < this.inventory.size()) { - inventory.set(slotID, ItemStack.loadItemStackFromNBT(tagList)); + this.inventory.set(slotID, ItemStack.loadItemStackFromNBT(tagList)); } } } @Override - public void writeToNBT (NBTTagCompound tags) + public void writeToNBT(NBTTagCompound tags) { super.writeToNBT(tags); - if (invName != null) - tags.setString("InvName", invName); - NBTTagList nbttaglist = new NBTTagList(); - for (int iter = 0; iter < inventory.size(); iter++) + if (this.invName != null) { - if (inventory.get(iter) != null) + tags.setString("InvName", this.invName); + } + NBTTagList nbttaglist = new NBTTagList(); + for (int iter = 0; iter < this.inventory.size(); iter++) + { + if (this.inventory.get(iter) != null) { NBTTagCompound tagList = new NBTTagCompound(); tagList.setByte("Slot", (byte) iter); - inventory.get(iter).writeToNBT(tagList); + this.inventory.get(iter).writeToNBT(tagList); nbttaglist.appendTag(tagList); } } @@ -160,39 +173,46 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements } /* Default implementations of hardly used methods */ - public ItemStack getStackInSlotOnClosing (int slot) + @Override + public ItemStack getStackInSlotOnClosing(int slot) { return null; } - public void openChest () + @Override + public void openChest() { } - public void closeChest () + @Override + public void closeChest() { } - protected abstract String getDefaultName (); + @Override + protected abstract String getDefaultName(); - public void setInvName (String name) + @Override + public void setInvName(String name) { this.invName = name; } - public String getInvName () + @Override + public String getInvName() { - return this.isInvNameLocalized() ? this.invName : getDefaultName(); + return this.isInvNameLocalized() ? this.invName : this.getDefaultName(); } - public boolean isInvNameLocalized () + @Override + public boolean isInvNameLocalized() { return this.invName != null && this.invName.length() > 0; } - public void cleanInventory () + public void cleanInventory() { - Iterator i1 = inventory.iterator(); + Iterator i1 = this.inventory.iterator(); while (i1.hasNext()) { if (i1.next() == null) @@ -203,18 +223,20 @@ public abstract class ExpandableInventoryLogic extends InventoryLogic implements } @Override - public boolean isItemValidForSlot (int slot, ItemStack itemstack) + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - if (slot < getSizeInventory()) + if (slot < this.getSizeInventory()) { - if (inventory.get(slot) == null || itemstack.stackSize + inventory.get(slot).stackSize <= getInventoryStackLimit()) + if (this.inventory.get(slot) == null || itemstack.stackSize + this.inventory.get(slot).stackSize <= this.getInventoryStackLimit()) + { return true; + } } else { - return slot < getMaxSize(); + return slot < this.getMaxSize(); } return false; } -} \ No newline at end of file +} diff --git a/src/mantle/blocks/abstracts/InventoryBlock.java b/src/mantle/blocks/abstracts/InventoryBlock.java index 9edc40c..140f2f8 100644 --- a/src/mantle/blocks/abstracts/InventoryBlock.java +++ b/src/mantle/blocks/abstracts/InventoryBlock.java @@ -2,31 +2,26 @@ package mantle.blocks.abstracts; import java.util.Random; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.EnumFaceDirection; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.relauncher.Side; import mantle.blocks.iface.IActiveLogic; import mantle.blocks.iface.IFacingLogic; import mantle.debug.DebugHelper; import mantle.debug.IDebuggable; -import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.BlockPos; -import net.minecraft.util.MathHelper; +import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; public abstract class InventoryBlock extends BlockContainer { @@ -38,24 +33,27 @@ public abstract class InventoryBlock extends BlockContainer } /* Logic backend */ - public TileEntity createNewTileEntity (World var1) + public TileEntity createNewTileEntity(World var1) { return null; } - public abstract TileEntity createNewTileEntity (World world, int metadata); + @Override + public abstract TileEntity createNewTileEntity(World world, int metadata); - public abstract Integer getGui (World world, int x, int y, int z, EntityPlayer entityplayer); + public abstract Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer); - public abstract Object getModInstance (); + public abstract Object getModInstance(); @Override - public boolean onBlockActivated (World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float clickX, float clickY, float clickZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float clickX, float clickY, float clickZ) { if (player.isSneaking()) + { return false; + } - Integer integer = getGui(world, pos.getX(), pos.getY(), pos.getZ(), player); + Integer integer = this.getGui(world, pos.getX(), pos.getY(), pos.getZ(), player); if (integer == null || integer == -1) { return false; @@ -63,14 +61,16 @@ public abstract class InventoryBlock extends BlockContainer else { if (!world.isRemote) - player.openGui(getModInstance(), integer, world, pos.getX(), pos.getY(), pos.getZ()); + { + player.openGui(this.getModInstance(), integer, world, pos.getX(), pos.getY(), pos.getZ()); + } return true; } } /* Inventory */ @Override - public void breakBlock (World par1World, BlockPos pos, IBlockState meta) + public void breakBlock(World par1World, BlockPos pos, IBlockState meta) { TileEntity te = par1World.getTileEntity(pos); @@ -84,13 +84,13 @@ public abstract class InventoryBlock extends BlockContainer if (stack != null && logic.canDropInventorySlot(iter)) { - float jumpX = rand.nextFloat() * 0.8F + 0.1F; - float jumpY = rand.nextFloat() * 0.8F + 0.1F; - float jumpZ = rand.nextFloat() * 0.8F + 0.1F; + float jumpX = this.rand.nextFloat() * 0.8F + 0.1F; + float jumpY = this.rand.nextFloat() * 0.8F + 0.1F; + float jumpZ = this.rand.nextFloat() * 0.8F + 0.1F; while (stack.stackSize > 0) { - int itemSize = rand.nextInt(21) + 10; + int itemSize = this.rand.nextInt(21) + 10; if (itemSize > stack.stackSize) { @@ -107,9 +107,9 @@ public abstract class InventoryBlock extends BlockContainer } float offset = 0.05F; - entityitem.motionX = (double) ((float) rand.nextGaussian() * offset); - entityitem.motionY = (double) ((float) rand.nextGaussian() * offset + 0.2F); - entityitem.motionZ = (double) ((float) rand.nextGaussian() * offset); + entityitem.motionX = (double) ((float) this.rand.nextGaussian() * offset); + entityitem.motionY = (double) ((float) this.rand.nextGaussian() * offset + 0.2F); + entityitem.motionZ = (double) ((float) this.rand.nextGaussian() * offset); par1World.spawnEntityInWorld(entityitem); } } @@ -125,25 +125,26 @@ public abstract class InventoryBlock extends BlockContainer //This class does not have an actual block placed in the world @Override - public IBlockState onBlockPlaced (World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) + public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { this.side = side; return world.getBlockState(pos).getBlock().getStateFromMeta(meta); } @Override - @SuppressWarnings("deprecation") // TODO: Remove this when setDirection calls updated. - public void onBlockPlacedBy (World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, ItemStack stack) + @SuppressWarnings("deprecation") + // TODO: Remove this when setDirection calls updated. + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, ItemStack stack) { TileEntity logic = world.getTileEntity(pos); if (logic instanceof IFacingLogic) { IFacingLogic direction = (IFacingLogic) logic; // TODO: Convert all setDirection calls to modern invokation, when that's ready. - if (side != null) + if (this.side != null) { - direction.setDirection(side, 0F, 0F, null); - side = null; + direction.setDirection(this.side, 0F, 0F, null); + this.side = null; } if (entityliving == null) { @@ -167,7 +168,7 @@ public abstract class InventoryBlock extends BlockContainer } @SuppressWarnings("unused") - public static boolean isActive (IBlockAccess world, BlockPos pos) + public static boolean isActive(IBlockAccess world, BlockPos pos) { TileEntity logic = world.getTileEntity(pos); if (logic instanceof IActiveLogic) @@ -177,16 +178,16 @@ public abstract class InventoryBlock extends BlockContainer return false; } - public int damageDropped (int meta) + public int damageDropped(int meta) { return meta; } /* IDebuggable */ @Override - public void onBlockClicked (World world, BlockPos pos, EntityPlayer player) + public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && player.getHeldItem().getItem() != null && player.getHeldItem().getItem() == Items.stick) + if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && player.getHeldItem().getItem() != null && player.getHeldItem().getItem() == Items.stick) { TileEntity te = world.getTileEntity(pos); if (te instanceof IDebuggable) @@ -197,4 +198,4 @@ public abstract class InventoryBlock extends BlockContainer super.onBlockClicked(world, pos, player); } -} \ No newline at end of file +} diff --git a/src/mantle/blocks/abstracts/InventoryLogic.java b/src/mantle/blocks/abstracts/InventoryLogic.java index dc0a6e0..9bc1099 100644 --- a/src/mantle/blocks/abstracts/InventoryLogic.java +++ b/src/mantle/blocks/abstracts/InventoryLogic.java @@ -21,7 +21,9 @@ import net.minecraft.world.World; public abstract class InventoryLogic extends TileEntity implements IInventory, IDebuggable { protected ItemStack[] inventory; + protected String invName; + protected int stackSizeLimit; public InventoryLogic(int invSize) @@ -31,65 +33,65 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I public InventoryLogic(int invSize, int maxStackSize) { - inventory = new ItemStack[invSize]; - stackSizeLimit = maxStackSize; + this.inventory = new ItemStack[invSize]; + this.stackSizeLimit = maxStackSize; } /* Inventory management */ @Override - public ItemStack getStackInSlot (int slot) + public ItemStack getStackInSlot(int slot) { - return slot < inventory.length ? inventory[slot] : null; + return slot < this.inventory.length ? this.inventory[slot] : null; } - public boolean isStackInSlot (int slot) + public boolean isStackInSlot(int slot) { - return slot < inventory.length && inventory[slot] != null; + return slot < this.inventory.length && this.inventory[slot] != null; } @Override - public int getSizeInventory () + public int getSizeInventory() { - return inventory.length; + return this.inventory.length; } @Override - public int getInventoryStackLimit () + public int getInventoryStackLimit() { - return stackSizeLimit; + return this.stackSizeLimit; } - public boolean canDropInventorySlot (int slot) + public boolean canDropInventorySlot(int slot) { return true; } @Override - public void setInventorySlotContents (int slot, ItemStack itemstack) + public void setInventorySlotContents(int slot, ItemStack itemstack) { - inventory[slot] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) + this.inventory[slot] = itemstack; + if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { - itemstack.stackSize = getInventoryStackLimit(); + itemstack.stackSize = this.getInventoryStackLimit(); } } @Override - public ItemStack decrStackSize (int slot, int quantity) + public ItemStack decrStackSize(int slot, int quantity) { - if (inventory[slot] != null) + if (this.inventory[slot] != null) { - if (inventory[slot].stackSize <= quantity) + if (this.inventory[slot].stackSize <= quantity) { - ItemStack stack = inventory[slot]; - inventory[slot] = null; + ItemStack stack = this.inventory[slot]; + this.inventory[slot] = null; return stack; } - ItemStack split = inventory[slot].splitStack(quantity); - if (inventory[slot].stackSize == 0) + ItemStack split = this.inventory[slot].splitStack(quantity); + if (this.inventory[slot].stackSize == 0) { - inventory[slot] = null; + this.inventory[slot] = null; } return split; } @@ -101,29 +103,32 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I /* Supporting methods */ @Override - public boolean isUseableByPlayer (EntityPlayer entityplayer) + public boolean isUseableByPlayer(EntityPlayer entityplayer) { - if (worldObj.getTileEntity(pos) != this) + if (this.worldObj.getTileEntity(this.pos) != this) + { return false; - + } else - return entityplayer.getDistance((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64D; + { + return entityplayer.getDistance((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64D; + } } - public abstract Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z); + public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z); /* NBT */ @Override - public void readFromNBT (NBTTagCompound tags) + public void readFromNBT(NBTTagCompound tags) { super.readFromNBT(tags); - readInventoryFromNBT(tags); + this.readInventoryFromNBT(tags); } - public void readInventoryFromNBT (NBTTagCompound tags) + public void readInventoryFromNBT(NBTTagCompound tags) { - super.readFromNBT(tags); + super.readFromNBT(tags); NBTTagList nbttaglist = tags.getTagList("Items", 10); this.inventory = new ItemStack[this.getSizeInventory()]; @@ -142,31 +147,31 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } - + //Not removed in case of things going terribly wrong -// super.readFromNBT(tags); -// this.invName = tags.getString("InvName"); -// NBTTagList nbttaglist = tags.getTagList("Items", 9); -// inventory = new ItemStack[getSizeInventory()]; -// for (int iter = 0; iter < nbttaglist.tagCount(); iter++) -// { -// NBTTagCompound tagList = (NBTTagCompound) nbttaglist.getCompoundTagAt(iter); -// byte slotID = tagList.getByte("Slot"); -// if (slotID >= 0 && slotID < inventory.length) -// { -// inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); -// } -// } + // super.readFromNBT(tags); + // this.invName = tags.getString("InvName"); + // NBTTagList nbttaglist = tags.getTagList("Items", 9); + // inventory = new ItemStack[getSizeInventory()]; + // for (int iter = 0; iter < nbttaglist.tagCount(); iter++) + // { + // NBTTagCompound tagList = (NBTTagCompound) nbttaglist.getCompoundTagAt(iter); + // byte slotID = tagList.getByte("Slot"); + // if (slotID >= 0 && slotID < inventory.length) + // { + // inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); + // } + // } } @Override - public void writeToNBT (NBTTagCompound tags) + public void writeToNBT(NBTTagCompound tags) { super.writeToNBT(tags); - writeInventoryToNBT(tags); + this.writeInventoryToNBT(tags); } - public void writeInventoryToNBT (NBTTagCompound tags) + public void writeInventoryToNBT(NBTTagCompound tags) { super.writeToNBT(tags); NBTTagList nbttaglist = new NBTTagList(); @@ -176,7 +181,7 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I if (this.inventory[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte)i); + nbttagcompound1.setByte("Slot", (byte) i); this.inventory[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } @@ -188,23 +193,23 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I { tags.setString("CustomName", this.invName); } - - //Not removed in case of things going terribly wrong -// if (invName != null) -// tags.setString("InvName", invName); -// NBTTagList nbttaglist = new NBTTagList(); -// for (int iter = 0; iter < inventory.length; iter++) -// { -// if (inventory[iter] != null) -// { -// NBTTagCompound tagList = new NBTTagCompound(); -// tagList.setByte("Slot", (byte) iter); -// inventory[iter].writeToNBT(tagList); -// nbttaglist.appendTag(tagList); -// } -// } -// -// tags.setTag("Items", nbttaglist); + + //Not removed in case of things going terribly wrong + // if (invName != null) + // tags.setString("InvName", invName); + // NBTTagList nbttaglist = new NBTTagList(); + // for (int iter = 0; iter < inventory.length; iter++) + // { + // if (inventory[iter] != null) + // { + // NBTTagCompound tagList = new NBTTagCompound(); + // tagList.setByte("Slot", (byte) iter); + // inventory[iter].writeToNBT(tagList); + // nbttaglist.appendTag(tagList); + // } + // } + // + // tags.setTag("Items", nbttaglist); } /* Cause of the heisenbug. Do not uncomment! */ @@ -212,75 +217,78 @@ public abstract class InventoryLogic extends TileEntity implements IInventory, I { super.readFromNBT(tags); } - + public void superWriteToNBT (NBTTagCompound tags) { super.writeToNBT(tags); }*/ /* Default implementations of hardly used methods */ - public ItemStack getStackInSlotOnClosing (int slot) + @Override + public ItemStack getStackInSlotOnClosing(int slot) { return null; } - public void openChest () + public void openChest() { } - public void closeChest () + public void closeChest() { } - protected abstract String getDefaultName (); + protected abstract String getDefaultName(); - public void setInvName (String name) + public void setInvName(String name) { this.invName = name; } - public String getInvName () + public String getInvName() { - return this.isInvNameLocalized() ? this.invName : getDefaultName(); + return this.isInvNameLocalized() ? this.invName : this.getDefaultName(); } public boolean hasCustomInventoryName() { - return isInvNameLocalized(); + return this.isInvNameLocalized(); } - - public boolean isInvNameLocalized () + + public boolean isInvNameLocalized() { return this.invName != null && this.invName.length() > 0; } @Override - public boolean isItemValidForSlot (int slot, ItemStack itemstack) + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { - if (slot < getSizeInventory()) + if (slot < this.getSizeInventory()) { - if (inventory[slot] == null || itemstack.stackSize + inventory[slot].stackSize <= getInventoryStackLimit()) + if (this.inventory[slot] == null || itemstack.stackSize + this.inventory[slot].stackSize <= this.getInventoryStackLimit()) + { return true; + } } return false; } - public void placeBlock (EntityLivingBase entity, ItemStack stack) + public void placeBlock(EntityLivingBase entity, ItemStack stack) { } - public void removeBlock () + public void removeBlock() { } - + /* IDebuggable */ @Override - public DebugData getDebugInfo (EntityPlayer player) + public DebugData getDebugInfo(EntityPlayer player) { String[] strs = new String[1]; - strs[0] = "invName: " + invName + ", inventory.length: " + inventory.length + ", stackSizeLimit: " + stackSizeLimit; - return new DebugData(player, getClass(), strs); + strs[0] = "invName: " + this.invName + ", inventory.length: " + this.inventory.length + ", stackSizeLimit: " + this.stackSizeLimit; + return new DebugData(player, this.getClass(), strs); } -} \ No newline at end of file +} diff --git a/src/mantle/blocks/abstracts/InventorySlab.java b/src/mantle/blocks/abstracts/InventorySlab.java index bd39aa8..47869dd 100644 --- a/src/mantle/blocks/abstracts/InventorySlab.java +++ b/src/mantle/blocks/abstracts/InventorySlab.java @@ -25,66 +25,76 @@ public abstract class InventorySlab extends InventoryBlock /* Rendering */ @Override - public boolean isFullCube () + public boolean isFullCube() { return false; } @Override - public boolean isOpaqueCube () + public boolean isOpaqueCube() { return false; } @Override - public boolean shouldSideBeRendered (IBlockAccess world, BlockPos pos, EnumFacing side) + public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, EnumFacing side) { if (side.getHorizontalIndex() > 1) + { return super.shouldSideBeRendered(world, pos, side); + } IBlockState iblockstate = world.getBlockState(pos); int meta = iblockstate.getBlock().getMetaFromState(iblockstate); boolean top = (meta | 8) == 1; if ((top && side == side.DOWN) || (!top && side == side.UP)) + { return true; + } return super.shouldSideBeRendered(world, pos, side); } @Override @SuppressWarnings("rawtypes") - public void addCollisionBoxesToList (World world, BlockPos pos, IBlockState state, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) + public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) { - setBlockBoundsBasedOnState(world, pos); - super.addCollisionBoxesToList(world,pos ,state, axisalignedbb, arraylist, entity); + this.setBlockBoundsBasedOnState(world, pos); + super.addCollisionBoxesToList(world, pos, state, axisalignedbb, arraylist, entity); } - public void setBlockBoundsForItemRender () + @Override + public void setBlockBoundsForItemRender() { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } - public void setBlockBoundsBasedOnState (IBlockAccess world, BlockPos pos, IBlockState state) + public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos, IBlockState state) { IBlockState iblockstate = world.getBlockState(pos); int meta = iblockstate.getBlock().getMetaFromState(iblockstate) / 8; float minY = meta == 1 ? 0.5F : 0.0F; float maxY = meta == 1 ? 1.0F : 0.5F; - setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); + this.setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); } - public int onBlockPlaced (World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata) + public int onBlockPlaced(World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata) { if (side == 1) + { return metadata; + } if (side == 0 || clickY >= 0.5F) + { return metadata | 8; + } return metadata; } - public int damageDropped (int meta) + @Override + public int damageDropped(int meta) { return meta % 8; } -} \ No newline at end of file +} diff --git a/src/mantle/blocks/abstracts/ItemBlockVariants.java b/src/mantle/blocks/abstracts/ItemBlockVariants.java index e295195..20cd084 100644 --- a/src/mantle/blocks/abstracts/ItemBlockVariants.java +++ b/src/mantle/blocks/abstracts/ItemBlockVariants.java @@ -7,27 +7,27 @@ import net.minecraft.item.ItemStack; public class ItemBlockVariants extends ItemBlock { - private final IBlockWithVariants variantBlock; + private final IBlockWithVariants variantBlock; - public ItemBlockVariants(Block block) - { - super(block); + public ItemBlockVariants(Block block) + { + super(block); - this.variantBlock = (IBlockWithVariants) block; - this.setMaxDamage(0); - this.setHasSubtypes(true); - } + this.variantBlock = (IBlockWithVariants) block; + this.setMaxDamage(0); + this.setHasSubtypes(true); + } - @Override - public int getMetadata(int damage) - { - return damage; - } + @Override + public int getMetadata(int damage) + { + return damage; + } - @Override - public String getUnlocalizedName(ItemStack stack) - { - return super.getUnlocalizedName() + "." + this.variantBlock.getVariantNameFromStack(stack); - } + @Override + public String getUnlocalizedName(ItemStack stack) + { + return super.getUnlocalizedName() + "." + this.variantBlock.getVariantNameFromStack(stack); + } } diff --git a/src/mantle/blocks/abstracts/MultiItemBlock.java b/src/mantle/blocks/abstracts/MultiItemBlock.java index e100405..e515bf6 100644 --- a/src/mantle/blocks/abstracts/MultiItemBlock.java +++ b/src/mantle/blocks/abstracts/MultiItemBlock.java @@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; /** - * + * * @author progwml6 * base class for itemBlocks with different unlocalized names based on metadata */ @@ -15,17 +15,24 @@ import net.minecraft.util.MathHelper; public class MultiItemBlock extends ItemBlock { private String blockType[]; + private String unlocalizedName; + private String append; + private int specialIndex[] = { -1, -1 }; public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String[] blockTypes) { super(b); if (itemBlockUnlocalizedName.isEmpty()) + { this.unlocalizedName = super.getUnlocalizedName(); + } else + { this.unlocalizedName = itemBlockUnlocalizedName; + } this.blockType = blockTypes; this.append = ""; } @@ -38,33 +45,37 @@ public class MultiItemBlock extends ItemBlock this.append = "." + appendToEnd; } - public void setSpecialIndex (int clampIndex, int stringBuilderIndex) + public void setSpecialIndex(int clampIndex, int stringBuilderIndex) { - specialIndex[0] = clampIndex; - specialIndex[1] = stringBuilderIndex; + this.specialIndex[0] = clampIndex; + this.specialIndex[1] = stringBuilderIndex; } - public int getMetadata (int meta) + @Override + public int getMetadata(int meta) { return meta; } - public String getUnlocalizedName (ItemStack itemstack) + @Override + public String getUnlocalizedName(ItemStack itemstack) { - int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, (specialIndex[0] > -1) ? specialIndex[0] : (blockType.length - 1)); - int sbIndex = (specialIndex[1] > -1) ? pos : (specialIndex[1] - pos); + int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, (this.specialIndex[0] > -1) ? this.specialIndex[0] : (this.blockType.length - 1)); + int sbIndex = (this.specialIndex[1] > -1) ? pos : (this.specialIndex[1] - pos); if (sbIndex < 0) + { sbIndex = -1 * sbIndex; + } try { - return (new StringBuilder()).append(unlocalizedName).append(".").append(blockType[sbIndex - 1]).append(append).toString(); + return (new StringBuilder()).append(this.unlocalizedName).append(".").append(this.blockType[sbIndex - 1]).append(this.append).toString(); } catch (ArrayIndexOutOfBoundsException ex) { logger.warn("[MultiItemBlock] Caught array index error in getUnlocalizedName: " + ex.getMessage()); - logger.warn("[MultiItemBlock] Returning unlocalized name: " + getUnlocalizedName()); - return getUnlocalizedName(); + logger.warn("[MultiItemBlock] Returning unlocalized name: " + this.getUnlocalizedName()); + return this.getUnlocalizedName(); } } diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/mantle/blocks/abstracts/MultiServantLogic.java index 92de706..c157281 100644 --- a/src/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/mantle/blocks/abstracts/MultiServantLogic.java @@ -19,187 +19,196 @@ import net.minecraft.world.World; public class MultiServantLogic extends TileEntity implements IServantLogic, IDebuggable { boolean hasMaster; + BlockPos master; + Block masterBlock; + IBlockState state; - public boolean canUpdate () + public boolean canUpdate() { return false; } - public boolean getHasMaster () + public boolean getHasMaster() { - return hasMaster; + return this.hasMaster; } - public boolean hasValidMaster () + public boolean hasValidMaster() { - if (!hasMaster) + if (!this.hasMaster) + { return false; + } - if (worldObj.getBlockState(master).getBlock() == masterBlock && worldObj.getBlockState(master) == state) + if (this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj.getBlockState(this.master) == this.state) + { return true; - + } else { - hasMaster = false; - master = null; + this.hasMaster = false; + this.master = null; return false; } } - public BlockPos getMasterPosition () + @Override + public BlockPos getMasterPosition() { - return master; + return this.master; } - public void overrideMaster (BlockPos pos) + public void overrideMaster(BlockPos pos) { - hasMaster = true; - master = pos; - state = worldObj.getBlockState(master); - masterBlock = state.getBlock(); + this.hasMaster = true; + this.master = pos; + this.state = this.worldObj.getBlockState(this.master); + this.masterBlock = this.state.getBlock(); } - public void removeMaster () + public void removeMaster() { - hasMaster = false; - master = null; - masterBlock = null; - state = null; + this.hasMaster = false; + this.master = null; + this.masterBlock = null; + this.state = null; } @Override - public boolean setPotentialMaster (IMasterLogic master, World w, BlockPos pos) + public boolean setPotentialMaster(IMasterLogic master, World w, BlockPos pos) { - return !hasMaster; + return !this.hasMaster; } @Deprecated - public boolean verifyMaster (IMasterLogic logic, BlockPos pos) + public boolean verifyMaster(IMasterLogic logic, BlockPos pos) { - return master.equals(pos) && worldObj.getBlockState(pos) == state && worldObj.getBlockState(pos).getBlock() == masterBlock; + 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) + public boolean verifyMaster(IMasterLogic logic, World world, BlockPos pos) { - if (hasMaster) + if (this.hasMaster) { - return hasValidMaster(); + return this.hasValidMaster(); } else { - overrideMaster(pos); + this.overrideMaster(pos); return true; } } @Override - public void invalidateMaster (IMasterLogic master, World w, BlockPos pos) + public void invalidateMaster(IMasterLogic master, World w, BlockPos pos) { - hasMaster = false; + this.hasMaster = false; master = null; } - public void notifyMasterOfChange () + @Override + public void notifyMasterOfChange() { - if (hasValidMaster()) + if (this.hasValidMaster()) { - IMasterLogic logic = (IMasterLogic) worldObj.getTileEntity(pos); - logic.notifyChange(this, pos); + IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.pos); + logic.notifyChange(this, this.pos); } } - public void readCustomNBT (NBTTagCompound tags) + public void readCustomNBT(NBTTagCompound tags) { - hasMaster = tags.getBoolean("TiedToMaster"); - if (hasMaster) + this.hasMaster = tags.getBoolean("TiedToMaster"); + if (this.hasMaster) { int xCenter = tags.getInteger("xCenter"); int yCenter = tags.getInteger("yCenter"); int zCenter = tags.getInteger("zCenter"); - master = new BlockPos(xCenter, yCenter, zCenter); - masterBlock = BlockUtils.getBlockFromUniqueName(tags.getString("MasterBlockName")); + this.master = new BlockPos(xCenter, yCenter, zCenter); + this.masterBlock = BlockUtils.getBlockFromUniqueName(tags.getString("MasterBlockName")); // TODO: Make this a byte. - state = Block.getStateById(tags.getInteger("masterState")); + this.state = Block.getStateById(tags.getInteger("masterState")); } } - public void writeCustomNBT (NBTTagCompound tags) + public void writeCustomNBT(NBTTagCompound tags) { - tags.setBoolean("TiedToMaster", hasMaster); - if (hasMaster) + tags.setBoolean("TiedToMaster", this.hasMaster); + if (this.hasMaster) { - tags.setInteger("xCenter", master.getX()); - tags.setInteger("yCenter", master.getY()); - tags.setInteger("zCenter", master.getZ()); - tags.setString("MasterBlockName", BlockUtils.getUniqueName(masterBlock)); + tags.setInteger("xCenter", this.master.getX()); + tags.setInteger("yCenter", this.master.getY()); + tags.setInteger("zCenter", this.master.getZ()); + tags.setString("MasterBlockName", BlockUtils.getUniqueName(this.masterBlock)); // TODO: Make this a byte. - tags.setInteger("masterState", Block.getStateId(state)); + tags.setInteger("masterState", Block.getStateId(this.state)); } } @Override - public void readFromNBT (NBTTagCompound tags) + public void readFromNBT(NBTTagCompound tags) { super.readFromNBT(tags); - readCustomNBT(tags); + this.readCustomNBT(tags); } @Override - public void writeToNBT (NBTTagCompound tags) + public void writeToNBT(NBTTagCompound tags) { super.writeToNBT(tags); - writeCustomNBT(tags); + this.writeCustomNBT(tags); } /* Packets */ @Override - public Packet getDescriptionPacket () + public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); - writeCustomNBT(tag); - return new S35PacketUpdateTileEntity(pos, 1, tag); + this.writeCustomNBT(tag); + return new S35PacketUpdateTileEntity(this.pos, 1, tag); } @Override - public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet) + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { - readCustomNBT(packet.getNbtCompound()); - worldObj.notifyLightSet(pos); - worldObj.markBlockForUpdate(pos); + this.readCustomNBT(packet.getNbtCompound()); + this.worldObj.notifyLightSet(this.pos); + this.worldObj.markBlockForUpdate(this.pos); } /* IDebuggable */ @Override - public DebugData getDebugInfo (EntityPlayer player) + public DebugData getDebugInfo(EntityPlayer player) { String[] strs = new String[2]; - strs[0] = "Location: x" + pos.getX() + ", y" + pos.getY() + ", z" + pos.getZ(); - if (hasMaster) + strs[0] = "Location: x" + this.pos.getX() + ", y" + this.pos.getY() + ", z" + this.pos.getZ(); + if (this.hasMaster) { - strs[1] = "masterBlock: " + masterBlock.toString() + ", masterMeat: " + state.toString(); + strs[1] = "masterBlock: " + this.masterBlock.toString() + ", masterMeat: " + this.state.toString(); } else { strs[1] = "No active master."; } - return new DebugData(player, getClass(), strs); + return new DebugData(player, this.getClass(), strs); } - public World getWorld () + @Override + public World getWorld() { - return worldObj; + return this.worldObj; } @Deprecated - public boolean setMaster (BlockPos pos) + public boolean setMaster(BlockPos pos) { - if (!hasMaster || worldObj.getBlockState(master) != state || (worldObj.getBlockState(master).getBlock() != masterBlock)) + if (!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj.getBlockState(this.master).getBlock() != this.masterBlock)) { - overrideMaster(pos); + this.overrideMaster(pos); return true; } else diff --git a/src/mantle/blocks/iface/IActiveLogic.java b/src/mantle/blocks/iface/IActiveLogic.java index c670f8d..51e7e5c 100644 --- a/src/mantle/blocks/iface/IActiveLogic.java +++ b/src/mantle/blocks/iface/IActiveLogic.java @@ -7,7 +7,7 @@ package mantle.blocks.iface; */ public interface IActiveLogic { - public boolean getActive (); + public boolean getActive(); - public void setActive (boolean flag); + public void setActive(boolean flag); } diff --git a/src/mantle/blocks/iface/ICrop.java b/src/mantle/blocks/iface/ICrop.java index da0b3fb..9473de2 100644 --- a/src/mantle/blocks/iface/ICrop.java +++ b/src/mantle/blocks/iface/ICrop.java @@ -1,6 +1,5 @@ package mantle.blocks.iface; - import java.util.Collections; import java.util.List; @@ -24,11 +23,11 @@ public interface ICrop * @param type * @return A list of items harvested. If no items are returned, NO_YIELD should be passed. */ - public List harvestCrop (IBlockAccess world, BlockPos pos, HarvestType type); + public List harvestCrop(IBlockAccess world, BlockPos pos, HarvestType type); - public boolean isFullyGrown (IBlockAccess world, BlockPos pos); + public boolean isFullyGrown(IBlockAccess world, BlockPos pos); - public boolean hasYield (IBlockAccess world, BlockPos pos); + public boolean hasYield(IBlockAccess world, BlockPos pos); - public void growthTick (IBlockAccess world, BlockPos pos); + public void growthTick(IBlockAccess world, BlockPos pos); } diff --git a/src/mantle/blocks/iface/IFacingLogic.java b/src/mantle/blocks/iface/IFacingLogic.java index a9667ed..ae1c76d 100644 --- a/src/mantle/blocks/iface/IFacingLogic.java +++ b/src/mantle/blocks/iface/IFacingLogic.java @@ -11,11 +11,10 @@ import net.minecraft.util.EnumFacing; public interface IFacingLogic { - public byte getRenderDirection (); + public byte getRenderDirection(); - public EnumFacing getForgeDirection (); + public EnumFacing getForgeDirection(); - - public void setDirection(EnumFacing facing, float yaw, float pitch, EntityLivingBase player); + public void setDirection(EnumFacing facing, float yaw, float pitch, EntityLivingBase player); } diff --git a/src/mantle/blocks/iface/IMasterLogic.java b/src/mantle/blocks/iface/IMasterLogic.java index cd3acca..9a9e690 100644 --- a/src/mantle/blocks/iface/IMasterLogic.java +++ b/src/mantle/blocks/iface/IMasterLogic.java @@ -5,8 +5,8 @@ import net.minecraft.util.BlockPos; public interface IMasterLogic { /** Called when servants change their state - * + * * @param pos servant position */ - public void notifyChange (IServantLogic servant, BlockPos pos); + public void notifyChange(IServantLogic servant, BlockPos pos); } diff --git a/src/mantle/blocks/iface/IMasterNode.java b/src/mantle/blocks/iface/IMasterNode.java index 1906f92..f33b884 100644 --- a/src/mantle/blocks/iface/IMasterNode.java +++ b/src/mantle/blocks/iface/IMasterNode.java @@ -2,7 +2,7 @@ package mantle.blocks.iface; public interface IMasterNode extends IMasterLogic, IServantLogic { - public boolean isCurrentlyMaster (); + public boolean isCurrentlyMaster(); - public boolean isEquivalentMaster (IMasterLogic master); + public boolean isEquivalentMaster(IMasterLogic master); } diff --git a/src/mantle/blocks/iface/IServantLogic.java b/src/mantle/blocks/iface/IServantLogic.java index 4ca6e86..aeaf726 100644 --- a/src/mantle/blocks/iface/IServantLogic.java +++ b/src/mantle/blocks/iface/IServantLogic.java @@ -5,37 +5,37 @@ import net.minecraft.world.World; public interface IServantLogic { - public BlockPos getMasterPosition (); + public BlockPos getMasterPosition(); /** The block should already have a valid master */ - public void notifyMasterOfChange (); + public void notifyMasterOfChange(); /** 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 */ - public boolean setPotentialMaster (IMasterLogic master, World world, BlockPos pos); + public boolean setPotentialMaster(IMasterLogic master, World world, BlockPos pos); /** Used to set and verify that this is the block's master - * + * * @param master - * @param world + * @param world * @param pos position of master * @return Is this block tied to this master? */ - public boolean verifyMaster (IMasterLogic master, World world, BlockPos pos); + public boolean verifyMaster(IMasterLogic master, World world, BlockPos pos); /** Exactly what it says on the tin - * + * * @param master - * @param world + * @param world * @param pos position of master */ - public void invalidateMaster (IMasterLogic master, World world, BlockPos pos); + public void invalidateMaster(IMasterLogic master, World world, BlockPos pos); } diff --git a/src/mantle/blocks/util/IBlockWithVariants.java b/src/mantle/blocks/util/IBlockWithVariants.java index dc9458f..4c56312 100644 --- a/src/mantle/blocks/util/IBlockWithVariants.java +++ b/src/mantle/blocks/util/IBlockWithVariants.java @@ -4,5 +4,5 @@ import net.minecraft.item.ItemStack; public interface IBlockWithVariants { - String getVariantNameFromStack(ItemStack stack); -} \ No newline at end of file + String getVariantNameFromStack(ItemStack stack); +} diff --git a/src/mantle/books/BookData.java b/src/mantle/books/BookData.java index 4fd63f4..09fa53e 100644 --- a/src/mantle/books/BookData.java +++ b/src/mantle/books/BookData.java @@ -8,23 +8,32 @@ import org.w3c.dom.Document; public class BookData { public String unlocalizedName = ""; + public String toolTip = ""; + public String modID = ""; + public ResourceLocation leftImage = new ResourceLocation("mantle", "textures/gui/bookleft.png"); + public ResourceLocation rightImage = new ResourceLocation("mantle", "textures/gui/bookright.png"); + public ResourceLocation itemImage = new ResourceLocation("mantle", "textures/items/mantlebook_blue.png"); + public Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml"); + //font can be left null if so, the default from mantle will be used public FontRenderer font; + public Boolean isTranslatable = false; + public boolean isFromZip = false; - public Document getDoc () + public Document getDoc() { return this.doc; } - public String getFullUnlocalizedName () + public String getFullUnlocalizedName() { return this.modID + ":" + this.unlocalizedName; } diff --git a/src/mantle/books/BookDataStore.java b/src/mantle/books/BookDataStore.java index de7f13f..7129607 100644 --- a/src/mantle/books/BookDataStore.java +++ b/src/mantle/books/BookDataStore.java @@ -8,44 +8,50 @@ import com.google.common.collect.Lists; public class BookDataStore { private static HashBiMap data = HashBiMap.create(); + private static HashBiMap intMap = HashBiMap.create(); - private static List zipBooks= Lists.newArrayList(); - public static void addBook (BookData bd) + + private static List zipBooks = Lists.newArrayList(); + + public static void addBook(BookData bd) { int insertOrder = data.size(); data.put(bd.getFullUnlocalizedName(), bd); intMap.put(insertOrder, bd.getFullUnlocalizedName()); - if(bd.isFromZip) + if (bd.isFromZip) + { zipBooks.add(bd.getFullUnlocalizedName()); - + } + } - public static BookData getBookfromName (String ModID, String unlocalizedName) + public static BookData getBookfromName(String ModID, String unlocalizedName) { return getBookFromName(ModID + ":" + unlocalizedName); } - public static BookData getBookFromName (String fullBookName) + public static BookData getBookFromName(String fullBookName) { return data.get(fullBookName); } - public static BookData getBookfromID (int bookIDNum) + public static BookData getBookfromID(int bookIDNum) { return data.get(intMap.get(bookIDNum)); } - public static int getIDFromName (String FullUnlocalizedName) + public static int getIDFromName(String FullUnlocalizedName) { return intMap.inverse().get(FullUnlocalizedName); } - public static int getIDFromBook (BookData b) + public static int getIDFromBook(BookData b) { return getIDFromName(data.inverse().get(b)); } - - public static List getZipBooks(){ + + public static List getZipBooks() + { return zipBooks; } } diff --git a/src/mantle/books/ManualReader.java b/src/mantle/books/ManualReader.java index 5e9a204..6b2ac49 100644 --- a/src/mantle/books/ManualReader.java +++ b/src/mantle/books/ManualReader.java @@ -13,7 +13,7 @@ import org.w3c.dom.Document; public class ManualReader { - public static Document readManual (String location) + public static Document readManual(String location) { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); @@ -29,7 +29,8 @@ public class ManualReader return null; } } - public static Document readManual (InputStream is, String filenameOrLocation) + + public static Document readManual(InputStream is, String filenameOrLocation) { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); diff --git a/src/mantle/books/client/BookImage.java b/src/mantle/books/client/BookImage.java index 8482568..62c42b4 100644 --- a/src/mantle/books/client/BookImage.java +++ b/src/mantle/books/client/BookImage.java @@ -3,12 +3,16 @@ package mantle.books.client; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.util.ResourceLocation; -public class BookImage { +public class BookImage +{ public int height, width; + public DynamicTexture texture; + public ResourceLocation resource; - public BookImage(int width, int height, DynamicTexture texture, ResourceLocation resource) { + public BookImage(int width, int height, DynamicTexture texture, ResourceLocation resource) + { this.width = width; this.height = height; this.texture = texture; diff --git a/src/mantle/books/external/BookIS.java b/src/mantle/books/external/BookIS.java index f0ecd76..e38af7f 100644 --- a/src/mantle/books/external/BookIS.java +++ b/src/mantle/books/external/BookIS.java @@ -14,9 +14,9 @@ public class BookIS public int stackSize; - public int getStackSize () + public int getStackSize() { - return stackSize >= 0 ? stackSize : 1; + return this.stackSize >= 0 ? this.stackSize : 1; } } diff --git a/src/mantle/books/external/BookLoad.java b/src/mantle/books/external/BookLoad.java index 1c0bc0c..6ef315c 100644 --- a/src/mantle/books/external/BookLoad.java +++ b/src/mantle/books/external/BookLoad.java @@ -4,17 +4,26 @@ import com.google.gson.JsonObject; public class BookLoad { -public String unlocalizedName; -public String tooltip; -public boolean translatable; -public String BookIcon; -public String LeftImage; -public String rightImage; -public BookIS[] registerItemStacks; -public JsonObject[] smallRecipes; -public JsonObject[] largeRecipes; -public JsonObject[] furnaceRecipes; -public JsonObject[] manualIcons; + public String unlocalizedName; + public String tooltip; + + public boolean translatable; + + public String BookIcon; + + public String LeftImage; + + public String rightImage; + + public BookIS[] registerItemStacks; + + public JsonObject[] smallRecipes; + + public JsonObject[] largeRecipes; + + public JsonObject[] furnaceRecipes; + + public JsonObject[] manualIcons; } diff --git a/src/mantle/books/external/ZipLoader.java b/src/mantle/books/external/ZipLoader.java index 97c663c..3bc19bb 100644 --- a/src/mantle/books/external/ZipLoader.java +++ b/src/mantle/books/external/ZipLoader.java @@ -1,5 +1,7 @@ package mantle.books.external; +import static mantle.lib.CoreRepo.logger; + import java.awt.image.BufferedImage; import java.io.File; import java.util.Enumeration; @@ -9,7 +11,6 @@ import java.util.zip.ZipFile; import javax.imageio.ImageIO; -import static mantle.lib.CoreRepo.logger; import mantle.books.BookData; import mantle.books.BookDataStore; import mantle.books.ManualReader; @@ -21,8 +22,9 @@ import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.relauncher.Side; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; @@ -33,14 +35,11 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.relauncher.Side; - public class ZipLoader { public static Map loadedIS = Maps.newHashMap(); - public static BookData loadZip (File f) + public static BookData loadZip(File f) { BookLoad bl; String flName = ""; @@ -187,9 +186,9 @@ public class ZipLoader b.isTranslatable = bl.translatable; b.leftImage = bl.LeftImage == null ? new ResourceLocation("mantle", "textures/gui/bookleft.png") : MantleClientRegistry.getBookImageFromCache(bl.LeftImage).resource; b.rightImage = bl.rightImage == null ? new ResourceLocation("mantle", "textures/gui/bookright.png") - : MantleClientRegistry.getBookImageFromCache(bl.rightImage).resource; + : MantleClientRegistry.getBookImageFromCache(bl.rightImage).resource; b.itemImage = bl.BookIcon == null ? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png") - : MantleClientRegistry.getBookImageFromCache(bl.BookIcon).resource; + : MantleClientRegistry.getBookImageFromCache(bl.BookIcon).resource; b.isFromZip = true; BookDataStore.addBook(b); } @@ -226,12 +225,12 @@ public class ZipLoader return null; } - public static boolean isImage (String ext) + public static boolean isImage(String ext) { return ext.equalsIgnoreCase("png"); } - public static ItemStack[] getISArray (JsonArray a) + public static ItemStack[] getISArray(JsonArray a) { ItemStack[] is = new ItemStack[a.size()]; ItemStack loadedStack; diff --git a/src/mantle/client/MProxyClient.java b/src/mantle/client/MProxyClient.java index e0d1635..dc13871 100644 --- a/src/mantle/client/MProxyClient.java +++ b/src/mantle/client/MProxyClient.java @@ -20,10 +20,8 @@ import mantle.client.pages.SidebarPage; import mantle.client.pages.TextPage; import mantle.client.pages.TitlePage; import mantle.common.MProxyCommon; -import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class MProxyClient extends MProxyCommon @@ -32,29 +30,31 @@ public class MProxyClient extends MProxyCommon public static final String MINECRAFT_ASCII_PATH = "minecraft:textures/font/ascii.png"; /* Registers any rendering code. */ - public void registerRenderer () + @Override + public void registerRenderer() { ModelHelper.registerItem(Mantle.mantleBook, "mantleBook"); } public static Map> pageClasses = new HashMap>(); - public static void registerManualPage (String type, Class clazz) + public static void registerManualPage(String type, Class clazz) { pageClasses.put(type, clazz); } - public static Class getPageClass (String type) + public static Class getPageClass(String type) { return pageClasses.get(type); } - public void readManuals () + @Override + public void readManuals() { - initManualPages(); + this.initManualPages(); } - void initManualPages () + void initManualPages() { MProxyClient.registerManualPage("crafting", CraftingPage.class); MProxyClient.registerManualPage("picture", PicturePage.class); @@ -69,17 +69,23 @@ public class MProxyClient extends MProxyCommon } @Override - public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == manualGuiID) { ItemStack stack = player.getCurrentEquippedItem(); if (stack == null) + { logger.error("Null stack in book."); + } if (stack != null && stack.getItem() == null) + { logger.error("Null item in book."); + } if (stack != null && stack.getItem() != null && stack.getItem().getUnlocalizedName() == null) + { logger.error("Null unlocalized name in book."); + } else { return new GuiManual(stack, MProxyClient.getBookDataFromStack(stack)); @@ -88,7 +94,7 @@ public class MProxyClient extends MProxyCommon return null; } - private static BookData getBookDataFromStack (ItemStack stack) + private static BookData getBookDataFromStack(ItemStack stack) { return BookDataStore.getBookFromName(stack.getItem().getUnlocalizedName(stack)); } diff --git a/src/mantle/client/ModelHelper.java b/src/mantle/client/ModelHelper.java index d8c031f..aca485c 100644 --- a/src/mantle/client/ModelHelper.java +++ b/src/mantle/client/ModelHelper.java @@ -9,7 +9,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelHelper +public class ModelHelper { public static void registerItem(Item item, int metadata, String itemName) { @@ -31,4 +31,4 @@ public class ModelHelper { registerItem(item, 0, itemName); } -} \ No newline at end of file +} diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index bee1882..6a070fe 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -31,7 +31,7 @@ public class ModelVariant Item item = Item.getItemFromBlock(block); this.registerItemModel(item, variant.getName(), variant.getMeta()); - ModelBakery.addVariantName(item, (MOD_ID + ":") + variant.getName()); + ModelBakery.addVariantName(item, (this.MOD_ID + ":") + variant.getName()); } } @@ -58,6 +58,6 @@ public class ModelVariant private ModelResourceLocation getModelResource(String name, String type) { - return new ModelResourceLocation((MOD_ID + ":") + name, type); + return new ModelResourceLocation((this.MOD_ID + ":") + name, type); } } diff --git a/src/mantle/client/gui/GuiManual.java b/src/mantle/client/gui/GuiManual.java index d6a4214..b3f8aa1 100644 --- a/src/mantle/client/gui/GuiManual.java +++ b/src/mantle/client/gui/GuiManual.java @@ -10,6 +10,8 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; import org.w3c.dom.Document; @@ -17,28 +19,37 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) public class GuiManual extends GuiScreen { ItemStack itemstackBook; + Document manual; + public RenderItem renderitem = Minecraft.getMinecraft().getRenderItem(); + int bookImageWidth = 206; + int bookImageHeight = 200; + int bookTotalPages = 1; + int currentPage; + int maxPages; + BookData bData; private TurnPageButton buttonNextPage; + private TurnPageButton buttonPreviousPage; + private static ResourceLocation bookRight;// = new ResourceLocation("mantle", "textures/gui/bookright.png"); + private static ResourceLocation bookLeft;// = new ResourceLocation("mantle", "textures/gui/bookleft.png"); BookPage pageLeft; + BookPage pageRight; public FontRenderer fonts = Minecraft.getMinecraft().fontRendererObj; @@ -47,10 +58,12 @@ public class GuiManual extends GuiScreen { this.mc = Minecraft.getMinecraft(); this.itemstackBook = stack; - currentPage = 0; //Stack page - manual = data.getDoc(); + this.currentPage = 0; //Stack page + this.manual = data.getDoc(); if (data.font != null) + { this.fonts = data.font; + } bookLeft = data.leftImage; bookRight = data.rightImage; this.bData = data; @@ -69,50 +82,64 @@ public class GuiManual extends GuiScreen this.initGui(); }*/ + @Override @SuppressWarnings("unchecked") - public void initGui () + public void initGui() { - maxPages = manual.getElementsByTagName("page").getLength(); - updateText(); + this.maxPages = this.manual.getElementsByTagName("page").getLength(); + this.updateText(); int xPos = (this.width) / 2; //TODO Width? //TODO buttonList - this.buttonList.add(this.buttonNextPage = new TurnPageButton(1, xPos + bookImageWidth - 50, 180, true, bData)); - this.buttonList.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false, bData)); + this.buttonList.add(this.buttonNextPage = new TurnPageButton(1, xPos + this.bookImageWidth - 50, 180, true, this.bData)); + this.buttonList.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - this.bookImageWidth + 24, 180, false, this.bData)); } - protected void actionPerformed (GuiButton button) + @Override + protected void actionPerformed(GuiButton button) { if (button.enabled) { if (button.id == 1) - currentPage += 2; + { + this.currentPage += 2; + } if (button.id == 2) - currentPage -= 2; + { + this.currentPage -= 2; + } - updateText(); + this.updateText(); } } - void updateText () + void updateText() { - if (maxPages % 2 == 1) + if (this.maxPages % 2 == 1) { - if (currentPage > maxPages) - currentPage = maxPages; + if (this.currentPage > this.maxPages) + { + this.currentPage = this.maxPages; + } } else { - if (currentPage >= maxPages) - currentPage = maxPages - 2; + if (this.currentPage >= this.maxPages) + { + this.currentPage = this.maxPages - 2; + } + } + if (this.currentPage % 2 == 1) + { + this.currentPage--; + } + if (this.currentPage < 0) + { + this.currentPage = 0; } - if (currentPage % 2 == 1) - currentPage--; - if (currentPage < 0) - currentPage = 0; - NodeList nList = manual.getElementsByTagName("page"); + NodeList nList = this.manual.getElementsByTagName("page"); - Node node = nList.item(currentPage); + Node node = nList.item(this.currentPage); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; @@ -121,9 +148,9 @@ public class GuiManual extends GuiScreen { try { - pageLeft = clazz.newInstance(); - pageLeft.init(this, 0); - pageLeft.readPageFromXML(element); + this.pageLeft = clazz.newInstance(); + this.pageLeft.init(this, 0); + this.pageLeft.readPageFromXML(element); } catch (Exception e) { @@ -131,11 +158,11 @@ public class GuiManual extends GuiScreen } else { - pageLeft = null; + this.pageLeft = null; } } - node = nList.item(currentPage + 1); + node = nList.item(this.currentPage + 1); if (node != null && node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; @@ -144,9 +171,9 @@ public class GuiManual extends GuiScreen { try { - pageRight = clazz.newInstance(); - pageRight.init(this, 1); - pageRight.readPageFromXML(element); + this.pageRight = clazz.newInstance(); + this.pageRight.init(this, 1); + this.pageRight.readPageFromXML(element); } catch (Exception e) { @@ -154,16 +181,17 @@ public class GuiManual extends GuiScreen } else { - pageLeft = null; + this.pageLeft = null; } } else { - pageRight = null; + this.pageRight = null; } } - public void drawScreen (int par1, int par2, float par3) + @Override + public void drawScreen(int par1, int par2, float par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(bookRight); @@ -178,23 +206,32 @@ public class GuiManual extends GuiScreen super.drawScreen(par1, par2, par3); //16, 12, 220, 12 - if (pageLeft != null) - pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12); - if (pageRight != null) - pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12); - if (pageLeft != null) - pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, bData.isTranslatable); - if (pageRight != null) - pageRight.renderContentLayer(localWidth + 220, localHeight + 12, bData.isTranslatable); + if (this.pageLeft != null) + { + this.pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12); + } + if (this.pageRight != null) + { + this.pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12); + } + if (this.pageLeft != null) + { + this.pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, this.bData.isTranslatable); + } + if (this.pageRight != null) + { + this.pageRight.renderContentLayer(localWidth + 220, localHeight + 12, this.bData.isTranslatable); + } } - public Minecraft getMC () + public Minecraft getMC() { - return mc; + return this.mc; } - public boolean doesGuiPauseGame () + @Override + public boolean doesGuiPauseGame() { return false; } diff --git a/src/mantle/client/gui/TurnPageButton.java b/src/mantle/client/gui/TurnPageButton.java index 2aa2844..f5a7fb2 100644 --- a/src/mantle/client/gui/TurnPageButton.java +++ b/src/mantle/client/gui/TurnPageButton.java @@ -4,12 +4,11 @@ import mantle.books.BookData; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.opengl.GL11; + @SideOnly(Side.CLIENT) public class TurnPageButton extends GuiButton { @@ -17,6 +16,7 @@ public class TurnPageButton extends GuiButton * True for pointing right (next page), false for pointing left (previous page). */ private final boolean nextPage; + private static ResourceLocation background;// = new ResourceLocation("tinker", "textures/gui/bookleft.png"); public TurnPageButton(int par1, int par2, int par3, boolean par4, BookData data) @@ -29,7 +29,8 @@ public class TurnPageButton extends GuiButton /** * Draws this button to the screen. */ - public void drawButton (Minecraft par1Minecraft, int par2, int par3) + @Override + public void drawButton(Minecraft par1Minecraft, int par2, int par3) { if (this.visible) { diff --git a/src/mantle/client/pages/BlankPage.java b/src/mantle/client/pages/BlankPage.java index d9fa597..8815653 100644 --- a/src/mantle/client/pages/BlankPage.java +++ b/src/mantle/client/pages/BlankPage.java @@ -6,12 +6,12 @@ public class BlankPage extends BookPage { @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { } @Override - public void renderContentLayer (int localwidth, int localheight, boolean isTranslatable) + public void renderContentLayer(int localwidth, int localheight, boolean isTranslatable) { } diff --git a/src/mantle/client/pages/BookPage.java b/src/mantle/client/pages/BookPage.java index f9359cd..8667107 100644 --- a/src/mantle/client/pages/BookPage.java +++ b/src/mantle/client/pages/BookPage.java @@ -7,19 +7,20 @@ import org.w3c.dom.Element; public abstract class BookPage { protected GuiManual manual; + protected int side; - public void init (GuiManual manual, int side) + public void init(GuiManual manual, int side) { this.manual = manual; this.side = side; } - public abstract void readPageFromXML (Element element); + public abstract void readPageFromXML(Element element); - public void renderBackgroundLayer (int localwidth, int localheight) + public void renderBackgroundLayer(int localwidth, int localheight) { } - public abstract void renderContentLayer (int localwidth, int localheight, boolean isTranslatable); + public abstract void renderContentLayer(int localwidth, int localheight, boolean isTranslatable); } diff --git a/src/mantle/client/pages/ContentsTablePage.java b/src/mantle/client/pages/ContentsTablePage.java index f36f414..a27f39f 100644 --- a/src/mantle/client/pages/ContentsTablePage.java +++ b/src/mantle/client/pages/ContentsTablePage.java @@ -13,51 +13,61 @@ import org.w3c.dom.NodeList; public class ContentsTablePage extends BookPage { String text; + String[] iconText; + ItemStack[] icons; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } nodes = element.getElementsByTagName("link"); - iconText = new String[nodes.getLength()]; - icons = new ItemStack[nodes.getLength()]; + this.iconText = new String[nodes.getLength()]; + this.icons = new ItemStack[nodes.getLength()]; for (int i = 0; i < nodes.getLength(); i++) { NodeList children = nodes.item(i).getChildNodes(); - iconText[i] = children.item(1).getTextContent(); - icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent()); + this.iconText[i] = children.item(1).getTextContent(); + this.icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent()); } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { - if (text != null) + if (this.text != null) { if (isTranslatable) - text = StatCollector.translateToLocal(text); - manual.fonts.drawString("\u00a7n" + text, localWidth + 25 + manual.fonts.getStringWidth(text) / 2, localHeight + 4, 0); + { + this.text = StatCollector.translateToLocal(this.text); + } + this.manual.fonts.drawString("\u00a7n" + this.text, localWidth + 25 + this.manual.fonts.getStringWidth(this.text) / 2, localHeight + 4, 0); } GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); - manual.renderitem.zLevel = 100; - for (int i = 0; i < icons.length; i++) + this.manual.renderitem.zLevel = 100; + for (int i = 0; i < this.icons.length; i++) { - manual.renderitem.renderItemIntoGUI(icons[i], localWidth + 16, localHeight + 18 * i + 18); + this.manual.renderitem.renderItemIntoGUI(this.icons[i], localWidth + 16, localHeight + 18 * i + 18); int yOffset = 18; if (isTranslatable) - iconText[i] = StatCollector.translateToLocal(iconText[i]); + { + this.iconText[i] = StatCollector.translateToLocal(this.iconText[i]); + } - if (iconText[i].length() > 40) + if (this.iconText[i].length() > 40) + { yOffset = 13; - manual.fonts.drawString(iconText[i], localWidth + 38, localHeight + 18 * i + yOffset, 0); + } + this.manual.fonts.drawString(this.iconText[i], localWidth + 38, localHeight + 18 * i + yOffset, 0); } - manual.renderitem.zLevel = 0; + this.manual.renderitem.zLevel = 0; RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); } diff --git a/src/mantle/client/pages/CraftingPage.java b/src/mantle/client/pages/CraftingPage.java index ba28944..0af7be8 100644 --- a/src/mantle/client/pages/CraftingPage.java +++ b/src/mantle/client/pages/CraftingPage.java @@ -14,94 +14,127 @@ import org.w3c.dom.NodeList; public class CraftingPage extends BookPage { String text; + String size; + ItemStack[] icons; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } nodes = element.getElementsByTagName("name"); if (nodes != null) - icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + { + this.icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + } nodes = element.getElementsByTagName("size"); if (nodes != null) - size = nodes.item(0).getTextContent(); + { + this.size = nodes.item(0).getTextContent(); + } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { if (isTranslatable) - text = StatCollector.translateToLocal(text); - if (size.equals("two")) - drawCraftingPage(text, icons, 2, localWidth, localHeight + 12); - if (size.equals("three")) - drawCraftingPage(text, icons, 3, localWidth + (side != 1 ? 6 : 0), localHeight + 12); + { + this.text = StatCollector.translateToLocal(this.text); + } + if (this.size.equals("two")) + { + this.drawCraftingPage(this.text, this.icons, 2, localWidth, localHeight + 12); + } + if (this.size.equals("three")) + { + this.drawCraftingPage(this.text, this.icons, 3, localWidth + (this.side != 1 ? 6 : 0), localHeight + 12); + } } - public void drawCraftingPage (String info, ItemStack[] icons, int recipeSize, int localWidth, int localHeight) + public void drawCraftingPage(String info, ItemStack[] icons, int recipeSize, int localWidth, int localHeight) { if (info != null) - manual.fonts.drawString("\u00a7n" + info, localWidth + 50, localHeight + 4, 0); + { + this.manual.fonts.drawString("\u00a7n" + info, localWidth + 50, localHeight + 4, 0); + } GL11.glScalef(2f, 2f, 2f); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); - manual.renderitem.zLevel = 100; + this.manual.renderitem.zLevel = 100; if (recipeSize == 2) { - manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); + this.manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); if (icons[0].stackSize > 1) - manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + { + this.manual.renderitem.renderItemOverlayIntoGUI(this.manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + } for (int i = 0; i < icons.length - 1; i++) { if (icons[i + 1] != null) - manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); + { + this.manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); + } } } if (recipeSize == 3) { - manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); + this.manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); if (icons[0].stackSize > 1) - manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + { + this.manual.renderitem.renderItemOverlayIntoGUI(this.manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); + } for (int i = 0; i < icons.length - 1; i++) { if (icons[i + 1] != null) - manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); + { + this.manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); + } } } - manual.renderitem.zLevel = 0; + this.manual.renderitem.zLevel = 0; GL11.glScalef(0.5F, 0.5F, 0.5F); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); } - public void renderBackgroundLayer (int localwidth, int localheight) + @Override + public void renderBackgroundLayer(int localwidth, int localheight) { - if (size.equals("two")) - drawBackground(2, localwidth, localheight + 12); + if (this.size.equals("two")) + { + this.drawBackground(2, localwidth, localheight + 12); + } - if (size.equals("three")) - drawBackground(3, localwidth + (side != 1 ? 6 : 0), localheight + 12); + if (this.size.equals("three")) + { + this.drawBackground(3, localwidth + (this.side != 1 ? 6 : 0), localheight + 12); + } } private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookcrafting.png"); - public void drawBackground (int size, int localWidth, int localHeight) + public void drawBackground(int size, int localWidth, int localHeight) { - manual.getMC().getTextureManager().bindTexture(background); + this.manual.getMC().getTextureManager().bindTexture(background); if (size == 2) - manual.drawTexturedModalRect(localWidth + 8, localHeight + 46, 0, 116, 154, 78); + { + this.manual.drawTexturedModalRect(localWidth + 8, localHeight + 46, 0, 116, 154, 78); + } if (size == 3) - manual.drawTexturedModalRect(localWidth - 8, localHeight + 28, 0, 0, 183, 114); + { + this.manual.drawTexturedModalRect(localWidth - 8, localHeight + 28, 0, 0, 183, 114); + } } } diff --git a/src/mantle/client/pages/FurnacePage.java b/src/mantle/client/pages/FurnacePage.java index 601a7d8..e58ec75 100644 --- a/src/mantle/client/pages/FurnacePage.java +++ b/src/mantle/client/pages/FurnacePage.java @@ -14,42 +14,51 @@ import org.w3c.dom.NodeList; public class FurnacePage extends BookPage { String text; + ItemStack[] icons; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } nodes = element.getElementsByTagName("recipe"); if (nodes != null) - icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + { + this.icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); + } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { - if (text != null) + if (this.text != null) { if (isTranslatable) - text = StatCollector.translateToLocal(text); - manual.fonts.drawString("\u00a7n" + text, localWidth + 50, localHeight + 4, 0); + { + this.text = StatCollector.translateToLocal(this.text); + } + this.manual.fonts.drawString("\u00a7n" + this.text, localWidth + 50, localHeight + 4, 0); } GL11.glScalef(2f, 2f, 2f); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); - manual.renderitem.zLevel = 100; + this.manual.renderitem.zLevel = 100; - manual.renderitem.renderItemAndEffectIntoGUI(MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); - manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); - manual.renderitem.renderItemAndEffectIntoGUI(icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); + this.manual.renderitem.renderItemAndEffectIntoGUI(MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); + this.manual.renderitem.renderItemAndEffectIntoGUI(this.icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); + this.manual.renderitem.renderItemAndEffectIntoGUI(this.icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); - if (icons[0].stackSize > 1) - manual.renderitem.renderItemOverlayIntoGUI(manual.fonts, icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(icons[0].stackSize)); + if (this.icons[0].stackSize > 1) + { + this.manual.renderitem.renderItemOverlayIntoGUI(this.manual.fonts, this.icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(this.icons[0].stackSize)); + } - manual.renderitem.zLevel = 0; + this.manual.renderitem.zLevel = 0; GL11.glScalef(0.5F, 0.5F, 0.5F); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); @@ -57,9 +66,10 @@ public class FurnacePage extends BookPage private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookfurnace.png"); - public void renderBackgroundLayer (int localWidth, int localHeight) + @Override + public void renderBackgroundLayer(int localWidth, int localHeight) { - manual.getMC().getTextureManager().bindTexture(background); - manual.drawTexturedModalRect(localWidth + 32, localHeight + 32, 0, 0, 111, 114); + this.manual.getMC().getTextureManager().bindTexture(background); + this.manual.drawTexturedModalRect(localWidth + 32, localHeight + 32, 0, 0, 111, 114); } } diff --git a/src/mantle/client/pages/PicturePage.java b/src/mantle/client/pages/PicturePage.java index eeda9fc..b63edc8 100644 --- a/src/mantle/client/pages/PicturePage.java +++ b/src/mantle/client/pages/PicturePage.java @@ -1,62 +1,70 @@ package mantle.client.pages; +import static mantle.lib.CoreRepo.logger; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; -import static mantle.lib.CoreRepo.logger; + import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class PicturePage extends BookPage { String text; + String location; + ResourceLocation background; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } nodes = element.getElementsByTagName("location"); if (nodes != null) { - location = nodes.item(0).getTextContent(); - background = new ResourceLocation(location); - if(background == null) + this.location = nodes.item(0).getTextContent(); + this.background = new ResourceLocation(this.location); + if (this.background == null) { logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(location)!"); } } //this borked stuffs somehow unless someone is interested in using it this stays disabled for now - /* nodes = element.getElementsByTagName("bookImage"); - if (nodes != null) - { - //TODO 1.7 null check all of this - background = MantleClientRegistry.imageCache.get(nodes.item(0).getTextContent()).resource; - if(background == null){ - logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(bookimage)!"); - } - }*/ + /* nodes = element.getElementsByTagName("bookImage"); + if (nodes != null) + { + //TODO 1.7 null check all of this + background = MantleClientRegistry.imageCache.get(nodes.item(0).getTextContent()).resource; + if(background == null){ + logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(bookimage)!"); + } + }*/ } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { if (isTranslatable) - text = StatCollector.translateToLocal(text); - manual.fonts.drawSplitString(text, localWidth + 8, localHeight, 178, 0); + { + this.text = StatCollector.translateToLocal(this.text); + } + this.manual.fonts.drawSplitString(this.text, localWidth + 8, localHeight, 178, 0); } - public void renderBackgroundLayer (int localWidth, int localHeight) + @Override + public void renderBackgroundLayer(int localWidth, int localHeight) { - if (background != null) + if (this.background != null) { - manual.getMC().getTextureManager().bindTexture(background); + this.manual.getMC().getTextureManager().bindTexture(this.background); } //manual.getMC().renderEngine.bindTexture(location); - manual.drawTexturedModalRect(localWidth, localHeight + 12, 0, 0, 170, 144); + this.manual.drawTexturedModalRect(localWidth, localHeight + 12, 0, 0, 170, 144); } } diff --git a/src/mantle/client/pages/SectionPage.java b/src/mantle/client/pages/SectionPage.java index b1ca875..972f580 100644 --- a/src/mantle/client/pages/SectionPage.java +++ b/src/mantle/client/pages/SectionPage.java @@ -8,29 +8,34 @@ import org.w3c.dom.NodeList; public class SectionPage extends BookPage { String title; + String body; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("title"); if (nodes != null) - title = nodes.item(0).getTextContent(); + { + this.title = nodes.item(0).getTextContent(); + } nodes = element.getElementsByTagName("text"); if (nodes != null) - body = nodes.item(0).getTextContent(); + { + this.body = nodes.item(0).getTextContent(); + } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { if (isTranslatable) { - title = StatCollector.translateToLocal(title); - body = StatCollector.translateToLocal(body); + this.title = StatCollector.translateToLocal(this.title); + this.body = StatCollector.translateToLocal(this.body); } - manual.fonts.drawSplitString("\u00a7n" + title, localWidth + 70, localHeight + 4, 178, 0); - manual.fonts.drawSplitString(body, localWidth, localHeight + 16, 190, 0); + this.manual.fonts.drawSplitString("\u00a7n" + this.title, localWidth + 70, localHeight + 4, 178, 0); + this.manual.fonts.drawSplitString(this.body, localWidth, localHeight + 16, 190, 0); } } diff --git a/src/mantle/client/pages/SidebarPage.java b/src/mantle/client/pages/SidebarPage.java index cda297f..adb4ad6 100644 --- a/src/mantle/client/pages/SidebarPage.java +++ b/src/mantle/client/pages/SidebarPage.java @@ -13,52 +13,58 @@ import org.w3c.dom.NodeList; public class SidebarPage extends BookPage { String text; + String[] iconText; + ItemStack[] icons; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } nodes = element.getElementsByTagName("item"); - iconText = new String[nodes.getLength()]; - icons = new ItemStack[nodes.getLength()]; + this.iconText = new String[nodes.getLength()]; + this.icons = new ItemStack[nodes.getLength()]; for (int i = 0; i < nodes.getLength(); i++) { NodeList children = nodes.item(i).getChildNodes(); - iconText[i] = children.item(1).getTextContent(); - icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent()); + this.iconText[i] = children.item(1).getTextContent(); + this.icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent()); } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { if (isTranslatable) { - text = StatCollector.translateToLocal(text); + this.text = StatCollector.translateToLocal(this.text); } - manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0); + this.manual.fonts.drawSplitString(this.text, localWidth, localHeight, 178, 0); GL11.glEnable(GL12.GL_RESCALE_NORMAL); RenderHelper.enableGUIStandardItemLighting(); - manual.renderitem.zLevel = 100; - int offset = text.length() / 4 + 10; - for (int i = 0; i < icons.length; i++) + this.manual.renderitem.zLevel = 100; + int offset = this.text.length() / 4 + 10; + for (int i = 0; i < this.icons.length; i++) { if (isTranslatable) { - iconText[i] = StatCollector.translateToLocal(iconText[i]); + this.iconText[i] = StatCollector.translateToLocal(this.iconText[i]); } - manual.renderitem.renderItemIntoGUI(icons[i], localWidth + 8, localHeight + 18 * i + offset); + this.manual.renderitem.renderItemIntoGUI(this.icons[i], localWidth + 8, localHeight + 18 * i + offset); int yOffset = 39; - if (iconText[i].length() > 40) + if (this.iconText[i].length() > 40) + { yOffset = 34; - manual.fonts.drawSplitString(iconText[i], localWidth + 30, localHeight + 18 * i + offset, 140, 0); + } + this.manual.fonts.drawSplitString(this.iconText[i], localWidth + 30, localHeight + 18 * i + offset, 140, 0); } - manual.renderitem.zLevel = 0; + this.manual.renderitem.zLevel = 0; RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); } diff --git a/src/mantle/client/pages/TextPage.java b/src/mantle/client/pages/TextPage.java index 00c52fa..09e7fbe 100644 --- a/src/mantle/client/pages/TextPage.java +++ b/src/mantle/client/pages/TextPage.java @@ -10,18 +10,22 @@ public class TextPage extends BookPage String text; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean IsTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean IsTranslatable) { if (IsTranslatable) - text = StatCollector.translateToLocal(text); - manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0); + { + this.text = StatCollector.translateToLocal(this.text); + } + this.manual.fonts.drawSplitString(this.text, localWidth, localHeight, 178, 0); } } diff --git a/src/mantle/client/pages/TitlePage.java b/src/mantle/client/pages/TitlePage.java index b103bc6..fdc9590 100644 --- a/src/mantle/client/pages/TitlePage.java +++ b/src/mantle/client/pages/TitlePage.java @@ -10,18 +10,22 @@ public class TitlePage extends BookPage String text; @Override - public void readPageFromXML (Element element) + public void readPageFromXML(Element element) { NodeList nodes = element.getElementsByTagName("text"); if (nodes != null) - text = nodes.item(0).getTextContent(); + { + this.text = nodes.item(0).getTextContent(); + } } @Override - public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable) + public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) { if (isTranslatable) - text = StatCollector.translateToLocal(text); - manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0); + { + this.text = StatCollector.translateToLocal(this.text); + } + this.manual.fonts.drawSplitString(this.text, localWidth, localHeight, 178, 0); } } diff --git a/src/mantle/common/ComparisonHelper.java b/src/mantle/common/ComparisonHelper.java index 0a89577..55a8fba 100644 --- a/src/mantle/common/ComparisonHelper.java +++ b/src/mantle/common/ComparisonHelper.java @@ -6,24 +6,24 @@ import net.minecraft.item.ItemStack; public class ComparisonHelper { - public static boolean areEquivalent (Item item, Block block) + public static boolean areEquivalent(Item item, Block block) { return item == Item.getItemFromBlock(block); } - public static boolean areEquivalent (Block block1, Block block2) + public static boolean areEquivalent(Block block1, Block block2) { return block1 == block2; } - public static boolean areEquivalent (Item item1, Item item2) + public static boolean areEquivalent(Item item1, Item item2) { return item1 == item2; } //@TODO make this a more verbose comparison - public static boolean areEquivalent (ItemStack is1, ItemStack is2) + public static boolean areEquivalent(ItemStack is1, ItemStack is2) { - return is1.getItem() == is2.getItem(); + return is1.getItem() == is2.getItem(); } } diff --git a/src/mantle/common/IDDumps.java b/src/mantle/common/IDDumps.java index 7d65fe5..4e9da89 100644 --- a/src/mantle/common/IDDumps.java +++ b/src/mantle/common/IDDumps.java @@ -8,7 +8,8 @@ import net.minecraft.world.biome.BiomeGenBase; public class IDDumps { - public static void dump(){ + public static void dump() + { if (CoreConfig.dumpBiomeIDs) { for (BiomeGenBase b : BiomeGenBase.getBiomeGenArray()) diff --git a/src/mantle/common/MProxyCommon.java b/src/mantle/common/MProxyCommon.java index cfccaf9..5efc875 100644 --- a/src/mantle/common/MProxyCommon.java +++ b/src/mantle/common/MProxyCommon.java @@ -9,24 +9,26 @@ public class MProxyCommon implements IGuiHandler public static int manualGuiID = -1; @Override - public Object getServerGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID < 0) + { return null; + } return null; } @Override - public Object getClientGuiElement (int ID, EntityPlayer player, World world, int x, int y, int z) + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } - public void registerRenderer () + public void registerRenderer() { } - public void readManuals () + public void readManuals() { } } diff --git a/src/mantle/common/network/AbstractPacket.java b/src/mantle/common/network/AbstractPacket.java index 8d2b14a..39d0151 100644 --- a/src/mantle/common/network/AbstractPacket.java +++ b/src/mantle/common/network/AbstractPacket.java @@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayer; /** * AbstractPacket class. Should be the parent of all packets wishing to use the * PacketPipeline. - * + * * @author sirgingalot */ public abstract class AbstractPacket @@ -17,41 +17,41 @@ public abstract class AbstractPacket * Encode the packet data into the ByteBuf stream. Complex data sets may * need specific data handlers (See * @link{cpw.mods.fml.common.network.ByteBuffUtils}) - * + * * @param ctx * channel context * @param buffer * the buffer to encode into */ - public abstract void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer); + public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer); /** * Decode the packet data from the ByteBuf stream. Complex data sets may * need specific data handlers (See * @link{cpw.mods.fml.common.network.ByteBuffUtils}) - * + * * @param ctx * channel context * @param buffer * the buffer to decode from */ - public abstract void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer); + public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer); /** * Handle a packet on the client side. Note this occurs after decoding has * completed. - * + * * @param player * the player reference */ - public abstract void handleClientSide (EntityPlayer player); + public abstract void handleClientSide(EntityPlayer player); /** * Handle a packet on the server side. Note this occurs after decoding has * completed. - * + * * @param player * the player reference */ - public abstract void handleServerSide (EntityPlayer player); + public abstract void handleServerSide(EntityPlayer player); } diff --git a/src/mantle/common/network/PacketUpdateTE.java b/src/mantle/common/network/PacketUpdateTE.java index d351403..18ecd13 100644 --- a/src/mantle/common/network/PacketUpdateTE.java +++ b/src/mantle/common/network/PacketUpdateTE.java @@ -11,6 +11,7 @@ import net.minecraft.util.BlockPos; public class PacketUpdateTE extends AbstractPacket { private BlockPos pos; + private NBTTagCompound data; public PacketUpdateTE() @@ -25,15 +26,15 @@ public class PacketUpdateTE extends AbstractPacket } @Override - public void encodeInto (ChannelHandlerContext ctx, ByteBuf buffer) + public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { PacketBuffer pbuff = new PacketBuffer(buffer); - pbuff.writeInt(pos.getX()); - pbuff.writeShort(pos.getY()); - pbuff.writeInt(pos.getZ()); + pbuff.writeInt(this.pos.getX()); + pbuff.writeShort(this.pos.getY()); + pbuff.writeInt(this.pos.getZ()); try { - pbuff.writeNBTTagCompoundToBuffer(data); + pbuff.writeNBTTagCompoundToBuffer(this.data); } catch (Exception e) { @@ -42,13 +43,13 @@ public class PacketUpdateTE extends AbstractPacket } @Override - public void decodeInto (ChannelHandlerContext ctx, ByteBuf buffer) + public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { PacketBuffer pbuff = new PacketBuffer(buffer); - pos = new BlockPos(pbuff.readInt(), pbuff.readShort(), pbuff.readInt()); + this.pos = new BlockPos(pbuff.readInt(), pbuff.readShort(), pbuff.readInt()); try { - data = pbuff.readNBTTagCompoundFromBuffer(); + this.data = pbuff.readNBTTagCompoundFromBuffer(); } catch (Exception e) { @@ -57,18 +58,18 @@ public class PacketUpdateTE extends AbstractPacket } @Override - public void handleClientSide (EntityPlayer player) + public void handleClientSide(EntityPlayer player) { - TileEntity te = player.worldObj.getTileEntity(pos); + TileEntity te = player.worldObj.getTileEntity(this.pos); if (te != null) { - te.readFromNBT(data); + te.readFromNBT(this.data); } } @Override - public void handleServerSide (EntityPlayer player) + public void handleServerSide(EntityPlayer player) { } diff --git a/src/mantle/crash/CallableSuppConfig.java b/src/mantle/crash/CallableSuppConfig.java index 94819cc..089033c 100644 --- a/src/mantle/crash/CallableSuppConfig.java +++ b/src/mantle/crash/CallableSuppConfig.java @@ -18,15 +18,15 @@ public class CallableSuppConfig implements ICrashCallable } @Override - public String call () throws Exception + public String call() throws Exception { return "Environment healthy."; } @Override - public String getLabel () + public String getLabel() { - return modId + " Environment"; + return this.modId + " Environment"; } } diff --git a/src/mantle/crash/CallableUnsuppConfig.java b/src/mantle/crash/CallableUnsuppConfig.java index 036fb01..5e0b0bb 100644 --- a/src/mantle/crash/CallableUnsuppConfig.java +++ b/src/mantle/crash/CallableUnsuppConfig.java @@ -9,6 +9,7 @@ public class CallableUnsuppConfig implements ICrashCallable { private String modId; + private List modIds; public CallableUnsuppConfig(String modId, List modIds) @@ -18,17 +19,17 @@ public class CallableUnsuppConfig implements ICrashCallable } @Override - public String getLabel () + public String getLabel() { - return modId + " Environment"; + return this.modId + " Environment"; } @Override - public String call () throws Exception + public String call() throws Exception { String str = "DO NOT REPORT THIS CRASH! Unsupported mods in environment: "; Boolean firstEntry = true; - for (String id : modIds) + for (String id : this.modIds) { str = str + (firstEntry ? id : ", " + id); firstEntry = false; @@ -37,4 +38,4 @@ public class CallableUnsuppConfig implements ICrashCallable return str; } -} \ No newline at end of file +} diff --git a/src/mantle/debug/DebugData.java b/src/mantle/debug/DebugData.java index 86fd9f5..94b6a4c 100644 --- a/src/mantle/debug/DebugData.java +++ b/src/mantle/debug/DebugData.java @@ -11,7 +11,10 @@ public class DebugData { public final EntityPlayer player; - @SuppressWarnings("rawtypes") public final Class cl; + + @SuppressWarnings("rawtypes") + public final Class cl; + public final String[] strings; @SuppressWarnings("rawtypes") diff --git a/src/mantle/debug/DebugHelper.java b/src/mantle/debug/DebugHelper.java index 304835e..88c4c30 100644 --- a/src/mantle/debug/DebugHelper.java +++ b/src/mantle/debug/DebugHelper.java @@ -19,15 +19,19 @@ public class DebugHelper // No instantiation } - public static void handleDebugData (DebugData data) + public static void handleDebugData(DebugData data) { if (debug_enableChat) + { handleChatDebug(data); + } if (debug_enableConsole) + { handleConsoleDebug(data); + } } - private static void handleChatDebug (DebugData data) + private static void handleChatDebug(DebugData data) { EntityPlayer player = data.player; String prefix = "[" + data.cl.getSimpleName() + "] "; @@ -37,7 +41,7 @@ public class DebugHelper } } - private static void handleConsoleDebug (DebugData data) + private static void handleConsoleDebug(DebugData data) { String player = data.player.getGameProfile().getName(); String prefix = "[" + player + ":" + data.cl.getSimpleName() + "] "; diff --git a/src/mantle/debug/IDebuggable.java b/src/mantle/debug/IDebuggable.java index b972df9..8f3fee9 100644 --- a/src/mantle/debug/IDebuggable.java +++ b/src/mantle/debug/IDebuggable.java @@ -12,6 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; public interface IDebuggable { - public DebugData getDebugInfo (EntityPlayer player); + public DebugData getDebugInfo(EntityPlayer player); } diff --git a/src/mantle/event/ManualOpenEvent.java b/src/mantle/event/ManualOpenEvent.java index 04d8667..8c3bf34 100644 --- a/src/mantle/event/ManualOpenEvent.java +++ b/src/mantle/event/ManualOpenEvent.java @@ -1,28 +1,35 @@ package mantle.event; -import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.eventhandler.Event; -public abstract class ManualOpenEvent extends Event { +public abstract class ManualOpenEvent extends Event +{ - public ItemStack bookStack; - public EntityPlayer player; + public ItemStack bookStack; - public ManualOpenEvent(ItemStack book, EntityPlayer player) { - this.bookStack = book; - this.player = player; - } + public EntityPlayer player; - public static class Pre extends ManualOpenEvent { - public Pre(ItemStack book, EntityPlayer player) { - super(book, player); - } - } + public ManualOpenEvent(ItemStack book, EntityPlayer player) + { + this.bookStack = book; + this.player = player; + } - public static class Post extends ManualOpenEvent { - public Post(ItemStack book, EntityPlayer player) { - super(book, player); - } - } + public static class Pre extends ManualOpenEvent + { + public Pre(ItemStack book, EntityPlayer player) + { + super(book, player); + } + } + + public static class Post extends ManualOpenEvent + { + public Post(ItemStack book, EntityPlayer player) + { + super(book, player); + } + } } diff --git a/src/mantle/event/Migration.java b/src/mantle/event/Migration.java index 6a3c689..699dfa4 100644 --- a/src/mantle/event/Migration.java +++ b/src/mantle/event/Migration.java @@ -1,21 +1,27 @@ package mantle.event; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; +import static mantle.lib.CoreRepo.logger; + +import java.util.List; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import static mantle.lib.CoreRepo.logger; -import java.util.List; -import java.util.Map; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; public abstract class Migration { Map remapItem = Maps.newHashMap(); + Map remapBlock = Maps.newHashMap(); + List ignore = Lists.newArrayList(); + private ModContainer mod; private String modID; @@ -25,8 +31,8 @@ public abstract class Migration */ public Migration(ModContainer m) { - mod = m; - modID = m.getModId(); + this.mod = m; + this.modID = m.getModId(); } /* @@ -34,28 +40,29 @@ public abstract class Migration * Use an encapsulated object of form Map to store this. * The prefix will be created using the ID given during construction during processing. */ - public void addMigration (String old, Item newItem) + public void addMigration(String old, Item newItem) { - remapItem.put(modID + ":" + old, newItem); + this.remapItem.put(this.modID + ":" + old, newItem); } /* - * Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!). - * Use an encapsulated object of form Map to store this. - * The prefix will be created using the ID given during construction during processing. - */ - public void addMigration (String old, Block newBlock) + * Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!). + * Use an encapsulated object of form Map to store this. + * The prefix will be created using the ID given during construction during processing. + */ + public void addMigration(String old, Block newBlock) { - remapBlock.put(modID + ":" + old, newBlock); + this.remapBlock.put(this.modID + ":" + old, newBlock); } + /* * Register an old ID that's been removed entirely. This isn't suitable for renaming operations! * Store this in a List seperate to the rename mapping. * @param id ID to be removed (without ID prefix!). */ - public void addRemoval (String id) + public void addRemoval(String id) { - ignore.add(modID + ":" + id); + this.ignore.add(this.modID + ":" + id); } /* @@ -63,26 +70,35 @@ public abstract class Migration * This works on the assumption the FML event will have a list of string IDs that are missing. * During this phase, check for old IDs and remap as needed, or destroy ones marked for removal. */ - public void processMigrationEvent (FMLMissingMappingsEvent event) { - if ((!remapBlock.isEmpty() || !remapItem.isEmpty())) { - event.applyModContainer(mod); + public void processMigrationEvent(FMLMissingMappingsEvent event) + { + if ((!this.remapBlock.isEmpty() || !this.remapItem.isEmpty())) + { + event.applyModContainer(this.mod); List l = event.get(); - if(l != null) + if (l != null) { - for (MissingMapping miss : event.get()) { - if (remapItem.containsKey(miss.name)) - miss.remap(remapItem.get(miss.name)); - else if (remapBlock.containsKey(miss.name)) - miss.remap(remapBlock.get(miss.name)); - else if (ignore.contains(miss.name)) + for (MissingMapping miss : event.get()) + { + if (this.remapItem.containsKey(miss.name)) + { + miss.remap(this.remapItem.get(miss.name)); + } + else if (this.remapBlock.containsKey(miss.name)) + { + miss.remap(this.remapBlock.get(miss.name)); + } + else if (this.ignore.contains(miss.name)) + { miss.ignore(); + } } } else { - logger.error("migration list from FML empty for mod " + modID); + logger.error("migration list from FML empty for mod " + this.modID); } } } -} \ No newline at end of file +} diff --git a/src/mantle/items/ItemUtils.java b/src/mantle/items/ItemUtils.java index f359e98..c8ac743 100644 --- a/src/mantle/items/ItemUtils.java +++ b/src/mantle/items/ItemUtils.java @@ -5,11 +5,12 @@ import net.minecraftforge.fml.common.registry.GameData; public class ItemUtils { - public static String getUniqueName (Item item) + public static String getUniqueName(Item item) { - return (String)GameData.getItemRegistry().getNameForObject(item); + return (String) GameData.getItemRegistry().getNameForObject(item); } - public static Item getItemFromUniqueName (String uniqueName) + + public static Item getItemFromUniqueName(String uniqueName) { return GameData.getItemRegistry().getObject(uniqueName); } diff --git a/src/mantle/items/Manual.java b/src/mantle/items/Manual.java index d09da98..84194cb 100644 --- a/src/mantle/items/Manual.java +++ b/src/mantle/items/Manual.java @@ -1,13 +1,10 @@ package mantle.items; -import net.minecraftforge.common.MinecraftForge; - -import mantle.event.ManualOpenEvent; - import java.util.List; import mantle.Mantle; import mantle.books.BookDataStore; +import mantle.event.ManualOpenEvent; import mantle.items.abstracts.CraftingItem; import mantle.lib.CoreRepo; import net.minecraft.creativetab.CreativeTabs; @@ -15,6 +12,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -22,18 +20,20 @@ public class Manual extends CraftingItem { public final String modID; + static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary" }; + static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue" }; public Manual() { super(name, textureName, "", "mantle", null); - modID = CoreRepo.modId; + this.modID = CoreRepo.modId; } - public void updateManual () + public void updateManual() { - updateData(new String[] { "test" }, new String[] { "mantlebook_blue" }, "", "mantle"); + this.updateData(new String[] { "test" }, new String[] { "mantlebook_blue" }, "", "mantle"); } public Manual(String[] name, String[] textureName, String folder, String modTexturePrefix, CreativeTabs tab, String modID) @@ -43,10 +43,10 @@ public class Manual extends CraftingItem } @Override - public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player) + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { - ManualOpenEvent.Pre preOpenEvent = new ManualOpenEvent.Pre(stack, player); - MinecraftForge.EVENT_BUS.post(preOpenEvent); + ManualOpenEvent.Pre preOpenEvent = new ManualOpenEvent.Pre(stack, player); + MinecraftForge.EVENT_BUS.post(preOpenEvent); player.openGui(Mantle.instance, mantle.client.MProxyClient.manualGuiID, world, 0, 0, 0); ManualOpenEvent.Post postOpenEvent = new ManualOpenEvent.Post(stack, player); @@ -57,20 +57,20 @@ public class Manual extends CraftingItem @Override @SideOnly(Side.CLIENT) - @SuppressWarnings({"unchecked", "rawtypes"}) - public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4) + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { list.add("\u00a7o" + StatCollector.translateToLocal(BookDataStore.getBookfromID(stack.getItemDamage()).toolTip)); } @Override - public String getUnlocalizedName () + public String getUnlocalizedName() { - return modID + ":" + super.getUnlocalizedName(); + return this.modID + ":" + super.getUnlocalizedName(); } @Override - public String getUnlocalizedName (ItemStack par1ItemStack) + public String getUnlocalizedName(ItemStack par1ItemStack) { return super.getUnlocalizedName(par1ItemStack); } diff --git a/src/mantle/items/abstracts/CraftingItem.java b/src/mantle/items/abstracts/CraftingItem.java index e7ae7aa..c54d848 100644 --- a/src/mantle/items/abstracts/CraftingItem.java +++ b/src/mantle/items/abstracts/CraftingItem.java @@ -6,14 +6,15 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public class CraftingItem extends Item { public String modTexPrefix; + public String[] textureNames; + public String[] unlocalizedNames; + public String folder; public CraftingItem(String[] names, String[] tex, String folder, String modTexturePrefix, CreativeTabs tab) @@ -31,7 +32,7 @@ public class CraftingItem extends Item this.folder = folder; } - public void updateData (String[] names, String[] tex, String folder, String modTexturePrefix) + public void updateData(String[] names, String[] tex, String folder, String modTexturePrefix) { this.modTexPrefix = modTexturePrefix; this.textureNames = tex; @@ -39,18 +40,24 @@ public class CraftingItem extends Item this.folder = folder; } - public String getUnlocalizedName (ItemStack stack) + @Override + public String getUnlocalizedName(ItemStack stack) { - int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length); - return getUnlocalizedName() + "." + unlocalizedNames[arr]; + int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, this.unlocalizedNames.length); + return this.getUnlocalizedName() + "." + this.unlocalizedNames[arr]; } - @SuppressWarnings({"unchecked","rawtypes"}) - public void getSubItems (Item b, CreativeTabs tab, List list) + @Override + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void getSubItems(Item b, CreativeTabs tab, List list) { - for (int i = 0; i < unlocalizedNames.length; i++) - if (!(textureNames[i].equals(""))) + for (int i = 0; i < this.unlocalizedNames.length; i++) + { + if (!(this.textureNames[i].equals(""))) + { list.add(new ItemStack(b, 1, i)); + } + } } } diff --git a/src/mantle/lib/CoreConfig.java b/src/mantle/lib/CoreConfig.java index d17030b..e0e5d20 100644 --- a/src/mantle/lib/CoreConfig.java +++ b/src/mantle/lib/CoreConfig.java @@ -6,11 +6,11 @@ import static mantle.lib.CoreRepo.modId; import java.io.File; import java.io.IOException; -import org.apache.commons.io.FilenameUtils; - import mantle.books.external.ZipLoader; import net.minecraftforge.common.config.Configuration; +import org.apache.commons.io.FilenameUtils; + /** * Mantle configuration handler * @@ -21,6 +21,7 @@ import net.minecraftforge.common.config.Configuration; public class CoreConfig { static Configuration config; + public static File configFolder; /** @@ -28,14 +29,16 @@ public class CoreConfig * * @param mainConfigFolder Configuration folder (as a Java File) */ - public static void loadConfiguration (File mainConfigFolder) + public static void loadConfiguration(File mainConfigFolder) { logger.info("Loading configuration from disk."); try { configFolder = new File(mainConfigFolder.getCanonicalPath(), "SlimeKnights"); if (!configFolder.exists()) + { configFolder.mkdirs(); + } } catch (IOException e) { @@ -63,7 +66,7 @@ public class CoreConfig /** * Checks for MANTLE_DBGCONSOLE/CHAT config overrides in system environment for compile time testing, and other dev work. **/ - private static void checkSysOverrides () + private static void checkSysOverrides() { if (System.getenv("MANTLE_DBGCONSOLE") != null) { @@ -77,12 +80,14 @@ public class CoreConfig } } - public static void loadBookLocations () + public static void loadBookLocations() { for (File f : configFolder.listFiles()) { - if(f.isFile() && FilenameUtils.getExtension(f.getAbsolutePath()).equalsIgnoreCase("zip")) + if (f.isFile() && FilenameUtils.getExtension(f.getAbsolutePath()).equalsIgnoreCase("zip")) + { ZipLoader.loadZip(f); + } } } @@ -92,10 +97,13 @@ public class CoreConfig // Debug Helpers public static boolean debug_enableConsole = false; + public static boolean debug_enableChat = false; + public static boolean dumpBiomeIDs = false; + public static boolean dumpPotionIDs = false; + public static boolean dumpEnchantIDs = false; - } diff --git a/src/mantle/lib/CoreRepo.java b/src/mantle/lib/CoreRepo.java index 45fb33e..7419f54 100644 --- a/src/mantle/lib/CoreRepo.java +++ b/src/mantle/lib/CoreRepo.java @@ -14,7 +14,9 @@ public final class CoreRepo { public static final String modId = "mantle"; + public static final String modName = "Mantle"; + public static final String modVersion = "${version}"; public static final Logger logger = LogManager.getLogger("Mantle"); diff --git a/src/mantle/lib/TabTools.java b/src/mantle/lib/TabTools.java index 489edb6..fe93f97 100644 --- a/src/mantle/lib/TabTools.java +++ b/src/mantle/lib/TabTools.java @@ -13,18 +13,20 @@ public class TabTools extends CreativeTabs super(label); } - public void init (ItemStack stack) + public void init(ItemStack stack) { - display = stack; + this.display = stack; } - public ItemStack getIconItemStack () + @Override + public ItemStack getIconItemStack() { - return display; + return this.display; } - public Item getTabIconItem () + @Override + public Item getTabIconItem() { - return display.getItem(); + return this.display.getItem(); } -} \ No newline at end of file +} diff --git a/src/mantle/lib/client/MantleClientRegistry.java b/src/mantle/lib/client/MantleClientRegistry.java index f4423c7..e8b1e9b 100644 --- a/src/mantle/lib/client/MantleClientRegistry.java +++ b/src/mantle/lib/client/MantleClientRegistry.java @@ -3,39 +3,43 @@ package mantle.lib.client; import java.util.HashMap; import java.util.Map; -import com.google.common.collect.Maps; - import mantle.books.client.BookImage; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import com.google.common.collect.Maps; + public class MantleClientRegistry { public static Map manualIcons = Maps.newHashMap(); + public static Map recipeIcons = Maps.newHashMap(); + public static HashMap imageCache = Maps.newHashMap(); public static ItemStack defaultStack = new ItemStack(Items.iron_ingot); - public static BookImage getBookImageFromCache (String s) + public static BookImage getBookImageFromCache(String s) { return imageCache.get(s); } - public static void registerManualIcon (String name, ItemStack stack) + public static void registerManualIcon(String name, ItemStack stack) { manualIcons.put(name, stack); } - public static ItemStack getManualIcon (String textContent) + public static ItemStack getManualIcon(String textContent) { ItemStack stack = manualIcons.get(textContent); if (stack != null) + { return stack; + } return defaultStack; } - public static void registerManualSmallRecipe (String name, ItemStack output, ItemStack... stacks) + public static void registerManualSmallRecipe(String name, ItemStack output, ItemStack... stacks) { ItemStack[] recipe = new ItemStack[5]; recipe[0] = output; @@ -43,7 +47,7 @@ public class MantleClientRegistry recipeIcons.put(name, recipe); } - public static void registerManualLargeRecipe (String name, ItemStack output, ItemStack... stacks) + public static void registerManualLargeRecipe(String name, ItemStack output, ItemStack... stacks) { ItemStack[] recipe = new ItemStack[10]; recipe[0] = output; @@ -51,7 +55,7 @@ public class MantleClientRegistry recipeIcons.put(name, recipe); } - public static void registerManualFurnaceRecipe (String name, ItemStack output, ItemStack input) + public static void registerManualFurnaceRecipe(String name, ItemStack output, ItemStack input) { ItemStack[] recipe = new ItemStack[2]; recipe[0] = output; @@ -59,7 +63,7 @@ public class MantleClientRegistry recipeIcons.put(name, recipe); } - public static ItemStack[] getRecipeIcons (String recipeName) + public static ItemStack[] getRecipeIcons(String recipeName) { return recipeIcons.get(recipeName); } diff --git a/src/mantle/lib/environment/EnvironmentChecks.java b/src/mantle/lib/environment/EnvironmentChecks.java index 94c072f..1ad9f01 100644 --- a/src/mantle/lib/environment/EnvironmentChecks.java +++ b/src/mantle/lib/environment/EnvironmentChecks.java @@ -5,7 +5,6 @@ import static mantle.lib.CoreRepo.modId; import java.util.List; -import com.google.common.collect.Lists; import mantle.crash.CallableSuppConfig; import mantle.crash.CallableUnsuppConfig; import mantle.lib.CoreConfig; @@ -15,6 +14,8 @@ import net.minecraftforge.fml.common.ICrashCallable; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.relauncher.Side; +import com.google.common.collect.Lists; + /** * Environment Checks * @@ -37,14 +38,16 @@ public class EnvironmentChecks * Note: This code adds additional data to crashlogs. It does not trigger any crashes. */ @SuppressWarnings("rawtypes") - public static void verifyEnvironmentSanity () + public static void verifyEnvironmentSanity() { List modIds = Lists.newArrayList(); if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine() || Loader.isModLoaded("optifine")) { if (!CoreConfig.silenceEnvChecks) + { logger.error("[Environment Checks] Optifine detected. This may cause issues due to base edits or ASM usage."); + } hasOptifine = true; modIds.add("optifine"); } @@ -55,7 +58,9 @@ public class EnvironmentChecks if (cl != null) { if (!CoreConfig.silenceEnvChecks) + { logger.error("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and spigot. Please try Sponge instead"); + } modIds.add("bukkit"); } } diff --git a/src/mantle/math/Dozenal.java b/src/mantle/math/Dozenal.java index 883fa15..ea8ec13 100644 --- a/src/mantle/math/Dozenal.java +++ b/src/mantle/math/Dozenal.java @@ -8,32 +8,32 @@ package mantle.math; * @author mDiyo */ -import com.google.common.collect.Lists; - import java.util.LinkedList; +import com.google.common.collect.Lists; + public class Dozenal { @SuppressWarnings("unused") - public static String convertToDozenal (byte i) + public static String convertToDozenal(byte i) { return convertDecimal(i); } @SuppressWarnings("unused") - public static String convertToDozenal (short i) + public static String convertToDozenal(short i) { return convertDecimal(i); } @SuppressWarnings("unused") - public static String convertToDozenal (int i) + public static String convertToDozenal(int i) { return convertDecimal(i); } - public static String convertDecimal (int i) + public static String convertDecimal(int i) { int num = i; LinkedList list = Lists.newLinkedList(); @@ -50,7 +50,7 @@ public class Dozenal return builder.toString(); } - public static char getDozenalCharacter (int i) + public static char getDozenalCharacter(int i) { assert i < 12 : "Base 10 number should be less than 12"; @@ -84,4 +84,4 @@ public class Dozenal return 'Q'; } -} \ No newline at end of file +} diff --git a/src/mantle/player/PlayerUtils.java b/src/mantle/player/PlayerUtils.java index 5c00465..e97ffa4 100644 --- a/src/mantle/player/PlayerUtils.java +++ b/src/mantle/player/PlayerUtils.java @@ -5,7 +5,7 @@ import net.minecraft.util.ChatComponentText; /** * Misc utils for dealing with players. - * + * * @author progwml6 */ public class PlayerUtils @@ -14,10 +14,12 @@ public class PlayerUtils /** * Sends a given message to a specific player (due to 1.7 axing addChatMessage()) */ - public static void sendChatMessage (EntityPlayer p, String message) + public static void sendChatMessage(EntityPlayer p, String message) { if (p != null && message != null && !message.isEmpty()) + { p.addChatComponentMessage(new ChatComponentText(message)); + } } } diff --git a/src/mantle/pulsar/config/ForgeCFG.java b/src/mantle/pulsar/config/ForgeCFG.java index 948bfb0..c75e344 100644 --- a/src/mantle/pulsar/config/ForgeCFG.java +++ b/src/mantle/pulsar/config/ForgeCFG.java @@ -1,19 +1,22 @@ package mantle.pulsar.config; -import net.minecraftforge.fml.common.Loader; +import java.io.File; + import mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.common.config.Configuration; - -import java.io.*; +import net.minecraftforge.fml.common.Loader; /** * Mantle specific pulsar addon class to support using the forge CFG format for configurations * @author progwml6 */ -public class ForgeCFG implements IConfiguration{ +public class ForgeCFG implements IConfiguration +{ private static Configuration config; + private final String confPath; + private final String description; /** @@ -24,26 +27,32 @@ public class ForgeCFG implements IConfiguration{ * @param confName The config file name (without path or .cfg suffix) * @param description The description for the group that the config entries will be placed in. */ - public ForgeCFG(String confName, String description) { + public ForgeCFG(String confName, String description) + { this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".cfg"; this.description = description; } @Override - public void load() { - config = new Configuration(new File(confPath)); + public void load() + { + config = new Configuration(new File(this.confPath)); config.load(); } @Override - public boolean isModuleEnabled(PulseMeta meta) { - return config.get(description, meta.getId(), meta.isEnabled(), meta.getDescription()).getBoolean(meta.isEnabled()); + public boolean isModuleEnabled(PulseMeta meta) + { + return config.get(this.description, meta.getId(), meta.isEnabled(), meta.getDescription()).getBoolean(meta.isEnabled()); } @Override - public void flush() { - if(config.hasChanged()) + public void flush() + { + if (config.hasChanged()) + { config.save(); + } } } diff --git a/src/mantle/pulsar/config/IConfiguration.java b/src/mantle/pulsar/config/IConfiguration.java index 01c67eb..cf14e24 100755 --- a/src/mantle/pulsar/config/IConfiguration.java +++ b/src/mantle/pulsar/config/IConfiguration.java @@ -7,7 +7,8 @@ import mantle.pulsar.pulse.PulseMeta; * * @author Arkan */ -public interface IConfiguration { +public interface IConfiguration +{ /** * Perform any configuration loading required. diff --git a/src/mantle/pulsar/control/PulseManager.java b/src/mantle/pulsar/control/PulseManager.java index 557aa53..08e512a 100755 --- a/src/mantle/pulsar/control/PulseManager.java +++ b/src/mantle/pulsar/control/PulseManager.java @@ -5,10 +5,13 @@ import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; -import com.google.common.eventbus.SubscriberExceptionContext; -import com.google.common.eventbus.SubscriberExceptionHandler; +import mantle.pulsar.config.IConfiguration; +import mantle.pulsar.internal.Configuration; +import mantle.pulsar.internal.CrashHandler; +import mantle.pulsar.internal.logging.ILogger; +import mantle.pulsar.internal.logging.LogManager; +import mantle.pulsar.pulse.Pulse; +import mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLModContainer; import net.minecraftforge.fml.common.Loader; @@ -16,13 +19,10 @@ import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import mantle.pulsar.config.IConfiguration; -import mantle.pulsar.internal.Configuration; -import mantle.pulsar.internal.CrashHandler; -import mantle.pulsar.pulse.PulseMeta; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.internal.logging.LogManager; -import mantle.pulsar.pulse.Pulse; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; +import com.google.common.eventbus.SubscriberExceptionContext; +import com.google.common.eventbus.SubscriberExceptionHandler; /** * Manager class for a given mods Pulses. @@ -36,17 +36,23 @@ import mantle.pulsar.pulse.Pulse; * @author Arkan */ @SuppressWarnings("unused") -public class PulseManager { +public class PulseManager +{ private ILogger log; + private final boolean useConfig; private final LinkedHashMap pulses = new LinkedHashMap(); private boolean blockNewRegistrations = false; + private boolean configLoaded = false; + private IConfiguration conf; + private EventBus bus; + private String id; /** @@ -56,10 +62,11 @@ public class PulseManager { * * @param configName The config file name. */ - public PulseManager(String configName) { - init(); - useConfig = true; - conf = new Configuration(configName, log); + public PulseManager(String configName) + { + this.init(); + this.useConfig = true; + this.conf = new Configuration(configName, this.log); } /** @@ -70,23 +77,25 @@ public class PulseManager { * * @param config Configuration handler. */ - public PulseManager(IConfiguration config) { - init(); - useConfig = true; - conf = config; + public PulseManager(IConfiguration config) + { + this.init(); + this.useConfig = true; + this.conf = config; } /** * Shared initialiser code between all the constructors. */ - private void init() { + private void init() + { String modId = Loader.instance().activeModContainer().getModId(); this.id = modId; - log = LogManager.getLogger("Pulsar-" + modId); + this.log = LogManager.getLogger("Pulsar-" + modId); FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this)); // Attach us to the mods FML bus and setup our own bus - bus = new EventBus(new BusExceptionHandler(modId)); - attachToContainerEventBus(this); + this.bus = new EventBus(new BusExceptionHandler(modId)); + this.attachToContainerEventBus(this); } /** @@ -96,18 +105,24 @@ public class PulseManager { * * @param pulse The Pulse to register. */ - public void registerPulse(Object pulse) { - if (blockNewRegistrations) throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " - + pulse); - if (!configLoaded) { - conf.load(); - configLoaded = true; + public void registerPulse(Object pulse) + { + if (this.blockNewRegistrations) + { + throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " + + pulse); + } + if (!this.configLoaded) + { + this.conf.load(); + this.configLoaded = true; } String id, description, deps; boolean forced, enabled, defaultEnabled, missingDeps = false; - try { + try + { Pulse p = pulse.getClass().getAnnotation(Pulse.class); id = p.id(); description = p.description(); @@ -115,18 +130,26 @@ public class PulseManager { forced = p.forced(); enabled = p.defaultEnable(); defaultEnabled = p.defaultEnable(); - } catch (NullPointerException ex) { + } + catch (NullPointerException ex) + { throw new RuntimeException("Could not parse @Pulse annotation for Pulse: " + pulse); } // Work around Java not allowing default-null fields. - if (description.equals("")) description = null; + if (description.equals("")) + { + description = null; + } - if (!deps.equals("")) { + if (!deps.equals("")) + { String[] parsedDeps = deps.split(";"); - for (String s : parsedDeps) { - if (!Loader.isModLoaded(s)) { - log.info("Skipping Pulse " + id + "; missing dependency: " + s); + for (String s : parsedDeps) + { + if (!Loader.isModLoaded(s)) + { + this.log.info("Skipping Pulse " + id + "; missing dependency: " + s); missingDeps = true; enabled = false; break; @@ -135,12 +158,13 @@ public class PulseManager { } PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); - meta.setEnabled(!missingDeps && getEnabledFromConfig(meta)); + meta.setEnabled(!missingDeps && this.getEnabledFromConfig(meta)); - if (meta.isEnabled()) { - pulses.put(pulse, meta); + if (meta.isEnabled()) + { + this.pulses.put(pulse, meta); // Attach Pulse to internal event bus - bus.register(pulse); + this.bus.register(pulse); } } @@ -149,24 +173,32 @@ public class PulseManager { * * @param obj Object to register. */ - private void attachToContainerEventBus(Object obj) { - ModContainer cnt = Loader.instance().activeModContainer(); - log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); - try { - FMLModContainer mc = (FMLModContainer)cnt; + private void attachToContainerEventBus(Object obj) + { + ModContainer cnt = Loader.instance().activeModContainer(); + this.log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); + try + { + FMLModContainer mc = (FMLModContainer) cnt; Field ebf = mc.getClass().getDeclaredField("eventBus"); boolean access = ebf.isAccessible(); ebf.setAccessible(true); - EventBus eb = (EventBus)ebf.get(mc); + EventBus eb = (EventBus) ebf.get(mc); ebf.setAccessible(access); eb.register(obj); - } catch (NoSuchFieldException nsfe) { + } + catch (NoSuchFieldException nsfe) + { throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?"); - } catch (IllegalAccessException iae) { + } + catch (IllegalAccessException iae) + { throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue."); - } catch (ClassCastException cce) { + } + catch (ClassCastException cce) + { throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage()); } } @@ -179,34 +211,32 @@ public class PulseManager { * @param evt An event object. */ @Subscribe - public void propagateEvent(FMLEvent evt) { - if (evt instanceof FMLPreInitializationEvent) preInit((FMLPreInitializationEvent) evt); - bus.post(evt); - } - - private boolean getEnabledFromConfig(PulseMeta meta) { - if (meta.isForced() || !useConfig) return true; // Forced or no config set. - - return conf.isModuleEnabled(meta); - } - - public void preInit(FMLPreInitializationEvent evt) { - if (!blockNewRegistrations) conf.flush(); // First preInit call, so flush config - blockNewRegistrations = true; - } - - private boolean hasRequiredPulses(Map.Entry entry) { - String deps = entry.getKey().getClass().getAnnotation(Pulse.class).pulsesRequired(); - if (!deps.equals("")) { - String[] parsedDeps = deps.split(";"); - for (String s : parsedDeps) { - if (!isPulseLoaded(s)) { - log.info("Skipping Pulse " + entry.getValue().getId() + "; missing pulse: " + s); - return false; - } - } + public void propagateEvent(FMLEvent evt) + { + if (evt instanceof FMLPreInitializationEvent) + { + this.preInit((FMLPreInitializationEvent) evt); } - return true; + this.bus.post(evt); + } + + private boolean getEnabledFromConfig(PulseMeta meta) + { + if (meta.isForced() || !this.useConfig) + { + return true; // Forced or no config set. + } + + return this.conf.isModuleEnabled(meta); + } + + public void preInit(FMLPreInitializationEvent evt) + { + if (!this.blockNewRegistrations) + { + this.conf.flush(); // First preInit call, so flush config + } + this.blockNewRegistrations = true; } /** @@ -215,42 +245,50 @@ public class PulseManager { * @param pulseId The ID to check. * @return Whether the ID was present. */ - public boolean isPulseLoaded(String pulseId) { - for(Map.Entry entry : pulses.entrySet()) { - if (entry.getValue().getId().equals(pulseId)) { + public boolean isPulseLoaded(String pulseId) + { + for (Map.Entry entry : this.pulses.entrySet()) + { + if (entry.getValue().getId().equals(pulseId)) + { return true; } } return false; } - public Collection getAllPulseMetadata() { - return pulses.values(); + public Collection getAllPulseMetadata() + { + return this.pulses.values(); } /** * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) */ - private class BusExceptionHandler implements SubscriberExceptionHandler { + private class BusExceptionHandler implements SubscriberExceptionHandler + { private final String id; /** * @param id Mod ID to include in exception raises. */ - public BusExceptionHandler(String id) { + public BusExceptionHandler(String id) + { this.id = id; } @Override - public void handleException(Throwable exception, SubscriberExceptionContext ctx) { - FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + id + " >> Exception uncaught in [" + public void handleException(Throwable exception, SubscriberExceptionContext ctx) + { + FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + this.id + " >> Exception uncaught in [" + ctx.getSubscriber().getClass().getName() + ":" + ctx.getSubscriberMethod().getName() + "] for event [" + ctx.getEvent().getClass().getSimpleName() + "]", true); } } @Override - public String toString() { - return "PulseManager[" + id + "]"; + public String toString() + { + return "PulseManager[" + this.id + "]"; } } diff --git a/src/mantle/pulsar/debug/EventSpy.java b/src/mantle/pulsar/debug/EventSpy.java index 6fa6bb5..36d11aa 100755 --- a/src/mantle/pulsar/debug/EventSpy.java +++ b/src/mantle/pulsar/debug/EventSpy.java @@ -1,25 +1,28 @@ package mantle.pulsar.debug; -import com.google.common.eventbus.Subscribe; import mantle.pulsar.internal.logging.ILogger; import mantle.pulsar.internal.logging.LogManager; import mantle.pulsar.pulse.Pulse; import net.minecraftforge.fml.common.Loader; +import com.google.common.eventbus.Subscribe; + /** * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. * * @author Arkan */ @SuppressWarnings("unused") -@Pulse(id="EventSpy", description="we iz in ur buses, monitorin ur eventz", forced=true) -public class EventSpy { +@Pulse(id = "EventSpy", description = "we iz in ur buses, monitorin ur eventz", forced = true) +public class EventSpy +{ private final ILogger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); @Subscribe - public void receive(Object evt) { - log.info("Received event: " + evt); + public void receive(Object evt) + { + this.log.info("Received event: " + evt); } } diff --git a/src/mantle/pulsar/internal/Configuration.java b/src/mantle/pulsar/internal/Configuration.java index ab5ba54..44769e9 100755 --- a/src/mantle/pulsar/internal/Configuration.java +++ b/src/mantle/pulsar/internal/Configuration.java @@ -1,29 +1,39 @@ package mantle.pulsar.internal; -import java.io.*; -import java.util.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.HashMap; +import java.util.Map; + +import mantle.pulsar.config.IConfiguration; +import mantle.pulsar.internal.logging.ILogger; +import mantle.pulsar.pulse.PulseMeta; +import net.minecraftforge.fml.common.Loader; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import net.minecraftforge.fml.common.Loader; -import mantle.pulsar.config.IConfiguration; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.pulse.PulseMeta; /** * Default Gson Configuration helper. * * @author Arkan */ -public class Configuration implements IConfiguration { +public class Configuration implements IConfiguration +{ private static final int CONFIG_LEVEL = 1; private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + private final String confPath; + private final ILogger logger; private Map modules; @@ -36,111 +46,151 @@ public class Configuration implements IConfiguration { * @param confName The config file name (without path or .json suffix) * @param logger The logger to send debug info to. */ - public Configuration(String confName, ILogger logger) { + public Configuration(String confName, ILogger logger) + { this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json"; this.logger = logger; } @Override - public void load() { - getModulesFromJson(); + public void load() + { + this.getModulesFromJson(); } @Override - public boolean isModuleEnabled(PulseMeta meta) { - ConfigEntry entry = modules.get(meta.getId()); - if (entry == null) { - modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); + public boolean isModuleEnabled(PulseMeta meta) + { + ConfigEntry entry = this.modules.get(meta.getId()); + if (entry == null) + { + this.modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); return meta.isEnabled(); - } else { + } + else + { return entry.getEnabled(); } } @Override - public void flush() { - writeModulesToJson(); + public void flush() + { + this.writeModulesToJson(); } - private void getModulesFromJson() { + private void getModulesFromJson() + { // Step 1: Does the file exist? - File f = new File(confPath); - if (!f.exists()) { - logger.info("Couldn't find config file; will generate a new one later."); - modules = new HashMap(); + File f = new File(this.confPath); + if (!f.exists()) + { + this.logger.info("Couldn't find config file; will generate a new one later."); + this.modules = new HashMap(); return; } // Step 2: File exists. Let's make sure it's usable. - if (!(f.canRead() && f.canWrite())) { - throw new FileNotReadWritableException("Could not read/write Pulsar config: " + confPath); + if (!(f.canRead() && f.canWrite())) + { + throw new FileNotReadWritableException("Could not read/write Pulsar config: " + this.confPath); } // Step 3: Good enough. Read it. - try { - try { - modules = parseV1Config(f); - } catch (Exception ex) { - logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); - Map conf = parseV0Config(f); - logger.info("Found valid v0 configuration. Upgrading it."); - modules = conf; - writeModulesToJson(); - logger.info("Upgrade complete! Config is now in v1 format."); + try + { + try + { + this.modules = this.parseV1Config(f); } - } catch (Exception ex) { - logger.warn("Invalid config file. Discarding."); + catch (Exception ex) + { + this.logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); + Map conf = this.parseV0Config(f); + this.logger.info("Found valid v0 configuration. Upgrading it."); + this.modules = conf; + this.writeModulesToJson(); + this.logger.info("Upgrade complete! Config is now in v1 format."); + } + } + catch (Exception ex) + { + this.logger.warn("Invalid config file. Discarding."); ex.printStackTrace(); - modules = new HashMap(); + this.modules = new HashMap(); } } - private Map parseV0Config(File f) throws Exception { - try { + private Map parseV0Config(File f) throws Exception + { + try + { JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); - Map m = gson.fromJson(reader, new TypeToken>(){}.getType()); // NASTY! - if (m == null) { + Map m = gson.fromJson(reader, new TypeToken>() + { + }.getType()); // NASTY! + if (m == null) + { throw new NullPointerException("Gson returned null."); } Map out = new HashMap(); - for (Map.Entry e : m.entrySet()) { + for (Map.Entry e : m.entrySet()) + { out.put(e.getKey(), new ConfigEntry(e.getValue())); } return out; - } catch (FileNotFoundException fnfe) { + } + catch (FileNotFoundException fnfe) + { throw new RuntimeException("This shouldn't be possible... " + fnfe); } } - private Map parseV1Config(File f) throws Exception { - try { + private Map parseV1Config(File f) throws Exception + { + try + { JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); GsonConfig c = gson.fromJson(reader, GsonConfig.class); - if (c.getConfigVersion() > 1) throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); - if (c.getModules() == null) throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); + if (c.getConfigVersion() > 1) + { + throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); + } + if (c.getModules() == null) + { + throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); + } return c.getModules(); - } catch (FileNotFoundException fnfe) { + } + catch (FileNotFoundException fnfe) + { throw new RuntimeException("This shouldn't be possible... " + fnfe); } } - private void writeModulesToJson() { - try { - JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(confPath)))); + private void writeModulesToJson() + { + try + { + JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(this.confPath)))); writer.setIndent(" "); - GsonConfig out = new GsonConfig(CONFIG_LEVEL, modules); + GsonConfig out = new GsonConfig(CONFIG_LEVEL, this.modules); gson.toJson(out, GsonConfig.class, writer); writer.close(); - } catch (Exception ex) { - logger.warn("Could not write config? " + confPath); + } + catch (Exception ex) + { + this.logger.warn("Could not write config? " + this.confPath); } } /** * Internal exception for an unreadable/unwritable config. */ - private static class FileNotReadWritableException extends RuntimeException { - public FileNotReadWritableException(String message) { + private static class FileNotReadWritableException extends RuntimeException + { + public FileNotReadWritableException(String message) + { super(message); } } @@ -148,53 +198,54 @@ public class Configuration implements IConfiguration { /** * Internal data holder, for use in the map and JSON. */ - private static class ConfigEntry { + private static class ConfigEntry + { private Boolean enabled; + private String description = null; - public ConfigEntry(Boolean enabled) { + public ConfigEntry(Boolean enabled) + { this.enabled = enabled; } - public ConfigEntry(Boolean enabled, String description) { + public ConfigEntry(Boolean enabled, String description) + { this(enabled); this.description = description; } - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(Boolean enabled) { - this.enabled = enabled; - } - - public String getDescription() { - return description; + public Boolean getEnabled() + { + return this.enabled; } } /** * Internal representation of a version 1+ config file. */ - private static class GsonConfig { + private static class GsonConfig + { private int CONFIG_VERSION = 0; private Map modules; - public GsonConfig(int version, Map modules) { + public GsonConfig(int version, Map modules) + { this.CONFIG_VERSION = version; this.modules = modules; } - public int getConfigVersion() { - return CONFIG_VERSION; + public int getConfigVersion() + { + return this.CONFIG_VERSION; } - public Map getModules() { - return modules; + public Map getModules() + { + return this.modules; } } diff --git a/src/mantle/pulsar/internal/CrashHandler.java b/src/mantle/pulsar/internal/CrashHandler.java index 30a4603..aa9233d 100755 --- a/src/mantle/pulsar/internal/CrashHandler.java +++ b/src/mantle/pulsar/internal/CrashHandler.java @@ -1,46 +1,59 @@ package mantle.pulsar.internal; -import net.minecraftforge.fml.common.ICrashCallable; import mantle.pulsar.control.PulseManager; import mantle.pulsar.pulse.PulseMeta; +import net.minecraftforge.fml.common.ICrashCallable; /** * FML crash callable for Pulse Managers; dumps a list of loaded pulses to the error log. * * @author Arkan */ -public class CrashHandler implements ICrashCallable { +public class CrashHandler implements ICrashCallable +{ private String id; + private PulseManager manager; - public CrashHandler(String modId, PulseManager manager) { + public CrashHandler(String modId, PulseManager manager) + { this.id = "Pulsar/" + modId + " loaded Pulses"; this.manager = manager; } @Override - public String getLabel() { - return id; + public String getLabel() + { + return this.id; } @Override - public String call() throws Exception { + public String call() throws Exception + { String out = "\n"; - for (PulseMeta meta : manager.getAllPulseMetadata()) { + for (PulseMeta meta : this.manager.getAllPulseMetadata()) + { String state = getStateFromMeta(meta); out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... } return out; } - private static String getStateFromMeta(PulseMeta meta) { - if (meta.isForced()) { + private static String getStateFromMeta(PulseMeta meta) + { + if (meta.isForced()) + { return "Enabled/Forced"; - } else { - if (meta.isEnabled()) { + } + else + { + if (meta.isEnabled()) + { return "Enabled/Not Forced"; - } else { + } + else + { return "Disabled/Not Forced"; } } diff --git a/src/mantle/pulsar/internal/logging/ILogger.java b/src/mantle/pulsar/internal/logging/ILogger.java index 2d26787..d1b38d6 100755 --- a/src/mantle/pulsar/internal/logging/ILogger.java +++ b/src/mantle/pulsar/internal/logging/ILogger.java @@ -6,7 +6,8 @@ package mantle.pulsar.internal.logging; * @author Arkan */ @SuppressWarnings("unused") -public interface ILogger { +public interface ILogger +{ public void fatal(String msg); diff --git a/src/mantle/pulsar/internal/logging/JULLogger.java b/src/mantle/pulsar/internal/logging/JULLogger.java index 13cbd43..b632936 100755 --- a/src/mantle/pulsar/internal/logging/JULLogger.java +++ b/src/mantle/pulsar/internal/logging/JULLogger.java @@ -7,42 +7,50 @@ import java.util.logging.Logger; * * @author Arkan */ -public class JULLogger implements ILogger { +public class JULLogger implements ILogger +{ private final Logger log; - public JULLogger(String name) { - log = Logger.getLogger(name); + public JULLogger(String name) + { + this.log = Logger.getLogger(name); } @Override - public void fatal(String msg) { - log.severe(msg); // JUL doesn't -have- fatal... + public void fatal(String msg) + { + this.log.severe(msg); // JUL doesn't -have- fatal... } @Override - public void severe(String msg) { - log.severe(msg); + public void severe(String msg) + { + this.log.severe(msg); } @Override - public void warn(String msg) { - log.warning(msg); + public void warn(String msg) + { + this.log.warning(msg); } @Override - public void info(String msg) { - log.info(msg); + public void info(String msg) + { + this.log.info(msg); } @Override - public void debug(String msg) { - log.fine(msg); // Good enough. + public void debug(String msg) + { + this.log.fine(msg); // Good enough. } @Override - public void trace(String msg) { - log.finest(msg); // Closest we'll get. + public void trace(String msg) + { + this.log.finest(msg); // Closest we'll get. } } diff --git a/src/mantle/pulsar/internal/logging/Log4jLogger.java b/src/mantle/pulsar/internal/logging/Log4jLogger.java index 9f38239..ab6c80d 100755 --- a/src/mantle/pulsar/internal/logging/Log4jLogger.java +++ b/src/mantle/pulsar/internal/logging/Log4jLogger.java @@ -7,42 +7,50 @@ import org.apache.logging.log4j.Logger; * * @author Arkan */ -public class Log4jLogger implements ILogger { +public class Log4jLogger implements ILogger +{ private final Logger log; - public Log4jLogger(String name) { - log = org.apache.logging.log4j.LogManager.getLogger(name); + public Log4jLogger(String name) + { + this.log = org.apache.logging.log4j.LogManager.getLogger(name); } @Override - public void fatal(String msg) { - log.fatal(msg); + public void fatal(String msg) + { + this.log.fatal(msg); } @Override - public void severe(String msg) { - log.error(msg); + public void severe(String msg) + { + this.log.error(msg); } @Override - public void warn(String msg) { - log.warn(msg); + public void warn(String msg) + { + this.log.warn(msg); } @Override - public void info(String msg) { - log.info(msg); + public void info(String msg) + { + this.log.info(msg); } @Override - public void debug(String msg) { - log.debug(msg); + public void debug(String msg) + { + this.log.debug(msg); } @Override - public void trace(String msg) { - log.trace(msg); + public void trace(String msg) + { + this.log.trace(msg); } } diff --git a/src/mantle/pulsar/internal/logging/LogManager.java b/src/mantle/pulsar/internal/logging/LogManager.java index b727ebf..16b2ba9 100755 --- a/src/mantle/pulsar/internal/logging/LogManager.java +++ b/src/mantle/pulsar/internal/logging/LogManager.java @@ -5,9 +5,12 @@ package mantle.pulsar.internal.logging; * * @author Arkan */ -public class LogManager { +public class LogManager +{ - private LogManager() {} // Singleton. + private LogManager() + { + } // Singleton. private static final boolean useLog4j2; @@ -16,22 +19,33 @@ public class LogManager { * * If it's present, we can assume we should be using the damn thing. */ - static { + static + { boolean l4j = false; - try { + try + { Class cl = Class.forName("org.apache.logging.log4j.LogManager"); - if (cl == null) throw new ClassNotFoundException("This should never happen..."); + if (cl == null) + { + throw new ClassNotFoundException("This should never happen..."); + } l4j = true; - } catch (ClassNotFoundException cnfe) { + } + catch (ClassNotFoundException cnfe) + { // Ignore } useLog4j2 = l4j; } - public static ILogger getLogger(String name) { - if (useLog4j2) { + public static ILogger getLogger(String name) + { + if (useLog4j2) + { return new Log4jLogger(name); - } else { + } + else + { return new JULLogger(name); } } diff --git a/src/mantle/pulsar/pulse/Pulse.java b/src/mantle/pulsar/pulse/Pulse.java index 9ebce64..ad9366c 100755 --- a/src/mantle/pulsar/pulse/Pulse.java +++ b/src/mantle/pulsar/pulse/Pulse.java @@ -1,6 +1,10 @@ package mantle.pulsar.pulse; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * Metadata annotation for IPulse implementations. @@ -11,9 +15,10 @@ import java.lang.annotation.*; * @author Arkan */ @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) +@Target({ ElementType.TYPE }) @Documented -public @interface Pulse { +public @interface Pulse +{ /** * @return This Pulses UID - Much like FML mods have mod IDs. diff --git a/src/mantle/pulsar/pulse/PulseMeta.java b/src/mantle/pulsar/pulse/PulseMeta.java index 7059a9e..c1ef504 100755 --- a/src/mantle/pulsar/pulse/PulseMeta.java +++ b/src/mantle/pulsar/pulse/PulseMeta.java @@ -5,12 +5,15 @@ package mantle.pulsar.pulse; * * @author Arkan */ -public class PulseMeta { +public class PulseMeta +{ private String id, description; + private boolean forced, enabled, defaultEnabled; - public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) { + public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) + { this.id = id; this.description = description; this.forced = forced; @@ -18,27 +21,33 @@ public class PulseMeta { this.defaultEnabled = defaultEnabled; } - public String getId() { - return id; + public String getId() + { + return this.id; } - public String getDescription() { - return description; + public String getDescription() + { + return this.description; } - public boolean isForced() { - return forced; + public boolean isForced() + { + return this.forced; } - public boolean isEnabled() { - return enabled; + public boolean isEnabled() + { + return this.enabled; } - public void setEnabled(boolean enabled) { + public void setEnabled(boolean enabled) + { this.enabled = enabled; } - public boolean isDefaultEnabled() { - return defaultEnabled; + public boolean isDefaultEnabled() + { + return this.defaultEnabled; } } diff --git a/src/mantle/utils/ItemMetaWrapper.java b/src/mantle/utils/ItemMetaWrapper.java index e44c59c..36df03e 100644 --- a/src/mantle/utils/ItemMetaWrapper.java +++ b/src/mantle/utils/ItemMetaWrapper.java @@ -3,11 +3,14 @@ package mantle.utils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemMetaWrapper { +public class ItemMetaWrapper +{ public final Item item; + public final Integer meta; - public ItemMetaWrapper(Item item, Integer meta) { + public ItemMetaWrapper(Item item, Integer meta) + { this.item = item; this.meta = meta; } @@ -19,21 +22,32 @@ public class ItemMetaWrapper { } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || this.getClass() != o.getClass()) + { + return false; + } ItemMetaWrapper itemMeta = (ItemMetaWrapper) o; - if (item != null ? !(item == itemMeta.item) : itemMeta.item != null) return false; - return !(meta != null ? !meta.equals(itemMeta.meta) : itemMeta.meta != null); + if (this.item != null ? !(this.item == itemMeta.item) : itemMeta.item != null) + { + return false; + } + return !(this.meta != null ? !this.meta.equals(itemMeta.meta) : itemMeta.meta != null); } @Override - public int hashCode() { - int result = item != null ? item.hashCode() : 0; - result = 31 * result + (meta != null ? meta.hashCode() : 0); + public int hashCode() + { + int result = this.item != null ? this.item.hashCode() : 0; + result = 31 * result + (this.meta != null ? this.meta.hashCode() : 0); return result; } } diff --git a/src/mantle/utils/ItemStackNBTWrapper.java b/src/mantle/utils/ItemStackNBTWrapper.java index 932cf62..bd78329 100644 --- a/src/mantle/utils/ItemStackNBTWrapper.java +++ b/src/mantle/utils/ItemStackNBTWrapper.java @@ -2,17 +2,26 @@ package mantle.utils; import net.minecraft.item.ItemStack; -public class ItemStackNBTWrapper { +public class ItemStackNBTWrapper +{ public final ItemStack stack; - public ItemStackNBTWrapper(ItemStack stack) { + public ItemStackNBTWrapper(ItemStack stack) + { this.stack = stack; } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || this.getClass() != o.getClass()) + { + return false; + } ItemStackNBTWrapper that = (ItemStackNBTWrapper) o; @@ -20,11 +29,12 @@ public class ItemStackNBTWrapper { } @Override - public int hashCode() { - int result = stack.getItem() != null ? stack.getItem().hashCode() : 0; - result = 31 * result + stack.getItemDamage(); - result = 31 * result + (stack.getTagCompound() != null ? stack.getTagCompound().hashCode() : 0); - result = 31 * result + stack.stackSize; + public int hashCode() + { + int result = this.stack.getItem() != null ? this.stack.getItem().hashCode() : 0; + result = 31 * result + this.stack.getItemDamage(); + result = 31 * result + (this.stack.getTagCompound() != null ? this.stack.getTagCompound().hashCode() : 0); + result = 31 * result + this.stack.stackSize; return result; } } diff --git a/src/mantle/utils/ItemStackWrapper.java b/src/mantle/utils/ItemStackWrapper.java index 261762f..b8eb378 100644 --- a/src/mantle/utils/ItemStackWrapper.java +++ b/src/mantle/utils/ItemStackWrapper.java @@ -3,35 +3,49 @@ package mantle.utils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemStackWrapper extends ItemMetaWrapper { +public class ItemStackWrapper extends ItemMetaWrapper +{ public final Integer stacksize; - public ItemStackWrapper(Item item, Integer meta, Integer stacksize) { + public ItemStackWrapper(Item item, Integer meta, Integer stacksize) + { super(item, meta); this.stacksize = stacksize; } - public ItemStackWrapper(ItemStack stack, Integer stacksize) { + public ItemStackWrapper(ItemStack stack, Integer stacksize) + { super(stack); this.stacksize = stacksize; } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (o == null || this.getClass() != o.getClass()) + { + return false; + } + if (!super.equals(o)) + { + return false; + } ItemStackWrapper that = (ItemStackWrapper) o; - return !(stacksize != null ? !stacksize.equals(that.stacksize) : that.stacksize != null); + return !(this.stacksize != null ? !this.stacksize.equals(that.stacksize) : that.stacksize != null); } @Override - public int hashCode() { + public int hashCode() + { int result = super.hashCode(); - result = 31 * result + (stacksize != null ? stacksize.hashCode() : 0); + result = 31 * result + (this.stacksize != null ? this.stacksize.hashCode() : 0); return result; } } diff --git a/src/mantle/utils/RecipeRemover.java b/src/mantle/utils/RecipeRemover.java index 3ddbef9..8da1de6 100644 --- a/src/mantle/utils/RecipeRemover.java +++ b/src/mantle/utils/RecipeRemover.java @@ -15,13 +15,15 @@ import net.minecraftforge.common.ChestGenHooks; @SuppressWarnings("unchecked") public class RecipeRemover { - public static void removeShapedRecipes (List removelist) + public static void removeShapedRecipes(List removelist) { for (ItemStack stack : removelist) + { removeShapedRecipe(stack); + } } - public static void removeAnyRecipe (ItemStack resultItem) + public static void removeAnyRecipe(ItemStack resultItem) { List recipes = CraftingManager.getInstance().getRecipeList(); for (int i = 0; i < recipes.size(); i++) @@ -35,7 +37,7 @@ public class RecipeRemover } } - public static void removeShapedRecipe (ItemStack resultItem) + public static void removeShapedRecipe(ItemStack resultItem) { List recipes = CraftingManager.getInstance().getRecipeList(); for (int i = 0; i < recipes.size(); i++) @@ -54,7 +56,7 @@ public class RecipeRemover } } - public static void removeShapelessRecipe (ItemStack resultItem) + public static void removeShapelessRecipe(ItemStack resultItem) { List recipes = CraftingManager.getInstance().getRecipeList(); for (int i = 0; i < recipes.size(); i++) @@ -73,24 +75,24 @@ public class RecipeRemover } } - public static void removeFurnaceRecipe (ItemStack resultItem) + public static void removeFurnaceRecipe(ItemStack resultItem) { Map recipes = FurnaceRecipes.instance().getSmeltingList(); recipes.remove(resultItem); } - public static void removeFurnaceRecipe (Item i, int metadata) + public static void removeFurnaceRecipe(Item i, int metadata) { removeFurnaceRecipe(new ItemStack(i, 1, metadata)); } - public static void removeFurnaceRecipe (Item i) + public static void removeFurnaceRecipe(Item i) { removeFurnaceRecipe(new ItemStack(i, 1, 32767)); } //removes from all vanilla worldgen chests :D - public static void removeFromChests (ItemStack resultItem) + public static void removeFromChests(ItemStack resultItem) { ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).removeItem(resultItem); ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).removeItem(resultItem); diff --git a/src/mantle/world/ChunkCoord.java b/src/mantle/world/ChunkCoord.java index e6154e2..30bbfff 100644 --- a/src/mantle/world/ChunkCoord.java +++ b/src/mantle/world/ChunkCoord.java @@ -9,12 +9,13 @@ import net.minecraft.world.chunk.Chunk; * Standardized implementation for representing and manipulating Chunk Coordinates. Provides standard Java Collection interaction. * From COFH LIB(modified to use mantle's coordtuple instead) * @author King Lemming - * + * */ public final class ChunkCoord implements Comparable, Serializable { public int chunkX; + public int chunkZ; public ChunkCoord(Chunk chunk) @@ -37,26 +38,26 @@ public final class ChunkCoord implements Comparable, Serializable this.chunkZ = z; } - public int getCenterX () + public int getCenterX() { return (this.chunkX << 4) + 8; } - public int getCenterZ () + public int getCenterZ() { return (this.chunkZ << 4) + 8; } - public ChunkCoord copy () + public ChunkCoord copy() { - return new ChunkCoord(chunkX, chunkZ); + return new ChunkCoord(this.chunkX, this.chunkZ); } @Override - public boolean equals (Object obj) + public boolean equals(Object obj) { if (!(obj instanceof ChunkCoord)) @@ -68,16 +69,16 @@ public final class ChunkCoord implements Comparable, Serializable } @Override - public int hashCode () + public int hashCode() { - int hash = chunkX; + int hash = this.chunkX; hash *= 31 + this.chunkZ; return hash; } @Override - public String toString () + public String toString() { return "[" + this.chunkX + ", " + this.chunkZ + "]"; @@ -85,7 +86,7 @@ public final class ChunkCoord implements Comparable, Serializable /* Comparable */ @Override - public int compareTo (ChunkCoord other) + public int compareTo(ChunkCoord other) { return this.chunkX == other.chunkX ? this.chunkZ - other.chunkZ : this.chunkX - other.chunkX; diff --git a/src/mantle/world/CoordTuplePair.java b/src/mantle/world/CoordTuplePair.java index 2bee4f4..5a59570 100644 --- a/src/mantle/world/CoordTuplePair.java +++ b/src/mantle/world/CoordTuplePair.java @@ -10,6 +10,7 @@ import net.minecraft.util.BlockPos; public class CoordTuplePair { public BlockPos a; + public BlockPos b; public CoordTuplePair(BlockPos a, BlockPos b) @@ -23,4 +24,4 @@ public class CoordTuplePair this.a = new BlockPos(aX, aY, aZ); this.b = new BlockPos(bX, bY, bZ); } -} \ No newline at end of file +} diff --git a/src/mantle/world/DimensionCoordPair.java b/src/mantle/world/DimensionCoordPair.java index 660b3c5..8f8a8f6 100644 --- a/src/mantle/world/DimensionCoordPair.java +++ b/src/mantle/world/DimensionCoordPair.java @@ -8,49 +8,56 @@ package mantle.world; public class DimensionCoordPair { public final int dim; + public final int x; + public final int z; public DimensionCoordPair(int worldID, int posX, int posZ) { - dim = worldID; - x = posX; - z = posZ; + this.dim = worldID; + this.x = posX; + this.z = posZ; } - public boolean equalCoords (int worldID, int posX, int posZ) + public boolean equalCoords(int worldID, int posX, int posZ) { return this.dim == posX && this.x == posX && this.z == posZ; } @Override - public boolean equals (Object obj) + public boolean equals(Object obj) { if (obj == null) + { return false; + } - if (getClass() == obj.getClass()) + if (this.getClass() == obj.getClass()) { DimensionCoordPair coord = (DimensionCoordPair) obj; if (this.dim == coord.dim && this.x == coord.x && this.z == coord.z) + { return true; + } } return false; } @Override - public int hashCode () + public int hashCode() { final int prime = 37; int result = 1; - result = prime * result + dim; - result = prime * result + x; - result = prime * result + z; + result = prime * result + this.dim; + result = prime * result + this.x; + result = prime * result + this.z; return result; } - public String toString () + @Override + public String toString() { - return "Dim: " + dim + ", X: " + x + ", Z: " + z; + return "Dim: " + this.dim + ", X: " + this.x + ", Z: " + this.z; } } diff --git a/src/mantle/world/DimensionCoordTuple.java b/src/mantle/world/DimensionCoordTuple.java index 8ee1bdd..b35fe04 100644 --- a/src/mantle/world/DimensionCoordTuple.java +++ b/src/mantle/world/DimensionCoordTuple.java @@ -9,51 +9,57 @@ package mantle.world; public class DimensionCoordTuple { public final int dim; + public final int x; + public final int y; + public final int z; public DimensionCoordTuple(int worldID, int posX, int posY, int posZ) { - dim = worldID; - y = posY; - x = posX; - z = posZ; + this.dim = worldID; + this.y = posY; + this.x = posX; + this.z = posZ; } - public boolean equalCoords (int worldID, int posX, int posY, int posZ) + public boolean equalCoords(int worldID, int posX, int posY, int posZ) { return this.dim == worldID && this.x == posX && this.y == posY && this.z == posZ; } @Override - public boolean equals (Object obj) + public boolean equals(Object obj) { if (obj == null) + { return false; + } - if (getClass() == obj.getClass()) + if (this.getClass() == obj.getClass()) { DimensionCoordTuple coord = (DimensionCoordTuple) obj; - return equalCoords(coord.dim, coord.x, coord.y, coord.z); + return this.equalCoords(coord.dim, coord.x, coord.y, coord.z); } return false; } @Override - public int hashCode () + public int hashCode() { final int prime = 37; int result = 1; - result = prime * result + dim; - result = prime * result + x; - result = prime * result + y; - result = prime * result + z; + result = prime * result + this.dim; + result = prime * result + this.x; + result = prime * result + this.y; + result = prime * result + this.z; return result; } - public String toString () + @Override + public String toString() { - return "Dim: " + dim + ", X: " + x + ", Y: " + y + ", Z: " + z; + return "Dim: " + this.dim + ", X: " + this.x + ", Y: " + this.y + ", Z: " + this.z; } } diff --git a/src/mantle/world/DirectionUtils.java b/src/mantle/world/DirectionUtils.java index 3d1fbd4..5b4aa20 100644 --- a/src/mantle/world/DirectionUtils.java +++ b/src/mantle/world/DirectionUtils.java @@ -16,12 +16,12 @@ public class DirectionUtils // No instantiation } - public static boolean isRightAngles (EnumFacing a, EnumFacing b) + public static boolean isRightAngles(EnumFacing a, EnumFacing b) { return a != b && a != b.getOpposite(); } - public static boolean isHorizontal (EnumFacing a) + public static boolean isHorizontal(EnumFacing a) { return a == EnumFacing.EAST || a == EnumFacing.NORTH || a == EnumFacing.SOUTH || a == EnumFacing.WEST; } From d0c7d26a10905f5755192ffeb403a298e078af3d Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 25 Apr 2015 21:58:22 -0400 Subject: [PATCH 25/91] Forgot to push this. --- src/mantle/items/util/IItemWithVariants.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/mantle/items/util/IItemWithVariants.java diff --git a/src/mantle/items/util/IItemWithVariants.java b/src/mantle/items/util/IItemWithVariants.java new file mode 100644 index 0000000..efbd31a --- /dev/null +++ b/src/mantle/items/util/IItemWithVariants.java @@ -0,0 +1,6 @@ +package mantle.items.util; + +public interface IItemWithVariants +{ + String[] getVariantNames(); +} From ec3cc219f060c83ccf98ecfa6a0e010b1e87ec1e Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 25 Apr 2015 22:42:24 -0400 Subject: [PATCH 26/91] Remove the replace of the MOD_ID. --- src/mantle/client/ModelVariant.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 6a070fe..04a6588 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -52,8 +52,7 @@ public class ModelVariant public void registerItemModel(Item item, String name, int meta) { - String NAME = name.replace(this.MOD_ID + ".", ""); - this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(NAME, "inventory")); + this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(name, "inventory")); } private ModelResourceLocation getModelResource(String name, String type) From 30a05ebeaee856a24e1df400521f306731e28ece Mon Sep 17 00:00:00 2001 From: Alexander Date: Sun, 26 Apr 2015 02:12:20 -0400 Subject: [PATCH 27/91] Add a way to register multiple item variants. --- src/mantle/client/ModelVariant.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 04a6588..dbc5351 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -3,6 +3,7 @@ package mantle.client; import java.util.Collection; import mantle.blocks.util.BlockVariant; +import mantle.items.util.IItemWithVariants; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; @@ -55,6 +56,16 @@ public class ModelVariant this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(name, "inventory")); } + public void registerItemModelVariants(Item item) + { + for (int i = 0; i < ((IItemWithVariants) item).getVariantNames().length; i++) + { + String NAME = item.getUnlocalizedName().substring(5) + "_" + ((IItemWithVariants) item).getVariantNames()[i]; + ModelBakery.addVariantName(item, (this.MOD_ID + ":") + NAME); + this.registerItemModel(item, NAME, i); + } + } + private ModelResourceLocation getModelResource(String name, String type) { return new ModelResourceLocation((this.MOD_ID + ":") + name, type); From 82f48263aaeaf0266f0fdf130113702279bb4e17 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 29 Apr 2015 22:13:55 -0400 Subject: [PATCH 28/91] Add a method to allow the spawn eggs to render correctly. --- src/mantle/client/ModelVariant.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index dbc5351..c6a79dc 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -1,5 +1,6 @@ package mantle.client; +import java.util.ArrayList; import java.util.Collection; import mantle.blocks.util.BlockVariant; @@ -8,7 +9,9 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -66,6 +69,16 @@ public class ModelVariant } } + public void registerItemSubTypesModel(Item item, CreativeTabs tab) + { + ArrayList list = new ArrayList(); + item.getSubItems(item, tab, list); + for (ItemStack i : list) + { + this.registerItemModel(item, item.getUnlocalizedName().substring(5), i.getItemDamage()); + } + } + private ModelResourceLocation getModelResource(String name, String type) { return new ModelResourceLocation((this.MOD_ID + ":") + name, type); From 2737713f6ccdee611eecb26fcc3da9c407eb2219 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Sun, 10 May 2015 14:11:44 -0400 Subject: [PATCH 29/91] update to gradle 2.4 --- gradle/wrapper/gradle-wrapper.jar | Bin 51017 -> 52266 bytes gradle/wrapper/gradle-wrapper.properties | 4 +- gradlew.bat | 180 +++++++++++------------ 3 files changed, 92 insertions(+), 92 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b7612167031001b7b84baf2a959e8ea8ad03c011..b5166dad4d90021f6a0b45268c0755719f1d5cd4 100644 GIT binary patch delta 23033 zcmZ6yb8w(dvpyVdY}>Y-Y-}4F+jert+1R#id*f_u+xEtre9!Z~r|S2e^H+EE^i0)# zPuI*feRcni1+Pp8M^usphkykEfrbV#R4$Q7K%{{AS31)z?+GRFYha#b+&bSmgM$1& zw;%tyl@dezM~+kdSN>u8k4&Nl-G%vgV0b%p89fOF%od1=fMJoZl$R5-GXl4$^)Piv zxUYMRvSYu4dMS!-`kq1zigq(NeaZhY$n#)QbVmupFqzA0UpeI2B9Y!P7b)pYv%ytmD|GV8E^RXW@&z$+X4T< zlG%iv^!8)uMpCz^ng`P*r2kk})&radcB-z(m1>7Rb(Tpw);D-Og@(^S;Lx5pnNOg? zcvlcys+UbwwxbXVjc?0{dQ#ey8EK%__NQhpp(1b$Mr%cb$*NV1>tf16-v0R!zH4nd`h9Iclz*Op5YKa<{v8-J8~dxl16n z{w+6b>kVF4!H-^Cn#oc<5(vl6m6!gIw038eAXU?{anVjmO!^t3%3sNHSk}y4d3K?n z;RMK4&l#8t15QJaHS=UTg*mdR`skRgGsy393h>%GNx{UUW;!)SV77W>S>F*~Q95Ll zV~+YrKDQOJP5KqqM|e~W9M9m7%OaeOtM&Y~Vt>KgM~@3o;o(^sEwmhl!H_Ym>-JB9 z+PTF8aGJl@4@;DXFw)xfU7u`MGrL8AP-M2Q!3rv}(RYe0g45G5r*U;=Uu78YjC zj3%~5E-s--?+)`y=%amUqqKD_BaU+EXgRRrnqdwslwqbYC`2&kl#O=wQCNR=13Q~QBJ8GOfUB1 zC!fe>iX*Xb!mQ!XxUz2^IKV2*;5yqN>*fi3!@2ZTy1t#yFPz37gZp)5gMuF06@Ezy zoL#M@nWL2^(0ts{9c3dS1&b{NKjsMB44sdPiee=;l{;H&UCM@$IqY%@l&*3sh}4GF z7=D~}#2TG3Bq-tD{}x;7fu}=M%L~v34;wM|eOGhy_T@iH9nozGjRLT8+o%=Dmnluc zjJ5DZ*^<}JLR1dWG~I?Cd6WC;?8?>=|Cr+n*oB$SHMQmnMkl zh_J=@v@`7q<02_b75$VH;m6#EIfBVy9US@kaCo!OD*|hqri-wyjcj0gc@~t{6D)@F zkx_>1LmSlCo`==bfdDka7o|S4P1d)iv`UBb^_ufA_V$Vg3HX%;ul1 zp&t|j64{UN%hKk*c|}6}zpH%0P^S44-=|bVb4t~c$=tIVuTsjO@XXwIN2EgW%PU#s ztcs8r_QI!Yzw(jhC47Wg`h~5swnM;}&DSvoG`TpYDzpkXq5yoLFX|xEue-@ev3+TM z^aXSwy$U4naHpI2IfEE7*F_VcIz@~okJIm`(cjZNEVOh(HDUD0q_%=5{8#aFk#Q?KU=K z4zxF&T~$M2&S=!neh^^E@87U=Xoi|W{SV{7de?sFw$d&D%Xy93addR>A*fKSa|*EUFxKL@l@0YTAH03`98%DaRA&l2d)tJXXP1-b}vI zWv!NIz#J9!C6A382Q2PX;EAI451f3#@}l=toqTcg5{50rI|+tQOh0|`M{gV94Sw!N zDf`ldF^$fJ)(zdND}QFf8(?MaAfIKi_{ttTjNay8_u`E{-}?1CQH2o=-HP&fQAKva zB1UUP0Xj}&j(Qtf)E!}Fv`Q|e6&u0gQ%@B%kY?ayI)@X2<;Z86v37X|bm*hM&=u%xF-zh0a^Y96?w|QIY3~gQu1rJW2 z%xtvTec8fN{06Ac*-^YUnGv1~gGSVztAl3qft0fKPn5yMQJD$2PJtQ*bhkUET?>wl zc(-~S=QQ}jYy5^wk!6pR9y1#{y3U-O+07Dvi55BetXRZi_fAZQceu_jHll|L@7CNq z3kjbs>SSAa*BOt#niVt$>Gnfgr!EXgx2Z+9a^lu}p0{+$i0C7$WvndQ31jTmzQ}PR zKo4>r!$iE_^Soxs2g_->!nfHJi^*mhmEw3djj;Bh#P}BKw zIMJ@%W^L{YP!;N~KZfPQt3{+%!agXl(+JnZ`jbK|gfi;VKd}DR=%z}f@8-5}H;>QS zb4fiJmS{2^H2%(W0Uw{$nU#|{+AtL_y4TFK@s66b&PdFT>27fS0n>)yX;o_+?tcragzHP5Ptauw4 z2}yr1vr>pnjWgVBU-eRP`T;LwA<;-NiW;~Uz2rph93XYS6p6-3+(}{p19|Gz2kIC=zX3+Gr)26GBcCC< zb7>V8#2=eNN6-+y&F!FZjtmu@=ymG3x0VDbn&$e# zH+-GDpnb(ZI+oQONxG~%9SB65J|T?ZtD-ZQO8&w;CYEy7x7B$%l zLsp3DZ6I%gK0(Ei<6ptM*)J<||AXINamS=4{5?Jr9#>&3XRQ9B@Fkrk6cRFYUQ;C< zj_2nAVz|Gdwn;0p`&_6~s^B<(+?bVL%Q3AjGkDqbKyco%1@1n)oxixTXhZQmbdJ(6 z*gowIR_OWl-CILk&KuAJR^nwN+vY)am(>fI2j>(1s8qI5=#DGypsY~`AKSd+4qXz> z`+q&*t7$b6#vJ|ZH#*aV+%?8ot{di@KZrHs95uMZ7ci*nyeo9&OoR$Myhm{K2F=(rLeHVm=pP)_8Wq&{Pe%eC*mwLz4%i>yzSPfnHyPShp<4f!_^HQN{XDJ4tcfL~e@sk7Rlf^VQ`rbqO@b>n7yy_I^MlJFX<6 zz9Cu^1D{Y9AEqy`$R#GDqC@FsQJ}eYCHb0N)_p`Y9o6pnc9uG6S#WtlS7P*A>{RH_BLNKZEX8EN$=A;n{D(^fTJ_v-sNACi zdiRsq>OU^{-_cmulX!FJ-LWPZUZz=lq1Ra=XmTx$%}ZHC>3<|!+(l!_?_j(&f6?v7Pgq8BBeQL%~D%r%aYu=GmqAbkFy`rD*SsN*>N zfLt=7&VMlnWaW_rGG(nBm&LrE5?-MkXLqg&hYMT?5EPtDNNEZXnwuJ`8A%kgmYR|Y?B zb3RMBGXG}65gZ(CI=vq<4PupyPe0TT_8lCkhTtZ~D-o_d%7-@-*6_+0I1;ul;R5f* zXRAX_PicgO^unmqXcyVz0Mo`P=Ifx9^5LnzT_Ja?Kp$Xe`v## z9^9UB?R>I3^!AaqpK{+~p>#;YS;DaFT0+f1L*Gy{}lv zrkZQ1%^KuML9c@cQ)}0}+Y(wcu4!reojk&XC8Ot}OV+|NHZ@Ohx0rRssEi}`23$%z zHzXh<_K6*EL~&jTn^EPC7~hKR+u#W!z)a0V#4Z^FRNK)udf?hJ7A;v}aA6R}gTdUl zR63TT;sf$Y`Q7j|a?^N})x&`_GzppB0+IIc+(a9z(5`fim~(fMMzT_vt=8pf$tG?~ z%!=klC5A0;?^RZn+MnC)M#9Y)*9h5EI^LjBd^X2j18TG5 zplxnZG+vVUXFZu_>VqLvSk5={r_%V2$rVGt3SEC;%UipT%wy4+kh}q;ljaTyNC&zx;pWTslVtN#D+Ko=ZU#cj7e+#gRv1z>m z@kIN{x+{%9VuFr+QEw*m;b9&f5*4A!{AvusGxu=XFY>6gt@v~_wYT|`Qh0v6*j7Lv z8r9YBDW3sH zEX6<#X(m{H;xso7!pD9T!b|@xc1V*e_j+a0aAFq~g3lDd^v0o($NhXN;5aKW&HnCR8UZSDu-`n3Kq_T(RSOaeu+R21FY2XQHv;(;U$YBHLmx{I*Nd@mDHt|aQQ zTSn7TrzEe;K_fxm2U_j7^lX2(k96&y@9>*KofUX z@Q%NkFwlv$rjfLb8Ik49o5+3zt&h`cPEMxd3~QJwXq%M?nn@;*MB{sU_tQ>7A|96P zt(eo6s+4r&!BKUJI>Y4=2_a{=bsXGR4Vy^q6`RO{*G-kOv3Y^mNMd9M2Z~nc7t7%i z&&^dmy`2o8r*(w(=#`>)A55E|1=_Rr!ol^FaJsx*=z@6(D)joc+_gwh_AyjeyJ_Je| znaT)IOQ{TS`1cJEDZO@cPeHwk^0Y8jHqi=EV0!B?*Xmkkh(5qNsvEsv5=JQJqTu;y zl^7HnXuN2r2n}q(0%}JmFDA4=woo8*pI7NGUCK5xl5Z1NT5sS27WSj1kYPg`lG}JK zbLEp8_DzueaEAR^1j=f^3mhg(NOQlrS9E2Mw>BfTOoTOxoeos(K*uRI8- zniqGuco9mqc>03=#V_)-x9xD_f@ahVXkcWpqC|KJZ2z`!zFz2DTfuOzi+={xK?d`B2 zAxlhZ@eEj~-9fhl{cEoYW3r4{Y2kmPuKWnH%~D$OE+=~n^9Tp-~&@c7HJMZSKTo^b(+uo4c+gZOf;=qpIMc;uCl1 zg_%I^p?*oF70aSlFe1G-TC@sDm$*|GF+ooZ=UXQ68s=l$-kFXbwxjMctm*%PR_)X-d^Nw2OScjnExdIdqClF!G_>M%(<3b3(JXFJ5ZK z;kPY7P>X2@W96>!aGEb-7e1^Gp>o$4P>*Or?d4z1DWw(WKVfs>XVzO z*V^7;m#16r#@1|ot*;34YeJ7)3imT|IDoIoEL}1vh-5nK&;`%KF37OwVvB-y+J`=t3^ z$Te<#r>=q@@qU44KDM#rnzGD{TUDuD868^Ly+V!uz>e50VqGt1i zIH9$pE~pmE1@qg9yMqQ8%0N%;k?-+~7`^kq@BHS%nvWGYpW&vZ5-T`YT^|b?5!`LhFmMjYU1Lwzn~N zjPzb+H6gBoH~3kl_CsWJ=KWr9b}}!_Xj%!N6A<$-@{QLy+#b+Z6OkJ#0X@q?cbEH908LU*gb zYh8;qT8eg_idA9tTq~U>7;=Sd}3tE`(Sk6oGz+_L!9a!d?Sai!!?v;rfX4Mx)h%z~B8{2!Rejtj~ia zV7eVYx4;Lm06K@)w$ntDSM^5(N9XN?+lxn+UsQ-OpPYD^RJRmo=60vMbm)Icdu%ed zw>FT^b4q&?XA)=L6HiKf_n~>%b4g#KL5nj^?c7dCwR8j>jVGf5X}Vywqb7`4j;N*x5*m7W<_1(Y{NvL zQ7VWj)ggwgLqrgQ3J3#df8G!{?nfte_^xW6Vi|!jX;qd^KqDbt+m)B@(wY%Z8gs={I*qZ) zBmDwo`&eXI+Fv48yPI%$c|?&~UoQsr*LX3WW@fFNp4rkYGcH~%2FCx$atYFi5hYFq zG{HjE8ia|JDY4KyS_spzP5_gFN9iXx7Va%>Akx9R62k3Mu=VdY^q>;p8{VSJl# zsyRUk(;~8z?50Nk_-|eVbE6oB-Z;ED(^No#wdo>`H)N+k=(>AK@1^NBoR@%pKvY-8 zAF#&W_AS`m^P=Hrir?CP25iwoJ+x1R{>-KiKKcIYa& znwi-5FaynXm?uIXRE=k}N17p;7a=mc5;EwZNQ)x%_Bo0i#L&5pJ5!8g`918k6C!>2 zSpoiKF}9fqDT_?FBVH=uvHNQd>Hj>an^NfEApc9A6tjfF{)aLN!7Z+8{DEugTEp3P0Q7Ab#;PNm@CeKU2|!}n_8;l{hgAY#yqGBq;kF25IVy&>b&nAP@0PWrTaU3$=~e~<5>*cf(4^r$7_Iv28ME1=F?`|JM)dr0 z=MCwgq)gc`ekEr0LZrMFFz=26*>bfa=>4|#KU;1A(&PLnReDQXaZ+{5&QbqLD?L)m3==m4# zkG@1i=IvX+`qvgB^&yw9d*!$ER2?`14x>QeV3&6%AL8@n#l__s9r7t}Y2NH0i+~{N zbqng;%NS;0A}3pJ^J6}=#Z?rtxiX>%92IG{!qIP!Vrthv@@H^kC?S{KGa`V5 zTPYEuSe(5i7(d@lsSuC#4PlFw8p#9pajp@AKnl0;d->LqiwKnas#|VMr61E>e?q=j z1fy^a@)fcKmz5mAB!z1%O3C~TNMx3;5|G&(a1uyhe`(;=ospu)wPzb0d3>p7ch8Fv zl@Lc^^ACz9?>Fm!=qXD|Wocz1qm2TDH`sB!sE^w*%s%+V)}6zePJim>P8!K#@jR7O zThjA`r@8ZXzg1i^x=Z%;`Li#;15@0ZidcN8z^izT@nbX(^H)wroD-_#Tchtg`Pqf_CkPBT>j!|pP`o~h zqYQu5B#ic7OyqQ5bEI*w)H~-f*bK=NIVFyoqqD0#2ZSB3!PTX)rP)$`V%JFTW51>U z+K;x+xw}g~3XrZOkQO%?go^%&LeR!)$@y-}z_s{;TmF7>N06zo!&&62Wy>eecQ3Usc9HDP$!BxGM4~OG3g|Aqi#+WmPm4^KTwol_0 z520`P=BJBZ{;nsj^{fTnR~%jW-t$Xvn9#l=>}T~J(+gda^|8p+d{WWYTYFgF-VN?Q zgtWEPJ|aTdoh<_9wc0Hc!q*4@k?P%Er@DNk6^%80P`|~G6PNMEY!d*uII9dkIAuNV zvo&pT$~P#sN$4g?n?z%9klcMvgff1wfx1_(wvvv*!^zW^ZHvJWp*O5FD}$PHqt3Dz zFEs5^LJ^cl|0yC*9bJB_%Ap*xp(Rmk)Q-jhHoQhIf-#(^VA7GU7^5i`K`A4iK|0RS zAO(T0To57CpoJpKu1o<`o;CAa)BP1lVuDg}qT@9;MJ&M;7N=ht5?3+UQO>N0Ff;D> z)ygSA$W=32FYFP`f+CWTo+}r-&{R-lPI_30XM6%pAfIkh0G+joB48C_y+Ur2Wl>@^ zlVBn-G(QB}pdtfrWt@VJ1;4@7L9?fKq%Ek!z-VsyoJoR5aaah1lvY8gOAUw9l+0HZ z+Z0Mv&kgA))73}tZ|a~$ZVXc<<8zVD6)Br=qsQch15Kpo?8mfM;x*yc<6KG5pIPME6VY9T4-szoZ{7K&j*;id)>ogDh}~iB$#Z9PooY$A8;S# zxMDIp-(K0bMHYaiXXlwaLqtr01vl5&#>E3xCc>qpnuvtObd)y6Vx6$MY?xRHNfj9V zY7Q?mt{v>Pd)Uhglip>|SV(PC_c;?fT$bv~S}lRChI=T;;T#i)+Dyr!vHgMZ_7Xu0 zrttFQCE6dgDK z;g(Pw>j;r1*cV{TW$^JtZ-vlHA zA-zl24I`zJ9HKbJBU z*rF9?O+G+KCDVWt+%D;As3Bol+ZMSR?yB@5Q(M3fDk=I0sdWzG$-dHMWCshr&{$g< zTjJeX>Zsds@<-*2#|W&X!jFs!E;cSchBljt$Ku^2o~!bgCR5 zZssiMGPKt1v2vq6sptb50SSO%n$iRJBK0j;%n%^KUcecp;}3Eg3m&11j}oxF;xna+ z=Qt0!_`Y4Pev!L{LE z5DmZxycP78upI%NUG6)- zVG;hZjwQI}u6J!_FbILarfJG9qTni;j&BcgN`^VgX}%|!bPY3NUIwOArj z(4ggwmXv0N0+-O*Jz+TxTPR~%*ivsK0xocQy&3FkN(RrBL%-2Wk}(eRUW%|iE!Y8? zCIUT8DBlXo>S5Z9+3Y3Z^n+@+gX!+Db?k0p_y|e2mHB+*?s<4*;xP9}#9k>x?}>?0 zi?pP8o)5ka{cIr`WeMZ%@fYZ^Pn0F$(UY|VgEeb$q9zEObYHdl1UI&S3?HR|RX47|9pm<41IrFI zV5P?z_^0EtvuRb`Z1wKXbz@grZIbs*?XNI)&Qd2U+_aJgs~JD)v&@0xf)N-%&ncEw z2TXT<)f=gjg4wa;2E`UnXLXh@;tI`knMX5Y8Ai`-IaOU@NAKFYF^Dxlf8ZPRl_PT60VGYwOyfdiR#pklAr~6dkWXzAEb+&*0 zx7`y{ea`Qlshh2*I+K}iZ)hL1g~t^1pz3nPDRRTOr7mQCc%^A|hKp^?b{=d-&&=8- zF$l@CQnC(ZSB)|)`;eX_dvq{m5{Nw5LrEYY}5bm%D>>tTk_k?XLQ;@?Xo)R2{` zYD8JX=8PzFe)cIc;%mMjVJsA*EKObkalis(x zE^fAbc6=U2cltIV>M=D>3NYU@9$C*!=5Iuiq4>E^gYm-oJy)Ta5O4RHXJS3?pyPlz z))Q*9(BB|Q^4O2*9vZTkOjLhRa zo#vxd`30^95AbX76zi98h>U#agUk3m*Mlt}J_aN8i?Wo(g^DR!Z8~Y|iJkRuGzKzp zj@_ER<6I0i7jM;SgGIT}$>K?^Wm*A`I&Z}Z1?zj;*9xr88^Jn_rNa5N#yWS7n<~bg zxP%SKVj?XAITG_4t~q~n*hQP#pk2S2t4@xp*`~n#*q|bA$zWOkJ@C`K{6|Fr=+b%} z{O$HQS@)9Q@VsY^nGC!-2$*x3QMpD|EqM~Hlg4yVxj92%+8B=AHc>glWX23YC?jXS zh;cBKV#xs}i!UydO?cg`F54g6U&X3K`69Il>Y z{eA3XVN^odI^2dyX?6Lzt^V|JTkcYM2!Vte zS5hX*PR)9-`DCz#8GpD7YfhgV>oPHUQLZ#L0xRwvzgIfp_Yt^N`g&hjGbD~$l%3T1 z$8_u8+;LcD-63feGJlR?aO!S5QLs$ABUenjrwJm%_cm7thJlnACak5 zXgoFMiZ@=jz0t~g$#Z8Z??6SyTK+^Ps@33RYzkcUBv(4l*&ghS2R}`~6i>Cod9)o^tRS}G zk-ED)30lNNlbH16Pm1ZjG@E&{U8`!ZVUvlmS5ZmBtdiV8KXildFuRWDbFrv@<)kt^ zXZ$llSyl!1iX`bTfs>Y&8H;PzM^j&(Pt-oovl{b-(Dlpn_^O9EPqd-s^5VOucYf?6CWgg47+*Od5|L^ahF0=tbQjEq$^{Bn#a#7cA# zIW}%Mofb)qD6GEd8Af8NA(=AQT0r-qK_W-df8O zWecoiM6CgkEfZ;rFSKY*6E-HB)WQ1tx72iyi!zPXlIOqSQ?C(Yl%Ta&ea#E?VOs87 z5z{(7PH6JUY8LQRaa&rKmP9-`A(d1}kBh}qIx>~q_kO}!(W^Q#>Jz1++IwQ z35j$|m+?xL@yzAMnhlvyo6J%h-?<~UH=_F#siFo(Ih8{>8(^=DiFk*UFOfOjBiT;T zEgI++;I|%Q{Bvzvl?FS;Dr1jHtb>IrdRhxHP}@XX)xq|mTNBiF>&wM;OF

XnE@i z81K8G`J`x#ELwl#Yg4`Y{p3bch{l5`fpa! z$=}|aaFqY^gK#shhX@$fBccH-VD3hi06=-Y+cqTjnG&-e@gh>IypId%Ie)y9p8IY4 z5WlGkRM`g=61FFC7YQpOmMOUth+r#m7B>$)`2M(1%Q-S^O3-WB_HO_VrK%5^M*-+pY zzB%|y`kw}2PY)pOazsa3Y&}AVtE({u4OYEr{GOe&`XO)cPDu5;CBGv&uITp)Q~Gs8 z2UMij?2}7A{B~a^NnJ9fM?8f`?+}qkbBO2Y3q(x%@C@b2MYBaDdJ^FXIx}+g-RlXIo|6fn9GyIVn$Hs?{DC!4B}t-3S5AHHMd~ zp&YCa)K0Mf4FM8OWbkmHK|o~xDJmiP&#v}$BLbnC5dgXcj=yb$ls; z?KLTEV)G(-y!!@wKRwJ3C8tKdHTtbdTMKg-HM^e5KlUwz>c#pPx^bzkw$!ux>T3Kt zH5$4fSRYu6Cs|vUC>oPYud&bX+Xp^*Cq5?=DL@_o`OE!7)yyQc9-L=xlL=SX?10)) z9XNE78!3c^997T$1x_m%f)sU3W;_#2OE@5D<|{Wcs?L6ZMw@vnje&HaYW%tYOQ`%$ z{z-#9Pxa2rS9lofj$)1 z%7PC=aEBIaLx0&;lWo+6Gq`v960z6K=a6nsS<#isP~h~ncu1i7zJEtn5HX5)Rb;8#6k@n6Q-+|k#%;fL7T8=<1~iWR zDy%sSQxA z+3rIgEmn7MpyRS4(`iorB3XmJ#T8>AXF}S?Y_kgWxK@o7pR(A*)|rFykT`oYZIM1I z{|Eo31#_ypqzwBRL3$#4qWGb;0buRlhQTcyXiB7|ky=G%_-287{p(S!8r^yX7kk1K zfk{qVvBY+;;AUjKMvTOa+kS+8&AxgmCI6Z)m)+TTF5wOhW@^ITq||1$G}nyZi?3_o zmYW0bA=U_~EC%&-^265OULoLukAEP3@?#*GWWZs3O+!bF%lar(S>>2f2WYvk4QX}e zPx9hQ^T_ZPHOO}pavAbmS@EQpkRziBIzluEyQneyo333$NXh-%SHmOb?1-A8I>vpe zC_yG*{84#03};XdrnZh&K}MD#r37|^zD#O1{zwfj{OXWDX1Jz1hh41FOEMK_mg&-R zHOdL0?LYuGjHS>>jorf}8;Hp9*wOBI`sBv%(6=#Yp$qw|3&vnxuU?8O3x**Wp zo>p>8=7k4E8(6+j_?PUhc&d+>A@ub-n0+V=VtnWi5{WSr{UXYE2cmZ)b7nduWJdDX zyTeu}s%ZuVv?*&t#+)(NvE0gfWEu>_L^&!9M)Ej5ARWeDs{YAl{c{G7Uf_O`pkDWH z{!o#POpO3BgriTaHG zfC0hbfEJ?;oY| zvmK?Y2~R~xmMIPiuxV&jqtUR|lYLy*!HZa~(@vR{dF%cy2NY`4=%8{|J1VQruAkS{ zr?YUWj{Nn)yoY7nINw$I!do7LP*<0Pxu|4S)8$-QL}|j@&?i6=LyB`9wx)J5>}_x6 z&1i!Jn|N54(M_KJIFClF(wja%@5!56hAEPf`{H3K(h!h+lN zxoVfH&S1Be0t7CvFp1nGnpz1r;VtH-+YhrQn}>`^1HSdzQ!AP?jF$Ik>&HhMPd8$@ z5*m5rkl_;=Xk(vmv2Bh$AGr5!ZAXA`8ghN(A>8kp4cF!AtFi8dGP?8Iqy0hy3uNC_Z}q!_2ibBtJ)4KrL&jK+ z;z~3l60|4LZHe>!++)0{>D+!`@*+bCoWYC0#^pX9twrz0J~3Wdcf7?voUrT$p&(%( zaYeKq_962C&GB`1C|M~#QKmaj;g@NLLfd4pRd8ur-C5NARSDJ{yd}^htJO2Fhcxxa zdGjR024Jd8MwqJZMg)pw`-8%6VDDy3>ZgdO{oCf|wK6I4C| z&Qf94W&(8pEx{1f=9{?03gS2l(9S`MHH&$NRd3Hc+gS5j$XXuaUXk!!jK>EF4m;<%p0;H`%NE>~@UzMzNT))sTL?_NX&&SCz-IV2tLU?9(A+bdwABEovj;n)e;2c+(rPrkzKJ76GipItx5_rN8 znO6JfUdd0A{_f3$@ZC+;qL<3AU&)aA0zBKZ)Ox8l2i-|GC){U=uF-xFZ!&cndVY6x zen~YyGP6}=SE?e(y?q`+3zQi3q?CNM z8Z)yxGkZN4sj4ib#mX)+BpJAOQkv}$HXd|rJT=XjuUYhgmV_jZE z!DF-w{C!yQx-%rVDTapik?-yZJT20wRj0CO^O-)ze&>+$I}L=vPL4ogK`9jj48~cL z$hlmZq8%IcvH}i|C99pNqil%;ye&bUOf=5c5a|($?`t%7nr@}G`>zV-O{Zap>ESZV zl+%!p1YDJl>tiIMv>k-*M+r+3q_S&f=fg{wB|%u?g$EWb*pshMnRWtA$P2QA zpwJr3D>xwpya%ZN2fqIO!lZ9nbP)e4O&nU`VE@sQe(9Y4*Ho?h`Cn60t^Vo%XqiTd zp#L3ZHX(#Y`FAS54Q9jCKmA=B|KxGFk^=3?lXmpKCCU6kZpyG(`JZX7_PpST|2mU; z|JF(Trx7dzAqfa2PD1L3Z#s3#hWzi6KRsSS|Kp|WX`i0_PqWS_N>ZE`Bd`YGX<~dz zY>dr|HK>oqZc(Z)aHpE_gptpBRzw|8%Hwa)I7vI|z@piZD#lwR&y7Xs%E%VXhL)5- zW~TbFMFkeK!%zyPa=qM5<2iKSY9jaYvEj-tx3e&@oow?w^PTuwbj%BVzK;rlzc6nr z=A(tdvjrkYV;(A}I?)7{16}n)MWllY`NLZklno&h(t7=kp8tR{ZJa#Wd<+S&jXOQm zyiqfp8LB(5UgXgz*535p1}2Kx*fdjLo}=1Zp|yBPB<=L z?&L+h$FntME!1SOY#f?~kFqI4M3UrTNc`$To_KHYO7rOQ$V&Teb2|uW1gOf!^mCP=j-)qm7Tc11CQ6&Ktyvigqew~h4{#Rt2W)s zldXXgYO<{Q!tzMWKyd|JVQ>^mUbchqdgfHLqiFWg2XzR86&J?3qTW z&OA@TTK+8zFSECywpHZsJ zdiP)(cTbNgfLYc|QFHigAz9xTqPH6^4@Lytii7{wfgrY2xZw@eg2C~A8rG3mtFHLh zbZw=%LmFgbQKVm(zbLhGo$|3suSoX#8S{Jv8sPo@e0}rj+#!|lg9k7B7zvG1YL3P%yqrDqiXbAESWC=Rn(ser^QFDiYqh4!&@!D&j zHxg_0OWrEuXkv5+dzkrZ_W#r01u66kiNf^yn2W8ILj(N-S}64njdMui+U!HEf9BQ& z2CB!2JNvBSkSzu)p=-rcH=^g;FVz#K#(0d$-Q*yQk08w%O4VQwalxY9v=@wUiMk*f zIl6QZ;Po$uhS`TiKNU;aZrcliq}NuoVHx_8%2ZX6<}pWHcuuWi#&)iZ!wB=0oN(8# zQ@D5W5yr9h(p_E+jPCF<^bf+SsY6Z{Dw1prw*>oKO`ip7LjjEuvZE{!(ygX76(A-Vk4b<86Ra0{OH#Xb`uRq@63$uuuR=opDhNcA zj1LB|2QZsncPDm1(stE%C3761m*TO1=DmdUkPq z;;p7_UPp|^c{76KH+#~aFduSw$*#g&eF>>p<9A2;XF<{*4Ygyq?jcU@N7H>8*WDgD z(;+MaC!o~6?retyA2mC|6-h!<9<0Ej4@<;5bJUOe20W&H|LzcYeM;#fey42EHK{$L zXp*q9xhTn7me0|2ihb@_WQW8TG|yyr!hzA8Iuc>f*nR9>sW=qz0hn>vo$Kjh#eHd+ zY<%BD5#Jz<5Cx!CI@Bdvwl_4V$pwXkl7NMFs2%w$pw3cdsdJf(fbT13la!l6BW5nkGb}Sitv5w&02Ni%-g=|?ksex zx?LU5={s@Q|FjX@de0d@6~*TvKNU~KNVBLRFr6JF_se#3&qh~pw#ek5-fwX z%f`55eS;Fw`eP->4Lgt{i9gD_3EqolH~EacN1pu-vg*lvNp7UL4f!O^e{^&%-wO%u z2eF~LLbBC@XqET7fsL>`($duJpM4mt@`vS>Dl9LvS7`_*zbvWic?7i5r%{@-5MhD~ z&Di|6o?fpX_f)H&-#Rh)@}8{z!c*wG>wjPrhJ?miit=`GiJj<_JphB#8>bnvH&NV6 zn@q4znBHHB26gMrXhwnZrOLhEsj%>=*cc6SL>Yx>TB|L4kdGeHpVM(&)4>Z1r8!&0 zDrzYT3G?y90~KQ=wg76vKaJ(k$Px)=fAn_Zf3eEGtNZ}N*b#;l9~EW>*%D>%hPbxh zHIqpGv7KS*$IeoJ?Jy3bBbQBEHlLWsK>FhD&bJ`tTnsaMg04d#Gqe`SV1C)BCwWqui$V7(N8?_r&|uo<(4g{iLpm19?v7b0k0o`xZwZS##KN?wRY`ckdp3U=&p+}4BaUR3L>2r zUD6FB4Fjk!N=ho--Q5jRN=OSxi8O-#!@&LS$Nj%E>#TFmo@YPro_F?{HS0Y4-SoX{ z#o!B`xZi5@n=9#>V%twX<%a7o(~rxL3*GKAboKbw>3uTzJu%~Ugs;(G z%oe>C@W}gzd&vKdW4=CBT~HU;ZN7*Vk|MxQP?ynWbb$0R&}j=Xil+T z3!eJ!Qp#u4@PWAU4>ir~lZl{P&xUvCQ9!`|$05!X(4 z+bHa+`pj}PPg(oqs_9}cyBaYx9xlOO9st3Qzb&(UnZisq@ceKfbm~#Ax8{^w{exUA zsbQjfFazg&G^4z;P|6lPJwzr(ZuJG9W!xF@o+05le_oxJyiWft@rv)#@$`jr~g zx{FyOsv7d32>N^y?l5q>8y2v)pvIjP#yM}2++;64R-@WJ(;jX7)Z3|&DoTH}tA?st zfIxPsGdp4P36}$i07^cA^&ApbWnuHd&ib}@u3eO&hPObLV~|w^SX3Gm)k$4nC09%U zodsg{7fdRT_kpKspk^G zYMcPysjfZLJyF|u?@11qb)|lNzD|;(CAmqD0M|3_`U3IZ=UQOb#xFRDvt3UNKS#PN zmbR}Zlt*l(GD2r{%%FNT{3Ley))9$3jQM$@WCbc)c4mCGU;6GC0aGx{Imo_f)6d#f zvJ7-~P?w+!rY!Ofz{slfk~Q+bXf?eg;~=D-E(?t260DE{ckt<@LLSI*=EbH^MkW}_ zQ~b4KOooTGtQv2`nzl#g=Dui1Jt`n;=7_F4U*5GCyG`CEq!tdMdNE81`7X;Rn zditWuLc!;rN^y`16R))Qo8B=_)%b7kY-wyeKiO))VXBET4zL~@x)YpM0$V_Gzq_zu z@5>IlZ*d0^^{bEY5kI&gn&?LAFg6;7QV*!v&YBC{ zcCVAy0X>j)7P9qmI%7>^CI1Tu4%F-5A1xe(KW`OHV2%h0ee9L}WGE9-j<0r*?VVLs zPD*TVK~6FsX3B7|u3XUxXG8SRkyip<6!ww#MxP5*>cB9cXXM({PvC$4Y!y<+F#bGv zS>v>E);@wi+A|Rxs~ufbb1UsbNRP~WdD`zHJ*JL+P9Onh=-Uvd6ruwE$%&^s=81`R zvdD$?v6bm#Z+Kj$L&hM>HC{U--H2te<0@q$;;I}LJ6~fKva-Z?-N|y(Xay1?Y#qHD z%2n2zLVPgdSxrRgTkbNm7IFx;c8^E3TV)koy$heD;{IS*jSeS0|L`$dNJO9MbJb*b z7DW5(c=ph`7T0%k=W_Ch2T9`2Y-0y8>9T2L7&1dU3FzEw{e8|M$0^YGokCxD8I+Ur+2eF+a20dD4GXX7UGtM4 zcIS$LFV@5XmaMAJGjZUZ@60ggd$EGo?*#6ClLy!d@{aMVhIUwahL^$z- zN$USFsyx2Xo^kNGRi7HKQW;sp;z|hXUGPT!p$pull$U662c0uWoBn9`=~>_%lf;y6 zdu{F0u~3X%ZHqi*Oa`tP^r-$5SU<&U;dK1MlIa6nJu*&-!Gs! zW!3^X-abWO`xk1T*m0sV87-d;aub6c_Xd7^2@;eG1R-ck_~0#{05r8Y+>C?q3!+Z;3#j+qpZG_zQ09;Ao2 z$62OTZgzK-9kXEDC+e~A3BHD@TyIvUw~(ueHZ^d*ky^76&Xd%yg71eQZqN*ggs~bC z4AI6|_N)bB$d`%CskS*R&7CIuTODOLE8%0o)%Wj0+&vt`)_b4ToW8$sXeB!lh|64D z@cs5d>2za*_7U$z!^W%5!dJ3{I7f~R4rv9$VmaFS(q1Dxu)w-+7U>jylEqY{TQRpS zmlx_vTpSXlnb7N6WXR7K1d2W$xWF<${1FJwUl*7>?RuTC-Odpd(xgJ*OPP}Sk(^)> zc&NqaXogi`Zp*vP^;pD%tY+4}3tTYgc$gMgH%hA`eK+o{82S7ut@*J|ZKKk1?~JKN zxV(P7>{oU-mxOdZ3fWJ_40@0r>pu+-1m2GhZZFNw>P=1RF=a%k=!nEFF|)wd$Er$N zpW^-**q+%-HaC@v2kAFX4bXHs%S@JsQs7nV)vp@2MDY|7(HA>>O)O$iVdWmE4nI{+Hfc&268z z4(7yrLy04-&~^{&8+YG|P;3OuuSh6&V8{(Fncbp>j;sBt)**#CemWz%Xy{Nj+Ay8~ z|K|#$qww?f0d)mSiZYgA6~VROlIe%*qzhOZ8PDZ&LjwaMX{za;+%;!Pvm4nj&~p}u z_u1Zj%N}`3AVih*u3@Io-Yg{=9dVeY*UgNE(|j^+1JBr#Js0~G)frI)qm?@1?rp)9 z^}@zO+uY#gBz@2C&G1>GFue#=0p2!!K=ZLZa<1c7OMrT&jrl|I3}&OE{O|ncp*jY8 zseA6hWJQV-+rBR~Xt}!XF65KjSMl4L@)lQ9^0+J*rLG8bMJ1gNV#j}a))}CY&+1A@ zdTYHcXfo14yLw+;*(E zvBJpmu}BMq5K5zJe{E(Om5e2Maqfa@M+6i5<{AZ-Kzo2?Ib}A35ZErTB>w}BO9}~J zmw5~kLu36qW7uaU!m&7rg-!B@9H;)i*JC|&;6p8Vq3%XCSCqCrT>Fls-0Nq*vCqo3 zix>X1AAo9uayJ)Ul?9rv6KBtNZev^iiD? z-P`WRqas=IK99WovR=SOPQdEH^JDTBbW7~#DQ!5C0((TO$73Ja^u=lyvF9Tem*~Vc ziK4JF=h2rqB?T(GHjj@+1co zEy>a15mOzllf-#ca_HT_S=XzSyTwQDUq>?@%2}KW{Grtup$CLzfQxNscDFzD(I^an z7FQoAYfX>V<9roN%orzm`-|%=_jaT?#nAWkFLDy~p+nJb)=|T|o9UvVIU~EO_LO-e zXjCaP3%Nr)edGvjX@&h#?(-Pm!JJX3{&$>MFZk+g$VIKs%6Pw$C8ta8JzZf4vUHd* zGmdDZ&ukz3%0~iLo)P*DizUT~E9KQAz;qmujacg>7~`D_VO!WsqU5`VF1m z+;d&@W80!Jze#>cDwo)sw(D-#oP529*l_d$HY&Zb<VA-IN zACe9xuN|?@Pdt>hx6ja3DIOb38%qmpoD5CAK%4X;X|_2P^}>`Se77%N(gC@5NaM~= zIO=`tY;m#$)~skxs}!rY`dEWr5-aJL9dcJgGBvtTsH5@aZyYa(znC+GiK_TrEn}7~ z0NZw{tDhRM_#?zwU%e}F&C^!81?D3A*Bxjs2eNNni|rV6e?%5 zw>f{3)zZtUPl^cEL1{1e4a!&t!^D1~NrhN}Wj?^Ge1-dtmrqhwpjz(Rs>K?L9cFvLl}2 z`hlMK6J~f(QIXpaH-zCc3Dk)bM8nwh+Gq%YlQkWUI>l$C4ux*q$#K->uo(xmlN^a~ zHU`Ny2qobL58f`(P!5Z1=IC8{#-|@XFll?I_V?_qIM+|AG8K0i9&P)*%sTN^1C1#i zK5+|TBfPH;lJNbm(Og`zC{h?emQ!Nzxk<$nehhp1>Gsr8~gAS5;0D{M-6xc^_&b zfR^KRQIZwJ)CNS#I~Jr>k8X|37xw zZpXpo>c1#2Okm@ZT2bFk+>uLEiJc=XRAV^!je&OL95nh1J8qsaNJ?(R=RUiBb~PY; ze$mG(X>G*))aZg%HM!JT;(=@s4e?sKt=AoT!MlCK0A&qO$%C{6+5Sxuc8 ze?h!(8w8b`lbhsUFiXs5TLJ3XA-}|fj*iD+@QIN_j33NGYyvE(4E{J#>ehhm=^`6c)%NZ%znIn_VI5pWo_ZNi%Vde?qy3*#(T z1$r-0)Y4887W-*`4WMl}$;)TH@4?);Ecr3>4sU<>*;<@sI+pRcx^7E?d87BeQ=1hY zm{ECI!Rx9lN;UyWjreg7HoB}?z|i@(Lp0GXgO6*#vUBW|O3aqbN1t>K{MneCSw2#X z6r<7oAxQJ2m)TF{!1#mvZsvuhsBc8fHI|xY8cKNyHGRJDfYfiboSVqyg9|4aKh0dnP_jf zC?&>xc8!RWU%8dJB|Oo9l&|(?SkS&*NKUJKJ@9uEA?Rv`=uw5J_8 zpnb6;{V&0<96$cYwPJ;qG=F`zl3aP~N}o#30HUKLud0?3=Xj*#m4}qPB>y9M&390g z|H#a^c8kq1x_$_Dlq+*hAXYSdZNo3oyvCW9#h~L{J|e@1u4F4B{#43K{FipgEdM{W zOT!zAB^r_#rN;rUBxk62L?*;UfN^o*{)1n^5Fi}t@lf11mVVyg z9+yHnJd~hB^jw4gQ$CLe05IJE58Xq7>+TXFKn+*SH_9h(fN3A1z$SH<)s!r#Fm6=k z-2k&cLV{@#-3=sHz)Qs)3Ao&Eex)!2#7iAk1YIK@!)1D3is=JL5EZh56S=JQKU;-A zp&>%0kqrg9wEmq?$a=u*?J}W=jSz1dX;JqfqO=hVlrcgKHcDSz6E%T>{U(UgOlE|7 z6Df-5ksJ<5iL!4R|F$Sg4$oX}2)-6(!;wHH#Gf`26!0;j)Ta-~ndU_5 z_0St5ynBy;w9BGEN~7jmF-XvRr1XCi6rPIuQ1$H~6wrfhN$Uynt_R}+0OB{;Y%`Ew zI28h~gYPP4nGP_JH5>UsnGk***Rzy}v~lMl38fLfT~}$xeoGneGUY5TL%cyqSBPNj z6uu%e>I4J*ick}f)X9#D1OX6FxSY9jq@(B!$F?$ra*=q<-^s(%1qQyWK>13Q5MK^_ z#TkXPZ&e|ufCG_OMvlm-xe5sNGmqp`MDFxAcmwJX*j0=a4^=UcNeci#kS`))0N_^r H<<)ImAa zi&aS@mQb^+ZRUp14T^n7I9uHIq2Ip8;JNE&5j-QHVWRZ5&|xK=m=P;IMIyvIw<38Y z?tHe+KLIidH-NE$kaJJuq4#eh<$X(qFg@ZFN|O6H$fex#2thBoTH$fS9vBc}8~%6_ zq3n|<#n!FXLwbXDzws_nH-nI`enc-D7ykj6A!nU(KAIIoGaHbH!2qKn>Scl3_)Yi_ zXA4R-xJ@&lagUiL<=WGM;W!U07#9@msjqs%z`D4rHvG=52E zNiF~VhNL9u3tjT=JpL!}OgqjRlVYnQA);$|I0OOH<@b&wwsW7FJaE;Cd;l>I**mXg zR}nv)m7hY9J!lwx8Gk}yF=jLENS_Ftf;rhYDH{(yDKbs9TYI(ixRmH1HM=$38#X-- zo8K1g2>=h(<}poc&H#_euj(-()$$~<1T!@B3U!!22~{L@`S90jznFH75{RuXah4#$ z8&ik0QtVM5@%M~;w()@c`Y5%sf#V+7aao1)4duj<#1Yig?t1&CN@GI<2D^@oee$p6 z!X9*8!g=-ZHx9>)YB_xzG2NiZD$@kHFOYwX2=;$WEhz--_}^yJWDi~h@*ji_g#z&( zM2k@NU)?eiBly3q%Kn0A2nP}f$O!=mh~nQ?)rW-+_%PW}NB>Snlm2ygQ zce^Aj)ti*=LPHs|;oB#RPKs%+myJ}D$e}m$ZibHG2nEKq?S=&({eZ`|b+=lD`TRo& zo=r;aeo1ZnF`)6HpXW2<(fhDP`t>33vIF9X^ONX^R>H>_tp<%_FUjhY8qSP}j?C?V z+pUQTxXT8ECf{cAG8Z#?SV$n+r*PQWH_{sp3kiM=2~oHQSls!d<)PeJLFWxv6uoAL z%pSmYzmm+_N57&7^wI5M>F@5*lJwH-+bDHY838eh-MO)ULm)CX&1!f)PgC`d%sNQi zmAJ9-y?0!YyGVa##N)t+_sgcX~je7c{wr@{B>!o4oU9QOKqOXfv+M5z<~>5l*pO@ zUrCv@@?0rqOW7)^lQd%%x3Ezack4TFYgIS}*Lkc{%ImNxy=F8vHkBEwKBuX6WyF_={;n(QrZn@>qva|cY{i7!VLFd&L!Qa5xqKucnv*jW1paF_ zqFjbX!K_Wzw%t6$3MW1Es7~@DLh+w_ z;l)Fuy8YaaveuH8%9)d{G=n{Th@o>EVPf+k&DnY5SPM_%u*I<4XmJ7tDeO59KYuH3m)lsRz;#j)utT|7ebd~ggMu|WomS}z(d9l2BNw}!Y$<3R-N@QaJa66=4 zaBsI#oY<&(#m73)B?GC1|Y2@BVfRd=_+|84R4bbA@dWPprx7W4x5nplaWRf zPQG&HrZz-Sn)!mMxTbk{r{1A<)0kk>x>o5Z#qel%lxH&gPp}IN%|<3P#~9pNqxB`< z(dK^P)WL8*Y>UnC`;+dsF`M54$WpG0Q~0GyE^PDD^?M6yS4sRS4_;nDx4u4yxsU z4x^3}BklI9cWNm1x(h3KJl9edA$}_n$eEi%JEogssWE*lq%T~$7B=z!96+&6;`BNl ze_bl_WnWyLK|=876%x}D?T5^+k(psw%G+r=is!wl(8ttJZJykAdkRu3oop%&~PKV zdNz)>w|pob+}`e_ObRK0eNl`qhb&5V03w8`w_T&!(1725!Oy}}_h^#KP8MzQ!Pyq} zRtv6p$D}7bQ!>_JDwfl7RFvHHV5H4KwpH<|L^PT6_Dq2&1ClNC>CxP3h7Mb-&S$3^ z^kqIHIEaDjN?BdgB+%vX1;M1&_VrLWYR7In3He@?jNgpXgnBff&n~EreZ^|1aVbh- zKgQ}e*k!C<0NpO9pEG{RY?r(1fl@Z4T8g@z9_d2@~O784Z)`8@Xc)9m!z74+1+?! z1dm<02tLcbl(|d*I*0^vgWTC4WwM0awxkN0bsMOoBoVfdvc#bZ91=`n9VE=RI!kz; zRwDZ4IU(APsGbHtR@ZRLa$^8|4(8xSD`cjviCpWoZMhRwV`y;n__d=)aairNH#c9z zTzbALL<6A|9&suQ)*yGoWQE?H;EGCD>}0cq_Q1m*CHi&1>7pF3P?I}%)dKAmuTm26 zhg2bvtp78KLKBqM{KX9A0mK(-;YkA-v2ESHB7At6vBaRm{;9D~Wjz)S!=}iKxy+fo z%J@usdE)jNcclpf$UqKLFMDH*(Yn~u=nad&wI25vrGzox%dKLr==ef z$dMo0FwX%%4R2@4!N`!wJ;>ViKJem=6TPc1vPHs*Hy%ORgz~I0FN$9kN~NgB16kg#bls;) zlGQV^V=YE0c68h&tbL~Q?qGY(JA^^kjWoj437!z(awL~W>`#|ey{3S8$COTJe3ad} zC;=SK9{w&otD0ad$}5`@NJB_5`UYB>bdFcl$zD0H62Bfy&MU$+$O$&G6eYV7e&C{Z ziaQqn1CnDRPNB>s{L2;c@8N~zhU`e#mKxWA&=a>e8cjr?ZsyT zB)ufRg;WK26t@Ih`WWA@@ws4do?f)u=7f5xO-R5 zhLDfPIYQebT}Lh+za5Sk-Zn{#wqS0|V4j|CZU_i@T^k(?FXsjVbMHhzNrxyUx)AXV zEAe=1a{h7~Ya4f(Otr=gKN6Ip_n4Dd*+75PW5}EV_r_8qvCUE#mtvS{3s`C|;4h>C zFk;W}E$Hpc#oM?c-sdlzeZ`v;+$fX0eMw4nWO1YMv8H!|MQk3|#x-fIvj4u|GWGa4 zD=SchH;1s(qj5(mo%S6A|9-e(Lka7NuV}lw8tLh^l?%`4?lD)j(B`rvd)!m?6>dYY z(nR~nNYcKnH^;uu$$eZeiy>QBFU%eRG&W#~!pUoQnqT;d&zpC)l&4E<5?rS^_a;PANp)YF{N}JqIPaE`8xvX&=?mQ8*KB3 z8m&eRlq|@e3z7g6Fu{)o1GgHiv_DNo1Qd`kKVhq@r)F1Hl1?g_i1!)^8w%zD5=^8* z9V{v{m#=({A>~k8uWaean(*!?Wwo;$Qu+C~tgu;XqqfV9gj&?Dp{vKZAsR3()G>vP z>?uIQZxefbU^}jc)&!^2u#<;mitV&##(9n`Zb{tHny|6K5P6v-@~g(a~0_er(VWHQl>6gE>D%54A9B*&kqTyjKY z2=PYFwIsK27h@veRCVjo<)Sy8AO>^9bf-D3J^#ndyY^JUZxyG(=CFPMR0qT;TcSh^ z*gR?TGb=lOXpp(HW>Qj#5?`rIh>jRtXsk5zQ8E3WXh!yc;BghjnR(#mN|O=gCQ6!N z--=-_&Nanv3HExEed*sw;6z{Av7chVYlo`mcMTOyZV{QN59>FrPRl^=gKL| zzHFb(A)IJb-X4bm4v!rd7nAlvtiqib>)A+=mr-0+&CilrshKtiuJdvR!U^Cv%spYo zX{%?gliY0?y2-m7YVpMw#sH@KtfguMdrHWk3@M2BSPOSHFbT&wV6ZHB01uRM--xjU zXqW!0RysTRxvG03Z}B5i-?j;4Z2Th=ny(;DdQKy<`7lg?(v8r4mpVMP;$L|4;;C^J zCseQPCYv#Yl=uhe0%zqTA1xJ6;Ug&m70$}}wBkRD419SdcmxY}mMPR(dl|Z0a0(gf z8k$Gcx$19dSVT{Gim%NRFL!!>`bT6a8ScfLv%5;2V-83xgmIes&DZ8D3-xmaAsi&x z$%d0&ELzb4sgf!5Ypvf`Rb(nIbs14&`1#~@MKsrKMNE1!AXMg>3}ZnNXe34qwz8oo zQ>w3Y`nW-%XwR!U?Vp#u5$klR=HGalxFHx#mz4O$BpiZqc!l5^r z{RG75;NQ;rMJwq3sz>p+_%H&c_XnRL6NE?c#LIO#436OAQq3{4 zy>t+OZ8ss>=0L2ax)KMkEwMTqgwx*)lqwhu{_YZtoRU~(H17J}p~**~YIw+oWFH4C z?8XBEN1~k%>ALO`T&>xfDh;saatTc{u$)%e3;6B3YI}hdrWb-r$Y1Z(unWpwOA)0r zG6hy^JS9_-&t{2y5!QcCQNFQ-oVMDJ-s3p|k{vKXPu9>ZMnI4t@TKRYh2FLHbk2S5 z!oUozcvttcN4Xg2lN98zR$;NcI+_Z{iLC^)eVK7VQrFh!n6l%+g*EBpX>v!od??;q zs8TGcjcyua0e0q<8fwVqNRHyY#u4+*cns|hE5~BOds`i~uX4IEswq0seHW(e0Z*rZ z{0Gks9}y(oXRu_=sowgDTVNGZAn>EC?Sz(RQ{6rBsA6z0<+yk=!2N^{64m-~z83~I zq!`T@DL_Gq0H!jYpNH8kwjJA%ph*f-PHe};|0ObFeLLMDdN5p7?k_mdUUDiPGkuRh z=~x06&~Rf2zfGAyny>(F9?az#zv36*?qf5LMVJe~;A7x+h+DLKi&?^0@n~7{MSpQ5&XJpo9GCS}6-*Z8!^_hUc(mENHk-8Jd7PVAywQ-T2F5`FkI3F|j|7xn z%1++L&{N5Od>F3+cO>faZ}f|w62RAgfkB2a{$+RNKy2&jT)0>}tGZkA%qw)%iFL3^ z6FAH(i%pZXgMTw9)R8{@<3(uD`+l{YeS3i)B(b+{g7i(mdBo{958a7=uwgZ*vB7} zB@p-HdDMw;;1DE3eY^uQdcm0RGC`syp-qE}VYz^W$T)u-@q=z1<4Kb>O0qq1+z?Uc zma9FAQQk6%dq1P1lg4OntAemFYlsZxK&(n%n|saa{C4gkGQsPHXi&Pu zu%Zt)xoPy{xPjZu760;G(%qo$Mfpyv*d3NzI=Oi8IICp9EibP~zfPU*k8{ji4wIl2 zoW2=`HWxZP7hIeV7|^w-{~%8PWWxHgK&nz$2+n7hm?bji55IGX$T~r0VO;n)Q@i}c zC_LeDjOKI?n{e#KAGjrx{YGM&D?2UgzXPc$%7eH8YTrVv%nOU|>i=PRY;wF~S^Yr! z!aL6O5Le)N^{2gfZaZy?+o(FVd3?Z%3^NFoRYCYC43QfH94YyxNPemkcqTyP7QIX@ z_(1B=K%Q8YA6nge#7ju}KWM_gode|+C&}T#SZ&kX4>58}wTSxDNIksK z6{8tmTRR06;BVdjw%F-h*2pW&%EGs8soj8ar2lPE);9V<_QpG#`y!cdcp)ht5&H{@ z7!Mt+ILfjdAdbgMgp!F2Uh}#Q14fzCd^FT8+$Y-y(lCjPn1dAXms`t8ax;-> zgQ@#iPkN7Os7N{YX788?)!r^yglt;VrK^jde8@&IKH0yEM2Z;Or77SWX)Ttd{>BNS zcYJ1V_;?YG2HYPn4zrALx(c$jaO8mCWp?iQr%#X)0Cq{qxB!FsOer#9lUC=ioW4z) z1Z;r@)9nt9gAa)|On~9~n;+^_R}cU!-|@R;+20fnBqk_enx>x&?9bv5b`8*oUBD2& z4@OfEY7&dG2*7rX@iuU)+7OAS1Wci}7+C=2?lW zb`MlN0QOS7Ku`4jMKDa_484CRiyoOzbBu*ON0V?YTd=rbP{sfbt}Q>)Dj{cELCMP| zs|=!2LAUqaFTe;z$d_3|XKSi2;Mt6-OVVb51g`OkC>t0g!d%QY-=M_6MbtK*Q3!ba z6ZdrGjDyISYyS(LGQ(U<7d?Ncn6XT0GoDWwP?K_uk*o%&&40%avbl%p6z)qgFQ3zx zXIDCHD_IOUyqUWxm2%HdW24^a-3L?i2$n$#@00FJq!oki>G1<&c^mzK_%dQ5?%=$#fr?xcaDM(_`b{5+ zTMZ`l<|8?JISl#zCGdYUU;G-kmA}3)uaE~1*MY|MzIw(wuQ6}v9qne_?=o?GNS&wIj(tMGO1L< zyUb(Z*fNvdYN3nF&Wyuec(z#X=A-xKvG=C==Tf?nj(%(fF@0&O`)%iI8!lepZH^SE zHR_4ReHQ~==hm02TM&U!^_B$v$hiX#z^HzU!l-{fQsey0jLtYli`K0y*0NbQT6K6| zrPd8mr{ zR@~VOF7hJ{e}TKY;NfNU%?DTl6#FqdxNASdm-YVUk;#L$PiCMVNv!%}y(vf*{7cI* zdJ6K$b<1Wtg3~03r&56>2x5zH`uMTfn|j zWEQ+=2%jlWT?NtN#vyk2K$;=*eXPL4K)Vr0afMPkQvPfUHK4g99&xyl?1n@AMb_3PQ*XNTdee>Q z>Ys6~DhZO2324?9I`)VCjK}ozdM8mUIuZwZ_xby3)=*w+ZRtN?4a=O-&_gf;cxQxs z8TF5-UV%~vu}lOX~r!kGC7WUbZbpxwh+})Mr|UAAgE^0hDkAc@)(`h(t1Np)hLHElr^^YGrw0&rG5& z>yxl&OfjlDtNkGdb;lfjzd?Fe+1M0TgvdxEOwf81 zN+Mn~R+1=_6VyMPMBQc|B&I2~a}mV5c1-qR(-;E!Pg%~UmKTF3KllOWuY^}1Hnlp;pA zwe~;UQ`x)|sZowhGjFYJw?v`J8JUW?pVStens{rTb5~1V9eZt0+itqv%qm7HTvfdY z+hHd_!iqz^F%3LW??mYgR#EezQ#<kSuL?dV71DxB_XhHL8(V_Lgv-ux;>Wsq&FK z8SGh_-@S_H>7l;CbV9s+9o2OwMPxM5)`8^{G}6g*m#3f5RDt_QiJUany;bw|_ zjWN)32>K{N%{FhS0a)9S%mzoNA!B86=87qS?ELZ8%Jf%sFKIHJX8sB~5NtWu~4HntLZR6Y_OCU0w)JSp=d(c%L~b-xIA~)tTvI=g>RgE}AUSqh73X zuRTprQ~QHn)#QVnaG98{8=(N4xQksOmKLq}lGOtHnxeamBTqu4=X4nJEIFpRHWZEzdQ#; z9;v@GO8G>ZjnG#9E`OZm7exr|wdbUDORYaaG!p|SS+cNq_UqptG*JOA+J7OZ-gYHC zXO6u`vhRdxaak2qG|F6o%fOy9mT>l`l#i&b2H5MQq#&Rvo5Fu+46BQ!%udh^*{w-d z6lQ7X^p!>Jm$VV-SK8VHAf54wdZgBFV{ituf7`s+-P_INn_vtWxATEJK6!ESdo?+F zEEp-2$u@Hbh-cXM^DNpjUDw~VY_YzLUf#7-1ElZqngb~s~bfOS=Tx+A2 z_{&Jm4)1JZ_)sCAK?&+Vd)D);9}(Gg!}>RCP7G9r^kvoH>;M=-jzi+j?Xe@`8LXt% zlv{(P;38v64sO?cy(I?&fw{hwMYRj77!+={2TrlV1edE>Wg)A)t(s=blfwSk8&xB3 zWG-b-OAMBG;~7~t?^dfP{A#WQf5SHg8*V#}n^Kbtd%{q2-522lllMln4E4DR>k<}u z&XN+g3L)1@v2@xO^qeS?5@d5}TJ)P4f;$QEm zUg8@7hfo|i9DbXkpr^u9h~r5`O-K@bgxorWu)Caa>WIk$AtMmbxw%xqv8LE~#qHRS zCJ`f)Us%rvXo!S}yU^P;unPB;Wgx?MR)o2Cds>9Ks8ocDG1@~>)}zFH4SF2K{n>w* z>=a=y)YDI5LCkDX7n0<&>|v*7r)_%}k4{qo9Xsq47#Z`>H#g_`VkPo@xz&2~^<>6t zcaEFO#$j-XYuY5lSB~KsuB=0bT@+i3Ip%?JyRu<#*-_KZIxA05R5j``ycxKE<<>HA zPLrPbYvTQ?BI>L7GHV`qX;srJfxs3K7Lwho3doZZ$z&`HRlCCe(1MB2q(NT5m|!>p zAW%?|pN2Ud$-Qg(K~{c)ScLH4S=q#yHN6Fx6Q;G=@NXnDr`k4!$qvmMgX|+Qxm1ga zB1i{23r$3~<-(!_BVj!J|9uS4XwAdu5s3?CJqKhzK{~qu=ZSsu6Fh zUV#Yb!#Y%v?csxCUmfK~BwjT~C|?)DXH|XU7*%~E>r{PX9eiKaN4$JbhQQHx9uNeG zgej}!aORDWDlwyq%@9#H<6k3%n|F9iC{e15WLG#bsQpJ7`C}^EBV=g&&5|kH-Nt3v zWKvYp83WI;QN_C{(qz#h`uBAJHzK}8t&4bT;%*f64X5MRZXfECyp>}ru1HWVPU~Fv zVE<(FaWWS1qs^NncYnK8aDRuApC6|>ppUYjT`oeFRh8BKQ3s`e%#ex}Iu~0NH)W)7o8{~a z=egHP{N^Hx#)Y!x4#SP#%j(?(b;xYs6O%;1eri&oMC_<}7A0Ndx7&%#Ae@0b zDA%z>bmG)YvTkJ*cms*EfjP6};=L|}p8?wRqZtsZWVQ0eVx|umKjMVNq|r@e)jHWC zUocoHBF$5pIk(T3tA)g_RuWSS$IRG1h;()d*9&$xNHZR%IH5Q8J~ zeTL9W2(@je%_X1jJX{sJ8~2Rl_Ez-Ct%@>7>a2D;>#~rr*Bz09wPMq`6sJv@J)OTg zB{AlSQ_vSeStNXNF|C;G*tYrhCEqt<9|AFDYBj&TILi_g9Y*hq`l4IN*aVu zhi0-jJTiv9JKwzE4Pj?3euY|?d1|u%jp9=GtNtiQ`D{JMJgJmOx6zN9B~kbK)Gu+i zSmajB+(p-0+VK=A=WyAI7X2E(IkZjSBajh3Fp=xLNs=CH14F+A|*Zb8Z3KiVPAo>1b zu6R)ynCHEBFKmegNWR(`NnildF1=}Dr@OjnAMhNOOtZ5OLAMgyq&O+=*LOjZ0e3`# z0onoBvXHk-S4Hxx-+=hbQEe%)<;eI%nKc@yk}xeZHxyj!PYch_*<>UfM7+>ZB*hA> z=+>dEVY)n*Y`y-#$(N$j5hS#)0Ms75LbM*7!LLy_$cNOSDPPl4g%}ji2r%?o)r{B% z&0R!xX6?Axn9jf6F_fe==??ooLNxDj^D6>}x%BSzMvgqcNXY26Vcl->hb38EB~}ZrQdzDgQY-CtovRh}x+01EU%QB3 zj9;*JJ3LTQhI|bB9WFOqFLV#RC%GLz@3UKoKrwrS-0#FBSi^;Qsjdii zA|qKe{>A%aF!}wGTB(i{Fr^nT8bSu|fXa)={TP$9kb|Sp$+eU!%8Bj9`flIlM_UOY zSM%p7mZqe$$G1p}lTrm*MP(Rw+11pGj8qN>jEO?A(#m`{-|NMS@wJDu#WkrYgce#$ z7MYTu$KcQOm3e9pg@2U8EVjijwZ2W4xCzY|(?mjnlTtvge1#ZSytmQ){}Pb++d zUacz48BUM{d%D%00Qg(hRf2iliRk1Nu4Rl3>e%wMgECXC~k6qk*z(t~+L8eNyvr?p2e zrI#ra1O=Gp3ERQL5pUP)C@E~lk=3%PJRn}@9?O?1>P22Lho+O@3#cwx04c}Xet&?%h}1^7=m0S(7bVDy%sA3|`^K7K9*YqKy4E%#~$8G2U>@?wxoo~6Kkbuz|Q0zBF(quuHNT(zg9LW z*gapEABgJbTEBtgRKJ0f$cP;1&7K2bP~?1|O2nEu0;P~0S?{?@Fsbchf4;(6Lc^G0}Ye?)iN z>1*4=eL<)toEpjtz>WwAHtKImBk zTb+tZo49Ot(=YVB3M(z%EeLzrUa#TKidX}|@AC^oIT`&>iLJ2@3t?xnM_Q;P(`dF< z#|JB{!WL!ix;*4_E@rl*IRa?=N`Uv8QR&p{HMEfUg&#Tq{<=p|4DtOX+w7>gf~?f? z+ehBkefKKC5=QFs;_{Ap80u~UyH%7|7}kF5`3;*^YevwW=?A`-@TW4;1ShTQcH``8GOqpx{`06tY+zfR52F)&QBN`_VwsI7jI&_s&+t?-Y<2X z%74-Odx+Ss@i5Y0x*yd!^+oJ5;X}W?6WfpA z$6L{M7pGbE`RaQqzTSg*9uaxT9}z)+MA#AeaRiUol`xpMtW+=Iw)gc+x)l`=eEUOS+Pzf22NuDarzq4LgWP47{ohJ>m$c&4ToGE+9 zO7;rV8IZ=+p^k7w?!uVeC_XcoaZq)Mt>NUpWKc0l)83q_=!Rn-iOI5rowK-vA+uT| z9H3U8LG=iPY84mAKv-|qthDRYIb-(g`O}&Kj2`dge<|b%_0H0`Oy92kp%ds{n*Zcr z%j87{ZJT38zcBIRC-g}^aJ3Z}GyUZ*$S>Rwe2*N5pNPnoYPqs40VoYs4|JvAOrHta zFL0&6Lo8#l)|InpE^sa7ib&?@nbhg zOIx7f95(!x`uh;u=BQWU!=gG^pMOXT_DY3wR_nL^=$+P#@S|JIvIO+aFKE5nJ^0_O z84_`>lgCK;_DGg1<+#HV`9FyN*Tvo;mbfb=C2C7Z(@ZP<`lb4-zL}Y+jhS7;(H$N^ z=@;`a);$`kiCJkm2I^KhMrqk`sU^9Y@k1J#Y1;8Axt1f4{~3c>|7Xet?0khhiCBjM zAY?y8gw%bbQAtF!N(RZ$p;qZEwP@4QzfR0-2;BPq$t}m+ma&!bca>cByIWLdq&OSu zQlvdhvc)Jn_E6Yq8hoX4qYAMXST~NTS;4_p;q(Jojq+>vZ;}e+NLLXjOk)qqH&JtP zPq0ocy%E`g6}m0mDW!2o4AMFIo~}cORt9jHwBs0hU&Z3@BxG5Z?;-L-Z~yc@VQqho z``()jQ{R=dEy+k}$6sl_lq*wBKv6#M!6nLXHx3AGClrQ$=Gpa$Ys%Z7W~<5nQ~mna z7bX$v(t`a9G|B6RgZvvMt?8fsM>S&b{U24+nDOavec zow@&uCf(-2|D!ALc>_lN*Ab+wVTv^W1VHUb|C;U)EF(>-AB6y@s9$mGY2aX+4EFdmIX0l4El}am?Nwk-LNnxoTzexLz>b&V;K|#T>eh=(8+2-2#$aR^G0DPXr10WpX`j&nVH%7%1aHM;pT!bkByl@z5FF_f1|s@fa&S zwTjj#SuY1D)qJHzU?!b>wX5?Y51Neq#4NjM=mb_GXNQnC7@;5yRPVI$>TIz3)41=< ze8od2alUA=jm!q z``!{u%ezgbGASQA3LqfT636H(OcdG5cA?j&mL5rK$!h4i5UqH22Q=*FYIGjD1HH0I zgV=x-*O<^oEiC>zBIkLAOcJfajEWk%^cj}@oS@<49?Rre+&J>*Z=-MtCK0I6)^r%* z<$$2=(o54{EAFrI1}TqTVAOvullAuN{jx-K?1Gv}uM^ea=j#A$HJ(!O?`K*j4Yj zY6|5r*EZMI(`vu1SvZxNCd5>d)mtjd=*y((j|$6ek-Ga4@HZOl4SVrr#9Ou%d|0k< zhNi^JW<+fiREq54_I8A?(Ogadg2XKe7PJGY%aL9YgvEUZu}shE_m2bizqV=fClC!ti>N8S)+wRC_?{^Ku# z(#JVNH!8h`E!V%@vc)6FO6lO}ee+K6xZM7+u-yK^uven34aG#+$VUpzv-mUWlRvr* zq}tcw3l?;L{U?C`5VMF7lz43KN{ZQQLpDp0=~;H?$09E*p#1qLsjoW9H=8{+LE=h? zw^+|<%L6k<>ayjbh4AA=apVCoemPKP8NiyjEmfm&oakJ1uYbEB8#L3_8bLq$fc}C4 z@d<{Y2uuUR4-bwBGIVc|=U8|76*(L|66u`bGJ%Vq>_iAKr+5S9j0tJqAfmYz#@fr( z=xh)e<-2h*`9Wf>MLg(9-hrh0dd$B+Ji3&lTHAn{-VuG}CP6DgGg$!?D95N=wj*5q zp?9T8pVo-t*UNR&}u z==LOy;a1Bj@4N0MWjn=6<+vI?E{;q?8E|H9dWn zeXSBRm33?H?&zB6=Jm#+jbCQP#rTB8i-YMUPK1XXs$lcovNr>C_j7UEJs8qBiPBV? ztuP68+84x=oj;ael+aCDSc zlzu!zk}%H^m!kpjPPmSm8B5LPCx{|O>*n)-yR`2ny<=!3od3$%T3PJ!d)nS&Niv%y z=!~*FTp!H=gx0aOOQY1B*76^_N3=s|RuDH530s^s$3sU3>_e2`>alG~T3|i2ugoThpwrM*KG=7U;W_#BmXTnuQ;vQS-0G z^X<>{Z#&8Cs{fZA`nUUb51sq3UzQH91cCpTjtW{&O%(+Qs3HkCiV*vvC zVb6d>0t}%=5^YKzfI?&&77>*Q1Tg>=k#JvS69q>zwc{FY5YsshRjuYCUqG&}d|nnROrb^^%2Njp^?!P`}~nmklt zprtufp@uVu-l2J$!r)r!x!}dz6q07;n<|e9HKff?+CMo$Hu6QrlyvB6FVyuu!f}AQ9VygElCSZN zd}N34OwzPynn}CI$YC^L>DLiMc`ed9!Dt29q)D>FX=6c7YGB4`*>^)`NvKDWHPP^( z7;3OIVJ3)cT^ix$o^H>G8DT?Uk*i=qU7oNUjG`DEzXizCrbSfr>*sXX<1V~L7j6_a z=qdR)$6_mJ-i;P#G_!8U;WKiM>xNi0PdY-XDEV}^ZjvcA_=S?!P0$sdjK2Tro&5?c60+oa#UC@>-tJZI_ zKROSihX=Gg(Y97s=(X98gu=@fsBKK;n5$_p<5fiI*ezdIvYDeOi(xXwMy(Ap+{oWy zr3mRcxCc?JV%bM$j@NRs>L&1Yt$t%O71^n=2a8o1-?dh@wy&WyRA!Ry(MYtZ?UkFs zc3Dz;#<7zotk%BY+E>H3qni)|jijfpiIauFh@q;8iJ$;O-m2 z1wT zn+AXiG&I2C<{w6FO{>!o8MT0uW2@2rA261(gg1{q3ax=M_|vWj#RPU~ zkTe_rQ@Wn)ieR*=TN8DuXFtBYVhR<}_vB`#BPB`U|MM<(wr9(R?2*$E)zQ8r=cPyQ zdhfeDS7|}Z$IesP$)l2RbPS(XoS3Y|W(!z1@^YCFga8T5mXux;hrD<49w!pF2d<+P zuS(di8G<+GVAp3M2}U(u@(u{)&vvjFx-gbElam;Jfb3H8Xu(@(58MAwJ0eRrdc%zod8&D z+B%1@y<{cTTV1peOLBVa8MKdXOz`T&NmXm8Ee6Z43i%_LErNf}`N!Nz-WrRQv?(Oa zu@|a3aCyP#+B`GWMrh?WC%0%$>JLUo#h&|Adu=YqY zkyG1mcVJq=IA|wlio}}jPIy_cmqman$yL-Q-)>Y$3WMpVPM5aM2;~8!U9;}=ANLw% ze$%`gP&mxANaM*(w#0EGny3HQ#+86W`E~Iz)+|{<%-Du(S<5cF${rz;J&`ShB%v8h zD0^P}z7C^@wNN*wgS`A&7eCv)Rx^T)GxEQ@~o^hu)Qbsc-u-Q&JuaZoV zq}E)0A-tr}OUzNa@n;F@<_9_wk_n{7LuL=ZAEFBs9ctXICT_VBRtLUU|SR8atcf zwh0o;UiecQpD$(c`Q9C8`YLi_htvDFHBm*gk0F-Ms}eO+(|v0dewE|J7q^l3eOXm9 zN(ZLD?~uIgf=TrVR^BPUcNu9kVa{)V)?v z^F=wgVbCgWkGfdQ^aHo<094{UWtk_mQsdbJ_Sil+)d55?ZeXx+eZliJH*5TQaHrhX zf$i!X_Hx|$il3Dqg>nPibU8)OhfwVj?+;Apw)p9;)1uO6c*PMT8R@IY>nI=hxLj%) zln?i8jToI+ma)HGb6I2iwh3x)TgK_4>Z5#i{}?{uIARh-5oYNT)~6B(<%P&>g-*Uc zP`R@$(E}GaY44&3RYYmGQLWc}Sj&f5*Q~KHjvdpgP*c|fwKs9boUNg^=Zm1&Xd6|X zROaxu=vG@TEjK~yH_s}N{X^o$QW0X z>+Hn-Gk=F4x%Dbkq#?R%au@D-xymk7+^*b7*|Tjl{ORyRqq%W!X)9t47_82*n13{w zs&2xHnxt6*y!w@{q~E{#8NS2frK0gw>I_(4ALGPgwikO^7^7xmMbDI%#g@_*ACp!f zN12)<&5+pke(KwWGUQ{X)?V~zYvxMz{UMh?)C;8^de1^k16uIc#lr7_C^dqHW!tRA zPpO8Hl6h3M*MC`SYvh~yo1?8f@5MsB`FzVKT=TKFU{e|Juv zZri}tIvu=U?X9s!j1=MQcTWfU5~8_C`EnRg~-5EZe;j9OmL6URs|(@SAD#PMRq-vtVcO+C^K&!J60e` zw?nk8T(zLbw=XR!E6~2I7We!knLTvFNuVFM$7Zo1i%GogAF31N!2R3vwP~W=mj;_! z{*j*=N=+gJziwyQgU1lH`w_Ehqo>*TxNW8xIK+s8{C<5vjz&LoNtCB?svA*v5)nIrtJ+XGehTZX{{#kAXwSCZcd zLO*tYU%nD*COw+F9o{v~gFFj$szaWhD_om1w2}m)S5C_Du97Mugo1vYf%g zxi(0YAKl*#Afd7sCSLBon^P42{tBs75$GPzd!9)oUIoiWY+}~)bDs_&1QYRQ68g?- zIY_&<6+NQmpUZ&qSsm`D6Uu(>!8j3`W(5pB_E3C&`k6LPQe%?!IROOj%Pk?F0_2o!L$!7m*Vh)VG5lZ_qquzW)~eDCGQ2 zBShHMO>|!FfYZKa%`kI8fP;~;cLG}@)@tL*_oC_FsvCTdp5%W8?eMWX)$ALhhjg=( zyVAII*%>bW8sM)Le_59vlGJs+GQLeRW~*P?%&i7?k3HN@w&R|LNXy29B)z%Ulsn!F zLny3Q2V5Fi63oMz6M#q>Kc|%|&NA;KYBsK#%bIg4gK|ent|Iv5@V4p!Thi$Od5(lk zGTT63VlD554aa&NW1^5mmDhpgG>Atc26wfJ7t93D-w3^CP;QZ~O8yp>uBao0A&X_r z;?#>r?b2Yj42W57>~O~U<+X`824f$K3s4h?8F}p>Q(0p@Hqx4_uNuT8slG2NO@Gy3 z?>UpgmL$+}-)Di+A$OQa#h*=for56=%>MvJKEctv4)Gms%*se8*i|+Gy;;@TNHWg0 zD;r{s^G?Fl1nny;_|9UQ%PC90+zI*qf&C@3YA5&QD)*1rpl0^I!lg`N20C3f23@s0 z@Km@sl5IvlT+%?uT=VN7qlsGl^JmD<4gwDh#LP8>Jh+TIij6KCL*=!WH|PQvFO`QQ z$X{*otFT`uP0iqo%wUSlzLs|RQf0!dnWjdXuKBq7rAJ)Lv(7_3sU9*bF9fzpJ~c<8 zEfAFTkpl{5i$ybV2gQ2T(VxK{^1mZoW);ywSR}kER`KQM^>cgNn?6yuCOU$O21ZwF zQ7_Tf8`9p?Tpw+;Q8q#H6vj@nRMk2!co#GVWc*{0b)q__NW(w+wntceU0<` z{K%)*4g2iwybgC2$v~!9cqrMiT|GBfaZ%(gKNJLpzWWhCLn`K~r8PG~@R0El>gG5h z<5pGiSg;MU)3(tzfxy!~t)9zYO*W9p$ZbeZC{L5n+e&a96rgKH=7$Y6FA@dkD z=;j_xy<*WqcB?j3tYiYZQj=6Gj;zUW1C1PL=2hT>KJCmemL%u|7x&nV-I4s{=w&5@ zEha$J5h1GK1nxBJfe~OA>7uB-+v>(MH5LD+AnS5SwbB!brp+5& z@EYppMwN_&lX{{#Tm6A-nd#wvQ7B~Abq~fxEFGn0Rp-F{oWT&^0Nvqsd-DqF8JLzZ zq$WqK)~5DmChngP#&O+1fLvs=PDw|HJmdN|$xZZCzVc$u7kxZ=`b6l@W?uPkVnjk~ zI={P?pG~WzwW`D{dXQN}G|)wz;`CQlpV3#BI(w>y#L9}(Ia__uT-~6vbdLi$?Dk}` zo}&Q~B)SWlSu=ftwxkhfA2cl({Os3q?><3ov)#bMZNXjP(f+N<@JWpM2HTX1;xv3g z4J*5!Fa?gMuVGbcU5)c&Feknh7e#e@MQzb}b)X6D>4sM{g!BV!wE~5 zi^J?6*VNR_ZtLq-yz98Mh*bV`a5VZ}%Oa>nT=9GQ5>JHGNm^>T)gp)j%$d zIw6UA`G*H&S6VKz%G1k#LASU&Z2Az4jcyG_^YF|2}3~)(t6oT4b(#LN(;-`@}>x>l7r@Qs!5;p`47z zl$v2&-x7LMNyy5-X4b=%t4TfU%#^Fok~Wbsj9R1w4Gy9aa#YLhtoHTH2eBy~0%RNp z2cKnFU!z0pTAC)?-M=k;3%lR1_M3~cWE;8oP&icn{gtY{*{SLuDN;45zatN(OA~@i z#Fl=wZ@kDe>7mh)4)okW>apDXA+K%GCuV4rAbqvdj&H5}6^tb0iQ|_J-;IMD&s{QO zAtsrSDp&I}jlHVXQ21My^7w4?h)wcxAM_96$i9qP{T(;b<@IkK5})phDlji2%G0m- z2+fD05vP|Q*cWZh_fy#`Qtv|hCyAlQdc>sO2*x%ZDfL^r> z{<$$Ayc)uk00M#Tx!Z~8Y5kW@eKmxj2KZDBVLz;!heLsIkkeDD))yF0ILcN_;P#hHS~CQ@WuFm$QlOl!QW09Fh8(V zLwV#OwnqD?p1RR-#n*iZ|ts_nr`{J0C1Ze2w z#E*@aNS*R9UhQyR@Sh-knulKowl3%qseBg%ypWG4s4ay4&rkr+rNqM-#^Q)%P7nze z0+Xee{?0J&cp~_B5l~Vtez=ZDNUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega From cd4ec4c38eb9f3ee2102094d8daafd0f993db90c Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 6 Jun 2015 13:28:54 -0400 Subject: [PATCH 30/91] Working on the Variants/Block Subtypes. --- build.properties | 4 +- src/mantle/blocks/util/BlockVariant.java | 2 +- .../blocks/util/IBlockWithSubtypes.java | 8 +++ .../blocks/util/IBlockWithVariants.java | 8 --- .../ItemBlockSubtypes.java} | 14 ++--- src/mantle/blocks/util/PropertyVariant.java | 16 ++--- src/mantle/client/ModelVariant.java | 63 ++++++------------- 7 files changed, 44 insertions(+), 71 deletions(-) create mode 100644 src/mantle/blocks/util/IBlockWithSubtypes.java delete mode 100644 src/mantle/blocks/util/IBlockWithVariants.java rename src/mantle/blocks/{abstracts/ItemBlockVariants.java => util/ItemBlockSubtypes.java} (50%) diff --git a/build.properties b/build.properties index 43e5f71..563e76d 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.1.1392 -mappings=snapshot_20150424 +forge_version=11.14.2.1435 +mappings=snapshot_20150606 diff --git a/src/mantle/blocks/util/BlockVariant.java b/src/mantle/blocks/util/BlockVariant.java index beff5df..96fffe0 100644 --- a/src/mantle/blocks/util/BlockVariant.java +++ b/src/mantle/blocks/util/BlockVariant.java @@ -23,7 +23,7 @@ public class BlockVariant implements Comparable } @Override - public int compareTo(BlockVariant o) + public int compareTo(BlockVariant variant) { return this.meta; } diff --git a/src/mantle/blocks/util/IBlockWithSubtypes.java b/src/mantle/blocks/util/IBlockWithSubtypes.java new file mode 100644 index 0000000..4a5a09b --- /dev/null +++ b/src/mantle/blocks/util/IBlockWithSubtypes.java @@ -0,0 +1,8 @@ +package mantle.blocks.util; + +import net.minecraft.item.ItemStack; + +public interface IBlockWithSubtypes +{ + String getSubtypeUnlocalizedName(ItemStack stack); +} diff --git a/src/mantle/blocks/util/IBlockWithVariants.java b/src/mantle/blocks/util/IBlockWithVariants.java deleted file mode 100644 index 4c56312..0000000 --- a/src/mantle/blocks/util/IBlockWithVariants.java +++ /dev/null @@ -1,8 +0,0 @@ -package mantle.blocks.util; - -import net.minecraft.item.ItemStack; - -public interface IBlockWithVariants -{ - String getVariantNameFromStack(ItemStack stack); -} diff --git a/src/mantle/blocks/abstracts/ItemBlockVariants.java b/src/mantle/blocks/util/ItemBlockSubtypes.java similarity index 50% rename from src/mantle/blocks/abstracts/ItemBlockVariants.java rename to src/mantle/blocks/util/ItemBlockSubtypes.java index 20cd084..34acb42 100644 --- a/src/mantle/blocks/abstracts/ItemBlockVariants.java +++ b/src/mantle/blocks/util/ItemBlockSubtypes.java @@ -1,19 +1,19 @@ -package mantle.blocks.abstracts; +package mantle.blocks.util; -import mantle.blocks.util.IBlockWithVariants; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockVariants extends ItemBlock +public class ItemBlockSubtypes extends ItemBlock { - private final IBlockWithVariants variantBlock; + private final IBlockWithSubtypes blockWithSubtypes; - public ItemBlockVariants(Block block) + public ItemBlockSubtypes(Block block) { super(block); - this.variantBlock = (IBlockWithVariants) block; + this.blockWithSubtypes = (IBlockWithSubtypes) block; + this.setMaxDamage(0); this.setHasSubtypes(true); } @@ -27,7 +27,7 @@ public class ItemBlockVariants extends ItemBlock @Override public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + "." + this.variantBlock.getVariantNameFromStack(stack); + return super.getUnlocalizedName() + "." + this.blockWithSubtypes.getSubtypeUnlocalizedName(stack); } } diff --git a/src/mantle/blocks/util/PropertyVariant.java b/src/mantle/blocks/util/PropertyVariant.java index 386fa23..ff1ff38 100644 --- a/src/mantle/blocks/util/PropertyVariant.java +++ b/src/mantle/blocks/util/PropertyVariant.java @@ -1,7 +1,5 @@ package mantle.blocks.util; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -11,16 +9,17 @@ public class PropertyVariant implements IProperty { private String name; - private ArrayList values; + private BlockVariant defaultVariant; private HashMap metaMap; protected PropertyVariant(String name, BlockVariant... variants) { this.name = name; - this.values = new ArrayList(Arrays.asList(variants)); this.metaMap = new HashMap(); + this.defaultVariant = variants[0]; + for (BlockVariant variant : variants) { this.metaMap.put(variant.getMeta(), variant); @@ -41,7 +40,7 @@ public class PropertyVariant implements IProperty @Override public Collection getAllowedValues() { - return this.values; + return this.metaMap.values(); } @Override @@ -51,15 +50,16 @@ public class PropertyVariant implements IProperty } @Override - @SuppressWarnings("rawtypes") public String getName(Comparable value) { return ((BlockVariant) value).getName(); } - public BlockVariant getVariantFromMeta(int meta) + public BlockVariant fromMeta(int meta) { - return this.metaMap.get(meta); + BlockVariant variant = this.metaMap.get(meta); + + return variant != null ? variant : this.defaultVariant; } } diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index c6a79dc..7062e31 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -1,17 +1,11 @@ package mantle.client; -import java.util.ArrayList; -import java.util.Collection; - -import mantle.blocks.util.BlockVariant; -import mantle.items.util.IItemWithVariants; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -28,59 +22,38 @@ public class ModelVariant this.mc = mc; } - public void registerBlockModelVariants(Block block, Collection variants) + private void registerBlockModel(Block block) { - for (BlockVariant variant : variants) - { - Item item = Item.getItemFromBlock(block); + ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(block); - this.registerItemModel(item, variant.getName(), variant.getMeta()); - ModelBakery.addVariantName(item, (this.MOD_ID + ":") + variant.getName()); - } + registerBlockModel(block, 0, resourceLocation.getResourcePath()); } - public void registerBlockModel(Block block) + private void registerItemModel(Item item) { - this.registerBlockModel(block, block.getUnlocalizedName().substring(5), 0); + ResourceLocation resourceLocation = (ResourceLocation) Item.itemRegistry.getNameForObject(item); + + registerItemModel(item, 0, resourceLocation.getResourcePath()); } - public void registerBlockModel(Block block, String name, int meta) + private void registerBlockModel(Block block, int meta, String modelName) { - this.registerItemModel(Item.getItemFromBlock(block), name, meta); + registerItemModel(Item.getItemFromBlock(block), meta, modelName); } - public void registerItemModel(Item item) + private void registerItemModel(Item item, int meta, String resourcePath) { - this.registerItemModel(item, item.getUnlocalizedName().substring(5), 0); + ModelResourceLocation modelResourceLocation = new ModelResourceLocation((this.MOD_ID + ":") + resourcePath, "inventory"); + + this.mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); } - public void registerItemModel(Item item, String name, int meta) + private void registerBlockModelVariant(Block block, int meta, String resourcePath) { - this.mc.getRenderItem().getItemModelMesher().register(item, meta, this.getModelResource(name, "inventory")); - } + Item item = Item.getItemFromBlock(block); - public void registerItemModelVariants(Item item) - { - for (int i = 0; i < ((IItemWithVariants) item).getVariantNames().length; i++) - { - String NAME = item.getUnlocalizedName().substring(5) + "_" + ((IItemWithVariants) item).getVariantNames()[i]; - ModelBakery.addVariantName(item, (this.MOD_ID + ":") + NAME); - this.registerItemModel(item, NAME, i); - } - } + registerItemModel(item, meta, resourcePath); - public void registerItemSubTypesModel(Item item, CreativeTabs tab) - { - ArrayList list = new ArrayList(); - item.getSubItems(item, tab, list); - for (ItemStack i : list) - { - this.registerItemModel(item, item.getUnlocalizedName().substring(5), i.getItemDamage()); - } - } - - private ModelResourceLocation getModelResource(String name, String type) - { - return new ModelResourceLocation((this.MOD_ID + ":") + name, type); + ModelBakery.addVariantName(item, (this.MOD_ID + ":") + resourcePath); } } From dd0b53b6b47edeb192355c9b9aeca464f05eaa99 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 6 Jun 2015 13:37:23 -0400 Subject: [PATCH 31/91] Duh should be public not private. --- src/mantle/client/ModelVariant.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 7062e31..f3c4135 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -22,33 +22,33 @@ public class ModelVariant this.mc = mc; } - private void registerBlockModel(Block block) + public void registerBlockModel(Block block) { ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(block); registerBlockModel(block, 0, resourceLocation.getResourcePath()); } - private void registerItemModel(Item item) + public void registerItemModel(Item item) { ResourceLocation resourceLocation = (ResourceLocation) Item.itemRegistry.getNameForObject(item); registerItemModel(item, 0, resourceLocation.getResourcePath()); } - private void registerBlockModel(Block block, int meta, String modelName) + public void registerBlockModel(Block block, int meta, String modelName) { registerItemModel(Item.getItemFromBlock(block), meta, modelName); } - private void registerItemModel(Item item, int meta, String resourcePath) + public void registerItemModel(Item item, int meta, String resourcePath) { ModelResourceLocation modelResourceLocation = new ModelResourceLocation((this.MOD_ID + ":") + resourcePath, "inventory"); this.mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); } - private void registerBlockModelVariant(Block block, int meta, String resourcePath) + public void registerBlockModelVariant(Block block, int meta, String resourcePath) { Item item = Item.getItemFromBlock(block); From 962f10448826bc6fdca019283c7551a021254c05 Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 6 Jun 2015 15:41:44 -0400 Subject: [PATCH 32/91] Added methods I removed. --- src/mantle/client/ModelVariant.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index f3c4135..00b7a50 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -1,10 +1,15 @@ package mantle.client; +import java.util.ArrayList; + +import mantle.items.util.IItemWithVariants; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -56,4 +61,24 @@ public class ModelVariant ModelBakery.addVariantName(item, (this.MOD_ID + ":") + resourcePath); } + + public void registerItemModelVariant(Item item) + { + for (int i = 0; i < ((IItemWithVariants) item).getVariantNames().length; i++) + { + String NAME = item.getUnlocalizedName().substring(5) + "_" + ((IItemWithVariants) item).getVariantNames()[i]; + ModelBakery.addVariantName(item, (this.MOD_ID + ":") + NAME); + this.registerItemModel(item, i, NAME); + } + } + + public void registerItemSubTypesModel(Item item, CreativeTabs tab) + { + ArrayList list = new ArrayList(); + item.getSubItems(item, tab, list); + for (ItemStack i : list) + { + this.registerItemModel(item, i.getItemDamage(), item.getUnlocalizedName().substring(5)); + } + } } From 0bcb31c30de96ab2dca1ed8d1d9648929c29a6bb Mon Sep 17 00:00:00 2001 From: Alexander Behrhof Date: Sat, 11 Jul 2015 14:16:22 -0400 Subject: [PATCH 33/91] #Murder everything! --- build.properties | 4 +- .../blocks/util/IBlockWithSubtypes.java | 8 --- .../blocks/util/IBlockWithVariants.java | 8 +++ ...ckSubtypes.java => ItemBlockVariants.java} | 10 +-- src/mantle/blocks/util/PropertyVariant.java | 65 ------------------- .../util/{ => blockstates}/BlockVariant.java | 2 +- .../util/blockstates/PropertyVariant.java | 65 +++++++++++++++++++ src/mantle/client/ModelVariant.java | 52 ++++++++------- 8 files changed, 110 insertions(+), 104 deletions(-) delete mode 100644 src/mantle/blocks/util/IBlockWithSubtypes.java create mode 100644 src/mantle/blocks/util/IBlockWithVariants.java rename src/mantle/blocks/util/{ItemBlockSubtypes.java => ItemBlockVariants.java} (65%) delete mode 100644 src/mantle/blocks/util/PropertyVariant.java rename src/mantle/blocks/util/{ => blockstates}/BlockVariant.java (93%) create mode 100644 src/mantle/blocks/util/blockstates/PropertyVariant.java diff --git a/build.properties b/build.properties index 563e76d..0c8a802 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.2.1435 -mappings=snapshot_20150606 +forge_version=11.14.3.1487 +mappings=snapshot_20150708 diff --git a/src/mantle/blocks/util/IBlockWithSubtypes.java b/src/mantle/blocks/util/IBlockWithSubtypes.java deleted file mode 100644 index 4a5a09b..0000000 --- a/src/mantle/blocks/util/IBlockWithSubtypes.java +++ /dev/null @@ -1,8 +0,0 @@ -package mantle.blocks.util; - -import net.minecraft.item.ItemStack; - -public interface IBlockWithSubtypes -{ - String getSubtypeUnlocalizedName(ItemStack stack); -} diff --git a/src/mantle/blocks/util/IBlockWithVariants.java b/src/mantle/blocks/util/IBlockWithVariants.java new file mode 100644 index 0000000..4c56312 --- /dev/null +++ b/src/mantle/blocks/util/IBlockWithVariants.java @@ -0,0 +1,8 @@ +package mantle.blocks.util; + +import net.minecraft.item.ItemStack; + +public interface IBlockWithVariants +{ + String getVariantNameFromStack(ItemStack stack); +} diff --git a/src/mantle/blocks/util/ItemBlockSubtypes.java b/src/mantle/blocks/util/ItemBlockVariants.java similarity index 65% rename from src/mantle/blocks/util/ItemBlockSubtypes.java rename to src/mantle/blocks/util/ItemBlockVariants.java index 34acb42..eff4004 100644 --- a/src/mantle/blocks/util/ItemBlockSubtypes.java +++ b/src/mantle/blocks/util/ItemBlockVariants.java @@ -4,15 +4,15 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class ItemBlockSubtypes extends ItemBlock +public class ItemBlockVariants extends ItemBlock { - private final IBlockWithSubtypes blockWithSubtypes; + private final IBlockWithVariants blockWithVariants; - public ItemBlockSubtypes(Block block) + public ItemBlockVariants(Block block) { super(block); - this.blockWithSubtypes = (IBlockWithSubtypes) block; + this.blockWithVariants = (IBlockWithVariants) block; this.setMaxDamage(0); this.setHasSubtypes(true); @@ -27,7 +27,7 @@ public class ItemBlockSubtypes extends ItemBlock @Override public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName() + "." + this.blockWithSubtypes.getSubtypeUnlocalizedName(stack); + return super.getUnlocalizedName() + "." + this.blockWithVariants.getVariantNameFromStack(stack); } } diff --git a/src/mantle/blocks/util/PropertyVariant.java b/src/mantle/blocks/util/PropertyVariant.java deleted file mode 100644 index ff1ff38..0000000 --- a/src/mantle/blocks/util/PropertyVariant.java +++ /dev/null @@ -1,65 +0,0 @@ -package mantle.blocks.util; - -import java.util.Collection; -import java.util.HashMap; - -import net.minecraft.block.properties.IProperty; - -public class PropertyVariant implements IProperty -{ - private String name; - - private BlockVariant defaultVariant; - - private HashMap metaMap; - - protected PropertyVariant(String name, BlockVariant... variants) - { - this.name = name; - this.metaMap = new HashMap(); - - this.defaultVariant = variants[0]; - - for (BlockVariant variant : variants) - { - this.metaMap.put(variant.getMeta(), variant); - } - } - - public static PropertyVariant create(String name, BlockVariant... variants) - { - return new PropertyVariant(name, variants); - } - - @Override - public String getName() - { - return this.name; - } - - @Override - public Collection getAllowedValues() - { - return this.metaMap.values(); - } - - @Override - public Class getValueClass() - { - return BlockVariant.class; - } - - @Override - public String getName(Comparable value) - { - return ((BlockVariant) value).getName(); - } - - public BlockVariant fromMeta(int meta) - { - BlockVariant variant = this.metaMap.get(meta); - - return variant != null ? variant : this.defaultVariant; - } - -} diff --git a/src/mantle/blocks/util/BlockVariant.java b/src/mantle/blocks/util/blockstates/BlockVariant.java similarity index 93% rename from src/mantle/blocks/util/BlockVariant.java rename to src/mantle/blocks/util/blockstates/BlockVariant.java index 96fffe0..83b01a7 100644 --- a/src/mantle/blocks/util/BlockVariant.java +++ b/src/mantle/blocks/util/blockstates/BlockVariant.java @@ -1,4 +1,4 @@ -package mantle.blocks.util; +package mantle.blocks.util.blockstates; public class BlockVariant implements Comparable { diff --git a/src/mantle/blocks/util/blockstates/PropertyVariant.java b/src/mantle/blocks/util/blockstates/PropertyVariant.java new file mode 100644 index 0000000..8e9570a --- /dev/null +++ b/src/mantle/blocks/util/blockstates/PropertyVariant.java @@ -0,0 +1,65 @@ +package mantle.blocks.util.blockstates; + +import net.minecraft.block.properties.IProperty; + +import java.util.Collection; +import java.util.HashMap; + +public class PropertyVariant implements IProperty +{ + private String name; + + private BlockVariant defaultVariant; + + private HashMap metaMap; + + protected PropertyVariant(String name, BlockVariant... variants) + { + this.name = name; + this.metaMap = new HashMap(); + + this.defaultVariant = variants[0]; + + for (BlockVariant variant : variants) + { + this.metaMap.put(variant.getMeta(), variant); + } + } + + public static PropertyVariant create(String name, BlockVariant... variants) + { + return new PropertyVariant(name, variants); + } + + @Override + public String getName() + { + return this.name; + } + + @Override + public Collection getAllowedValues() + { + return this.metaMap.values(); + } + + @Override + public Class getValueClass() + { + return BlockVariant.class; + } + + @Override + public String getName(Comparable value) + { + return ((BlockVariant) value).getName(); + } + + public BlockVariant fromMeta(int meta) + { + BlockVariant variant = this.metaMap.get(meta); + + return variant != null ? variant : this.defaultVariant; + } + +} diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index 00b7a50..c92699f 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -27,51 +27,50 @@ public class ModelVariant this.mc = mc; } + public String getResource(String resource) + { + return (MOD_ID + ":") + resource; + } + + public void addVariantNames(Block block, String... names) + { + for (int i = 0; i < names.length; i++) + { + names[i] = getResource(names[i]); + } + + ModelBakery.addVariantName(Item.getItemFromBlock(block), names); + } + public void registerBlockModel(Block block) { ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(block); - registerBlockModel(block, 0, resourceLocation.getResourcePath()); + registerBlockModel(block, 0, resourceLocation.toString()); } public void registerItemModel(Item item) { ResourceLocation resourceLocation = (ResourceLocation) Item.itemRegistry.getNameForObject(item); - registerItemModel(item, 0, resourceLocation.getResourcePath()); + registerItemModel(item, 0, resourceLocation.toString()); } public void registerBlockModel(Block block, int meta, String modelName) { registerItemModel(Item.getItemFromBlock(block), meta, modelName); } - - public void registerItemModel(Item item, int meta, String resourcePath) - { - ModelResourceLocation modelResourceLocation = new ModelResourceLocation((this.MOD_ID + ":") + resourcePath, "inventory"); - - this.mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); - } - - public void registerBlockModelVariant(Block block, int meta, String resourcePath) - { - Item item = Item.getItemFromBlock(block); - - registerItemModel(item, meta, resourcePath); - - ModelBakery.addVariantName(item, (this.MOD_ID + ":") + resourcePath); - } - - public void registerItemModelVariant(Item item) + + public void registerItemModelVariants(Item item) { for (int i = 0; i < ((IItemWithVariants) item).getVariantNames().length; i++) { String NAME = item.getUnlocalizedName().substring(5) + "_" + ((IItemWithVariants) item).getVariantNames()[i]; - ModelBakery.addVariantName(item, (this.MOD_ID + ":") + NAME); - this.registerItemModel(item, i, NAME); + ModelBakery.addVariantName(item, getResource(NAME)); + this.registerItemModel(item, i, getResource(NAME)); } } - + public void registerItemSubTypesModel(Item item, CreativeTabs tab) { ArrayList list = new ArrayList(); @@ -81,4 +80,11 @@ public class ModelVariant this.registerItemModel(item, i.getItemDamage(), item.getUnlocalizedName().substring(5)); } } + + public void registerItemModel(Item item, int meta, String resourcePath) + { + ModelResourceLocation modelResourceLocation = new ModelResourceLocation(resourcePath, "inventory"); + + mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); + } } From 6a363b3981c4176083c6dae61d75345cefda28f7 Mon Sep 17 00:00:00 2001 From: Alexander Behrhof Date: Sat, 11 Jul 2015 15:59:15 -0400 Subject: [PATCH 34/91] Kill broken method/remove uneeded class. --- src/mantle/client/ModelVariant.java | 33 ++++++++++---------- src/mantle/items/util/IItemWithVariants.java | 6 ---- 2 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 src/mantle/items/util/IItemWithVariants.java diff --git a/src/mantle/client/ModelVariant.java b/src/mantle/client/ModelVariant.java index c92699f..7a4c4a4 100644 --- a/src/mantle/client/ModelVariant.java +++ b/src/mantle/client/ModelVariant.java @@ -2,7 +2,6 @@ package mantle.client; import java.util.ArrayList; -import mantle.items.util.IItemWithVariants; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; @@ -42,6 +41,16 @@ public class ModelVariant ModelBakery.addVariantName(Item.getItemFromBlock(block), names); } + public void addVariantNames(Item item, String... names) + { + for (int i = 0; i < names.length; i++) + { + names[i] = getResource(names[i]); + } + + ModelBakery.addVariantName(item, names); + } + public void registerBlockModel(Block block) { ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(block); @@ -60,17 +69,14 @@ public class ModelVariant { registerItemModel(Item.getItemFromBlock(block), meta, modelName); } - - public void registerItemModelVariants(Item item) + + public void registerItemModel(Item item, int meta, String resourcePath) { - for (int i = 0; i < ((IItemWithVariants) item).getVariantNames().length; i++) - { - String NAME = item.getUnlocalizedName().substring(5) + "_" + ((IItemWithVariants) item).getVariantNames()[i]; - ModelBakery.addVariantName(item, getResource(NAME)); - this.registerItemModel(item, i, getResource(NAME)); - } + ModelResourceLocation modelResourceLocation = new ModelResourceLocation(resourcePath, "inventory"); + + mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); } - + public void registerItemSubTypesModel(Item item, CreativeTabs tab) { ArrayList list = new ArrayList(); @@ -80,11 +86,4 @@ public class ModelVariant this.registerItemModel(item, i.getItemDamage(), item.getUnlocalizedName().substring(5)); } } - - public void registerItemModel(Item item, int meta, String resourcePath) - { - ModelResourceLocation modelResourceLocation = new ModelResourceLocation(resourcePath, "inventory"); - - mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); - } } diff --git a/src/mantle/items/util/IItemWithVariants.java b/src/mantle/items/util/IItemWithVariants.java deleted file mode 100644 index efbd31a..0000000 --- a/src/mantle/items/util/IItemWithVariants.java +++ /dev/null @@ -1,6 +0,0 @@ -package mantle.items.util; - -public interface IItemWithVariants -{ - String[] getVariantNames(); -} From 812ef0bf2d9f8bae71d9fd3284b6e6d218dc919c Mon Sep 17 00:00:00 2001 From: Alexander Date: Sat, 5 Sep 2015 22:01:35 -0400 Subject: [PATCH 35/91] Cleaned up and updated forge version. --- build.gradle | 42 ++++++------------ build.properties | 4 +- src/{ => main/java}/mantle/Mantle.java | 0 .../java}/mantle/blocks/BlockUtils.java | 0 .../java}/mantle/blocks/MantleBlock.java | 0 .../abstracts/AdaptiveInventoryLogic.java | 0 .../abstracts/ExpandableInventoryLogic.java | 0 .../blocks/abstracts/InventoryBlock.java | 0 .../blocks/abstracts/InventoryLogic.java | 0 .../blocks/abstracts/InventorySlab.java | 0 .../blocks/abstracts/MultiItemBlock.java | 0 .../blocks/abstracts/MultiServantLogic.java | 0 .../mantle/blocks/iface/IActiveLogic.java | 0 .../java}/mantle/blocks/iface/ICrop.java | 0 .../mantle/blocks/iface/IFacingLogic.java | 0 .../mantle/blocks/iface/IMasterLogic.java | 0 .../mantle/blocks/iface/IMasterNode.java | 0 .../mantle/blocks/iface/IServantLogic.java | 0 .../blocks/util/IBlockWithVariants.java | 0 .../mantle/blocks/util/ItemBlockVariants.java | 0 .../blocks/util/blockstates/BlockVariant.java | 0 .../util/blockstates/PropertyVariant.java | 0 .../java}/mantle/books/BookData.java | 0 .../java}/mantle/books/BookDataStore.java | 0 .../java}/mantle/books/ManualReader.java | 0 .../java}/mantle/books/client/BookImage.java | 0 .../java}/mantle/books/external/BookIS.java | 0 .../java}/mantle/books/external/BookLoad.java | 0 .../mantle/books/external/ZipLoader.java | 0 .../java}/mantle/client/MProxyClient.java | 0 .../java}/mantle/client/ModelHelper.java | 0 .../java}/mantle/client/ModelVariant.java | 0 .../java}/mantle/client/gui/GuiManual.java | 0 .../mantle/client/gui/TurnPageButton.java | 0 .../java}/mantle/client/pages/BlankPage.java | 0 .../java}/mantle/client/pages/BookPage.java | 0 .../client/pages/ContentsTablePage.java | 0 .../mantle/client/pages/CraftingPage.java | 0 .../mantle/client/pages/FurnacePage.java | 0 .../mantle/client/pages/PicturePage.java | 0 .../mantle/client/pages/SectionPage.java | 0 .../mantle/client/pages/SidebarPage.java | 0 .../java}/mantle/client/pages/TextPage.java | 0 .../java}/mantle/client/pages/TitlePage.java | 0 .../java}/mantle/common/ComparisonHelper.java | 0 .../java}/mantle/common/IDDumps.java | 0 .../java}/mantle/common/MProxyCommon.java | 0 .../mantle/common/network/AbstractPacket.java | 0 .../mantle/common/network/PacketUpdateTE.java | 0 .../mantle/crash/CallableSuppConfig.java | 0 .../mantle/crash/CallableUnsuppConfig.java | 0 .../java}/mantle/debug/DebugData.java | 0 .../java}/mantle/debug/DebugHelper.java | 0 .../java}/mantle/debug/IDebuggable.java | 0 .../java}/mantle/event/ManualOpenEvent.java | 0 .../java}/mantle/event/Migration.java | 0 .../java}/mantle/items/ItemUtils.java | 0 src/{ => main/java}/mantle/items/Manual.java | 0 .../mantle/items/abstracts/CraftingItem.java | 0 .../java}/mantle/items/iface/IDebugItem.java | 0 .../java}/mantle/lib/CoreConfig.java | 0 src/{ => main/java}/mantle/lib/CoreRepo.java | 0 src/{ => main/java}/mantle/lib/TabTools.java | 0 .../lib/client/MantleClientRegistry.java | 0 .../lib/environment/EnvironmentChecks.java | 0 src/{ => main/java}/mantle/math/Dozenal.java | 0 .../java}/mantle/player/PlayerUtils.java | 0 .../java}/mantle/pulsar/config/ForgeCFG.java | 0 .../mantle/pulsar/config/IConfiguration.java | 0 .../mantle/pulsar/control/PulseManager.java | 0 .../java}/mantle/pulsar/debug/EventSpy.java | 0 .../mantle/pulsar/internal/Configuration.java | 0 .../mantle/pulsar/internal/CrashHandler.java | 0 .../pulsar/internal/logging/ILogger.java | 0 .../pulsar/internal/logging/JULLogger.java | 0 .../pulsar/internal/logging/Log4jLogger.java | 0 .../pulsar/internal/logging/LogManager.java | 0 .../java}/mantle/pulsar/package-info.java | 0 .../java}/mantle/pulsar/pulse/Pulse.java | 0 .../java}/mantle/pulsar/pulse/PulseMeta.java | 0 .../java}/mantle/utils/ItemMetaWrapper.java | 0 .../mantle/utils/ItemStackNBTWrapper.java | 0 .../java}/mantle/utils/ItemStackWrapper.java | 0 .../java}/mantle/utils/RecipeRemover.java | 0 .../java}/mantle/world/ChunkCoord.java | 0 .../java}/mantle/world/CoordTuplePair.java | 0 .../mantle/world/DimensionCoordPair.java | 0 .../mantle/world/DimensionCoordTuple.java | 0 .../java}/mantle/world/DirectionUtils.java | 0 {resources => src/main/resources}/Mantle.png | Bin .../resources}/assets/mantle/manuals/test.xml | 0 .../assets/mantle/models/item/mantleBook.json | 0 .../assets/mantle/textures/gui/book.png | Bin .../mantle/textures/gui/bookcrafting.png | Bin .../mantle/textures/gui/bookfurnace.png | Bin .../assets/mantle/textures/gui/bookleft.png | Bin .../assets/mantle/textures/gui/bookright.png | Bin .../assets/mantle/textures/gui/missingno.png | Bin .../mantle/textures/gui/tinkerbook_blue.png | Bin .../mantle/textures/gui/tinkerbook_green.png | Bin .../mantle/textures/items/mantlebook_blue.png | Bin .../mantle/textures/items/tinkerbook_blue.png | Bin .../textures/items/tinkerbook_diary.png | Bin .../textures/items/tinkerbook_green.png | Bin .../textures/items/tinkerbook_smeltery.png | Bin .../textures/items/tinkerbook_toolstation.png | Bin {resources => src/main/resources}/mcmod.info | 0 107 files changed, 15 insertions(+), 31 deletions(-) rename src/{ => main/java}/mantle/Mantle.java (100%) rename src/{ => main/java}/mantle/blocks/BlockUtils.java (100%) rename src/{ => main/java}/mantle/blocks/MantleBlock.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/AdaptiveInventoryLogic.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/ExpandableInventoryLogic.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/InventoryBlock.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/InventoryLogic.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/InventorySlab.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/MultiItemBlock.java (100%) rename src/{ => main/java}/mantle/blocks/abstracts/MultiServantLogic.java (100%) rename src/{ => main/java}/mantle/blocks/iface/IActiveLogic.java (100%) rename src/{ => main/java}/mantle/blocks/iface/ICrop.java (100%) rename src/{ => main/java}/mantle/blocks/iface/IFacingLogic.java (100%) rename src/{ => main/java}/mantle/blocks/iface/IMasterLogic.java (100%) rename src/{ => main/java}/mantle/blocks/iface/IMasterNode.java (100%) rename src/{ => main/java}/mantle/blocks/iface/IServantLogic.java (100%) rename src/{ => main/java}/mantle/blocks/util/IBlockWithVariants.java (100%) rename src/{ => main/java}/mantle/blocks/util/ItemBlockVariants.java (100%) rename src/{ => main/java}/mantle/blocks/util/blockstates/BlockVariant.java (100%) rename src/{ => main/java}/mantle/blocks/util/blockstates/PropertyVariant.java (100%) rename src/{ => main/java}/mantle/books/BookData.java (100%) rename src/{ => main/java}/mantle/books/BookDataStore.java (100%) rename src/{ => main/java}/mantle/books/ManualReader.java (100%) rename src/{ => main/java}/mantle/books/client/BookImage.java (100%) rename src/{ => main/java}/mantle/books/external/BookIS.java (100%) rename src/{ => main/java}/mantle/books/external/BookLoad.java (100%) rename src/{ => main/java}/mantle/books/external/ZipLoader.java (100%) rename src/{ => main/java}/mantle/client/MProxyClient.java (100%) rename src/{ => main/java}/mantle/client/ModelHelper.java (100%) rename src/{ => main/java}/mantle/client/ModelVariant.java (100%) rename src/{ => main/java}/mantle/client/gui/GuiManual.java (100%) rename src/{ => main/java}/mantle/client/gui/TurnPageButton.java (100%) rename src/{ => main/java}/mantle/client/pages/BlankPage.java (100%) rename src/{ => main/java}/mantle/client/pages/BookPage.java (100%) rename src/{ => main/java}/mantle/client/pages/ContentsTablePage.java (100%) rename src/{ => main/java}/mantle/client/pages/CraftingPage.java (100%) rename src/{ => main/java}/mantle/client/pages/FurnacePage.java (100%) rename src/{ => main/java}/mantle/client/pages/PicturePage.java (100%) rename src/{ => main/java}/mantle/client/pages/SectionPage.java (100%) rename src/{ => main/java}/mantle/client/pages/SidebarPage.java (100%) rename src/{ => main/java}/mantle/client/pages/TextPage.java (100%) rename src/{ => main/java}/mantle/client/pages/TitlePage.java (100%) rename src/{ => main/java}/mantle/common/ComparisonHelper.java (100%) rename src/{ => main/java}/mantle/common/IDDumps.java (100%) rename src/{ => main/java}/mantle/common/MProxyCommon.java (100%) rename src/{ => main/java}/mantle/common/network/AbstractPacket.java (100%) rename src/{ => main/java}/mantle/common/network/PacketUpdateTE.java (100%) rename src/{ => main/java}/mantle/crash/CallableSuppConfig.java (100%) rename src/{ => main/java}/mantle/crash/CallableUnsuppConfig.java (100%) rename src/{ => main/java}/mantle/debug/DebugData.java (100%) rename src/{ => main/java}/mantle/debug/DebugHelper.java (100%) rename src/{ => main/java}/mantle/debug/IDebuggable.java (100%) rename src/{ => main/java}/mantle/event/ManualOpenEvent.java (100%) rename src/{ => main/java}/mantle/event/Migration.java (100%) rename src/{ => main/java}/mantle/items/ItemUtils.java (100%) rename src/{ => main/java}/mantle/items/Manual.java (100%) rename src/{ => main/java}/mantle/items/abstracts/CraftingItem.java (100%) rename src/{ => main/java}/mantle/items/iface/IDebugItem.java (100%) rename src/{ => main/java}/mantle/lib/CoreConfig.java (100%) rename src/{ => main/java}/mantle/lib/CoreRepo.java (100%) rename src/{ => main/java}/mantle/lib/TabTools.java (100%) rename src/{ => main/java}/mantle/lib/client/MantleClientRegistry.java (100%) rename src/{ => main/java}/mantle/lib/environment/EnvironmentChecks.java (100%) rename src/{ => main/java}/mantle/math/Dozenal.java (100%) rename src/{ => main/java}/mantle/player/PlayerUtils.java (100%) rename src/{ => main/java}/mantle/pulsar/config/ForgeCFG.java (100%) rename src/{ => main/java}/mantle/pulsar/config/IConfiguration.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/control/PulseManager.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/debug/EventSpy.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/internal/Configuration.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/internal/CrashHandler.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/internal/logging/ILogger.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/internal/logging/JULLogger.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/internal/logging/Log4jLogger.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/internal/logging/LogManager.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/package-info.java (100%) rename src/{ => main/java}/mantle/pulsar/pulse/Pulse.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/pulsar/pulse/PulseMeta.java (100%) mode change 100755 => 100644 rename src/{ => main/java}/mantle/utils/ItemMetaWrapper.java (100%) rename src/{ => main/java}/mantle/utils/ItemStackNBTWrapper.java (100%) rename src/{ => main/java}/mantle/utils/ItemStackWrapper.java (100%) rename src/{ => main/java}/mantle/utils/RecipeRemover.java (100%) rename src/{ => main/java}/mantle/world/ChunkCoord.java (100%) rename src/{ => main/java}/mantle/world/CoordTuplePair.java (100%) rename src/{ => main/java}/mantle/world/DimensionCoordPair.java (100%) rename src/{ => main/java}/mantle/world/DimensionCoordTuple.java (100%) rename src/{ => main/java}/mantle/world/DirectionUtils.java (100%) rename {resources => src/main/resources}/Mantle.png (100%) rename {resources => src/main/resources}/assets/mantle/manuals/test.xml (100%) rename {resources => src/main/resources}/assets/mantle/models/item/mantleBook.json (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/book.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/bookcrafting.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/bookfurnace.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/bookleft.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/bookright.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/missingno.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/tinkerbook_blue.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/gui/tinkerbook_green.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/items/mantlebook_blue.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/items/tinkerbook_blue.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/items/tinkerbook_diary.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/items/tinkerbook_green.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/items/tinkerbook_smeltery.png (100%) rename {resources => src/main/resources}/assets/mantle/textures/items/tinkerbook_toolstation.png (100%) rename {resources => src/main/resources}/mcmod.info (100%) diff --git a/build.gradle b/build.gradle index 6991104..be35c95 100644 --- a/build.gradle +++ b/build.gradle @@ -4,25 +4,27 @@ * Based on TConstruct's master build file * Authors: Sunstrike, ProgWML6 * Help from AbrarSyed - */ +*/ buildscript { repositories { mavenCentral() - mavenLocal() + mavenLocal() + jcenter() maven { - name = 'ForgeFS' - url = 'http://files.minecraftforge.net/maven' + name = "forge" + url = "http://files.minecraftforge.net/maven" } - maven { + maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT' } } +apply plugin: 'net.minecraftforge.gradle.forge' repositories { mavenLocal() @@ -32,8 +34,6 @@ repositories { } } - -apply plugin: 'forge' group = 'mantle' sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -48,8 +48,7 @@ configFile.withReader { project.ext.config = new ConfigSlurper().parse prop } -// sets version to the slimeKnights default version format -// Finds and sets version data +// sets version to the slimeKnights version format task buildInfo { def cmd = "git rev-parse --short HEAD" def proc = cmd.execute() @@ -83,30 +82,17 @@ minecraft { replace '${version}', project.version } - -sourceSets { - main { - resources { - srcDir 'resources' - } - java { - srcDir 'src' - } - } -} processResources { inputs.property "version", artifact_version inputs.property "MCversion", config.minecraft_version - - // replace stuff in text files, not binary ones. + // replace stuff in text files, not binary ones. from(sourceSets.main.resources.srcDirs) { include '**/*.info' - // replace version and MCVersion + // replace version and MCVersion expand 'version':artifact_version,'MCversion':config.minecraft_version } - - // copy everything else, thats not text + // copy everything else, thats not text from(sourceSets.main.resources.srcDirs) { exclude '**/*.info' } @@ -129,9 +115,7 @@ artifacts { } task("uploadJars", dependsOn:"build") { - description = "uploads JARs" - if (project.hasProperty("local_maven")) { apply plugin: 'maven' uploadArchives { @@ -142,4 +126,4 @@ task("uploadJars", dependsOn:"build") { } } } -} \ No newline at end of file +} diff --git a/build.properties b/build.properties index 0c8a802..74c1dfa 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.3.1487 -mappings=snapshot_20150708 +forge_version=11.14.3.1512 +mappings=snapshot_20150905 diff --git a/src/mantle/Mantle.java b/src/main/java/mantle/Mantle.java similarity index 100% rename from src/mantle/Mantle.java rename to src/main/java/mantle/Mantle.java diff --git a/src/mantle/blocks/BlockUtils.java b/src/main/java/mantle/blocks/BlockUtils.java similarity index 100% rename from src/mantle/blocks/BlockUtils.java rename to src/main/java/mantle/blocks/BlockUtils.java diff --git a/src/mantle/blocks/MantleBlock.java b/src/main/java/mantle/blocks/MantleBlock.java similarity index 100% rename from src/mantle/blocks/MantleBlock.java rename to src/main/java/mantle/blocks/MantleBlock.java diff --git a/src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java b/src/main/java/mantle/blocks/abstracts/AdaptiveInventoryLogic.java similarity index 100% rename from src/mantle/blocks/abstracts/AdaptiveInventoryLogic.java rename to src/main/java/mantle/blocks/abstracts/AdaptiveInventoryLogic.java diff --git a/src/mantle/blocks/abstracts/ExpandableInventoryLogic.java b/src/main/java/mantle/blocks/abstracts/ExpandableInventoryLogic.java similarity index 100% rename from src/mantle/blocks/abstracts/ExpandableInventoryLogic.java rename to src/main/java/mantle/blocks/abstracts/ExpandableInventoryLogic.java diff --git a/src/mantle/blocks/abstracts/InventoryBlock.java b/src/main/java/mantle/blocks/abstracts/InventoryBlock.java similarity index 100% rename from src/mantle/blocks/abstracts/InventoryBlock.java rename to src/main/java/mantle/blocks/abstracts/InventoryBlock.java diff --git a/src/mantle/blocks/abstracts/InventoryLogic.java b/src/main/java/mantle/blocks/abstracts/InventoryLogic.java similarity index 100% rename from src/mantle/blocks/abstracts/InventoryLogic.java rename to src/main/java/mantle/blocks/abstracts/InventoryLogic.java diff --git a/src/mantle/blocks/abstracts/InventorySlab.java b/src/main/java/mantle/blocks/abstracts/InventorySlab.java similarity index 100% rename from src/mantle/blocks/abstracts/InventorySlab.java rename to src/main/java/mantle/blocks/abstracts/InventorySlab.java diff --git a/src/mantle/blocks/abstracts/MultiItemBlock.java b/src/main/java/mantle/blocks/abstracts/MultiItemBlock.java similarity index 100% rename from src/mantle/blocks/abstracts/MultiItemBlock.java rename to src/main/java/mantle/blocks/abstracts/MultiItemBlock.java diff --git a/src/mantle/blocks/abstracts/MultiServantLogic.java b/src/main/java/mantle/blocks/abstracts/MultiServantLogic.java similarity index 100% rename from src/mantle/blocks/abstracts/MultiServantLogic.java rename to src/main/java/mantle/blocks/abstracts/MultiServantLogic.java diff --git a/src/mantle/blocks/iface/IActiveLogic.java b/src/main/java/mantle/blocks/iface/IActiveLogic.java similarity index 100% rename from src/mantle/blocks/iface/IActiveLogic.java rename to src/main/java/mantle/blocks/iface/IActiveLogic.java diff --git a/src/mantle/blocks/iface/ICrop.java b/src/main/java/mantle/blocks/iface/ICrop.java similarity index 100% rename from src/mantle/blocks/iface/ICrop.java rename to src/main/java/mantle/blocks/iface/ICrop.java diff --git a/src/mantle/blocks/iface/IFacingLogic.java b/src/main/java/mantle/blocks/iface/IFacingLogic.java similarity index 100% rename from src/mantle/blocks/iface/IFacingLogic.java rename to src/main/java/mantle/blocks/iface/IFacingLogic.java diff --git a/src/mantle/blocks/iface/IMasterLogic.java b/src/main/java/mantle/blocks/iface/IMasterLogic.java similarity index 100% rename from src/mantle/blocks/iface/IMasterLogic.java rename to src/main/java/mantle/blocks/iface/IMasterLogic.java diff --git a/src/mantle/blocks/iface/IMasterNode.java b/src/main/java/mantle/blocks/iface/IMasterNode.java similarity index 100% rename from src/mantle/blocks/iface/IMasterNode.java rename to src/main/java/mantle/blocks/iface/IMasterNode.java diff --git a/src/mantle/blocks/iface/IServantLogic.java b/src/main/java/mantle/blocks/iface/IServantLogic.java similarity index 100% rename from src/mantle/blocks/iface/IServantLogic.java rename to src/main/java/mantle/blocks/iface/IServantLogic.java diff --git a/src/mantle/blocks/util/IBlockWithVariants.java b/src/main/java/mantle/blocks/util/IBlockWithVariants.java similarity index 100% rename from src/mantle/blocks/util/IBlockWithVariants.java rename to src/main/java/mantle/blocks/util/IBlockWithVariants.java diff --git a/src/mantle/blocks/util/ItemBlockVariants.java b/src/main/java/mantle/blocks/util/ItemBlockVariants.java similarity index 100% rename from src/mantle/blocks/util/ItemBlockVariants.java rename to src/main/java/mantle/blocks/util/ItemBlockVariants.java diff --git a/src/mantle/blocks/util/blockstates/BlockVariant.java b/src/main/java/mantle/blocks/util/blockstates/BlockVariant.java similarity index 100% rename from src/mantle/blocks/util/blockstates/BlockVariant.java rename to src/main/java/mantle/blocks/util/blockstates/BlockVariant.java diff --git a/src/mantle/blocks/util/blockstates/PropertyVariant.java b/src/main/java/mantle/blocks/util/blockstates/PropertyVariant.java similarity index 100% rename from src/mantle/blocks/util/blockstates/PropertyVariant.java rename to src/main/java/mantle/blocks/util/blockstates/PropertyVariant.java diff --git a/src/mantle/books/BookData.java b/src/main/java/mantle/books/BookData.java similarity index 100% rename from src/mantle/books/BookData.java rename to src/main/java/mantle/books/BookData.java diff --git a/src/mantle/books/BookDataStore.java b/src/main/java/mantle/books/BookDataStore.java similarity index 100% rename from src/mantle/books/BookDataStore.java rename to src/main/java/mantle/books/BookDataStore.java diff --git a/src/mantle/books/ManualReader.java b/src/main/java/mantle/books/ManualReader.java similarity index 100% rename from src/mantle/books/ManualReader.java rename to src/main/java/mantle/books/ManualReader.java diff --git a/src/mantle/books/client/BookImage.java b/src/main/java/mantle/books/client/BookImage.java similarity index 100% rename from src/mantle/books/client/BookImage.java rename to src/main/java/mantle/books/client/BookImage.java diff --git a/src/mantle/books/external/BookIS.java b/src/main/java/mantle/books/external/BookIS.java similarity index 100% rename from src/mantle/books/external/BookIS.java rename to src/main/java/mantle/books/external/BookIS.java diff --git a/src/mantle/books/external/BookLoad.java b/src/main/java/mantle/books/external/BookLoad.java similarity index 100% rename from src/mantle/books/external/BookLoad.java rename to src/main/java/mantle/books/external/BookLoad.java diff --git a/src/mantle/books/external/ZipLoader.java b/src/main/java/mantle/books/external/ZipLoader.java similarity index 100% rename from src/mantle/books/external/ZipLoader.java rename to src/main/java/mantle/books/external/ZipLoader.java diff --git a/src/mantle/client/MProxyClient.java b/src/main/java/mantle/client/MProxyClient.java similarity index 100% rename from src/mantle/client/MProxyClient.java rename to src/main/java/mantle/client/MProxyClient.java diff --git a/src/mantle/client/ModelHelper.java b/src/main/java/mantle/client/ModelHelper.java similarity index 100% rename from src/mantle/client/ModelHelper.java rename to src/main/java/mantle/client/ModelHelper.java diff --git a/src/mantle/client/ModelVariant.java b/src/main/java/mantle/client/ModelVariant.java similarity index 100% rename from src/mantle/client/ModelVariant.java rename to src/main/java/mantle/client/ModelVariant.java diff --git a/src/mantle/client/gui/GuiManual.java b/src/main/java/mantle/client/gui/GuiManual.java similarity index 100% rename from src/mantle/client/gui/GuiManual.java rename to src/main/java/mantle/client/gui/GuiManual.java diff --git a/src/mantle/client/gui/TurnPageButton.java b/src/main/java/mantle/client/gui/TurnPageButton.java similarity index 100% rename from src/mantle/client/gui/TurnPageButton.java rename to src/main/java/mantle/client/gui/TurnPageButton.java diff --git a/src/mantle/client/pages/BlankPage.java b/src/main/java/mantle/client/pages/BlankPage.java similarity index 100% rename from src/mantle/client/pages/BlankPage.java rename to src/main/java/mantle/client/pages/BlankPage.java diff --git a/src/mantle/client/pages/BookPage.java b/src/main/java/mantle/client/pages/BookPage.java similarity index 100% rename from src/mantle/client/pages/BookPage.java rename to src/main/java/mantle/client/pages/BookPage.java diff --git a/src/mantle/client/pages/ContentsTablePage.java b/src/main/java/mantle/client/pages/ContentsTablePage.java similarity index 100% rename from src/mantle/client/pages/ContentsTablePage.java rename to src/main/java/mantle/client/pages/ContentsTablePage.java diff --git a/src/mantle/client/pages/CraftingPage.java b/src/main/java/mantle/client/pages/CraftingPage.java similarity index 100% rename from src/mantle/client/pages/CraftingPage.java rename to src/main/java/mantle/client/pages/CraftingPage.java diff --git a/src/mantle/client/pages/FurnacePage.java b/src/main/java/mantle/client/pages/FurnacePage.java similarity index 100% rename from src/mantle/client/pages/FurnacePage.java rename to src/main/java/mantle/client/pages/FurnacePage.java diff --git a/src/mantle/client/pages/PicturePage.java b/src/main/java/mantle/client/pages/PicturePage.java similarity index 100% rename from src/mantle/client/pages/PicturePage.java rename to src/main/java/mantle/client/pages/PicturePage.java diff --git a/src/mantle/client/pages/SectionPage.java b/src/main/java/mantle/client/pages/SectionPage.java similarity index 100% rename from src/mantle/client/pages/SectionPage.java rename to src/main/java/mantle/client/pages/SectionPage.java diff --git a/src/mantle/client/pages/SidebarPage.java b/src/main/java/mantle/client/pages/SidebarPage.java similarity index 100% rename from src/mantle/client/pages/SidebarPage.java rename to src/main/java/mantle/client/pages/SidebarPage.java diff --git a/src/mantle/client/pages/TextPage.java b/src/main/java/mantle/client/pages/TextPage.java similarity index 100% rename from src/mantle/client/pages/TextPage.java rename to src/main/java/mantle/client/pages/TextPage.java diff --git a/src/mantle/client/pages/TitlePage.java b/src/main/java/mantle/client/pages/TitlePage.java similarity index 100% rename from src/mantle/client/pages/TitlePage.java rename to src/main/java/mantle/client/pages/TitlePage.java diff --git a/src/mantle/common/ComparisonHelper.java b/src/main/java/mantle/common/ComparisonHelper.java similarity index 100% rename from src/mantle/common/ComparisonHelper.java rename to src/main/java/mantle/common/ComparisonHelper.java diff --git a/src/mantle/common/IDDumps.java b/src/main/java/mantle/common/IDDumps.java similarity index 100% rename from src/mantle/common/IDDumps.java rename to src/main/java/mantle/common/IDDumps.java diff --git a/src/mantle/common/MProxyCommon.java b/src/main/java/mantle/common/MProxyCommon.java similarity index 100% rename from src/mantle/common/MProxyCommon.java rename to src/main/java/mantle/common/MProxyCommon.java diff --git a/src/mantle/common/network/AbstractPacket.java b/src/main/java/mantle/common/network/AbstractPacket.java similarity index 100% rename from src/mantle/common/network/AbstractPacket.java rename to src/main/java/mantle/common/network/AbstractPacket.java diff --git a/src/mantle/common/network/PacketUpdateTE.java b/src/main/java/mantle/common/network/PacketUpdateTE.java similarity index 100% rename from src/mantle/common/network/PacketUpdateTE.java rename to src/main/java/mantle/common/network/PacketUpdateTE.java diff --git a/src/mantle/crash/CallableSuppConfig.java b/src/main/java/mantle/crash/CallableSuppConfig.java similarity index 100% rename from src/mantle/crash/CallableSuppConfig.java rename to src/main/java/mantle/crash/CallableSuppConfig.java diff --git a/src/mantle/crash/CallableUnsuppConfig.java b/src/main/java/mantle/crash/CallableUnsuppConfig.java similarity index 100% rename from src/mantle/crash/CallableUnsuppConfig.java rename to src/main/java/mantle/crash/CallableUnsuppConfig.java diff --git a/src/mantle/debug/DebugData.java b/src/main/java/mantle/debug/DebugData.java similarity index 100% rename from src/mantle/debug/DebugData.java rename to src/main/java/mantle/debug/DebugData.java diff --git a/src/mantle/debug/DebugHelper.java b/src/main/java/mantle/debug/DebugHelper.java similarity index 100% rename from src/mantle/debug/DebugHelper.java rename to src/main/java/mantle/debug/DebugHelper.java diff --git a/src/mantle/debug/IDebuggable.java b/src/main/java/mantle/debug/IDebuggable.java similarity index 100% rename from src/mantle/debug/IDebuggable.java rename to src/main/java/mantle/debug/IDebuggable.java diff --git a/src/mantle/event/ManualOpenEvent.java b/src/main/java/mantle/event/ManualOpenEvent.java similarity index 100% rename from src/mantle/event/ManualOpenEvent.java rename to src/main/java/mantle/event/ManualOpenEvent.java diff --git a/src/mantle/event/Migration.java b/src/main/java/mantle/event/Migration.java similarity index 100% rename from src/mantle/event/Migration.java rename to src/main/java/mantle/event/Migration.java diff --git a/src/mantle/items/ItemUtils.java b/src/main/java/mantle/items/ItemUtils.java similarity index 100% rename from src/mantle/items/ItemUtils.java rename to src/main/java/mantle/items/ItemUtils.java diff --git a/src/mantle/items/Manual.java b/src/main/java/mantle/items/Manual.java similarity index 100% rename from src/mantle/items/Manual.java rename to src/main/java/mantle/items/Manual.java diff --git a/src/mantle/items/abstracts/CraftingItem.java b/src/main/java/mantle/items/abstracts/CraftingItem.java similarity index 100% rename from src/mantle/items/abstracts/CraftingItem.java rename to src/main/java/mantle/items/abstracts/CraftingItem.java diff --git a/src/mantle/items/iface/IDebugItem.java b/src/main/java/mantle/items/iface/IDebugItem.java similarity index 100% rename from src/mantle/items/iface/IDebugItem.java rename to src/main/java/mantle/items/iface/IDebugItem.java diff --git a/src/mantle/lib/CoreConfig.java b/src/main/java/mantle/lib/CoreConfig.java similarity index 100% rename from src/mantle/lib/CoreConfig.java rename to src/main/java/mantle/lib/CoreConfig.java diff --git a/src/mantle/lib/CoreRepo.java b/src/main/java/mantle/lib/CoreRepo.java similarity index 100% rename from src/mantle/lib/CoreRepo.java rename to src/main/java/mantle/lib/CoreRepo.java diff --git a/src/mantle/lib/TabTools.java b/src/main/java/mantle/lib/TabTools.java similarity index 100% rename from src/mantle/lib/TabTools.java rename to src/main/java/mantle/lib/TabTools.java diff --git a/src/mantle/lib/client/MantleClientRegistry.java b/src/main/java/mantle/lib/client/MantleClientRegistry.java similarity index 100% rename from src/mantle/lib/client/MantleClientRegistry.java rename to src/main/java/mantle/lib/client/MantleClientRegistry.java diff --git a/src/mantle/lib/environment/EnvironmentChecks.java b/src/main/java/mantle/lib/environment/EnvironmentChecks.java similarity index 100% rename from src/mantle/lib/environment/EnvironmentChecks.java rename to src/main/java/mantle/lib/environment/EnvironmentChecks.java diff --git a/src/mantle/math/Dozenal.java b/src/main/java/mantle/math/Dozenal.java similarity index 100% rename from src/mantle/math/Dozenal.java rename to src/main/java/mantle/math/Dozenal.java diff --git a/src/mantle/player/PlayerUtils.java b/src/main/java/mantle/player/PlayerUtils.java similarity index 100% rename from src/mantle/player/PlayerUtils.java rename to src/main/java/mantle/player/PlayerUtils.java diff --git a/src/mantle/pulsar/config/ForgeCFG.java b/src/main/java/mantle/pulsar/config/ForgeCFG.java similarity index 100% rename from src/mantle/pulsar/config/ForgeCFG.java rename to src/main/java/mantle/pulsar/config/ForgeCFG.java diff --git a/src/mantle/pulsar/config/IConfiguration.java b/src/main/java/mantle/pulsar/config/IConfiguration.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/config/IConfiguration.java rename to src/main/java/mantle/pulsar/config/IConfiguration.java diff --git a/src/mantle/pulsar/control/PulseManager.java b/src/main/java/mantle/pulsar/control/PulseManager.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/control/PulseManager.java rename to src/main/java/mantle/pulsar/control/PulseManager.java diff --git a/src/mantle/pulsar/debug/EventSpy.java b/src/main/java/mantle/pulsar/debug/EventSpy.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/debug/EventSpy.java rename to src/main/java/mantle/pulsar/debug/EventSpy.java diff --git a/src/mantle/pulsar/internal/Configuration.java b/src/main/java/mantle/pulsar/internal/Configuration.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/internal/Configuration.java rename to src/main/java/mantle/pulsar/internal/Configuration.java diff --git a/src/mantle/pulsar/internal/CrashHandler.java b/src/main/java/mantle/pulsar/internal/CrashHandler.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/internal/CrashHandler.java rename to src/main/java/mantle/pulsar/internal/CrashHandler.java diff --git a/src/mantle/pulsar/internal/logging/ILogger.java b/src/main/java/mantle/pulsar/internal/logging/ILogger.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/internal/logging/ILogger.java rename to src/main/java/mantle/pulsar/internal/logging/ILogger.java diff --git a/src/mantle/pulsar/internal/logging/JULLogger.java b/src/main/java/mantle/pulsar/internal/logging/JULLogger.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/internal/logging/JULLogger.java rename to src/main/java/mantle/pulsar/internal/logging/JULLogger.java diff --git a/src/mantle/pulsar/internal/logging/Log4jLogger.java b/src/main/java/mantle/pulsar/internal/logging/Log4jLogger.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/internal/logging/Log4jLogger.java rename to src/main/java/mantle/pulsar/internal/logging/Log4jLogger.java diff --git a/src/mantle/pulsar/internal/logging/LogManager.java b/src/main/java/mantle/pulsar/internal/logging/LogManager.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/internal/logging/LogManager.java rename to src/main/java/mantle/pulsar/internal/logging/LogManager.java diff --git a/src/mantle/pulsar/package-info.java b/src/main/java/mantle/pulsar/package-info.java similarity index 100% rename from src/mantle/pulsar/package-info.java rename to src/main/java/mantle/pulsar/package-info.java diff --git a/src/mantle/pulsar/pulse/Pulse.java b/src/main/java/mantle/pulsar/pulse/Pulse.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/pulse/Pulse.java rename to src/main/java/mantle/pulsar/pulse/Pulse.java diff --git a/src/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/mantle/pulsar/pulse/PulseMeta.java old mode 100755 new mode 100644 similarity index 100% rename from src/mantle/pulsar/pulse/PulseMeta.java rename to src/main/java/mantle/pulsar/pulse/PulseMeta.java diff --git a/src/mantle/utils/ItemMetaWrapper.java b/src/main/java/mantle/utils/ItemMetaWrapper.java similarity index 100% rename from src/mantle/utils/ItemMetaWrapper.java rename to src/main/java/mantle/utils/ItemMetaWrapper.java diff --git a/src/mantle/utils/ItemStackNBTWrapper.java b/src/main/java/mantle/utils/ItemStackNBTWrapper.java similarity index 100% rename from src/mantle/utils/ItemStackNBTWrapper.java rename to src/main/java/mantle/utils/ItemStackNBTWrapper.java diff --git a/src/mantle/utils/ItemStackWrapper.java b/src/main/java/mantle/utils/ItemStackWrapper.java similarity index 100% rename from src/mantle/utils/ItemStackWrapper.java rename to src/main/java/mantle/utils/ItemStackWrapper.java diff --git a/src/mantle/utils/RecipeRemover.java b/src/main/java/mantle/utils/RecipeRemover.java similarity index 100% rename from src/mantle/utils/RecipeRemover.java rename to src/main/java/mantle/utils/RecipeRemover.java diff --git a/src/mantle/world/ChunkCoord.java b/src/main/java/mantle/world/ChunkCoord.java similarity index 100% rename from src/mantle/world/ChunkCoord.java rename to src/main/java/mantle/world/ChunkCoord.java diff --git a/src/mantle/world/CoordTuplePair.java b/src/main/java/mantle/world/CoordTuplePair.java similarity index 100% rename from src/mantle/world/CoordTuplePair.java rename to src/main/java/mantle/world/CoordTuplePair.java diff --git a/src/mantle/world/DimensionCoordPair.java b/src/main/java/mantle/world/DimensionCoordPair.java similarity index 100% rename from src/mantle/world/DimensionCoordPair.java rename to src/main/java/mantle/world/DimensionCoordPair.java diff --git a/src/mantle/world/DimensionCoordTuple.java b/src/main/java/mantle/world/DimensionCoordTuple.java similarity index 100% rename from src/mantle/world/DimensionCoordTuple.java rename to src/main/java/mantle/world/DimensionCoordTuple.java diff --git a/src/mantle/world/DirectionUtils.java b/src/main/java/mantle/world/DirectionUtils.java similarity index 100% rename from src/mantle/world/DirectionUtils.java rename to src/main/java/mantle/world/DirectionUtils.java diff --git a/resources/Mantle.png b/src/main/resources/Mantle.png similarity index 100% rename from resources/Mantle.png rename to src/main/resources/Mantle.png diff --git a/resources/assets/mantle/manuals/test.xml b/src/main/resources/assets/mantle/manuals/test.xml similarity index 100% rename from resources/assets/mantle/manuals/test.xml rename to src/main/resources/assets/mantle/manuals/test.xml diff --git a/resources/assets/mantle/models/item/mantleBook.json b/src/main/resources/assets/mantle/models/item/mantleBook.json similarity index 100% rename from resources/assets/mantle/models/item/mantleBook.json rename to src/main/resources/assets/mantle/models/item/mantleBook.json diff --git a/resources/assets/mantle/textures/gui/book.png b/src/main/resources/assets/mantle/textures/gui/book.png similarity index 100% rename from resources/assets/mantle/textures/gui/book.png rename to src/main/resources/assets/mantle/textures/gui/book.png diff --git a/resources/assets/mantle/textures/gui/bookcrafting.png b/src/main/resources/assets/mantle/textures/gui/bookcrafting.png similarity index 100% rename from resources/assets/mantle/textures/gui/bookcrafting.png rename to src/main/resources/assets/mantle/textures/gui/bookcrafting.png diff --git a/resources/assets/mantle/textures/gui/bookfurnace.png b/src/main/resources/assets/mantle/textures/gui/bookfurnace.png similarity index 100% rename from resources/assets/mantle/textures/gui/bookfurnace.png rename to src/main/resources/assets/mantle/textures/gui/bookfurnace.png diff --git a/resources/assets/mantle/textures/gui/bookleft.png b/src/main/resources/assets/mantle/textures/gui/bookleft.png similarity index 100% rename from resources/assets/mantle/textures/gui/bookleft.png rename to src/main/resources/assets/mantle/textures/gui/bookleft.png diff --git a/resources/assets/mantle/textures/gui/bookright.png b/src/main/resources/assets/mantle/textures/gui/bookright.png similarity index 100% rename from resources/assets/mantle/textures/gui/bookright.png rename to src/main/resources/assets/mantle/textures/gui/bookright.png diff --git a/resources/assets/mantle/textures/gui/missingno.png b/src/main/resources/assets/mantle/textures/gui/missingno.png similarity index 100% rename from resources/assets/mantle/textures/gui/missingno.png rename to src/main/resources/assets/mantle/textures/gui/missingno.png diff --git a/resources/assets/mantle/textures/gui/tinkerbook_blue.png b/src/main/resources/assets/mantle/textures/gui/tinkerbook_blue.png similarity index 100% rename from resources/assets/mantle/textures/gui/tinkerbook_blue.png rename to src/main/resources/assets/mantle/textures/gui/tinkerbook_blue.png diff --git a/resources/assets/mantle/textures/gui/tinkerbook_green.png b/src/main/resources/assets/mantle/textures/gui/tinkerbook_green.png similarity index 100% rename from resources/assets/mantle/textures/gui/tinkerbook_green.png rename to src/main/resources/assets/mantle/textures/gui/tinkerbook_green.png diff --git a/resources/assets/mantle/textures/items/mantlebook_blue.png b/src/main/resources/assets/mantle/textures/items/mantlebook_blue.png similarity index 100% rename from resources/assets/mantle/textures/items/mantlebook_blue.png rename to src/main/resources/assets/mantle/textures/items/mantlebook_blue.png diff --git a/resources/assets/mantle/textures/items/tinkerbook_blue.png b/src/main/resources/assets/mantle/textures/items/tinkerbook_blue.png similarity index 100% rename from resources/assets/mantle/textures/items/tinkerbook_blue.png rename to src/main/resources/assets/mantle/textures/items/tinkerbook_blue.png diff --git a/resources/assets/mantle/textures/items/tinkerbook_diary.png b/src/main/resources/assets/mantle/textures/items/tinkerbook_diary.png similarity index 100% rename from resources/assets/mantle/textures/items/tinkerbook_diary.png rename to src/main/resources/assets/mantle/textures/items/tinkerbook_diary.png diff --git a/resources/assets/mantle/textures/items/tinkerbook_green.png b/src/main/resources/assets/mantle/textures/items/tinkerbook_green.png similarity index 100% rename from resources/assets/mantle/textures/items/tinkerbook_green.png rename to src/main/resources/assets/mantle/textures/items/tinkerbook_green.png diff --git a/resources/assets/mantle/textures/items/tinkerbook_smeltery.png b/src/main/resources/assets/mantle/textures/items/tinkerbook_smeltery.png similarity index 100% rename from resources/assets/mantle/textures/items/tinkerbook_smeltery.png rename to src/main/resources/assets/mantle/textures/items/tinkerbook_smeltery.png diff --git a/resources/assets/mantle/textures/items/tinkerbook_toolstation.png b/src/main/resources/assets/mantle/textures/items/tinkerbook_toolstation.png similarity index 100% rename from resources/assets/mantle/textures/items/tinkerbook_toolstation.png rename to src/main/resources/assets/mantle/textures/items/tinkerbook_toolstation.png diff --git a/resources/mcmod.info b/src/main/resources/mcmod.info similarity index 100% rename from resources/mcmod.info rename to src/main/resources/mcmod.info From dd29c426549352362264bb3be7ddb7d0d880997c Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 18 Sep 2015 23:56:13 -0400 Subject: [PATCH 36/91] Update forge and gradle versions. --- .gitignore | 3 ++- build.properties | 4 ++-- gradle/wrapper/gradle-wrapper.jar | Bin 52266 -> 52271 bytes gradle/wrapper/gradle-wrapper.properties | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 9d8ba96..0cacaee 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ version.properties #eclipse stuffs /*.classpath /*.project -/.settings/ \ No newline at end of file +/.settings/ +/*.launch \ No newline at end of file diff --git a/build.properties b/build.properties index 74c1dfa..30fae23 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ mod_version=0.4 minecraft_version=1.8 -forge_version=11.14.3.1512 -mappings=snapshot_20150905 +forge_version=11.14.3.1514 +mappings=snapshot_20150918 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b5166dad4d90021f6a0b45268c0755719f1d5cd4..30d399d8d2bf522ff5de94bf434a7cc43a9a74b5 100644 GIT binary patch delta 1828 zcmZuxdrXs86u=}&0Yh0A9D^~V27JID zgX;{{3W{tH4OpPEg#wnASHbGkF|GkgT*h-m3h+qI01o6# zGT1JlKBj;;;P5*T`Md@o+P(Omj=;#~HL=X7yPO9M-}?)eIpOn;6EJ^?HqHklZn+!l zvpKZf1(-?YG;7?9OPm!_nH>U8NX;S`ZrNdq|u1;OMX@g2VC9|pJ`XssDpje?- zgryYh5zJG|74p#AGU@P@cvWyOlAwRUQ%7SO}*5%Gts05`m${Z zp+z_#O}y8*iz{}&JN>Tz8Qy*|Pt_S)bz)u465)xEA2^bU^^a$CJ4%e&lRs)7<{kef z$5wlM*#-B%gYIh;4<{dF@ib+N1i3j4pPNhlzSmtZs_@QeP|8G6N7tqDkHl+|qpRzO z>h6C~84_6(enWX=>NI+d+oyE)&p;hB2;+LgkwEuxj5?60^vzVJeAZmTY*{3q$D zN7qMZYKNZ~4-BR&f_;TYS0yGleT5RvEp)Nm@;FuYG+VzX_c<@Rz*tl;wksxmn8Sh#g5m-O4N+Iom$3_O;82Z+9m=RmX%WZhwnww;&*SFzb5J{Y;XMO-i{ zH4&^aTzH)a%&C$mtn+`q+bDf!F zY1KEL5T`xaoCSpq%`M}8Lg%%4Ss+|fUg zUbw(4WPS}?Wu`f6akKd?I8B*p>T)`6)h)qti>DuxXk(P~>rF&u+7Y4Eb0P>C_H|}} zW4T2Fv3d(lb!7oHWsw3!_t8|-PTadQ1kd!l0aZ*WWj1(q_DP}4#d+SXHj?2c$*|Hc zLnh|*M?+YAKTYk|Kv<7Ph|@>hpg8|xYiczQA*}$R0J~6AAxXO!Pxbpiyz2l>9V?kF z&JmB5EMPR?>LYT6OL1hQKh_U;Kt&aiVIO`*2J6a2XqBC89-bVCgRo_TG_~d+DCQ5Y z0O~ZM?j0tSKb{z5m0mmzghK3;YVd-gC}<+)>ic)AN&h<1h`mo`-E75fxPHh3oQnc} zPR?{7e{8M@Mc4`MuE#BAUwm&!4#oIcX-e8i+6sO#dqM@Dog0G5>JQyY9Ae#kNw?Xg zhCn+>G3E@1gWBq0n%dU_q1`R?(xikJ4~bb4j3Ttmz-EZVn|2cYZTMDO1Qrgm!xoIt yRE+_*8bashpHHYiJBYLt%fET;6=`_yMDlI&71>Fbb>iAiG4{IT?&xe}ZvF+r(~xTb delta 1820 zcmZvb3rv$&6vr>$*V4k;6;Kqcj+e?yp(3(JMMN?(XnDv>6p*Q7Wf?DP*i4iWQMa)v z2v;V{a7qzzD6jxylNKqDQeHDtr%MI|$qi#9Ksj z;(b511TwN^ng#CMExogFDVS}P;^E9(pejY8}J20i`JY5zuG+L&t)!ft-_YcM-cs;iR zp~T+(x?r%MSlgQ+WQVYXROnrKk)RrLC$9Jz+o8>3q-n@Y55oo!OO8{ek`) z+2DRd=5<3=YRQ9RvqdYSu1=0g9L@}jbyLBqPLirgnR@i0#aP*-^7a->$6HS}#9Q8f z_D|>!t9I~zclj;vc+IjuUJ4LPp9mJto2(W)C9Y$MHbf?V%5VW5*gX!wnEVVtL(krE z8hn?6&0tEQau7n0p6S3sP^gyE;K%G+d>|EvW@z&HoZA8*2an&NMES{OYB-aB$p)q> z%N|qm<+-~wIIL;n!PKTImO9I;AJHkVnk4E|P#Z{dZr1-qNo8XU&6#b&tOa+N;*FzK zZ{pJCfPh8U!zJi{u1A8&r7&Zbvh!~T+i8909}kYvzQJ8rT%`2|?a=yx&T6-S`s>0$ z3v`*B7Po}KFtQ~c^m5B?P|-CyR$WVgvEf=Ms7>p3(05xEppC6GPoj^8af&_`v_(&S z#clgwe4tHfG5}<4-zVb;qYM7L!xdWAT?z9kBHuYmzTZ{kkJ~UwI&^&%E5IxZdltzYkRw-W~q3rD+CtileVKNlq`%# z78Yz$wi$;TW5N1(W#e*{4MJTWi>)W}Ne|BWo)Ml6o-s<9k}_P_=Y|8i?O_24-BKq1 z++3&TxV+nru8ZI_4LKoud_lANg;T<3b+$Uvl_TkDok>?~aA1!dEOL9KjA!+{v!TZs z@C3oH)DXN9U)4w?i_RYh_DY$LYN1MBE5&8KbW<)9++L4I>g6x=vfef|Pe6Ln@(}Vd z>7@jF^##H%1~&<({aJ*1EfA8M Date: Sun, 27 Sep 2015 22:07:13 +0200 Subject: [PATCH 37/91] A new start. Clean out mantle and copy in stuff from tcon and whatever made sense from the old version --- .gitignore | 3 +- build.gradle | 14 + build.properties | 5 +- src/main/java/mantle/Mantle.java | 111 ------ src/main/java/mantle/blocks/BlockUtils.java | 31 -- src/main/java/mantle/blocks/MantleBlock.java | 45 --- .../abstracts/AdaptiveInventoryLogic.java | 102 ----- .../abstracts/ExpandableInventoryLogic.java | 242 ------------ .../blocks/abstracts/InventoryBlock.java | 201 ---------- .../blocks/abstracts/InventoryLogic.java | 294 --------------- .../blocks/abstracts/InventorySlab.java | 100 ----- .../blocks/abstracts/MultiItemBlock.java | 82 ---- .../mantle/blocks/iface/IActiveLogic.java | 13 - src/main/java/mantle/blocks/iface/ICrop.java | 33 -- .../mantle/blocks/iface/IFacingLogic.java | 20 - .../blocks/util/IBlockWithVariants.java | 8 - .../mantle/blocks/util/ItemBlockVariants.java | 33 -- .../blocks/util/blockstates/BlockVariant.java | 36 -- .../util/blockstates/PropertyVariant.java | 65 ---- src/main/java/mantle/books/BookData.java | 41 -- src/main/java/mantle/books/BookDataStore.java | 57 --- src/main/java/mantle/books/ManualReader.java | 51 --- .../java/mantle/books/client/BookImage.java | 21 -- .../java/mantle/books/external/BookIS.java | 22 -- .../java/mantle/books/external/BookLoad.java | 29 -- .../java/mantle/books/external/ZipLoader.java | 256 ------------- src/main/java/mantle/client/MProxyClient.java | 101 ----- src/main/java/mantle/client/ModelHelper.java | 34 -- src/main/java/mantle/client/ModelVariant.java | 89 ----- .../java/mantle/client/gui/GuiManual.java | 238 ------------ .../mantle/client/gui/TurnPageButton.java | 56 --- .../java/mantle/client/pages/BlankPage.java | 18 - .../java/mantle/client/pages/BookPage.java | 26 -- .../client/pages/ContentsTablePage.java | 74 ---- .../mantle/client/pages/CraftingPage.java | 140 ------- .../java/mantle/client/pages/FurnacePage.java | 75 ---- .../java/mantle/client/pages/PicturePage.java | 70 ---- .../java/mantle/client/pages/SectionPage.java | 41 -- .../java/mantle/client/pages/SidebarPage.java | 71 ---- .../java/mantle/client/pages/TextPage.java | 31 -- .../java/mantle/client/pages/TitlePage.java | 31 -- .../java/mantle/common/ComparisonHelper.java | 29 -- src/main/java/mantle/common/IDDumps.java | 47 --- src/main/java/mantle/common/MProxyCommon.java | 34 -- .../mantle/common/network/AbstractPacket.java | 57 --- .../mantle/common/network/PacketUpdateTE.java | 76 ---- .../java/mantle/crash/CallableSuppConfig.java | 32 -- .../mantle/crash/CallableUnsuppConfig.java | 41 -- src/main/java/mantle/debug/DebugData.java | 28 -- src/main/java/mantle/debug/DebugHelper.java | 54 --- src/main/java/mantle/debug/IDebuggable.java | 17 - .../java/mantle/event/ManualOpenEvent.java | 35 -- src/main/java/mantle/event/Migration.java | 104 ----- src/main/java/mantle/items/ItemUtils.java | 17 - src/main/java/mantle/items/Manual.java | 77 ---- .../mantle/items/abstracts/CraftingItem.java | 63 ---- .../java/mantle/items/iface/IDebugItem.java | 6 - src/main/java/mantle/lib/CoreConfig.java | 109 ------ src/main/java/mantle/lib/CoreRepo.java | 24 -- src/main/java/mantle/lib/TabTools.java | 32 -- .../lib/client/MantleClientRegistry.java | 71 ---- .../lib/environment/EnvironmentChecks.java | 84 ----- src/main/java/mantle/math/Dozenal.java | 87 ----- src/main/java/mantle/player/PlayerUtils.java | 25 -- .../java/mantle/pulsar/config/ForgeCFG.java | 58 --- .../mantle/pulsar/config/IConfiguration.java | 31 -- .../mantle/pulsar/control/PulseManager.java | 294 --------------- .../java/mantle/pulsar/debug/EventSpy.java | 28 -- .../mantle/pulsar/internal/Configuration.java | 253 ------------- .../mantle/pulsar/internal/CrashHandler.java | 62 --- .../pulsar/internal/logging/ILogger.java | 24 -- .../pulsar/internal/logging/JULLogger.java | 56 --- .../pulsar/internal/logging/Log4jLogger.java | 56 --- .../pulsar/internal/logging/LogManager.java | 53 --- src/main/java/mantle/pulsar/package-info.java | 36 -- src/main/java/mantle/pulsar/pulse/Pulse.java | 53 --- .../java/mantle/pulsar/pulse/PulseMeta.java | 53 --- .../java/mantle/utils/ItemMetaWrapper.java | 53 --- .../mantle/utils/ItemStackNBTWrapper.java | 40 -- .../java/mantle/utils/ItemStackWrapper.java | 51 --- src/main/java/mantle/world/ChunkCoord.java | 95 ----- .../java/mantle/world/CoordTuplePair.java | 27 -- .../java/mantle/world/DimensionCoordPair.java | 63 ---- .../mantle/world/DimensionCoordTuple.java | 65 ---- .../java/mantle/world/DirectionUtils.java | 29 -- src/main/java/slimeknights/mantle/Mantle.java | 34 ++ .../mantle/block/BlockInventory.java | 91 +++++ .../mantle/block}/IMasterLogic.java | 2 +- .../mantle/block}/IMasterNode.java | 2 +- .../mantle/block}/IServantLogic.java | 2 +- .../mantle/block}/MultiServantLogic.java | 38 +- .../mantle/client/ClientProxy.java | 6 + .../mantle/client/CreativeTab.java | 43 +++ .../mantle/client/ModelHelper.java | 170 +++++++++ .../mantle/client/gui/GuiElement.java | 78 ++++ .../mantle/client/gui/GuiElementScalable.java | 69 ++++ .../mantle/client/gui/GuiModule.java | 118 ++++++ .../mantle/client/gui/GuiMultiModule.java | 356 ++++++++++++++++++ .../mantle/client/gui/GuiWidget.java | 26 ++ .../mantle/client/gui/GuiWidgetSlider.java | 232 ++++++++++++ .../mantle/client/gui/GuiWidgetTabs.java | 171 +++++++++ .../client/model/BlockItemModelWrapper.java | 87 +++++ .../mantle/client/model/TRSRBakedModel.java | 139 +++++++ .../mantle/common/CommonProxy.java | 4 + .../mantle/common/GuiHandler.java | 31 ++ .../mantle/common/IInventoryGui.java | 20 + .../mantle/inventory/BaseContainer.java | 297 +++++++++++++++ .../inventory/ContainerMultiModule.java | 284 ++++++++++++++ .../inventory/ContainerSimpleChest.java | 36 ++ .../inventory/IContainerCraftingCustom.java | 10 + .../mantle/inventory/SlotCraftingCustom.java | 34 ++ .../mantle/inventory/SlotOut.java | 18 + .../mantle/inventory/SlotRestrictedItem.java | 21 ++ .../mantle/inventory/SlotWrapper.java | 41 ++ .../mantle/item/ItemBlockMeta.java | 11 + .../slimeknights/mantle/item/ItemMeta.java | 36 ++ .../mantle/item/ItemMetaDynamic.java | 62 +++ .../mantle/network/AbstractPacket.java | 47 +++ .../network/AbstractPacketThreadsafe.java | 41 ++ .../mantle/network/NetworkWrapper.java | 55 +++ .../mantle/property/PropertyString.java | 32 ++ .../mantle/tileentity/TileInventory.java | 242 ++++++++++++ .../slimeknights/mantle/util/RecipeMatch.java | 205 ++++++++++ .../mantle/util/RecipeMatchRegistry.java | 133 +++++++ .../mantle/util}/RecipeRemover.java | 2 +- .../mantle/util/SlimeknightException.java | 27 ++ .../slimeknights/mantle/util/TagHelper.java | 40 ++ src/main/resources/META-INF/Mantle_at.cfg | 11 + 128 files changed, 3389 insertions(+), 5654 deletions(-) delete mode 100644 src/main/java/mantle/Mantle.java delete mode 100644 src/main/java/mantle/blocks/BlockUtils.java delete mode 100644 src/main/java/mantle/blocks/MantleBlock.java delete mode 100644 src/main/java/mantle/blocks/abstracts/AdaptiveInventoryLogic.java delete mode 100644 src/main/java/mantle/blocks/abstracts/ExpandableInventoryLogic.java delete mode 100644 src/main/java/mantle/blocks/abstracts/InventoryBlock.java delete mode 100644 src/main/java/mantle/blocks/abstracts/InventoryLogic.java delete mode 100644 src/main/java/mantle/blocks/abstracts/InventorySlab.java delete mode 100644 src/main/java/mantle/blocks/abstracts/MultiItemBlock.java delete mode 100644 src/main/java/mantle/blocks/iface/IActiveLogic.java delete mode 100644 src/main/java/mantle/blocks/iface/ICrop.java delete mode 100644 src/main/java/mantle/blocks/iface/IFacingLogic.java delete mode 100644 src/main/java/mantle/blocks/util/IBlockWithVariants.java delete mode 100644 src/main/java/mantle/blocks/util/ItemBlockVariants.java delete mode 100644 src/main/java/mantle/blocks/util/blockstates/BlockVariant.java delete mode 100644 src/main/java/mantle/blocks/util/blockstates/PropertyVariant.java delete mode 100644 src/main/java/mantle/books/BookData.java delete mode 100644 src/main/java/mantle/books/BookDataStore.java delete mode 100644 src/main/java/mantle/books/ManualReader.java delete mode 100644 src/main/java/mantle/books/client/BookImage.java delete mode 100644 src/main/java/mantle/books/external/BookIS.java delete mode 100644 src/main/java/mantle/books/external/BookLoad.java delete mode 100644 src/main/java/mantle/books/external/ZipLoader.java delete mode 100644 src/main/java/mantle/client/MProxyClient.java delete mode 100644 src/main/java/mantle/client/ModelHelper.java delete mode 100644 src/main/java/mantle/client/ModelVariant.java delete mode 100644 src/main/java/mantle/client/gui/GuiManual.java delete mode 100644 src/main/java/mantle/client/gui/TurnPageButton.java delete mode 100644 src/main/java/mantle/client/pages/BlankPage.java delete mode 100644 src/main/java/mantle/client/pages/BookPage.java delete mode 100644 src/main/java/mantle/client/pages/ContentsTablePage.java delete mode 100644 src/main/java/mantle/client/pages/CraftingPage.java delete mode 100644 src/main/java/mantle/client/pages/FurnacePage.java delete mode 100644 src/main/java/mantle/client/pages/PicturePage.java delete mode 100644 src/main/java/mantle/client/pages/SectionPage.java delete mode 100644 src/main/java/mantle/client/pages/SidebarPage.java delete mode 100644 src/main/java/mantle/client/pages/TextPage.java delete mode 100644 src/main/java/mantle/client/pages/TitlePage.java delete mode 100644 src/main/java/mantle/common/ComparisonHelper.java delete mode 100644 src/main/java/mantle/common/IDDumps.java delete mode 100644 src/main/java/mantle/common/MProxyCommon.java delete mode 100644 src/main/java/mantle/common/network/AbstractPacket.java delete mode 100644 src/main/java/mantle/common/network/PacketUpdateTE.java delete mode 100644 src/main/java/mantle/crash/CallableSuppConfig.java delete mode 100644 src/main/java/mantle/crash/CallableUnsuppConfig.java delete mode 100644 src/main/java/mantle/debug/DebugData.java delete mode 100644 src/main/java/mantle/debug/DebugHelper.java delete mode 100644 src/main/java/mantle/debug/IDebuggable.java delete mode 100644 src/main/java/mantle/event/ManualOpenEvent.java delete mode 100644 src/main/java/mantle/event/Migration.java delete mode 100644 src/main/java/mantle/items/ItemUtils.java delete mode 100644 src/main/java/mantle/items/Manual.java delete mode 100644 src/main/java/mantle/items/abstracts/CraftingItem.java delete mode 100644 src/main/java/mantle/items/iface/IDebugItem.java delete mode 100644 src/main/java/mantle/lib/CoreConfig.java delete mode 100644 src/main/java/mantle/lib/CoreRepo.java delete mode 100644 src/main/java/mantle/lib/TabTools.java delete mode 100644 src/main/java/mantle/lib/client/MantleClientRegistry.java delete mode 100644 src/main/java/mantle/lib/environment/EnvironmentChecks.java delete mode 100644 src/main/java/mantle/math/Dozenal.java delete mode 100644 src/main/java/mantle/player/PlayerUtils.java delete mode 100644 src/main/java/mantle/pulsar/config/ForgeCFG.java delete mode 100644 src/main/java/mantle/pulsar/config/IConfiguration.java delete mode 100644 src/main/java/mantle/pulsar/control/PulseManager.java delete mode 100644 src/main/java/mantle/pulsar/debug/EventSpy.java delete mode 100644 src/main/java/mantle/pulsar/internal/Configuration.java delete mode 100644 src/main/java/mantle/pulsar/internal/CrashHandler.java delete mode 100644 src/main/java/mantle/pulsar/internal/logging/ILogger.java delete mode 100644 src/main/java/mantle/pulsar/internal/logging/JULLogger.java delete mode 100644 src/main/java/mantle/pulsar/internal/logging/Log4jLogger.java delete mode 100644 src/main/java/mantle/pulsar/internal/logging/LogManager.java delete mode 100644 src/main/java/mantle/pulsar/package-info.java delete mode 100644 src/main/java/mantle/pulsar/pulse/Pulse.java delete mode 100644 src/main/java/mantle/pulsar/pulse/PulseMeta.java delete mode 100644 src/main/java/mantle/utils/ItemMetaWrapper.java delete mode 100644 src/main/java/mantle/utils/ItemStackNBTWrapper.java delete mode 100644 src/main/java/mantle/utils/ItemStackWrapper.java delete mode 100644 src/main/java/mantle/world/ChunkCoord.java delete mode 100644 src/main/java/mantle/world/CoordTuplePair.java delete mode 100644 src/main/java/mantle/world/DimensionCoordPair.java delete mode 100644 src/main/java/mantle/world/DimensionCoordTuple.java delete mode 100644 src/main/java/mantle/world/DirectionUtils.java create mode 100644 src/main/java/slimeknights/mantle/Mantle.java create mode 100644 src/main/java/slimeknights/mantle/block/BlockInventory.java rename src/main/java/{mantle/blocks/iface => slimeknights/mantle/block}/IMasterLogic.java (87%) rename src/main/java/{mantle/blocks/iface => slimeknights/mantle/block}/IMasterNode.java (83%) rename src/main/java/{mantle/blocks/iface => slimeknights/mantle/block}/IServantLogic.java (96%) rename src/main/java/{mantle/blocks/abstracts => slimeknights/mantle/block}/MultiServantLogic.java (79%) create mode 100644 src/main/java/slimeknights/mantle/client/ClientProxy.java create mode 100644 src/main/java/slimeknights/mantle/client/CreativeTab.java create mode 100644 src/main/java/slimeknights/mantle/client/ModelHelper.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiElement.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiModule.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiWidget.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java create mode 100644 src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java create mode 100644 src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java create mode 100644 src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java create mode 100644 src/main/java/slimeknights/mantle/common/CommonProxy.java create mode 100644 src/main/java/slimeknights/mantle/common/GuiHandler.java create mode 100644 src/main/java/slimeknights/mantle/common/IInventoryGui.java create mode 100644 src/main/java/slimeknights/mantle/inventory/BaseContainer.java create mode 100644 src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java create mode 100644 src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java create mode 100644 src/main/java/slimeknights/mantle/inventory/IContainerCraftingCustom.java create mode 100644 src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java create mode 100644 src/main/java/slimeknights/mantle/inventory/SlotOut.java create mode 100644 src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java create mode 100644 src/main/java/slimeknights/mantle/inventory/SlotWrapper.java create mode 100644 src/main/java/slimeknights/mantle/item/ItemBlockMeta.java create mode 100644 src/main/java/slimeknights/mantle/item/ItemMeta.java create mode 100644 src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java create mode 100644 src/main/java/slimeknights/mantle/network/AbstractPacket.java create mode 100644 src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java create mode 100644 src/main/java/slimeknights/mantle/network/NetworkWrapper.java create mode 100644 src/main/java/slimeknights/mantle/property/PropertyString.java create mode 100644 src/main/java/slimeknights/mantle/tileentity/TileInventory.java create mode 100644 src/main/java/slimeknights/mantle/util/RecipeMatch.java create mode 100644 src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java rename src/main/java/{mantle/utils => slimeknights/mantle/util}/RecipeRemover.java (99%) create mode 100644 src/main/java/slimeknights/mantle/util/SlimeknightException.java create mode 100644 src/main/java/slimeknights/mantle/util/TagHelper.java create mode 100644 src/main/resources/META-INF/Mantle_at.cfg diff --git a/.gitignore b/.gitignore index 0cacaee..248f529 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ version.properties /*.classpath /*.project /.settings/ -/*.launch \ No newline at end of file +/*.launch +/out \ No newline at end of file diff --git a/build.gradle b/build.gradle index be35c95..162ddf1 100644 --- a/build.gradle +++ b/build.gradle @@ -32,6 +32,14 @@ repositories { name 'ForgeFS' url 'http://files.minecraftforge.net/maven' } + maven { + name 'CB Maven FS' + url "http://chickenbones.net/maven/" + } + maven { + name 'forge' + url 'http://files.minecraftforge.net/maven' + } } group = 'mantle' @@ -82,6 +90,12 @@ minecraft { replace '${version}', project.version } +dependencies { + compile "codechicken:CodeChickenLib:${config.minecraft_version}-${config.CCLIB_version}:dev" + compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.ccc_version}:dev" + compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.NEI_version}:dev" +} + processResources { inputs.property "version", artifact_version diff --git a/build.properties b/build.properties index 30fae23..330a922 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,8 @@ -mod_version=0.4 +mod_version=0.5 minecraft_version=1.8 forge_version=11.14.3.1514 mappings=snapshot_20150918 +CCLIB_version=1.1.2.133 +ccc_version=1.0.5.36 +NEI_version=1.0.5.104 \ No newline at end of file diff --git a/src/main/java/mantle/Mantle.java b/src/main/java/mantle/Mantle.java deleted file mode 100644 index 34ab38f..0000000 --- a/src/main/java/mantle/Mantle.java +++ /dev/null @@ -1,111 +0,0 @@ -package mantle; - -import static mantle.lib.CoreRepo.logger; -import static mantle.lib.CoreRepo.modId; -import static mantle.lib.CoreRepo.modName; -import static mantle.lib.CoreRepo.modVersion; -import mantle.books.BookData; -import mantle.books.BookDataStore; -import mantle.common.IDDumps; -import mantle.common.MProxyCommon; -import mantle.items.Manual; -import mantle.lib.CoreConfig; -import mantle.lib.CoreRepo; -import mantle.lib.environment.EnvironmentChecks; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.Mod.Instance; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.registry.GameRegistry; - -/** - * Mantle - * - * Central mod object for Mantle - * - * @author Sunstrike - */ -@Mod(modid = modId, name = modName, version = modVersion, dependencies = "required-after:Forge@[10.13,)") -public class Mantle -{ - /* Instance of this mod, used for grabbing prototype fields */ - @Instance("mantle") - public static Mantle instance; - - /* Proxies for sides, used for graphics processing */ - @SidedProxy(clientSide = "mantle.client.MProxyClient", serverSide = "mantle.common.MProxyCommon") - public static MProxyCommon proxy; - - public static Manual mantleBook; - - /** - * Constructor - * - * EnvChecks invoked here so they run as soon as possible to enhance crash reports that may happen in preinit. - */ - public Mantle() - { - EnvironmentChecks.verifyEnvironmentSanity(); - } - - /** - * FML preinitialisation handler - * - * This is where we load our configs and related data, preparing for main load. - * - * @param evt The FMLPreInitializationEvent from FML - */ - @EventHandler - public void preInit(FMLPreInitializationEvent evt) - { - logger.info("Mantle (" + modVersion + ") -- Preparing for launch."); - logger.info("Entering preinitialization phase."); - CoreConfig.loadConfiguration(evt.getModConfigurationDirectory()); - - NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); - mantleBook = (Manual) new Manual().setUnlocalizedName("mantle.manual"); - GameRegistry.registerItem(mantleBook, "mantleBook"); - - } - - /** - * FML initialisation handler - * - * This is where we handle basic loading and populating any missing data in the Repo - * - * @param evt The FMLInitializationEvent from FML - */ - @EventHandler - public void Init(FMLInitializationEvent evt) - { - logger.info("Entering initialization phase."); - proxy.registerRenderer(); - } - - /** - * FML postinitialisation handler - * - * Final chance for cleanup before main game launch - * - * @param evt The FMLPostInitializationEvent from FML - */ - @EventHandler - public void postInit(FMLPostInitializationEvent evt) - { - logger.info("Entering postinitialization phase."); - proxy.readManuals(); - BookData data = new BookData(); - data.unlocalizedName = "item.mantle.manual.test"; - data.toolTip = "Test Book"; - data.modID = CoreRepo.modId; - BookDataStore.addBook(data); - mantleBook.updateManual(); - CoreConfig.loadBookLocations(); - IDDumps.dump(); - } - -} diff --git a/src/main/java/mantle/blocks/BlockUtils.java b/src/main/java/mantle/blocks/BlockUtils.java deleted file mode 100644 index b6c0523..0000000 --- a/src/main/java/mantle/blocks/BlockUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -package mantle.blocks; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.registry.GameData; - -public class BlockUtils -{ - public static Block getBlockFromItem(Item item) - { - return Block.getBlockFromItem(item); - } - - @SuppressWarnings("unused") - public static Block getBlockFromItemStack(ItemStack itemStack) - { - return getBlockFromItem(itemStack.getItem()); - } - - public static String getUniqueName(Block block) - { - return GameData.getBlockRegistry().getNameForObject(block).toString(); - } - - public static Block getBlockFromUniqueName(String uniqueName) - { - return GameData.getBlockRegistry().getObject(uniqueName); - } - -} diff --git a/src/main/java/mantle/blocks/MantleBlock.java b/src/main/java/mantle/blocks/MantleBlock.java deleted file mode 100644 index 552909e..0000000 --- a/src/main/java/mantle/blocks/MantleBlock.java +++ /dev/null @@ -1,45 +0,0 @@ -package mantle.blocks; - -import mantle.debug.DebugHelper; -import mantle.debug.IDebuggable; -import mantle.items.iface.IDebugItem; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.relauncher.Side; - -/** - * Root class for inheriting the Minecraft Block. - * - * @author Sunstrike - */ -public abstract class MantleBlock extends Block -{ - - public MantleBlock(Material material) - { - super(material); - } - - // IDebuggable support - Uses a stick for debug purposes. - @Override - public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) - { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null - && (player.getHeldItem().getItem() == Items.stick || player.getHeldItem().getItem() instanceof IDebugItem)) - { - TileEntity te = world.getTileEntity(pos); - if (te instanceof IDebuggable) - { - DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player)); - } - } - super.onBlockClicked(world, pos, player); - } - -} diff --git a/src/main/java/mantle/blocks/abstracts/AdaptiveInventoryLogic.java b/src/main/java/mantle/blocks/abstracts/AdaptiveInventoryLogic.java deleted file mode 100644 index 3f91f76..0000000 --- a/src/main/java/mantle/blocks/abstracts/AdaptiveInventoryLogic.java +++ /dev/null @@ -1,102 +0,0 @@ -package mantle.blocks.abstracts; - -import java.util.Random; - -import mantle.blocks.iface.IFacingLogic; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public abstract class AdaptiveInventoryLogic extends InventoryLogic implements IFacingLogic -{ - Random random = new Random(); - - protected int inventorySize; - - public AdaptiveInventoryLogic() - { - super(0); - } - - protected void adjustInventory(int size, boolean forceAdjust) - { - if (size != this.inventorySize || forceAdjust) - { - this.inventorySize = size; - - ItemStack[] tempInv = this.inventory; - this.inventory = new ItemStack[size]; - int invLength = tempInv.length > this.inventory.length ? this.inventory.length : tempInv.length; - System.arraycopy(tempInv, 0, this.inventory, 0, invLength); - - if (tempInv.length > this.inventory.length) - { - for (int i = this.inventory.length; i < tempInv.length; i++) - { - ItemStack stack = tempInv[i]; - if (stack != null) - { - float jumpX = this.random.nextFloat() * 0.8F + 0.1F; - float jumpY = this.random.nextFloat() * 0.8F + 0.1F; - float jumpZ = this.random.nextFloat() * 0.8F + 0.1F; - - int offsetX = 0; - int offsetY = 0; - int offsetZ = 0; - switch (this.getTossDirection()) - { - case 0: // -y - offsetY--; - break; - case 1: // +y - offsetY++; - break; - case 2: // +z - offsetZ--; - break; - case 3: // -z - offsetZ++; - break; - case 4: // +x - offsetX--; - break; - case 5: // -x - offsetX++; - break; - } - - while (stack.stackSize > 0) - { - int itemSize = this.random.nextInt(21) + 10; - - if (itemSize > stack.stackSize) - { - itemSize = stack.stackSize; - } - - stack.stackSize -= itemSize; - EntityItem entityitem = new EntityItem(this.worldObj, (double) ((float) this.pos.getX() + jumpX + offsetX), (double) ((float) this.pos.getY() + jumpY), - (double) ((float) this.pos.getZ() + jumpZ + offsetZ), new ItemStack(stack.getItem(), itemSize, stack.getItemDamage())); - - if (stack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); - } - - float offset = 0.05F; - entityitem.motionX = (double) ((float) this.random.nextGaussian() * offset); - entityitem.motionY = (double) ((float) this.random.nextGaussian() * offset + 0.2F); - entityitem.motionZ = (double) ((float) this.random.nextGaussian() * offset); - this.worldObj.spawnEntityInWorld(entityitem); - } - } - } - } - } - } - - public int getTossDirection() - { - return this.getRenderDirection(); - } -} diff --git a/src/main/java/mantle/blocks/abstracts/ExpandableInventoryLogic.java b/src/main/java/mantle/blocks/abstracts/ExpandableInventoryLogic.java deleted file mode 100644 index 33e46db..0000000 --- a/src/main/java/mantle/blocks/abstracts/ExpandableInventoryLogic.java +++ /dev/null @@ -1,242 +0,0 @@ -package mantle.blocks.abstracts; - -import java.util.ArrayList; -import java.util.Iterator; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.world.World; - -import com.google.common.collect.Lists; - -public abstract class ExpandableInventoryLogic extends InventoryLogic implements IInventory -{ - - public ExpandableInventoryLogic() - { - super(0); - } - - protected ArrayList inventory = Lists.newArrayList(); - - protected String invName; - - @Override - public ItemStack getStackInSlot(int slot) - { - return slot < this.inventory.size() ? this.inventory.get(slot) : null; - } - - @Override - public boolean isStackInSlot(int slot) - { - return slot < this.inventory.size() && this.inventory.get(slot) != null; - } - - @Override - public int getSizeInventory() - { - return this.inventory.size(); - } - - public int getMaxSize() - { - return 64; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public boolean canDropInventorySlot(int slot) - { - return true; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) - { - if (slot < this.inventory.size()) - { - this.inventory.set(slot, itemstack); - } - else if (slot == this.inventory.size()) - { - this.inventory.add(itemstack); - } - else if (slot < this.getMaxSize()) - { - this.inventory.ensureCapacity(slot); - this.inventory.set(slot, itemstack); - } - else - { - return; - } - if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) - { - itemstack.stackSize = this.getInventoryStackLimit(); - } - } - - @Override - public ItemStack decrStackSize(int slot, int quantity) - { - if (slot < this.inventory.size() && this.inventory.get(slot) != null) - { - if (this.inventory.get(slot).stackSize <= quantity) - { - ItemStack stack = this.inventory.get(slot); - this.inventory.set(slot, null); - return stack; - } - ItemStack split = this.inventory.get(slot).splitStack(quantity); - if (this.inventory.get(slot).stackSize == 0) - { - this.inventory.set(slot, null); - } - return split; - } - else - { - return null; - } - } - - /* Supporting methods */ - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - if (this.worldObj.getTileEntity(this.pos) != this) - { - return false; - } - else - { - return entityplayer.getDistance((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64D; - } - - } - - @Override - public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z); - - /* NBT */ - @Override - public void readFromNBT(NBTTagCompound tags) - { - super.readFromNBT(tags); - this.invName = tags.getString("InvName"); - NBTTagList nbttaglist = tags.getTagList("Items", 9); - this.inventory = new ArrayList(); - this.inventory.ensureCapacity(nbttaglist.tagCount() > this.getMaxSize() ? this.getMaxSize() : nbttaglist.tagCount()); - for (int iter = 0; iter < nbttaglist.tagCount(); iter++) - { - NBTTagCompound tagList = nbttaglist.getCompoundTagAt(iter); - byte slotID = tagList.getByte("Slot"); - if (slotID >= 0 && slotID < this.inventory.size()) - { - this.inventory.set(slotID, ItemStack.loadItemStackFromNBT(tagList)); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound tags) - { - super.writeToNBT(tags); - if (this.invName != null) - { - tags.setString("InvName", this.invName); - } - NBTTagList nbttaglist = new NBTTagList(); - for (int iter = 0; iter < this.inventory.size(); iter++) - { - if (this.inventory.get(iter) != null) - { - NBTTagCompound tagList = new NBTTagCompound(); - tagList.setByte("Slot", (byte) iter); - this.inventory.get(iter).writeToNBT(tagList); - nbttaglist.appendTag(tagList); - } - } - - tags.setTag("Items", nbttaglist); - } - - /* Default implementations of hardly used methods */ - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - return null; - } - - @Override - public void openChest() - { - } - - @Override - public void closeChest() - { - } - - @Override - protected abstract String getDefaultName(); - - @Override - public void setInvName(String name) - { - this.invName = name; - } - - @Override - public String getInvName() - { - return this.isInvNameLocalized() ? this.invName : this.getDefaultName(); - } - - @Override - public boolean isInvNameLocalized() - { - return this.invName != null && this.invName.length() > 0; - } - - public void cleanInventory() - { - Iterator i1 = this.inventory.iterator(); - while (i1.hasNext()) - { - if (i1.next() == null) - { - i1.remove(); - } - } - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) - { - if (slot < this.getSizeInventory()) - { - if (this.inventory.get(slot) == null || itemstack.stackSize + this.inventory.get(slot).stackSize <= this.getInventoryStackLimit()) - { - return true; - } - } - else - { - return slot < this.getMaxSize(); - } - return false; - } - -} diff --git a/src/main/java/mantle/blocks/abstracts/InventoryBlock.java b/src/main/java/mantle/blocks/abstracts/InventoryBlock.java deleted file mode 100644 index 140f2f8..0000000 --- a/src/main/java/mantle/blocks/abstracts/InventoryBlock.java +++ /dev/null @@ -1,201 +0,0 @@ -package mantle.blocks.abstracts; - -import java.util.Random; - -import mantle.blocks.iface.IActiveLogic; -import mantle.blocks.iface.IFacingLogic; -import mantle.debug.DebugHelper; -import mantle.debug.IDebuggable; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.relauncher.Side; - -public abstract class InventoryBlock extends BlockContainer -{ - protected Random rand = new Random(); - - protected InventoryBlock(Material material) - { - super(material); - } - - /* Logic backend */ - public TileEntity createNewTileEntity(World var1) - { - return null; - } - - @Override - public abstract TileEntity createNewTileEntity(World world, int metadata); - - public abstract Integer getGui(World world, int x, int y, int z, EntityPlayer entityplayer); - - public abstract Object getModInstance(); - - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float clickX, float clickY, float clickZ) - { - if (player.isSneaking()) - { - return false; - } - - Integer integer = this.getGui(world, pos.getX(), pos.getY(), pos.getZ(), player); - if (integer == null || integer == -1) - { - return false; - } - else - { - if (!world.isRemote) - { - player.openGui(this.getModInstance(), integer, world, pos.getX(), pos.getY(), pos.getZ()); - } - return true; - } - } - - /* Inventory */ - @Override - public void breakBlock(World par1World, BlockPos pos, IBlockState meta) - { - TileEntity te = par1World.getTileEntity(pos); - - if (te != null && te instanceof InventoryLogic) - { - InventoryLogic logic = (InventoryLogic) te; - logic.removeBlock(); - for (int iter = 0; iter < logic.getSizeInventory(); ++iter) - { - ItemStack stack = logic.getStackInSlot(iter); - - if (stack != null && logic.canDropInventorySlot(iter)) - { - float jumpX = this.rand.nextFloat() * 0.8F + 0.1F; - float jumpY = this.rand.nextFloat() * 0.8F + 0.1F; - float jumpZ = this.rand.nextFloat() * 0.8F + 0.1F; - - while (stack.stackSize > 0) - { - int itemSize = this.rand.nextInt(21) + 10; - - if (itemSize > stack.stackSize) - { - itemSize = stack.stackSize; - } - - stack.stackSize -= itemSize; - EntityItem entityitem = new EntityItem(par1World, (double) ((float) pos.getX() + jumpX), (double) ((float) pos.getY() + jumpY), (double) ((float) pos.getZ() + jumpZ), new ItemStack(stack.getItem(), - itemSize, stack.getItemDamage())); - - if (stack.hasTagCompound()) - { - entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); - } - - float offset = 0.05F; - entityitem.motionX = (double) ((float) this.rand.nextGaussian() * offset); - entityitem.motionY = (double) ((float) this.rand.nextGaussian() * offset + 0.2F); - entityitem.motionZ = (double) ((float) this.rand.nextGaussian() * offset); - par1World.spawnEntityInWorld(entityitem); - } - } - } - } - - super.breakBlock(par1World, pos, meta); - } - - /* Placement */ - - EnumFacing side; - - //This class does not have an actual block placed in the world - @Override - public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) - { - this.side = side; - return world.getBlockState(pos).getBlock().getStateFromMeta(meta); - } - - @Override - @SuppressWarnings("deprecation") - // TODO: Remove this when setDirection calls updated. - public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityliving, ItemStack stack) - { - TileEntity logic = world.getTileEntity(pos); - if (logic instanceof IFacingLogic) - { - IFacingLogic direction = (IFacingLogic) logic; - // TODO: Convert all setDirection calls to modern invokation, when that's ready. - if (this.side != null) - { - direction.setDirection(this.side, 0F, 0F, null); - this.side = null; - } - if (entityliving == null) - { - direction.setDirection(null, 0F, 0F, null); - } - else - { - direction.setDirection(null, entityliving.rotationYaw * 4F, entityliving.rotationPitch, entityliving); - } - } - - if (logic instanceof InventoryLogic) - { - InventoryLogic inv = (InventoryLogic) logic; - inv.placeBlock(entityliving, stack); - if (stack.hasDisplayName()) - { - inv.setInvName(stack.getDisplayName()); - } - } - } - - @SuppressWarnings("unused") - public static boolean isActive(IBlockAccess world, BlockPos pos) - { - TileEntity logic = world.getTileEntity(pos); - if (logic instanceof IActiveLogic) - { - return ((IActiveLogic) logic).getActive(); - } - return false; - } - - public int damageDropped(int meta) - { - return meta; - } - - /* IDebuggable */ - @Override - public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) - { - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && player.getHeldItem() != null && player.getHeldItem().getItem() != null && player.getHeldItem().getItem() == Items.stick) - { - TileEntity te = world.getTileEntity(pos); - if (te instanceof IDebuggable) - { - DebugHelper.handleDebugData(((IDebuggable) te).getDebugInfo(player)); - } - } - - super.onBlockClicked(world, pos, player); - } -} diff --git a/src/main/java/mantle/blocks/abstracts/InventoryLogic.java b/src/main/java/mantle/blocks/abstracts/InventoryLogic.java deleted file mode 100644 index 9bc1099..0000000 --- a/src/main/java/mantle/blocks/abstracts/InventoryLogic.java +++ /dev/null @@ -1,294 +0,0 @@ -package mantle.blocks.abstracts; - -import mantle.debug.DebugData; -import mantle.debug.IDebuggable; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -/* - * A simple logic class for storing items - * Abstract to avoid instantiation - */ - -public abstract class InventoryLogic extends TileEntity implements IInventory, IDebuggable -{ - protected ItemStack[] inventory; - - protected String invName; - - protected int stackSizeLimit; - - public InventoryLogic(int invSize) - { - this(invSize, 64); - } - - public InventoryLogic(int invSize, int maxStackSize) - { - this.inventory = new ItemStack[invSize]; - this.stackSizeLimit = maxStackSize; - } - - /* Inventory management */ - - @Override - public ItemStack getStackInSlot(int slot) - { - return slot < this.inventory.length ? this.inventory[slot] : null; - } - - public boolean isStackInSlot(int slot) - { - return slot < this.inventory.length && this.inventory[slot] != null; - } - - @Override - public int getSizeInventory() - { - return this.inventory.length; - } - - @Override - public int getInventoryStackLimit() - { - return this.stackSizeLimit; - } - - public boolean canDropInventorySlot(int slot) - { - return true; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack itemstack) - { - this.inventory[slot] = itemstack; - if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) - { - itemstack.stackSize = this.getInventoryStackLimit(); - } - } - - @Override - public ItemStack decrStackSize(int slot, int quantity) - { - if (this.inventory[slot] != null) - { - if (this.inventory[slot].stackSize <= quantity) - { - ItemStack stack = this.inventory[slot]; - this.inventory[slot] = null; - return stack; - } - ItemStack split = this.inventory[slot].splitStack(quantity); - if (this.inventory[slot].stackSize == 0) - { - this.inventory[slot] = null; - } - return split; - } - else - { - return null; - } - } - - /* Supporting methods */ - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - if (this.worldObj.getTileEntity(this.pos) != this) - { - return false; - } - else - { - return entityplayer.getDistance((double) this.pos.getX() + 0.5D, (double) this.pos.getY() + 0.5D, (double) this.pos.getZ() + 0.5D) <= 64D; - } - - } - - public abstract Container getGuiContainer(InventoryPlayer inventoryplayer, World world, int x, int y, int z); - - /* NBT */ - @Override - public void readFromNBT(NBTTagCompound tags) - { - super.readFromNBT(tags); - this.readInventoryFromNBT(tags); - } - - public void readInventoryFromNBT(NBTTagCompound tags) - { - super.readFromNBT(tags); - NBTTagList nbttaglist = tags.getTagList("Items", 10); - this.inventory = new ItemStack[this.getSizeInventory()]; - - if (tags.hasKey("CustomName", 8)) - { - this.invName = tags.getString("CustomName"); - } - - for (int i = 0; i < nbttaglist.tagCount(); ++i) - { - NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); - int j = nbttagcompound1.getByte("Slot") & 255; - - if (j >= 0 && j < this.inventory.length) - { - this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); - } - } - - //Not removed in case of things going terribly wrong - // super.readFromNBT(tags); - // this.invName = tags.getString("InvName"); - // NBTTagList nbttaglist = tags.getTagList("Items", 9); - // inventory = new ItemStack[getSizeInventory()]; - // for (int iter = 0; iter < nbttaglist.tagCount(); iter++) - // { - // NBTTagCompound tagList = (NBTTagCompound) nbttaglist.getCompoundTagAt(iter); - // byte slotID = tagList.getByte("Slot"); - // if (slotID >= 0 && slotID < inventory.length) - // { - // inventory[slotID] = ItemStack.loadItemStackFromNBT(tagList); - // } - // } - } - - @Override - public void writeToNBT(NBTTagCompound tags) - { - super.writeToNBT(tags); - this.writeInventoryToNBT(tags); - } - - public void writeInventoryToNBT(NBTTagCompound tags) - { - super.writeToNBT(tags); - NBTTagList nbttaglist = new NBTTagList(); - - for (int i = 0; i < this.inventory.length; ++i) - { - if (this.inventory[i] != null) - { - NBTTagCompound nbttagcompound1 = new NBTTagCompound(); - nbttagcompound1.setByte("Slot", (byte) i); - this.inventory[i].writeToNBT(nbttagcompound1); - nbttaglist.appendTag(nbttagcompound1); - } - } - - tags.setTag("Items", nbttaglist); - - if (this.isInvNameLocalized()) - { - tags.setString("CustomName", this.invName); - } - - //Not removed in case of things going terribly wrong - // if (invName != null) - // tags.setString("InvName", invName); - // NBTTagList nbttaglist = new NBTTagList(); - // for (int iter = 0; iter < inventory.length; iter++) - // { - // if (inventory[iter] != null) - // { - // NBTTagCompound tagList = new NBTTagCompound(); - // tagList.setByte("Slot", (byte) iter); - // inventory[iter].writeToNBT(tagList); - // nbttaglist.appendTag(tagList); - // } - // } - // - // tags.setTag("Items", nbttaglist); - } - - /* Cause of the heisenbug. Do not uncomment! */ - /*public void superReadFromNBT (NBTTagCompound tags) - { - super.readFromNBT(tags); - } - - public void superWriteToNBT (NBTTagCompound tags) - { - super.writeToNBT(tags); - }*/ - - /* Default implementations of hardly used methods */ - @Override - public ItemStack getStackInSlotOnClosing(int slot) - { - return null; - } - - public void openChest() - { - } - - public void closeChest() - { - } - - protected abstract String getDefaultName(); - - public void setInvName(String name) - { - this.invName = name; - } - - public String getInvName() - { - return this.isInvNameLocalized() ? this.invName : this.getDefaultName(); - } - - public boolean hasCustomInventoryName() - { - return this.isInvNameLocalized(); - } - - public boolean isInvNameLocalized() - { - return this.invName != null && this.invName.length() > 0; - } - - @Override - public boolean isItemValidForSlot(int slot, ItemStack itemstack) - { - if (slot < this.getSizeInventory()) - { - if (this.inventory[slot] == null || itemstack.stackSize + this.inventory[slot].stackSize <= this.getInventoryStackLimit()) - { - return true; - } - } - return false; - } - - public void placeBlock(EntityLivingBase entity, ItemStack stack) - { - - } - - public void removeBlock() - { - - } - - /* IDebuggable */ - @Override - public DebugData getDebugInfo(EntityPlayer player) - { - String[] strs = new String[1]; - strs[0] = "invName: " + this.invName + ", inventory.length: " + this.inventory.length + ", stackSizeLimit: " + this.stackSizeLimit; - return new DebugData(player, this.getClass(), strs); - } -} diff --git a/src/main/java/mantle/blocks/abstracts/InventorySlab.java b/src/main/java/mantle/blocks/abstracts/InventorySlab.java deleted file mode 100644 index 47869dd..0000000 --- a/src/main/java/mantle/blocks/abstracts/InventorySlab.java +++ /dev/null @@ -1,100 +0,0 @@ -package mantle.blocks.abstracts; - -import java.util.List; - -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -/** - * Slab version of InventoryBlock. - * - * @author mDiyo - */ -public abstract class InventorySlab extends InventoryBlock -{ - public InventorySlab(Material material) - { - super(material); - } - - /* Rendering */ - @Override - public boolean isFullCube() - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, EnumFacing side) - { - if (side.getHorizontalIndex() > 1) - { - return super.shouldSideBeRendered(world, pos, side); - } - - IBlockState iblockstate = world.getBlockState(pos); - int meta = iblockstate.getBlock().getMetaFromState(iblockstate); - boolean top = (meta | 8) == 1; - if ((top && side == side.DOWN) || (!top && side == side.UP)) - { - return true; - } - - return super.shouldSideBeRendered(world, pos, side); - } - - @Override - @SuppressWarnings("rawtypes") - public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) - { - this.setBlockBoundsBasedOnState(world, pos); - super.addCollisionBoxesToList(world, pos, state, axisalignedbb, arraylist, entity); - } - - @Override - public void setBlockBoundsForItemRender() - { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); - } - - public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos, IBlockState state) - { - IBlockState iblockstate = world.getBlockState(pos); - int meta = iblockstate.getBlock().getMetaFromState(iblockstate) / 8; - float minY = meta == 1 ? 0.5F : 0.0F; - float maxY = meta == 1 ? 1.0F : 0.5F; - this.setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); - } - - public int onBlockPlaced(World par1World, int blockX, int blockY, int blockZ, int side, float clickX, float clickY, float clickZ, int metadata) - { - if (side == 1) - { - return metadata; - } - if (side == 0 || clickY >= 0.5F) - { - return metadata | 8; - } - - return metadata; - } - - @Override - public int damageDropped(int meta) - { - return meta % 8; - } -} diff --git a/src/main/java/mantle/blocks/abstracts/MultiItemBlock.java b/src/main/java/mantle/blocks/abstracts/MultiItemBlock.java deleted file mode 100644 index e515bf6..0000000 --- a/src/main/java/mantle/blocks/abstracts/MultiItemBlock.java +++ /dev/null @@ -1,82 +0,0 @@ -package mantle.blocks.abstracts; - -import static mantle.lib.CoreRepo.logger; -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; - -/** - * - * @author progwml6 - * base class for itemBlocks with different unlocalized names based on metadata - */ - -public class MultiItemBlock extends ItemBlock -{ - private String blockType[]; - - private String unlocalizedName; - - private String append; - - private int specialIndex[] = { -1, -1 }; - - public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String[] blockTypes) - { - super(b); - if (itemBlockUnlocalizedName.isEmpty()) - { - this.unlocalizedName = super.getUnlocalizedName(); - } - else - { - this.unlocalizedName = itemBlockUnlocalizedName; - } - this.blockType = blockTypes; - this.append = ""; - } - - public MultiItemBlock(Block b, String itemBlockUnlocalizedName, String appendToEnd, String[] blockTypes) - { - super(b); - this.unlocalizedName = itemBlockUnlocalizedName; - this.blockType = blockTypes; - this.append = "." + appendToEnd; - } - - public void setSpecialIndex(int clampIndex, int stringBuilderIndex) - { - this.specialIndex[0] = clampIndex; - this.specialIndex[1] = stringBuilderIndex; - } - - @Override - public int getMetadata(int meta) - { - return meta; - } - - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - - int pos = MathHelper.clamp_int(itemstack.getItemDamage(), 0, (this.specialIndex[0] > -1) ? this.specialIndex[0] : (this.blockType.length - 1)); - int sbIndex = (this.specialIndex[1] > -1) ? pos : (this.specialIndex[1] - pos); - if (sbIndex < 0) - { - sbIndex = -1 * sbIndex; - } - try - { - return (new StringBuilder()).append(this.unlocalizedName).append(".").append(this.blockType[sbIndex - 1]).append(this.append).toString(); - } - catch (ArrayIndexOutOfBoundsException ex) - { - logger.warn("[MultiItemBlock] Caught array index error in getUnlocalizedName: " + ex.getMessage()); - logger.warn("[MultiItemBlock] Returning unlocalized name: " + this.getUnlocalizedName()); - return this.getUnlocalizedName(); - } - } - -} diff --git a/src/main/java/mantle/blocks/iface/IActiveLogic.java b/src/main/java/mantle/blocks/iface/IActiveLogic.java deleted file mode 100644 index 51e7e5c..0000000 --- a/src/main/java/mantle/blocks/iface/IActiveLogic.java +++ /dev/null @@ -1,13 +0,0 @@ -package mantle.blocks.iface; - -/** - * Marks blocks that can be active and inactive. - * - * @author mDiyo - */ -public interface IActiveLogic -{ - public boolean getActive(); - - public void setActive(boolean flag); -} diff --git a/src/main/java/mantle/blocks/iface/ICrop.java b/src/main/java/mantle/blocks/iface/ICrop.java deleted file mode 100644 index 9473de2..0000000 --- a/src/main/java/mantle/blocks/iface/ICrop.java +++ /dev/null @@ -1,33 +0,0 @@ -package mantle.blocks.iface; - -import java.util.Collections; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.BlockPos; -import net.minecraft.world.IBlockAccess; - -public interface ICrop -{ - public enum HarvestType - { - BREAK, USE, MACHINE - } - - public static final List NO_YIELD = Collections.emptyList(); - - /** - * - * @param world - * @param pos - * @param type - * @return A list of items harvested. If no items are returned, NO_YIELD should be passed. - */ - public List harvestCrop(IBlockAccess world, BlockPos pos, HarvestType type); - - public boolean isFullyGrown(IBlockAccess world, BlockPos pos); - - public boolean hasYield(IBlockAccess world, BlockPos pos); - - public void growthTick(IBlockAccess world, BlockPos pos); -} diff --git a/src/main/java/mantle/blocks/iface/IFacingLogic.java b/src/main/java/mantle/blocks/iface/IFacingLogic.java deleted file mode 100644 index ae1c76d..0000000 --- a/src/main/java/mantle/blocks/iface/IFacingLogic.java +++ /dev/null @@ -1,20 +0,0 @@ -package mantle.blocks.iface; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.EnumFacing; - -/** - * Logic for blocks which have a specific direction facing. - * - * @author mDiyo - */ -public interface IFacingLogic -{ - - public byte getRenderDirection(); - - public EnumFacing getForgeDirection(); - - public void setDirection(EnumFacing facing, float yaw, float pitch, EntityLivingBase player); - -} diff --git a/src/main/java/mantle/blocks/util/IBlockWithVariants.java b/src/main/java/mantle/blocks/util/IBlockWithVariants.java deleted file mode 100644 index 4c56312..0000000 --- a/src/main/java/mantle/blocks/util/IBlockWithVariants.java +++ /dev/null @@ -1,8 +0,0 @@ -package mantle.blocks.util; - -import net.minecraft.item.ItemStack; - -public interface IBlockWithVariants -{ - String getVariantNameFromStack(ItemStack stack); -} diff --git a/src/main/java/mantle/blocks/util/ItemBlockVariants.java b/src/main/java/mantle/blocks/util/ItemBlockVariants.java deleted file mode 100644 index eff4004..0000000 --- a/src/main/java/mantle/blocks/util/ItemBlockVariants.java +++ /dev/null @@ -1,33 +0,0 @@ -package mantle.blocks.util; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -public class ItemBlockVariants extends ItemBlock -{ - private final IBlockWithVariants blockWithVariants; - - public ItemBlockVariants(Block block) - { - super(block); - - this.blockWithVariants = (IBlockWithVariants) block; - - this.setMaxDamage(0); - this.setHasSubtypes(true); - } - - @Override - public int getMetadata(int damage) - { - return damage; - } - - @Override - public String getUnlocalizedName(ItemStack stack) - { - return super.getUnlocalizedName() + "." + this.blockWithVariants.getVariantNameFromStack(stack); - } - -} diff --git a/src/main/java/mantle/blocks/util/blockstates/BlockVariant.java b/src/main/java/mantle/blocks/util/blockstates/BlockVariant.java deleted file mode 100644 index 83b01a7..0000000 --- a/src/main/java/mantle/blocks/util/blockstates/BlockVariant.java +++ /dev/null @@ -1,36 +0,0 @@ -package mantle.blocks.util.blockstates; - -public class BlockVariant implements Comparable -{ - private int meta; - - private String name; - - public BlockVariant(int meta, String name) - { - this.meta = meta; - this.name = name; - } - - public int getMeta() - { - return this.meta; - } - - public String getName() - { - return this.name; - } - - @Override - public int compareTo(BlockVariant variant) - { - return this.meta; - } - - @Override - public String toString() - { - return this.getName(); - } -} diff --git a/src/main/java/mantle/blocks/util/blockstates/PropertyVariant.java b/src/main/java/mantle/blocks/util/blockstates/PropertyVariant.java deleted file mode 100644 index 8e9570a..0000000 --- a/src/main/java/mantle/blocks/util/blockstates/PropertyVariant.java +++ /dev/null @@ -1,65 +0,0 @@ -package mantle.blocks.util.blockstates; - -import net.minecraft.block.properties.IProperty; - -import java.util.Collection; -import java.util.HashMap; - -public class PropertyVariant implements IProperty -{ - private String name; - - private BlockVariant defaultVariant; - - private HashMap metaMap; - - protected PropertyVariant(String name, BlockVariant... variants) - { - this.name = name; - this.metaMap = new HashMap(); - - this.defaultVariant = variants[0]; - - for (BlockVariant variant : variants) - { - this.metaMap.put(variant.getMeta(), variant); - } - } - - public static PropertyVariant create(String name, BlockVariant... variants) - { - return new PropertyVariant(name, variants); - } - - @Override - public String getName() - { - return this.name; - } - - @Override - public Collection getAllowedValues() - { - return this.metaMap.values(); - } - - @Override - public Class getValueClass() - { - return BlockVariant.class; - } - - @Override - public String getName(Comparable value) - { - return ((BlockVariant) value).getName(); - } - - public BlockVariant fromMeta(int meta) - { - BlockVariant variant = this.metaMap.get(meta); - - return variant != null ? variant : this.defaultVariant; - } - -} diff --git a/src/main/java/mantle/books/BookData.java b/src/main/java/mantle/books/BookData.java deleted file mode 100644 index 09fa53e..0000000 --- a/src/main/java/mantle/books/BookData.java +++ /dev/null @@ -1,41 +0,0 @@ -package mantle.books; - -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.util.ResourceLocation; - -import org.w3c.dom.Document; - -public class BookData -{ - public String unlocalizedName = ""; - - public String toolTip = ""; - - public String modID = ""; - - public ResourceLocation leftImage = new ResourceLocation("mantle", "textures/gui/bookleft.png"); - - public ResourceLocation rightImage = new ResourceLocation("mantle", "textures/gui/bookright.png"); - - public ResourceLocation itemImage = new ResourceLocation("mantle", "textures/items/mantlebook_blue.png"); - - public Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml"); - - //font can be left null if so, the default from mantle will be used - public FontRenderer font; - - public Boolean isTranslatable = false; - - public boolean isFromZip = false; - - public Document getDoc() - { - return this.doc; - } - - public String getFullUnlocalizedName() - { - return this.modID + ":" + this.unlocalizedName; - } - -} diff --git a/src/main/java/mantle/books/BookDataStore.java b/src/main/java/mantle/books/BookDataStore.java deleted file mode 100644 index 7129607..0000000 --- a/src/main/java/mantle/books/BookDataStore.java +++ /dev/null @@ -1,57 +0,0 @@ -package mantle.books; - -import java.util.List; - -import com.google.common.collect.HashBiMap; -import com.google.common.collect.Lists; - -public class BookDataStore -{ - private static HashBiMap data = HashBiMap.create(); - - private static HashBiMap intMap = HashBiMap.create(); - - private static List zipBooks = Lists.newArrayList(); - - public static void addBook(BookData bd) - { - int insertOrder = data.size(); - data.put(bd.getFullUnlocalizedName(), bd); - intMap.put(insertOrder, bd.getFullUnlocalizedName()); - if (bd.isFromZip) - { - zipBooks.add(bd.getFullUnlocalizedName()); - } - - } - - public static BookData getBookfromName(String ModID, String unlocalizedName) - { - return getBookFromName(ModID + ":" + unlocalizedName); - } - - public static BookData getBookFromName(String fullBookName) - { - return data.get(fullBookName); - } - - public static BookData getBookfromID(int bookIDNum) - { - return data.get(intMap.get(bookIDNum)); - } - - public static int getIDFromName(String FullUnlocalizedName) - { - return intMap.inverse().get(FullUnlocalizedName); - } - - public static int getIDFromBook(BookData b) - { - return getIDFromName(data.inverse().get(b)); - } - - public static List getZipBooks() - { - return zipBooks; - } -} diff --git a/src/main/java/mantle/books/ManualReader.java b/src/main/java/mantle/books/ManualReader.java deleted file mode 100644 index 6b2ac49..0000000 --- a/src/main/java/mantle/books/ManualReader.java +++ /dev/null @@ -1,51 +0,0 @@ -package mantle.books; - -import static mantle.lib.CoreRepo.logger; - -import java.io.InputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import mantle.Mantle; - -import org.w3c.dom.Document; - -public class ManualReader -{ - public static Document readManual(String location) - { - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - - try - { - logger.info("Loading Manual XML from: " + location); - InputStream stream = Mantle.class.getResourceAsStream(location); - return readManual(stream, location); - } - catch (Exception e) - { - e.printStackTrace(); - return null; - } - } - - public static Document readManual(InputStream is, String filenameOrLocation) - { - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - - try - { - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(is); - doc.getDocumentElement().normalize(); - return doc; - } - catch (Exception e) - { - logger.error("Failed to Load Manual XML from: " + filenameOrLocation); - e.printStackTrace(); - return null; - } - } -} diff --git a/src/main/java/mantle/books/client/BookImage.java b/src/main/java/mantle/books/client/BookImage.java deleted file mode 100644 index 62c42b4..0000000 --- a/src/main/java/mantle/books/client/BookImage.java +++ /dev/null @@ -1,21 +0,0 @@ -package mantle.books.client; - -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.util.ResourceLocation; - -public class BookImage -{ - public int height, width; - - public DynamicTexture texture; - - public ResourceLocation resource; - - public BookImage(int width, int height, DynamicTexture texture, ResourceLocation resource) - { - this.width = width; - this.height = height; - this.texture = texture; - this.resource = resource; - } -} diff --git a/src/main/java/mantle/books/external/BookIS.java b/src/main/java/mantle/books/external/BookIS.java deleted file mode 100644 index e38af7f..0000000 --- a/src/main/java/mantle/books/external/BookIS.java +++ /dev/null @@ -1,22 +0,0 @@ -package mantle.books.external; - -public class BookIS -{ - //users chosen nickname for this specific itemstack - public String cname; - - //fully qualified name from the game registry for the item/block in question - public String fullISName; - - public int metadata; - - public String tags; - - public int stackSize; - - public int getStackSize() - { - return this.stackSize >= 0 ? this.stackSize : 1; - } - -} diff --git a/src/main/java/mantle/books/external/BookLoad.java b/src/main/java/mantle/books/external/BookLoad.java deleted file mode 100644 index 6ef315c..0000000 --- a/src/main/java/mantle/books/external/BookLoad.java +++ /dev/null @@ -1,29 +0,0 @@ -package mantle.books.external; - -import com.google.gson.JsonObject; - -public class BookLoad -{ - public String unlocalizedName; - - public String tooltip; - - public boolean translatable; - - public String BookIcon; - - public String LeftImage; - - public String rightImage; - - public BookIS[] registerItemStacks; - - public JsonObject[] smallRecipes; - - public JsonObject[] largeRecipes; - - public JsonObject[] furnaceRecipes; - - public JsonObject[] manualIcons; - -} diff --git a/src/main/java/mantle/books/external/ZipLoader.java b/src/main/java/mantle/books/external/ZipLoader.java deleted file mode 100644 index 3bc19bb..0000000 --- a/src/main/java/mantle/books/external/ZipLoader.java +++ /dev/null @@ -1,256 +0,0 @@ -package mantle.books.external; - -import static mantle.lib.CoreRepo.logger; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.util.Enumeration; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import javax.imageio.ImageIO; - -import mantle.books.BookData; -import mantle.books.BookDataStore; -import mantle.books.ManualReader; -import mantle.books.client.BookImage; -import mantle.lib.client.MantleClientRegistry; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.relauncher.Side; - -import org.apache.commons.io.FilenameUtils; -import org.apache.commons.io.IOUtils; - -import com.google.common.base.Charsets; -import com.google.common.collect.Maps; -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; - -public class ZipLoader -{ - public static Map loadedIS = Maps.newHashMap(); - - public static BookData loadZip(File f) - { - BookLoad bl; - String flName = ""; - String flExt = ""; - String lImg = ""; - String rImg = ""; - String bIcon = ""; - String unlocName = ""; - String toolTip = ""; - Boolean translatable = false; - BookData b = new BookData(); - boolean isClient = FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT; - if (f.exists()) - { - if (FilenameUtils.getExtension(f.getPath()).equalsIgnoreCase("zip")) - { - try - { - logger.info("Loading book zip " + f.getName()); - ZipFile zipfile = new ZipFile(f); - Enumeration e = zipfile.entries(); - while (e.hasMoreElements()) - { - ZipEntry entry = e.nextElement(); - flName = entry.getName(); - flExt = FilenameUtils.getExtension(flName); - if (!entry.isDirectory()) - { - if (isClient && isImage(flExt)) - { - String id = FilenameUtils.getBaseName(flName); - BufferedImage img = ImageIO.read(zipfile.getInputStream(entry)); - DynamicTexture dynTexture = new DynamicTexture(img); - ResourceLocation rsLoc = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation(id, dynTexture); - BookImage bI = new BookImage(img.getWidth(), img.getHeight(), dynTexture, rsLoc); - MantleClientRegistry.imageCache.put(id, bI); - } - if (flExt.equalsIgnoreCase("xml")) - { - b.doc = ManualReader.readManual(zipfile.getInputStream(entry), flName); - } - if (flExt.equalsIgnoreCase("lang")) - { - //TODO 1.7 put this data into the vanilla lang stuffs - } - if (flExt.equalsIgnoreCase("json")) - { - Gson g = new Gson(); - bl = g.fromJson(IOUtils.toString(zipfile.getInputStream(entry), Charsets.UTF_8), BookLoad.class); - for (BookIS bis : bl.registerItemStacks) - { - try - { - ItemStack is = loadedIS.get(bis.cname); - if (is == null) - { - Block blok = (Block) Block.blockRegistry.getObject(bis.cname); - Item it = (Item) Item.itemRegistry.getObject(bis.cname); - if (it != null) - { - is = new ItemStack(it, bis.getStackSize(), bis.metadata); - } - - else if (bl != null) - { - is = new ItemStack(blok, bis.getStackSize(), bis.metadata); - } - if (is != null) - { - if (bis.tags != null && !bis.tags.isEmpty()) - { - try - { - is.setTagCompound(JsonToNBT.getTagFromJson(bis.tags)); - } - catch (Exception e1) - { - } - } - loadedIS.put(bis.cname, is); - } - } - } - catch (Exception e1) - { - } - } - if (isClient) - { - for (JsonObject jso : bl.smallRecipes) - { - if (jso != null) - { - ItemStack out = loadedIS.get(jso.get("out").getAsString()); - ItemStack in[] = getISArray(jso.getAsJsonArray("in")); - String name = jso.get("name").getAsString(); - if (out != null && in != null && in.length <= 4 && name != null && !name.isEmpty()) - { - MantleClientRegistry.registerManualSmallRecipe(name, out, in); - } - } - } - for (JsonObject jso : bl.largeRecipes) - { - if (jso != null) - { - ItemStack out = loadedIS.get(jso.get("out").getAsString()); - ItemStack in[] = getISArray(jso.getAsJsonArray("in")); - String name = jso.get("name").getAsString(); - if (out != null && in != null && in.length <= 9 && name != null && !name.isEmpty()) - { - MantleClientRegistry.registerManualLargeRecipe(name, out, in); - } - } - } - for (JsonObject jso : bl.furnaceRecipes) - { - if (jso != null) - { - ItemStack out = loadedIS.get(jso.get("out").getAsString()); - ItemStack in = loadedIS.get(jso.get("in").getAsString()); - String name = jso.get("name").getAsString(); - if (out != null && in != null && name != null && !name.isEmpty()) - { - MantleClientRegistry.registerManualFurnaceRecipe(name, out, in); - } - } - } - for (JsonObject jso : bl.manualIcons) - { - if (jso != null) - { - ItemStack in = loadedIS.get(jso.get("stack").getAsString()); - String name = jso.get("name").getAsString(); - if (in != null && name != null && !name.isEmpty()) - { - MantleClientRegistry.registerManualIcon(name, in); - } - } - } - } - b.unlocalizedName = bl.unlocalizedName; - b.toolTip = bl.tooltip; - b.isTranslatable = bl.translatable; - b.leftImage = bl.LeftImage == null ? new ResourceLocation("mantle", "textures/gui/bookleft.png") : MantleClientRegistry.getBookImageFromCache(bl.LeftImage).resource; - b.rightImage = bl.rightImage == null ? new ResourceLocation("mantle", "textures/gui/bookright.png") - : MantleClientRegistry.getBookImageFromCache(bl.rightImage).resource; - b.itemImage = bl.BookIcon == null ? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png") - : MantleClientRegistry.getBookImageFromCache(bl.BookIcon).resource; - b.isFromZip = true; - BookDataStore.addBook(b); - } - } - - } - zipfile.close(); - b.unlocalizedName = unlocName; - b.toolTip = toolTip; - b.isTranslatable = translatable; - b.leftImage = lImg == null ? new ResourceLocation("mantle", "textures/gui/bookleft.png") : MantleClientRegistry.getBookImageFromCache(lImg).resource; - b.rightImage = rImg == null ? new ResourceLocation("mantle", "textures/gui/bookright.png") : MantleClientRegistry.getBookImageFromCache(rImg).resource; - b.itemImage = bIcon == null ? new ResourceLocation("mantle", "textures/items/mantlebook_blue.png") : MantleClientRegistry.getBookImageFromCache(bIcon).resource; - b.isFromZip = true; - BookDataStore.addBook(b); - } - catch (Exception e) - { - logger.info(" Error Loading book zip " + f.getName()); - } - return null; - - } - else - { - logger.error("Attempted to load non-zip file for mantle book. File " + f.getName() + " will be skipped"); - } - } - else - { - logger.error("Attempted to load non-existant file for mantle book. File will be skipped"); - - } - return null; - } - - public static boolean isImage(String ext) - { - return ext.equalsIgnoreCase("png"); - } - - public static ItemStack[] getISArray(JsonArray a) - { - ItemStack[] is = new ItemStack[a.size()]; - ItemStack loadedStack; - for (int i = 0; i < a.size(); i++) - { - if (a.get(i).getAsString() != null && !a.get(i).getAsString().isEmpty() && a.get(i).getAsString().equals("none")) - { - is[i] = null; - } - else - { - loadedStack = loadedIS.get(a.get(i).getAsString()); - if (loadedStack == null) - { - is = null; - return is; - } - is[i] = loadedStack; - } - } - return is; - } -} diff --git a/src/main/java/mantle/client/MProxyClient.java b/src/main/java/mantle/client/MProxyClient.java deleted file mode 100644 index dc13871..0000000 --- a/src/main/java/mantle/client/MProxyClient.java +++ /dev/null @@ -1,101 +0,0 @@ -package mantle.client; - -import static mantle.lib.CoreRepo.logger; - -import java.util.HashMap; -import java.util.Map; - -import mantle.Mantle; -import mantle.books.BookData; -import mantle.books.BookDataStore; -import mantle.client.gui.GuiManual; -import mantle.client.pages.BlankPage; -import mantle.client.pages.BookPage; -import mantle.client.pages.ContentsTablePage; -import mantle.client.pages.CraftingPage; -import mantle.client.pages.FurnacePage; -import mantle.client.pages.PicturePage; -import mantle.client.pages.SectionPage; -import mantle.client.pages.SidebarPage; -import mantle.client.pages.TextPage; -import mantle.client.pages.TitlePage; -import mantle.common.MProxyCommon; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class MProxyClient extends MProxyCommon -{ - - public static final String MINECRAFT_ASCII_PATH = "minecraft:textures/font/ascii.png"; - - /* Registers any rendering code. */ - @Override - public void registerRenderer() - { - ModelHelper.registerItem(Mantle.mantleBook, "mantleBook"); - } - - public static Map> pageClasses = new HashMap>(); - - public static void registerManualPage(String type, Class clazz) - { - pageClasses.put(type, clazz); - } - - public static Class getPageClass(String type) - { - return pageClasses.get(type); - } - - @Override - public void readManuals() - { - this.initManualPages(); - } - - void initManualPages() - { - MProxyClient.registerManualPage("crafting", CraftingPage.class); - MProxyClient.registerManualPage("picture", PicturePage.class); - MProxyClient.registerManualPage("text", TextPage.class); - MProxyClient.registerManualPage("intro", TextPage.class); - MProxyClient.registerManualPage("sectionpage", SectionPage.class); - MProxyClient.registerManualPage("intro", TitlePage.class); - MProxyClient.registerManualPage("contents", ContentsTablePage.class); - MProxyClient.registerManualPage("furnace", FurnacePage.class); - MProxyClient.registerManualPage("sidebar", SidebarPage.class); - MProxyClient.registerManualPage("blank", BlankPage.class); - } - - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - if (ID == manualGuiID) - { - ItemStack stack = player.getCurrentEquippedItem(); - if (stack == null) - { - logger.error("Null stack in book."); - } - if (stack != null && stack.getItem() == null) - { - logger.error("Null item in book."); - } - if (stack != null && stack.getItem() != null && stack.getItem().getUnlocalizedName() == null) - { - logger.error("Null unlocalized name in book."); - } - else - { - return new GuiManual(stack, MProxyClient.getBookDataFromStack(stack)); - } - } - return null; - } - - private static BookData getBookDataFromStack(ItemStack stack) - { - return BookDataStore.getBookFromName(stack.getItem().getUnlocalizedName(stack)); - } -} diff --git a/src/main/java/mantle/client/ModelHelper.java b/src/main/java/mantle/client/ModelHelper.java deleted file mode 100644 index aca485c..0000000 --- a/src/main/java/mantle/client/ModelHelper.java +++ /dev/null @@ -1,34 +0,0 @@ -package mantle.client; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemModelMesher; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.item.Item; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class ModelHelper -{ - public static void registerItem(Item item, int metadata, String itemName) - { - ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); - mesher.register(item, metadata, new ModelResourceLocation(itemName, "inventory")); - } - - public static void registerBlock(Block block, int metadata, String blockName) - { - registerItem(Item.getItemFromBlock(block), metadata, blockName); - } - - public static void registerBlock(Block block, String blockName) - { - registerBlock(block, 0, blockName); - } - - public static void registerItem(Item item, String itemName) - { - registerItem(item, 0, itemName); - } -} diff --git a/src/main/java/mantle/client/ModelVariant.java b/src/main/java/mantle/client/ModelVariant.java deleted file mode 100644 index 7a4c4a4..0000000 --- a/src/main/java/mantle/client/ModelVariant.java +++ /dev/null @@ -1,89 +0,0 @@ -package mantle.client; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public class ModelVariant -{ - private String MOD_ID; - - private Minecraft mc; - - public ModelVariant(String modId, Minecraft mc) - { - this.MOD_ID = modId; - this.mc = mc; - } - - public String getResource(String resource) - { - return (MOD_ID + ":") + resource; - } - - public void addVariantNames(Block block, String... names) - { - for (int i = 0; i < names.length; i++) - { - names[i] = getResource(names[i]); - } - - ModelBakery.addVariantName(Item.getItemFromBlock(block), names); - } - - public void addVariantNames(Item item, String... names) - { - for (int i = 0; i < names.length; i++) - { - names[i] = getResource(names[i]); - } - - ModelBakery.addVariantName(item, names); - } - - public void registerBlockModel(Block block) - { - ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(block); - - registerBlockModel(block, 0, resourceLocation.toString()); - } - - public void registerItemModel(Item item) - { - ResourceLocation resourceLocation = (ResourceLocation) Item.itemRegistry.getNameForObject(item); - - registerItemModel(item, 0, resourceLocation.toString()); - } - - public void registerBlockModel(Block block, int meta, String modelName) - { - registerItemModel(Item.getItemFromBlock(block), meta, modelName); - } - - public void registerItemModel(Item item, int meta, String resourcePath) - { - ModelResourceLocation modelResourceLocation = new ModelResourceLocation(resourcePath, "inventory"); - - mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation); - } - - public void registerItemSubTypesModel(Item item, CreativeTabs tab) - { - ArrayList list = new ArrayList(); - item.getSubItems(item, tab, list); - for (ItemStack i : list) - { - this.registerItemModel(item, i.getItemDamage(), item.getUnlocalizedName().substring(5)); - } - } -} diff --git a/src/main/java/mantle/client/gui/GuiManual.java b/src/main/java/mantle/client/gui/GuiManual.java deleted file mode 100644 index b3f8aa1..0000000 --- a/src/main/java/mantle/client/gui/GuiManual.java +++ /dev/null @@ -1,238 +0,0 @@ -package mantle.client.gui; - -import mantle.books.BookData; -import mantle.client.MProxyClient; -import mantle.client.pages.BookPage; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.lwjgl.opengl.GL11; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -@SideOnly(Side.CLIENT) -public class GuiManual extends GuiScreen -{ - ItemStack itemstackBook; - - Document manual; - - public RenderItem renderitem = Minecraft.getMinecraft().getRenderItem(); - - int bookImageWidth = 206; - - int bookImageHeight = 200; - - int bookTotalPages = 1; - - int currentPage; - - int maxPages; - - BookData bData; - - private TurnPageButton buttonNextPage; - - private TurnPageButton buttonPreviousPage; - - private static ResourceLocation bookRight;// = new ResourceLocation("mantle", "textures/gui/bookright.png"); - - private static ResourceLocation bookLeft;// = new ResourceLocation("mantle", "textures/gui/bookleft.png"); - - BookPage pageLeft; - - BookPage pageRight; - - public FontRenderer fonts = Minecraft.getMinecraft().fontRendererObj; - - public GuiManual(ItemStack stack, BookData data) - { - this.mc = Minecraft.getMinecraft(); - this.itemstackBook = stack; - this.currentPage = 0; //Stack page - this.manual = data.getDoc(); - if (data.font != null) - { - this.fonts = data.font; - } - bookLeft = data.leftImage; - bookRight = data.rightImage; - this.bData = data; - - //renderitem.renderInFrame = true; - } - - /*@Override - public void setWorldAndResolution (Minecraft minecraft, int w, int h) - { - this.guiParticles = new GuiParticle(minecraft); - this.mc = minecraft; - this.width = w; - this.height = h; - this.buttonList.clear(); - this.initGui(); - }*/ - - @Override - @SuppressWarnings("unchecked") - public void initGui() - { - this.maxPages = this.manual.getElementsByTagName("page").getLength(); - this.updateText(); - int xPos = (this.width) / 2; //TODO Width? - //TODO buttonList - this.buttonList.add(this.buttonNextPage = new TurnPageButton(1, xPos + this.bookImageWidth - 50, 180, true, this.bData)); - this.buttonList.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - this.bookImageWidth + 24, 180, false, this.bData)); - } - - @Override - protected void actionPerformed(GuiButton button) - { - if (button.enabled) - { - if (button.id == 1) - { - this.currentPage += 2; - } - if (button.id == 2) - { - this.currentPage -= 2; - } - - this.updateText(); - } - } - - void updateText() - { - if (this.maxPages % 2 == 1) - { - if (this.currentPage > this.maxPages) - { - this.currentPage = this.maxPages; - } - } - else - { - if (this.currentPage >= this.maxPages) - { - this.currentPage = this.maxPages - 2; - } - } - if (this.currentPage % 2 == 1) - { - this.currentPage--; - } - if (this.currentPage < 0) - { - this.currentPage = 0; - } - - NodeList nList = this.manual.getElementsByTagName("page"); - - Node node = nList.item(this.currentPage); - if (node.getNodeType() == Node.ELEMENT_NODE) - { - Element element = (Element) node; - Class clazz = MProxyClient.getPageClass(element.getAttribute("type")); - if (clazz != null) - { - try - { - this.pageLeft = clazz.newInstance(); - this.pageLeft.init(this, 0); - this.pageLeft.readPageFromXML(element); - } - catch (Exception e) - { - } - } - else - { - this.pageLeft = null; - } - } - - node = nList.item(this.currentPage + 1); - if (node != null && node.getNodeType() == Node.ELEMENT_NODE) - { - Element element = (Element) node; - Class clazz = MProxyClient.getPageClass(element.getAttribute("type")); - if (clazz != null) - { - try - { - this.pageRight = clazz.newInstance(); - this.pageRight.init(this, 1); - this.pageRight.readPageFromXML(element); - } - catch (Exception e) - { - } - } - else - { - this.pageLeft = null; - } - } - else - { - this.pageRight = null; - } - } - - @Override - public void drawScreen(int par1, int par2, float par3) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(bookRight); - int localWidth = (this.width / 2); - byte localHeight = 8; - this.drawTexturedModalRect(localWidth, localHeight, 0, 0, this.bookImageWidth, this.bookImageHeight); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(bookLeft); - localWidth = localWidth - this.bookImageWidth; - this.drawTexturedModalRect(localWidth, localHeight, 256 - this.bookImageWidth, 0, this.bookImageWidth, this.bookImageHeight); - - super.drawScreen(par1, par2, par3); //16, 12, 220, 12 - - if (this.pageLeft != null) - { - this.pageLeft.renderBackgroundLayer(localWidth + 16, localHeight + 12); - } - if (this.pageRight != null) - { - this.pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12); - } - if (this.pageLeft != null) - { - this.pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, this.bData.isTranslatable); - } - if (this.pageRight != null) - { - this.pageRight.renderContentLayer(localWidth + 220, localHeight + 12, this.bData.isTranslatable); - } - - } - - public Minecraft getMC() - { - return this.mc; - } - - @Override - public boolean doesGuiPauseGame() - { - return false; - } -} diff --git a/src/main/java/mantle/client/gui/TurnPageButton.java b/src/main/java/mantle/client/gui/TurnPageButton.java deleted file mode 100644 index f5a7fb2..0000000 --- a/src/main/java/mantle/client/gui/TurnPageButton.java +++ /dev/null @@ -1,56 +0,0 @@ -package mantle.client.gui; - -import mantle.books.BookData; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class TurnPageButton extends GuiButton -{ - /** - * True for pointing right (next page), false for pointing left (previous page). - */ - private final boolean nextPage; - - private static ResourceLocation background;// = new ResourceLocation("tinker", "textures/gui/bookleft.png"); - - public TurnPageButton(int par1, int par2, int par3, boolean par4, BookData data) - { - super(par1, par2, par3, 23, 13, ""); - this.nextPage = par4; - background = data.leftImage; - } - - /** - * Draws this button to the screen. - */ - @Override - public void drawButton(Minecraft par1Minecraft, int par2, int par3) - { - if (this.visible) - { - boolean var4 = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - par1Minecraft.getTextureManager().bindTexture(background); - int var5 = 0; - int var6 = 192; - - if (var4) - { - var5 += 23; - } - - if (!this.nextPage) - { - var6 += 13; - } - - this.drawTexturedModalRect(this.xPosition, this.yPosition, var5, var6, 23, 13); - } - } -} diff --git a/src/main/java/mantle/client/pages/BlankPage.java b/src/main/java/mantle/client/pages/BlankPage.java deleted file mode 100644 index 8815653..0000000 --- a/src/main/java/mantle/client/pages/BlankPage.java +++ /dev/null @@ -1,18 +0,0 @@ -package mantle.client.pages; - -import org.w3c.dom.Element; - -public class BlankPage extends BookPage -{ - - @Override - public void readPageFromXML(Element element) - { - } - - @Override - public void renderContentLayer(int localwidth, int localheight, boolean isTranslatable) - { - } - -} diff --git a/src/main/java/mantle/client/pages/BookPage.java b/src/main/java/mantle/client/pages/BookPage.java deleted file mode 100644 index 8667107..0000000 --- a/src/main/java/mantle/client/pages/BookPage.java +++ /dev/null @@ -1,26 +0,0 @@ -package mantle.client.pages; - -import mantle.client.gui.GuiManual; - -import org.w3c.dom.Element; - -public abstract class BookPage -{ - protected GuiManual manual; - - protected int side; - - public void init(GuiManual manual, int side) - { - this.manual = manual; - this.side = side; - } - - public abstract void readPageFromXML(Element element); - - public void renderBackgroundLayer(int localwidth, int localheight) - { - } - - public abstract void renderContentLayer(int localwidth, int localheight, boolean isTranslatable); -} diff --git a/src/main/java/mantle/client/pages/ContentsTablePage.java b/src/main/java/mantle/client/pages/ContentsTablePage.java deleted file mode 100644 index a27f39f..0000000 --- a/src/main/java/mantle/client/pages/ContentsTablePage.java +++ /dev/null @@ -1,74 +0,0 @@ -package mantle.client.pages; - -import mantle.lib.client.MantleClientRegistry; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class ContentsTablePage extends BookPage -{ - String text; - - String[] iconText; - - ItemStack[] icons; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - - nodes = element.getElementsByTagName("link"); - this.iconText = new String[nodes.getLength()]; - this.icons = new ItemStack[nodes.getLength()]; - for (int i = 0; i < nodes.getLength(); i++) - { - NodeList children = nodes.item(i).getChildNodes(); - this.iconText[i] = children.item(1).getTextContent(); - this.icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent()); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (this.text != null) - { - if (isTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - this.manual.fonts.drawString("\u00a7n" + this.text, localWidth + 25 + this.manual.fonts.getStringWidth(this.text) / 2, localHeight + 4, 0); - } - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - this.manual.renderitem.zLevel = 100; - for (int i = 0; i < this.icons.length; i++) - { - this.manual.renderitem.renderItemIntoGUI(this.icons[i], localWidth + 16, localHeight + 18 * i + 18); - int yOffset = 18; - if (isTranslatable) - { - this.iconText[i] = StatCollector.translateToLocal(this.iconText[i]); - } - - if (this.iconText[i].length() > 40) - { - yOffset = 13; - } - this.manual.fonts.drawString(this.iconText[i], localWidth + 38, localHeight + 18 * i + yOffset, 0); - } - this.manual.renderitem.zLevel = 0; - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } -} diff --git a/src/main/java/mantle/client/pages/CraftingPage.java b/src/main/java/mantle/client/pages/CraftingPage.java deleted file mode 100644 index 0af7be8..0000000 --- a/src/main/java/mantle/client/pages/CraftingPage.java +++ /dev/null @@ -1,140 +0,0 @@ -package mantle.client.pages; - -import mantle.lib.client.MantleClientRegistry; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class CraftingPage extends BookPage -{ - String text; - - String size; - - ItemStack[] icons; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - - nodes = element.getElementsByTagName("name"); - if (nodes != null) - { - this.icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); - } - - nodes = element.getElementsByTagName("size"); - if (nodes != null) - { - this.size = nodes.item(0).getTextContent(); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (isTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - if (this.size.equals("two")) - { - this.drawCraftingPage(this.text, this.icons, 2, localWidth, localHeight + 12); - } - if (this.size.equals("three")) - { - this.drawCraftingPage(this.text, this.icons, 3, localWidth + (this.side != 1 ? 6 : 0), localHeight + 12); - } - } - - public void drawCraftingPage(String info, ItemStack[] icons, int recipeSize, int localWidth, int localHeight) - { - if (info != null) - { - this.manual.fonts.drawString("\u00a7n" + info, localWidth + 50, localHeight + 4, 0); - } - - GL11.glScalef(2f, 2f, 2f); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - this.manual.renderitem.zLevel = 100; - - if (recipeSize == 2) - { - this.manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2); - if (icons[0].stackSize > 1) - { - this.manual.renderitem.renderItemOverlayIntoGUI(this.manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); - } - for (int i = 0; i < icons.length - 1; i++) - { - if (icons[i + 1] != null) - { - this.manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth + 14 + 36 * (i % 2)) / 2, (localHeight + 36 * (i / 2) + 52) / 2); - } - } - } - - if (recipeSize == 3) - { - this.manual.renderitem.renderItemAndEffectIntoGUI(icons[0], (localWidth + 138) / 2, (localHeight + 70) / 2); - if (icons[0].stackSize > 1) - { - this.manual.renderitem.renderItemOverlayIntoGUI(this.manual.fonts, icons[0], (localWidth + 126) / 2, (localHeight + 68) / 2, String.valueOf(icons[0].stackSize)); - } - for (int i = 0; i < icons.length - 1; i++) - { - if (icons[i + 1] != null) - { - this.manual.renderitem.renderItemAndEffectIntoGUI(icons[i + 1], (localWidth - 2 + 36 * (i % 3)) / 2, (localHeight + 36 * (i / 3) + 34) / 2); - } - } - } - - this.manual.renderitem.zLevel = 0; - GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } - - @Override - public void renderBackgroundLayer(int localwidth, int localheight) - { - if (this.size.equals("two")) - { - this.drawBackground(2, localwidth, localheight + 12); - } - - if (this.size.equals("three")) - { - this.drawBackground(3, localwidth + (this.side != 1 ? 6 : 0), localheight + 12); - } - } - - private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookcrafting.png"); - - public void drawBackground(int size, int localWidth, int localHeight) - { - this.manual.getMC().getTextureManager().bindTexture(background); - if (size == 2) - { - this.manual.drawTexturedModalRect(localWidth + 8, localHeight + 46, 0, 116, 154, 78); - } - if (size == 3) - { - this.manual.drawTexturedModalRect(localWidth - 8, localHeight + 28, 0, 0, 183, 114); - } - } - -} diff --git a/src/main/java/mantle/client/pages/FurnacePage.java b/src/main/java/mantle/client/pages/FurnacePage.java deleted file mode 100644 index e58ec75..0000000 --- a/src/main/java/mantle/client/pages/FurnacePage.java +++ /dev/null @@ -1,75 +0,0 @@ -package mantle.client.pages; - -import mantle.lib.client.MantleClientRegistry; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class FurnacePage extends BookPage -{ - String text; - - ItemStack[] icons; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - - nodes = element.getElementsByTagName("recipe"); - if (nodes != null) - { - this.icons = MantleClientRegistry.getRecipeIcons(nodes.item(0).getTextContent()); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (this.text != null) - { - if (isTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - this.manual.fonts.drawString("\u00a7n" + this.text, localWidth + 50, localHeight + 4, 0); - } - GL11.glScalef(2f, 2f, 2f); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - this.manual.renderitem.zLevel = 100; - - this.manual.renderitem.renderItemAndEffectIntoGUI(MantleClientRegistry.getManualIcon("coal"), (localWidth + 38) / 2, (localHeight + 110) / 2); - this.manual.renderitem.renderItemAndEffectIntoGUI(this.icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2); - this.manual.renderitem.renderItemAndEffectIntoGUI(this.icons[1], (localWidth + 38) / 2, (localHeight + 38) / 2); - - if (this.icons[0].stackSize > 1) - { - this.manual.renderitem.renderItemOverlayIntoGUI(this.manual.fonts, this.icons[0], (localWidth + 106) / 2, (localHeight + 74) / 2, String.valueOf(this.icons[0].stackSize)); - } - - this.manual.renderitem.zLevel = 0; - GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } - - private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookfurnace.png"); - - @Override - public void renderBackgroundLayer(int localWidth, int localHeight) - { - this.manual.getMC().getTextureManager().bindTexture(background); - this.manual.drawTexturedModalRect(localWidth + 32, localHeight + 32, 0, 0, 111, 114); - } -} diff --git a/src/main/java/mantle/client/pages/PicturePage.java b/src/main/java/mantle/client/pages/PicturePage.java deleted file mode 100644 index b63edc8..0000000 --- a/src/main/java/mantle/client/pages/PicturePage.java +++ /dev/null @@ -1,70 +0,0 @@ -package mantle.client.pages; - -import static mantle.lib.CoreRepo.logger; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class PicturePage extends BookPage -{ - String text; - - String location; - - ResourceLocation background; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - nodes = element.getElementsByTagName("location"); - if (nodes != null) - { - this.location = nodes.item(0).getTextContent(); - this.background = new ResourceLocation(this.location); - if (this.background == null) - { - logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(location)!"); - } - } - - //this borked stuffs somehow unless someone is interested in using it this stays disabled for now - /* nodes = element.getElementsByTagName("bookImage"); - if (nodes != null) - { - //TODO 1.7 null check all of this - background = MantleClientRegistry.imageCache.get(nodes.item(0).getTextContent()).resource; - if(background == null){ - logger.warn(nodes.item(0).getTextContent() + " could not be found in the image cache(bookimage)!"); - } - }*/ - - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (isTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - this.manual.fonts.drawSplitString(this.text, localWidth + 8, localHeight, 178, 0); - } - - @Override - public void renderBackgroundLayer(int localWidth, int localHeight) - { - if (this.background != null) - { - this.manual.getMC().getTextureManager().bindTexture(this.background); - } - //manual.getMC().renderEngine.bindTexture(location); - this.manual.drawTexturedModalRect(localWidth, localHeight + 12, 0, 0, 170, 144); - } -} diff --git a/src/main/java/mantle/client/pages/SectionPage.java b/src/main/java/mantle/client/pages/SectionPage.java deleted file mode 100644 index 972f580..0000000 --- a/src/main/java/mantle/client/pages/SectionPage.java +++ /dev/null @@ -1,41 +0,0 @@ -package mantle.client.pages; - -import net.minecraft.util.StatCollector; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class SectionPage extends BookPage -{ - String title; - - String body; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("title"); - if (nodes != null) - { - this.title = nodes.item(0).getTextContent(); - } - - nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.body = nodes.item(0).getTextContent(); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (isTranslatable) - { - this.title = StatCollector.translateToLocal(this.title); - this.body = StatCollector.translateToLocal(this.body); - } - this.manual.fonts.drawSplitString("\u00a7n" + this.title, localWidth + 70, localHeight + 4, 178, 0); - this.manual.fonts.drawSplitString(this.body, localWidth, localHeight + 16, 190, 0); - } -} diff --git a/src/main/java/mantle/client/pages/SidebarPage.java b/src/main/java/mantle/client/pages/SidebarPage.java deleted file mode 100644 index adb4ad6..0000000 --- a/src/main/java/mantle/client/pages/SidebarPage.java +++ /dev/null @@ -1,71 +0,0 @@ -package mantle.client.pages; - -import mantle.lib.client.MantleClientRegistry; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class SidebarPage extends BookPage -{ - String text; - - String[] iconText; - - ItemStack[] icons; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - - nodes = element.getElementsByTagName("item"); - this.iconText = new String[nodes.getLength()]; - this.icons = new ItemStack[nodes.getLength()]; - for (int i = 0; i < nodes.getLength(); i++) - { - NodeList children = nodes.item(i).getChildNodes(); - this.iconText[i] = children.item(1).getTextContent(); - this.icons[i] = MantleClientRegistry.getManualIcon(children.item(3).getTextContent()); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (isTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - this.manual.fonts.drawSplitString(this.text, localWidth, localHeight, 178, 0); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - RenderHelper.enableGUIStandardItemLighting(); - this.manual.renderitem.zLevel = 100; - int offset = this.text.length() / 4 + 10; - for (int i = 0; i < this.icons.length; i++) - { - if (isTranslatable) - { - this.iconText[i] = StatCollector.translateToLocal(this.iconText[i]); - } - this.manual.renderitem.renderItemIntoGUI(this.icons[i], localWidth + 8, localHeight + 18 * i + offset); - int yOffset = 39; - if (this.iconText[i].length() > 40) - { - yOffset = 34; - } - this.manual.fonts.drawSplitString(this.iconText[i], localWidth + 30, localHeight + 18 * i + offset, 140, 0); - } - this.manual.renderitem.zLevel = 0; - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - } -} diff --git a/src/main/java/mantle/client/pages/TextPage.java b/src/main/java/mantle/client/pages/TextPage.java deleted file mode 100644 index 09e7fbe..0000000 --- a/src/main/java/mantle/client/pages/TextPage.java +++ /dev/null @@ -1,31 +0,0 @@ -package mantle.client.pages; - -import net.minecraft.util.StatCollector; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class TextPage extends BookPage -{ - String text; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean IsTranslatable) - { - if (IsTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - this.manual.fonts.drawSplitString(this.text, localWidth, localHeight, 178, 0); - } -} diff --git a/src/main/java/mantle/client/pages/TitlePage.java b/src/main/java/mantle/client/pages/TitlePage.java deleted file mode 100644 index fdc9590..0000000 --- a/src/main/java/mantle/client/pages/TitlePage.java +++ /dev/null @@ -1,31 +0,0 @@ -package mantle.client.pages; - -import net.minecraft.util.StatCollector; - -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; - -public class TitlePage extends BookPage -{ - String text; - - @Override - public void readPageFromXML(Element element) - { - NodeList nodes = element.getElementsByTagName("text"); - if (nodes != null) - { - this.text = nodes.item(0).getTextContent(); - } - } - - @Override - public void renderContentLayer(int localWidth, int localHeight, boolean isTranslatable) - { - if (isTranslatable) - { - this.text = StatCollector.translateToLocal(this.text); - } - this.manual.fonts.drawSplitString(this.text, localWidth, localHeight, 178, 0); - } -} diff --git a/src/main/java/mantle/common/ComparisonHelper.java b/src/main/java/mantle/common/ComparisonHelper.java deleted file mode 100644 index 55a8fba..0000000 --- a/src/main/java/mantle/common/ComparisonHelper.java +++ /dev/null @@ -1,29 +0,0 @@ -package mantle.common; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class ComparisonHelper -{ - public static boolean areEquivalent(Item item, Block block) - { - return item == Item.getItemFromBlock(block); - } - - public static boolean areEquivalent(Block block1, Block block2) - { - return block1 == block2; - } - - public static boolean areEquivalent(Item item1, Item item2) - { - return item1 == item2; - } - - //@TODO make this a more verbose comparison - public static boolean areEquivalent(ItemStack is1, ItemStack is2) - { - return is1.getItem() == is2.getItem(); - } -} diff --git a/src/main/java/mantle/common/IDDumps.java b/src/main/java/mantle/common/IDDumps.java deleted file mode 100644 index 4e9da89..0000000 --- a/src/main/java/mantle/common/IDDumps.java +++ /dev/null @@ -1,47 +0,0 @@ -package mantle.common; - -import static mantle.lib.CoreRepo.logger; -import mantle.lib.CoreConfig; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.potion.Potion; -import net.minecraft.world.biome.BiomeGenBase; - -public class IDDumps -{ - public static void dump() - { - if (CoreConfig.dumpBiomeIDs) - { - for (BiomeGenBase b : BiomeGenBase.getBiomeGenArray()) - { - if (b != null && b.biomeName != null) - { - logger.info("Biome ID & Name: " + b.biomeID + " " + b.biomeName); - } - } - } - if (CoreConfig.dumpPotionIDs) - { - for (Potion p : Potion.potionTypes) - { - if (p != null && p.getName() != null) - { - - logger.info("Potion ID & name: " + p.getId() + " " + p.getName()); - } - } - } - if (CoreConfig.dumpEnchantIDs) - { - for (Enchantment e : Enchantment.enchantmentsBookList) - { - if (e != null && e.getName() != null) - { - - logger.info("Enchantment ID & name: " + e.effectId + " " + e.getName()); - } - } - } - } - -} diff --git a/src/main/java/mantle/common/MProxyCommon.java b/src/main/java/mantle/common/MProxyCommon.java deleted file mode 100644 index 5efc875..0000000 --- a/src/main/java/mantle/common/MProxyCommon.java +++ /dev/null @@ -1,34 +0,0 @@ -package mantle.common; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; -import net.minecraftforge.fml.common.network.IGuiHandler; - -public class MProxyCommon implements IGuiHandler -{ - public static int manualGuiID = -1; - - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - if (ID < 0) - { - return null; - } - return null; - } - - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return null; - } - - public void registerRenderer() - { - } - - public void readManuals() - { - } -} diff --git a/src/main/java/mantle/common/network/AbstractPacket.java b/src/main/java/mantle/common/network/AbstractPacket.java deleted file mode 100644 index 39d0151..0000000 --- a/src/main/java/mantle/common/network/AbstractPacket.java +++ /dev/null @@ -1,57 +0,0 @@ -package mantle.common.network; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import net.minecraft.entity.player.EntityPlayer; - -/** - * AbstractPacket class. Should be the parent of all packets wishing to use the - * PacketPipeline. - * - * @author sirgingalot - */ -public abstract class AbstractPacket -{ - - /** - * Encode the packet data into the ByteBuf stream. Complex data sets may - * need specific data handlers (See - * @link{cpw.mods.fml.common.network.ByteBuffUtils}) - * - * @param ctx - * channel context - * @param buffer - * the buffer to encode into - */ - public abstract void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer); - - /** - * Decode the packet data from the ByteBuf stream. Complex data sets may - * need specific data handlers (See - * @link{cpw.mods.fml.common.network.ByteBuffUtils}) - * - * @param ctx - * channel context - * @param buffer - * the buffer to decode from - */ - public abstract void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer); - - /** - * Handle a packet on the client side. Note this occurs after decoding has - * completed. - * - * @param player - * the player reference - */ - public abstract void handleClientSide(EntityPlayer player); - - /** - * Handle a packet on the server side. Note this occurs after decoding has - * completed. - * - * @param player - * the player reference - */ - public abstract void handleServerSide(EntityPlayer player); -} diff --git a/src/main/java/mantle/common/network/PacketUpdateTE.java b/src/main/java/mantle/common/network/PacketUpdateTE.java deleted file mode 100644 index 18ecd13..0000000 --- a/src/main/java/mantle/common/network/PacketUpdateTE.java +++ /dev/null @@ -1,76 +0,0 @@ -package mantle.common.network; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.BlockPos; - -public class PacketUpdateTE extends AbstractPacket -{ - private BlockPos pos; - - private NBTTagCompound data; - - public PacketUpdateTE() - { - - } - - public PacketUpdateTE(BlockPos pos, NBTTagCompound data) - { - this.pos = pos; - this.data = data; - } - - @Override - public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) - { - PacketBuffer pbuff = new PacketBuffer(buffer); - pbuff.writeInt(this.pos.getX()); - pbuff.writeShort(this.pos.getY()); - pbuff.writeInt(this.pos.getZ()); - try - { - pbuff.writeNBTTagCompoundToBuffer(this.data); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) - { - PacketBuffer pbuff = new PacketBuffer(buffer); - this.pos = new BlockPos(pbuff.readInt(), pbuff.readShort(), pbuff.readInt()); - try - { - this.data = pbuff.readNBTTagCompoundFromBuffer(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public void handleClientSide(EntityPlayer player) - { - TileEntity te = player.worldObj.getTileEntity(this.pos); - - if (te != null) - { - te.readFromNBT(this.data); - } - } - - @Override - public void handleServerSide(EntityPlayer player) - { - } - -} diff --git a/src/main/java/mantle/crash/CallableSuppConfig.java b/src/main/java/mantle/crash/CallableSuppConfig.java deleted file mode 100644 index 089033c..0000000 --- a/src/main/java/mantle/crash/CallableSuppConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package mantle.crash; - -import net.minecraftforge.fml.common.ICrashCallable; - -/** - * Crash Callable for supported environments. - * - * @author Sunstrike - */ -public class CallableSuppConfig implements ICrashCallable -{ - - private String modId; - - public CallableSuppConfig(String modId) - { - this.modId = modId; - } - - @Override - public String call() throws Exception - { - return "Environment healthy."; - } - - @Override - public String getLabel() - { - return this.modId + " Environment"; - } - -} diff --git a/src/main/java/mantle/crash/CallableUnsuppConfig.java b/src/main/java/mantle/crash/CallableUnsuppConfig.java deleted file mode 100644 index 5e0b0bb..0000000 --- a/src/main/java/mantle/crash/CallableUnsuppConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package mantle.crash; - -import java.util.List; - -import net.minecraftforge.fml.common.ICrashCallable; - -// Crash handler for when an unsupported mod is running alongside us -public class CallableUnsuppConfig implements ICrashCallable -{ - - private String modId; - - private List modIds; - - public CallableUnsuppConfig(String modId, List modIds) - { - this.modId = modId; - this.modIds = modIds; - } - - @Override - public String getLabel() - { - return this.modId + " Environment"; - } - - @Override - public String call() throws Exception - { - String str = "DO NOT REPORT THIS CRASH! Unsupported mods in environment: "; - Boolean firstEntry = true; - for (String id : this.modIds) - { - str = str + (firstEntry ? id : ", " + id); - firstEntry = false; - } - - return str; - } - -} diff --git a/src/main/java/mantle/debug/DebugData.java b/src/main/java/mantle/debug/DebugData.java deleted file mode 100644 index 94b6a4c..0000000 --- a/src/main/java/mantle/debug/DebugData.java +++ /dev/null @@ -1,28 +0,0 @@ -package mantle.debug; - -import net.minecraft.entity.player.EntityPlayer; - -/** - * Encapsulation for debug information - * - * @author Sunstrike - */ -public class DebugData -{ - - public final EntityPlayer player; - - @SuppressWarnings("rawtypes") - public final Class cl; - - public final String[] strings; - - @SuppressWarnings("rawtypes") - public DebugData(EntityPlayer player, Class cl, String[] strings) - { - this.player = player; - this.cl = cl; - this.strings = strings; - } - -} diff --git a/src/main/java/mantle/debug/DebugHelper.java b/src/main/java/mantle/debug/DebugHelper.java deleted file mode 100644 index 88c4c30..0000000 --- a/src/main/java/mantle/debug/DebugHelper.java +++ /dev/null @@ -1,54 +0,0 @@ -package mantle.debug; - -import static mantle.lib.CoreConfig.debug_enableChat; -import static mantle.lib.CoreConfig.debug_enableConsole; -import static mantle.lib.CoreRepo.logger; -import mantle.player.PlayerUtils; -import net.minecraft.entity.player.EntityPlayer; - -/** - * IDebuggable helper - * - * @author Sunstrike - */ -public class DebugHelper -{ - - private DebugHelper() - { - // No instantiation - } - - public static void handleDebugData(DebugData data) - { - if (debug_enableChat) - { - handleChatDebug(data); - } - if (debug_enableConsole) - { - handleConsoleDebug(data); - } - } - - private static void handleChatDebug(DebugData data) - { - EntityPlayer player = data.player; - String prefix = "[" + data.cl.getSimpleName() + "] "; - for (String str : data.strings) - { - PlayerUtils.sendChatMessage(player, prefix + str); - } - } - - private static void handleConsoleDebug(DebugData data) - { - String player = data.player.getGameProfile().getName(); - String prefix = "[" + player + ":" + data.cl.getSimpleName() + "] "; - for (String str : data.strings) - { - logger.info(prefix + str); - } - } - -} diff --git a/src/main/java/mantle/debug/IDebuggable.java b/src/main/java/mantle/debug/IDebuggable.java deleted file mode 100644 index 8f3fee9..0000000 --- a/src/main/java/mantle/debug/IDebuggable.java +++ /dev/null @@ -1,17 +0,0 @@ -package mantle.debug; - -import net.minecraft.entity.player.EntityPlayer; - -/** - * Interface for TEs which can be whacked with debug tools (sticks normally) for information. - * - * This is automatically used if the block containing the TE is a subclass of MantleBlock. - * - * @author Sunstrike - */ -public interface IDebuggable -{ - - public DebugData getDebugInfo(EntityPlayer player); - -} diff --git a/src/main/java/mantle/event/ManualOpenEvent.java b/src/main/java/mantle/event/ManualOpenEvent.java deleted file mode 100644 index 8c3bf34..0000000 --- a/src/main/java/mantle/event/ManualOpenEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -package mantle.event; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.eventhandler.Event; - -public abstract class ManualOpenEvent extends Event -{ - - public ItemStack bookStack; - - public EntityPlayer player; - - public ManualOpenEvent(ItemStack book, EntityPlayer player) - { - this.bookStack = book; - this.player = player; - } - - public static class Pre extends ManualOpenEvent - { - public Pre(ItemStack book, EntityPlayer player) - { - super(book, player); - } - } - - public static class Post extends ManualOpenEvent - { - public Post(ItemStack book, EntityPlayer player) - { - super(book, player); - } - } -} diff --git a/src/main/java/mantle/event/Migration.java b/src/main/java/mantle/event/Migration.java deleted file mode 100644 index 699dfa4..0000000 --- a/src/main/java/mantle/event/Migration.java +++ /dev/null @@ -1,104 +0,0 @@ -package mantle.event; - -import static mantle.lib.CoreRepo.logger; - -import java.util.List; -import java.util.Map; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; -import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -public abstract class Migration -{ - Map remapItem = Maps.newHashMap(); - - Map remapBlock = Maps.newHashMap(); - - List ignore = Lists.newArrayList(); - - private ModContainer mod; - - private String modID; - - /* - * Store the mod ID so we can convert e.g "item" to "mod:item" later. - */ - public Migration(ModContainer m) - { - this.mod = m; - this.modID = m.getModId(); - } - - /* - * Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!). - * Use an encapsulated object of form Map to store this. - * The prefix will be created using the ID given during construction during processing. - */ - public void addMigration(String old, Item newItem) - { - this.remapItem.put(this.modID + ":" + old, newItem); - } - - /* - * Add a new migration to the internal replacement map e.g. "olditem" -> "newitem" (without ID prefix!). - * Use an encapsulated object of form Map to store this. - * The prefix will be created using the ID given during construction during processing. - */ - public void addMigration(String old, Block newBlock) - { - this.remapBlock.put(this.modID + ":" + old, newBlock); - } - - /* - * Register an old ID that's been removed entirely. This isn't suitable for renaming operations! - * Store this in a List seperate to the rename mapping. - * @param id ID to be removed (without ID prefix!). - */ - public void addRemoval(String id) - { - this.ignore.add(this.modID + ":" + id); - } - - /* - * This must be called from your mod's main class as it requires @EventHandler notation - * This works on the assumption the FML event will have a list of string IDs that are missing. - * During this phase, check for old IDs and remap as needed, or destroy ones marked for removal. - */ - public void processMigrationEvent(FMLMissingMappingsEvent event) - { - if ((!this.remapBlock.isEmpty() || !this.remapItem.isEmpty())) - { - event.applyModContainer(this.mod); - List l = event.get(); - if (l != null) - { - for (MissingMapping miss : event.get()) - { - if (this.remapItem.containsKey(miss.name)) - { - miss.remap(this.remapItem.get(miss.name)); - } - else if (this.remapBlock.containsKey(miss.name)) - { - miss.remap(this.remapBlock.get(miss.name)); - } - else if (this.ignore.contains(miss.name)) - { - miss.ignore(); - } - } - } - else - { - logger.error("migration list from FML empty for mod " + this.modID); - } - - } - } -} diff --git a/src/main/java/mantle/items/ItemUtils.java b/src/main/java/mantle/items/ItemUtils.java deleted file mode 100644 index c8ac743..0000000 --- a/src/main/java/mantle/items/ItemUtils.java +++ /dev/null @@ -1,17 +0,0 @@ -package mantle.items; - -import net.minecraft.item.Item; -import net.minecraftforge.fml.common.registry.GameData; - -public class ItemUtils -{ - public static String getUniqueName(Item item) - { - return (String) GameData.getItemRegistry().getNameForObject(item); - } - - public static Item getItemFromUniqueName(String uniqueName) - { - return GameData.getItemRegistry().getObject(uniqueName); - } -} diff --git a/src/main/java/mantle/items/Manual.java b/src/main/java/mantle/items/Manual.java deleted file mode 100644 index 84194cb..0000000 --- a/src/main/java/mantle/items/Manual.java +++ /dev/null @@ -1,77 +0,0 @@ -package mantle.items; - -import java.util.List; - -import mantle.Mantle; -import mantle.books.BookDataStore; -import mantle.event.ManualOpenEvent; -import mantle.items.abstracts.CraftingItem; -import mantle.lib.CoreRepo; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public class Manual extends CraftingItem -{ - - public final String modID; - - static String[] name = new String[] { "beginner", "toolstation", "smeltery", "diary" }; - - static String[] textureName = new String[] { "tinkerbook_diary", "tinkerbook_toolstation", "tinkerbook_smeltery", "tinkerbook_blue" }; - - public Manual() - { - super(name, textureName, "", "mantle", null); - this.modID = CoreRepo.modId; - } - - public void updateManual() - { - this.updateData(new String[] { "test" }, new String[] { "mantlebook_blue" }, "", "mantle"); - } - - public Manual(String[] name, String[] textureName, String folder, String modTexturePrefix, CreativeTabs tab, String modID) - { - super(name, textureName, "", "mantle", tab); - this.modID = modID; - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - ManualOpenEvent.Pre preOpenEvent = new ManualOpenEvent.Pre(stack, player); - MinecraftForge.EVENT_BUS.post(preOpenEvent); - - player.openGui(Mantle.instance, mantle.client.MProxyClient.manualGuiID, world, 0, 0, 0); - ManualOpenEvent.Post postOpenEvent = new ManualOpenEvent.Post(stack, player); - MinecraftForge.EVENT_BUS.post(postOpenEvent); - - return stack; - } - - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) - { - list.add("\u00a7o" + StatCollector.translateToLocal(BookDataStore.getBookfromID(stack.getItemDamage()).toolTip)); - } - - @Override - public String getUnlocalizedName() - { - return this.modID + ":" + super.getUnlocalizedName(); - } - - @Override - public String getUnlocalizedName(ItemStack par1ItemStack) - { - return super.getUnlocalizedName(par1ItemStack); - } -} diff --git a/src/main/java/mantle/items/abstracts/CraftingItem.java b/src/main/java/mantle/items/abstracts/CraftingItem.java deleted file mode 100644 index c54d848..0000000 --- a/src/main/java/mantle/items/abstracts/CraftingItem.java +++ /dev/null @@ -1,63 +0,0 @@ -package mantle.items.abstracts; - -import java.util.List; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; - -public class CraftingItem extends Item -{ - public String modTexPrefix; - - public String[] textureNames; - - public String[] unlocalizedNames; - - public String folder; - - public CraftingItem(String[] names, String[] tex, String folder, String modTexturePrefix, CreativeTabs tab) - { - super(); - this.modTexPrefix = modTexturePrefix; - if (tab != null) - { - this.setCreativeTab(tab); - } - this.setMaxDamage(0); - this.setHasSubtypes(true); - this.textureNames = tex; - this.unlocalizedNames = names; - this.folder = folder; - } - - public void updateData(String[] names, String[] tex, String folder, String modTexturePrefix) - { - this.modTexPrefix = modTexturePrefix; - this.textureNames = tex; - this.unlocalizedNames = names; - this.folder = folder; - } - - @Override - public String getUnlocalizedName(ItemStack stack) - { - int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, this.unlocalizedNames.length); - return this.getUnlocalizedName() + "." + this.unlocalizedNames[arr]; - } - - @Override - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void getSubItems(Item b, CreativeTabs tab, List list) - { - for (int i = 0; i < this.unlocalizedNames.length; i++) - { - if (!(this.textureNames[i].equals(""))) - { - list.add(new ItemStack(b, 1, i)); - } - } - } - -} diff --git a/src/main/java/mantle/items/iface/IDebugItem.java b/src/main/java/mantle/items/iface/IDebugItem.java deleted file mode 100644 index bfb30fa..0000000 --- a/src/main/java/mantle/items/iface/IDebugItem.java +++ /dev/null @@ -1,6 +0,0 @@ -package mantle.items.iface; - -public interface IDebugItem -{ - // Will do more later; this is here for now to enable mods to use the debug stick functionality with their own debug items/tools. -} diff --git a/src/main/java/mantle/lib/CoreConfig.java b/src/main/java/mantle/lib/CoreConfig.java deleted file mode 100644 index e0e5d20..0000000 --- a/src/main/java/mantle/lib/CoreConfig.java +++ /dev/null @@ -1,109 +0,0 @@ -package mantle.lib; - -import static mantle.lib.CoreRepo.logger; -import static mantle.lib.CoreRepo.modId; - -import java.io.File; -import java.io.IOException; - -import mantle.books.external.ZipLoader; -import net.minecraftforge.common.config.Configuration; - -import org.apache.commons.io.FilenameUtils; - -/** - * Mantle configuration handler - * - * Stores configuration data for Mantle, and handles save/load. - * - * @author Sunstrike - */ -public class CoreConfig -{ - static Configuration config; - - public static File configFolder; - - /** - * Loads state from the configuration folder. - * - * @param mainConfigFolder Configuration folder (as a Java File) - */ - public static void loadConfiguration(File mainConfigFolder) - { - logger.info("Loading configuration from disk."); - try - { - configFolder = new File(mainConfigFolder.getCanonicalPath(), "SlimeKnights"); - if (!configFolder.exists()) - { - configFolder.mkdirs(); - } - } - catch (IOException e) - { - logger.error("Error getting/creating Mantle configuration directory: " + e.getMessage()); - } - - config = new Configuration(new File(configFolder, (modId + ".cfg"))); - config.load(); - - silenceEnvChecks = config.get("Environment", "unsupportedLogging", silenceEnvChecks).getBoolean(silenceEnvChecks); - - debug_enableConsole = config.get("DebugHelpers", "enableConsole", debug_enableConsole).getBoolean(debug_enableConsole); - debug_enableChat = config.get("DebugHelpers", "enableChat", debug_enableChat).getBoolean(debug_enableChat); - - dumpBiomeIDs = config.get("DebugHelpers", "Dump BIOME ID's in log", dumpBiomeIDs).getBoolean(dumpBiomeIDs); - dumpPotionIDs = config.get("DebugHelpers", "Dump POTION ID's in log", dumpPotionIDs).getBoolean(dumpPotionIDs); - dumpEnchantIDs = config.get("DebugHelpers", "Dump ENCHANT ID's in log", dumpEnchantIDs).getBoolean(dumpEnchantIDs); - - //check for debugging overrides in system environment - checkSysOverrides(); - config.save(); - logger.info("Configuration load completed."); - } - - /** - * Checks for MANTLE_DBGCONSOLE/CHAT config overrides in system environment for compile time testing, and other dev work. - **/ - private static void checkSysOverrides() - { - if (System.getenv("MANTLE_DBGCONSOLE") != null) - { - debug_enableConsole = true; - logger.info("Mantle Console debugging override enabled via system properties."); - } - if (System.getenv("MANTLE_DBGCHAT") != null) - { - debug_enableChat = true; - logger.info("Mantle Chat debugging override enabled via system properties."); - } - } - - public static void loadBookLocations() - { - for (File f : configFolder.listFiles()) - { - if (f.isFile() && FilenameUtils.getExtension(f.getAbsolutePath()).equalsIgnoreCase("zip")) - { - ZipLoader.loadZip(f); - } - } - } - - // BEGIN CONFIG VARS - // Env Checks - public static boolean silenceEnvChecks = false; - - // Debug Helpers - public static boolean debug_enableConsole = false; - - public static boolean debug_enableChat = false; - - public static boolean dumpBiomeIDs = false; - - public static boolean dumpPotionIDs = false; - - public static boolean dumpEnchantIDs = false; - -} diff --git a/src/main/java/mantle/lib/CoreRepo.java b/src/main/java/mantle/lib/CoreRepo.java deleted file mode 100644 index 7419f54..0000000 --- a/src/main/java/mantle/lib/CoreRepo.java +++ /dev/null @@ -1,24 +0,0 @@ -package mantle.lib; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -/** - * Mantle object repository - * - * Storage area for objects accessible throughout Mantle, such as loggers - * - * @author Sunstrike - */ -public final class CoreRepo -{ - - public static final String modId = "mantle"; - - public static final String modName = "Mantle"; - - public static final String modVersion = "${version}"; - - public static final Logger logger = LogManager.getLogger("Mantle"); - -} diff --git a/src/main/java/mantle/lib/TabTools.java b/src/main/java/mantle/lib/TabTools.java deleted file mode 100644 index fe93f97..0000000 --- a/src/main/java/mantle/lib/TabTools.java +++ /dev/null @@ -1,32 +0,0 @@ -package mantle.lib; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class TabTools extends CreativeTabs -{ - ItemStack display; - - public TabTools(String label) - { - super(label); - } - - public void init(ItemStack stack) - { - this.display = stack; - } - - @Override - public ItemStack getIconItemStack() - { - return this.display; - } - - @Override - public Item getTabIconItem() - { - return this.display.getItem(); - } -} diff --git a/src/main/java/mantle/lib/client/MantleClientRegistry.java b/src/main/java/mantle/lib/client/MantleClientRegistry.java deleted file mode 100644 index e8b1e9b..0000000 --- a/src/main/java/mantle/lib/client/MantleClientRegistry.java +++ /dev/null @@ -1,71 +0,0 @@ -package mantle.lib.client; - -import java.util.HashMap; -import java.util.Map; - -import mantle.books.client.BookImage; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import com.google.common.collect.Maps; - -public class MantleClientRegistry -{ - public static Map manualIcons = Maps.newHashMap(); - - public static Map recipeIcons = Maps.newHashMap(); - - public static HashMap imageCache = Maps.newHashMap(); - - public static ItemStack defaultStack = new ItemStack(Items.iron_ingot); - - public static BookImage getBookImageFromCache(String s) - { - return imageCache.get(s); - } - - public static void registerManualIcon(String name, ItemStack stack) - { - manualIcons.put(name, stack); - } - - public static ItemStack getManualIcon(String textContent) - { - ItemStack stack = manualIcons.get(textContent); - if (stack != null) - { - return stack; - } - return defaultStack; - } - - public static void registerManualSmallRecipe(String name, ItemStack output, ItemStack... stacks) - { - ItemStack[] recipe = new ItemStack[5]; - recipe[0] = output; - System.arraycopy(stacks, 0, recipe, 1, 4); - recipeIcons.put(name, recipe); - } - - public static void registerManualLargeRecipe(String name, ItemStack output, ItemStack... stacks) - { - ItemStack[] recipe = new ItemStack[10]; - recipe[0] = output; - System.arraycopy(stacks, 0, recipe, 1, 9); - recipeIcons.put(name, recipe); - } - - public static void registerManualFurnaceRecipe(String name, ItemStack output, ItemStack input) - { - ItemStack[] recipe = new ItemStack[2]; - recipe[0] = output; - recipe[1] = input; - recipeIcons.put(name, recipe); - } - - public static ItemStack[] getRecipeIcons(String recipeName) - { - return recipeIcons.get(recipeName); - } - -} diff --git a/src/main/java/mantle/lib/environment/EnvironmentChecks.java b/src/main/java/mantle/lib/environment/EnvironmentChecks.java deleted file mode 100644 index 1ad9f01..0000000 --- a/src/main/java/mantle/lib/environment/EnvironmentChecks.java +++ /dev/null @@ -1,84 +0,0 @@ -package mantle.lib.environment; - -import static mantle.lib.CoreRepo.logger; -import static mantle.lib.CoreRepo.modId; - -import java.util.List; - -import mantle.crash.CallableSuppConfig; -import mantle.crash.CallableUnsuppConfig; -import mantle.lib.CoreConfig; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.ICrashCallable; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.relauncher.Side; - -import com.google.common.collect.Lists; - -/** - * Environment Checks - * - * Checks the runtime environment is safe for use. If not, registers warnings and adds a suitable crash callable. - * - * @author Sunstrike - */ -public class EnvironmentChecks -{ - - private EnvironmentChecks() - { - } // Singleton - - // Usable by other mods to detect Optifine. - public static boolean hasOptifine = false; - - /** - * Checks for conflicting stuff in environment; adds callable to any crash logs if so. - * Note: This code adds additional data to crashlogs. It does not trigger any crashes. - */ - @SuppressWarnings("rawtypes") - public static void verifyEnvironmentSanity() - { - List modIds = Lists.newArrayList(); - - if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine() || Loader.isModLoaded("optifine")) - { - if (!CoreConfig.silenceEnvChecks) - { - logger.error("[Environment Checks] Optifine detected. This may cause issues due to base edits or ASM usage."); - } - hasOptifine = true; - modIds.add("optifine"); - } - - try - { - Class cl = Class.forName("org.bukkit.Bukkit"); - if (cl != null) - { - if (!CoreConfig.silenceEnvChecks) - { - logger.error("[Environment Checks] Bukkit implementation detected. This may cause issues. Bukkit implementations include Craftbukkit and spigot. Please try Sponge instead"); - } - modIds.add("bukkit"); - } - } - catch (Exception ex) - { - // No Bukkit in environment. - } - - if (modIds.size() == 0) - { - ICrashCallable callable = new CallableSuppConfig(modId); - FMLCommonHandler.instance().registerCrashCallable(callable); - } - else - { - ICrashCallable callable = new CallableUnsuppConfig(modId, modIds); - FMLCommonHandler.instance().registerCrashCallable(callable); - } - } - -} diff --git a/src/main/java/mantle/math/Dozenal.java b/src/main/java/mantle/math/Dozenal.java deleted file mode 100644 index ea8ec13..0000000 --- a/src/main/java/mantle/math/Dozenal.java +++ /dev/null @@ -1,87 +0,0 @@ -package mantle.math; - -/** - * Dozenal Converter - * - * Converts decimals into dozenal. - * - * @author mDiyo - */ - -import java.util.LinkedList; - -import com.google.common.collect.Lists; - -public class Dozenal -{ - - @SuppressWarnings("unused") - public static String convertToDozenal(byte i) - { - return convertDecimal(i); - } - - @SuppressWarnings("unused") - public static String convertToDozenal(short i) - { - return convertDecimal(i); - } - - @SuppressWarnings("unused") - public static String convertToDozenal(int i) - { - return convertDecimal(i); - } - - public static String convertDecimal(int i) - { - int num = i; - LinkedList list = Lists.newLinkedList(); - while (num > 0) - { - list.add(getDozenalCharacter(num % 12)); - num /= 12; - } - StringBuilder builder = new StringBuilder(); - for (int iter = list.size() - 1; iter > 0; iter--) - { - builder.append(list.get(iter)); - } - return builder.toString(); - } - - public static char getDozenalCharacter(int i) - { - assert i < 12 : "Base 10 number should be less than 12"; - - switch (i) - { - case 0: - return '0'; //Zero - case 1: - return '1'; //One - case 2: - return '2'; //Two - case 3: - return '3'; //Three - case 4: - return '4'; //Four - case 5: - return '5'; //Five - case 6: - return '6'; //Six - case 7: - return '7'; //Seven - case 8: - return '8'; //Eight - case 9: - return '9'; //Nine - case 10: - return 'X'; //Dec - case 11: - return 'E'; //El - } - - return 'Q'; - } -} diff --git a/src/main/java/mantle/player/PlayerUtils.java b/src/main/java/mantle/player/PlayerUtils.java deleted file mode 100644 index e97ffa4..0000000 --- a/src/main/java/mantle/player/PlayerUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package mantle.player; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; - -/** - * Misc utils for dealing with players. - * - * @author progwml6 - */ -public class PlayerUtils -{ - - /** - * Sends a given message to a specific player (due to 1.7 axing addChatMessage()) - */ - public static void sendChatMessage(EntityPlayer p, String message) - { - if (p != null && message != null && !message.isEmpty()) - { - p.addChatComponentMessage(new ChatComponentText(message)); - } - } - -} diff --git a/src/main/java/mantle/pulsar/config/ForgeCFG.java b/src/main/java/mantle/pulsar/config/ForgeCFG.java deleted file mode 100644 index c75e344..0000000 --- a/src/main/java/mantle/pulsar/config/ForgeCFG.java +++ /dev/null @@ -1,58 +0,0 @@ -package mantle.pulsar.config; - -import java.io.File; - -import mantle.pulsar.pulse.PulseMeta; -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.fml.common.Loader; - -/** - * Mantle specific pulsar addon class to support using the forge CFG format for configurations - * @author progwml6 - */ -public class ForgeCFG implements IConfiguration -{ - - private static Configuration config; - - private final String confPath; - - private final String description; - - /** - * Creates a new Configuration object. - * - * Do NOT make this the same as the overall mod configuration; it will clobber it! - * - * @param confName The config file name (without path or .cfg suffix) - * @param description The description for the group that the config entries will be placed in. - */ - public ForgeCFG(String confName, String description) - { - this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".cfg"; - this.description = description; - } - - @Override - public void load() - { - config = new Configuration(new File(this.confPath)); - config.load(); - } - - @Override - public boolean isModuleEnabled(PulseMeta meta) - { - return config.get(this.description, meta.getId(), meta.isEnabled(), meta.getDescription()).getBoolean(meta.isEnabled()); - } - - @Override - public void flush() - { - if (config.hasChanged()) - { - config.save(); - } - } - -} diff --git a/src/main/java/mantle/pulsar/config/IConfiguration.java b/src/main/java/mantle/pulsar/config/IConfiguration.java deleted file mode 100644 index cf14e24..0000000 --- a/src/main/java/mantle/pulsar/config/IConfiguration.java +++ /dev/null @@ -1,31 +0,0 @@ -package mantle.pulsar.config; - -import mantle.pulsar.pulse.PulseMeta; - -/** - * Interface for config handlers. - * - * @author Arkan - */ -public interface IConfiguration -{ - - /** - * Perform any configuration loading required. - */ - public void load(); - - /** - * Gets whether the given module is enabled in the config. - * - * @param meta The pulse metadata. - * @return Whether the module is enabled. - */ - public boolean isModuleEnabled(PulseMeta meta); - - /** - * Flush configuration to disk/database/whatever. - */ - public void flush(); - -} diff --git a/src/main/java/mantle/pulsar/control/PulseManager.java b/src/main/java/mantle/pulsar/control/PulseManager.java deleted file mode 100644 index 08e512a..0000000 --- a/src/main/java/mantle/pulsar/control/PulseManager.java +++ /dev/null @@ -1,294 +0,0 @@ -package mantle.pulsar.control; - -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; - -import mantle.pulsar.config.IConfiguration; -import mantle.pulsar.internal.Configuration; -import mantle.pulsar.internal.CrashHandler; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.internal.logging.LogManager; -import mantle.pulsar.pulse.Pulse; -import mantle.pulsar.pulse.PulseMeta; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.FMLModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.event.FMLEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; -import com.google.common.eventbus.SubscriberExceptionContext; -import com.google.common.eventbus.SubscriberExceptionHandler; - -/** - * Manager class for a given mods Pulses. - * - * This MUST be constructed by a mod BEFORE preinit as it registers on to the mod event bus - a static block would serve - * for this. No more Pulses can be registered after preinit has been caught, so assume preinit is too late to register - * new Pulses. - * - * Each Pulsar-enabled mod should create one and only one of these to manage its Pulses. - * - * @author Arkan - */ -@SuppressWarnings("unused") -public class PulseManager -{ - - private ILogger log; - - private final boolean useConfig; - - private final LinkedHashMap pulses = new LinkedHashMap(); - - private boolean blockNewRegistrations = false; - - private boolean configLoaded = false; - - private IConfiguration conf; - - private EventBus bus; - - private String id; - - /** - * Configuration-using constructor. - * - * This form creates a PulseManager that supports configuration of Pulses by file. - * - * @param configName The config file name. - */ - public PulseManager(String configName) - { - this.init(); - this.useConfig = true; - this.conf = new Configuration(configName, this.log); - } - - /** - * Custom configuration-using constructor. - * - * Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star. - * Whatever really. See {@link mantle.pulsar.config.IConfiguration}. - * - * @param config Configuration handler. - */ - public PulseManager(IConfiguration config) - { - this.init(); - this.useConfig = true; - this.conf = config; - } - - /** - * Shared initialiser code between all the constructors. - */ - private void init() - { - String modId = Loader.instance().activeModContainer().getModId(); - this.id = modId; - this.log = LogManager.getLogger("Pulsar-" + modId); - FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this)); - // Attach us to the mods FML bus and setup our own bus - this.bus = new EventBus(new BusExceptionHandler(modId)); - this.attachToContainerEventBus(this); - } - - /** - * Register a new Pulse with the manager. - * - * This CANNOT be done after preInit() has been invoked. - * - * @param pulse The Pulse to register. - */ - public void registerPulse(Object pulse) - { - if (this.blockNewRegistrations) - { - throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " - + pulse); - } - if (!this.configLoaded) - { - this.conf.load(); - this.configLoaded = true; - } - - String id, description, deps; - boolean forced, enabled, defaultEnabled, missingDeps = false; - - try - { - Pulse p = pulse.getClass().getAnnotation(Pulse.class); - id = p.id(); - description = p.description(); - deps = p.modsRequired(); - forced = p.forced(); - enabled = p.defaultEnable(); - defaultEnabled = p.defaultEnable(); - } - catch (NullPointerException ex) - { - throw new RuntimeException("Could not parse @Pulse annotation for Pulse: " + pulse); - } - - // Work around Java not allowing default-null fields. - if (description.equals("")) - { - description = null; - } - - if (!deps.equals("")) - { - String[] parsedDeps = deps.split(";"); - for (String s : parsedDeps) - { - if (!Loader.isModLoaded(s)) - { - this.log.info("Skipping Pulse " + id + "; missing dependency: " + s); - missingDeps = true; - enabled = false; - break; - } - } - } - - PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); - meta.setEnabled(!missingDeps && this.getEnabledFromConfig(meta)); - - if (meta.isEnabled()) - { - this.pulses.put(pulse, meta); - // Attach Pulse to internal event bus - this.bus.register(pulse); - } - } - - /** - * Helper to attach a given object to the modcontainer event bus. - * - * @param obj Object to register. - */ - private void attachToContainerEventBus(Object obj) - { - ModContainer cnt = Loader.instance().activeModContainer(); - this.log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); - try - { - FMLModContainer mc = (FMLModContainer) cnt; - Field ebf = mc.getClass().getDeclaredField("eventBus"); - - boolean access = ebf.isAccessible(); - ebf.setAccessible(true); - EventBus eb = (EventBus) ebf.get(mc); - ebf.setAccessible(access); - - eb.register(obj); - } - catch (NoSuchFieldException nsfe) - { - throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?"); - } - catch (IllegalAccessException iae) - { - throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue."); - } - catch (ClassCastException cce) - { - throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage()); - } - } - - /** - * Internal (but public for EventBus use) handler for events. - * - * DO NOT CALL THIS DIRECTLY! Let EventBus handle it. - * - * @param evt An event object. - */ - @Subscribe - public void propagateEvent(FMLEvent evt) - { - if (evt instanceof FMLPreInitializationEvent) - { - this.preInit((FMLPreInitializationEvent) evt); - } - this.bus.post(evt); - } - - private boolean getEnabledFromConfig(PulseMeta meta) - { - if (meta.isForced() || !this.useConfig) - { - return true; // Forced or no config set. - } - - return this.conf.isModuleEnabled(meta); - } - - public void preInit(FMLPreInitializationEvent evt) - { - if (!this.blockNewRegistrations) - { - this.conf.flush(); // First preInit call, so flush config - } - this.blockNewRegistrations = true; - } - - /** - * Check if a given Pulse ID is loaded in this manager. - * - * @param pulseId The ID to check. - * @return Whether the ID was present. - */ - public boolean isPulseLoaded(String pulseId) - { - for (Map.Entry entry : this.pulses.entrySet()) - { - if (entry.getValue().getId().equals(pulseId)) - { - return true; - } - } - return false; - } - - public Collection getAllPulseMetadata() - { - return this.pulses.values(); - } - - /** - * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) - */ - private class BusExceptionHandler implements SubscriberExceptionHandler - { - private final String id; - - /** - * @param id Mod ID to include in exception raises. - */ - public BusExceptionHandler(String id) - { - this.id = id; - } - - @Override - public void handleException(Throwable exception, SubscriberExceptionContext ctx) - { - FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + this.id + " >> Exception uncaught in [" - + ctx.getSubscriber().getClass().getName() + ":" + ctx.getSubscriberMethod().getName() - + "] for event [" + ctx.getEvent().getClass().getSimpleName() + "]", true); - } - } - - @Override - public String toString() - { - return "PulseManager[" + this.id + "]"; - } -} diff --git a/src/main/java/mantle/pulsar/debug/EventSpy.java b/src/main/java/mantle/pulsar/debug/EventSpy.java deleted file mode 100644 index 36d11aa..0000000 --- a/src/main/java/mantle/pulsar/debug/EventSpy.java +++ /dev/null @@ -1,28 +0,0 @@ -package mantle.pulsar.debug; - -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.internal.logging.LogManager; -import mantle.pulsar.pulse.Pulse; -import net.minecraftforge.fml.common.Loader; - -import com.google.common.eventbus.Subscribe; - -/** - * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. - * - * @author Arkan - */ -@SuppressWarnings("unused") -@Pulse(id = "EventSpy", description = "we iz in ur buses, monitorin ur eventz", forced = true) -public class EventSpy -{ - - private final ILogger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); - - @Subscribe - public void receive(Object evt) - { - this.log.info("Received event: " + evt); - } - -} diff --git a/src/main/java/mantle/pulsar/internal/Configuration.java b/src/main/java/mantle/pulsar/internal/Configuration.java deleted file mode 100644 index 44769e9..0000000 --- a/src/main/java/mantle/pulsar/internal/Configuration.java +++ /dev/null @@ -1,253 +0,0 @@ -package mantle.pulsar.internal; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.HashMap; -import java.util.Map; - -import mantle.pulsar.config.IConfiguration; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.pulse.PulseMeta; -import net.minecraftforge.fml.common.Loader; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; - -/** - * Default Gson Configuration helper. - * - * @author Arkan - */ -public class Configuration implements IConfiguration -{ - - private static final int CONFIG_LEVEL = 1; - - private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - private final String confPath; - - private final ILogger logger; - - private Map modules; - - /** - * Creates a new Configuration object. - * - * Do NOT make this the same as the overall mod configuration; it will clobber it! - * - * @param confName The config file name (without path or .json suffix) - * @param logger The logger to send debug info to. - */ - public Configuration(String confName, ILogger logger) - { - this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json"; - this.logger = logger; - } - - @Override - public void load() - { - this.getModulesFromJson(); - } - - @Override - public boolean isModuleEnabled(PulseMeta meta) - { - ConfigEntry entry = this.modules.get(meta.getId()); - if (entry == null) - { - this.modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); - return meta.isEnabled(); - } - else - { - return entry.getEnabled(); - } - } - - @Override - public void flush() - { - this.writeModulesToJson(); - } - - private void getModulesFromJson() - { - // Step 1: Does the file exist? - File f = new File(this.confPath); - if (!f.exists()) - { - this.logger.info("Couldn't find config file; will generate a new one later."); - this.modules = new HashMap(); - return; - } - - // Step 2: File exists. Let's make sure it's usable. - if (!(f.canRead() && f.canWrite())) - { - throw new FileNotReadWritableException("Could not read/write Pulsar config: " + this.confPath); - } - - // Step 3: Good enough. Read it. - try - { - try - { - this.modules = this.parseV1Config(f); - } - catch (Exception ex) - { - this.logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); - Map conf = this.parseV0Config(f); - this.logger.info("Found valid v0 configuration. Upgrading it."); - this.modules = conf; - this.writeModulesToJson(); - this.logger.info("Upgrade complete! Config is now in v1 format."); - } - } - catch (Exception ex) - { - this.logger.warn("Invalid config file. Discarding."); - ex.printStackTrace(); - this.modules = new HashMap(); - } - } - - private Map parseV0Config(File f) throws Exception - { - try - { - JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); - Map m = gson.fromJson(reader, new TypeToken>() - { - }.getType()); // NASTY! - if (m == null) - { - throw new NullPointerException("Gson returned null."); - } - Map out = new HashMap(); - for (Map.Entry e : m.entrySet()) - { - out.put(e.getKey(), new ConfigEntry(e.getValue())); - } - return out; - } - catch (FileNotFoundException fnfe) - { - throw new RuntimeException("This shouldn't be possible... " + fnfe); - } - } - - private Map parseV1Config(File f) throws Exception - { - try - { - JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); - GsonConfig c = gson.fromJson(reader, GsonConfig.class); - if (c.getConfigVersion() > 1) - { - throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); - } - if (c.getModules() == null) - { - throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); - } - return c.getModules(); - } - catch (FileNotFoundException fnfe) - { - throw new RuntimeException("This shouldn't be possible... " + fnfe); - } - } - - private void writeModulesToJson() - { - try - { - JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(this.confPath)))); - writer.setIndent(" "); - GsonConfig out = new GsonConfig(CONFIG_LEVEL, this.modules); - gson.toJson(out, GsonConfig.class, writer); - writer.close(); - } - catch (Exception ex) - { - this.logger.warn("Could not write config? " + this.confPath); - } - } - - /** - * Internal exception for an unreadable/unwritable config. - */ - private static class FileNotReadWritableException extends RuntimeException - { - public FileNotReadWritableException(String message) - { - super(message); - } - } - - /** - * Internal data holder, for use in the map and JSON. - */ - private static class ConfigEntry - { - - private Boolean enabled; - - private String description = null; - - public ConfigEntry(Boolean enabled) - { - this.enabled = enabled; - } - - public ConfigEntry(Boolean enabled, String description) - { - this(enabled); - this.description = description; - } - - public Boolean getEnabled() - { - return this.enabled; - } - } - - /** - * Internal representation of a version 1+ config file. - */ - private static class GsonConfig - { - - private int CONFIG_VERSION = 0; - - private Map modules; - - public GsonConfig(int version, Map modules) - { - this.CONFIG_VERSION = version; - this.modules = modules; - } - - public int getConfigVersion() - { - return this.CONFIG_VERSION; - } - - public Map getModules() - { - return this.modules; - } - - } - -} diff --git a/src/main/java/mantle/pulsar/internal/CrashHandler.java b/src/main/java/mantle/pulsar/internal/CrashHandler.java deleted file mode 100644 index aa9233d..0000000 --- a/src/main/java/mantle/pulsar/internal/CrashHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -package mantle.pulsar.internal; - -import mantle.pulsar.control.PulseManager; -import mantle.pulsar.pulse.PulseMeta; -import net.minecraftforge.fml.common.ICrashCallable; - -/** - * FML crash callable for Pulse Managers; dumps a list of loaded pulses to the error log. - * - * @author Arkan - */ -public class CrashHandler implements ICrashCallable -{ - - private String id; - - private PulseManager manager; - - public CrashHandler(String modId, PulseManager manager) - { - this.id = "Pulsar/" + modId + " loaded Pulses"; - this.manager = manager; - } - - @Override - public String getLabel() - { - return this.id; - } - - @Override - public String call() throws Exception - { - String out = "\n"; - for (PulseMeta meta : this.manager.getAllPulseMetadata()) - { - String state = getStateFromMeta(meta); - out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... - } - return out; - } - - private static String getStateFromMeta(PulseMeta meta) - { - if (meta.isForced()) - { - return "Enabled/Forced"; - } - else - { - if (meta.isEnabled()) - { - return "Enabled/Not Forced"; - } - else - { - return "Disabled/Not Forced"; - } - } - } - -} diff --git a/src/main/java/mantle/pulsar/internal/logging/ILogger.java b/src/main/java/mantle/pulsar/internal/logging/ILogger.java deleted file mode 100644 index d1b38d6..0000000 --- a/src/main/java/mantle/pulsar/internal/logging/ILogger.java +++ /dev/null @@ -1,24 +0,0 @@ -package mantle.pulsar.internal.logging; - -/** - * Interface for log wrappers. - * - * @author Arkan - */ -@SuppressWarnings("unused") -public interface ILogger -{ - - public void fatal(String msg); - - public void severe(String msg); - - public void warn(String msg); - - public void info(String msg); - - public void debug(String msg); - - public void trace(String msg); - -} diff --git a/src/main/java/mantle/pulsar/internal/logging/JULLogger.java b/src/main/java/mantle/pulsar/internal/logging/JULLogger.java deleted file mode 100644 index b632936..0000000 --- a/src/main/java/mantle/pulsar/internal/logging/JULLogger.java +++ /dev/null @@ -1,56 +0,0 @@ -package mantle.pulsar.internal.logging; - -import java.util.logging.Logger; - -/** - * Java logger wrapper. - * - * @author Arkan - */ -public class JULLogger implements ILogger -{ - - private final Logger log; - - public JULLogger(String name) - { - this.log = Logger.getLogger(name); - } - - @Override - public void fatal(String msg) - { - this.log.severe(msg); // JUL doesn't -have- fatal... - } - - @Override - public void severe(String msg) - { - this.log.severe(msg); - } - - @Override - public void warn(String msg) - { - this.log.warning(msg); - } - - @Override - public void info(String msg) - { - this.log.info(msg); - } - - @Override - public void debug(String msg) - { - this.log.fine(msg); // Good enough. - } - - @Override - public void trace(String msg) - { - this.log.finest(msg); // Closest we'll get. - } - -} diff --git a/src/main/java/mantle/pulsar/internal/logging/Log4jLogger.java b/src/main/java/mantle/pulsar/internal/logging/Log4jLogger.java deleted file mode 100644 index ab6c80d..0000000 --- a/src/main/java/mantle/pulsar/internal/logging/Log4jLogger.java +++ /dev/null @@ -1,56 +0,0 @@ -package mantle.pulsar.internal.logging; - -import org.apache.logging.log4j.Logger; - -/** - * Log4j log wrapper. - * - * @author Arkan - */ -public class Log4jLogger implements ILogger -{ - - private final Logger log; - - public Log4jLogger(String name) - { - this.log = org.apache.logging.log4j.LogManager.getLogger(name); - } - - @Override - public void fatal(String msg) - { - this.log.fatal(msg); - } - - @Override - public void severe(String msg) - { - this.log.error(msg); - } - - @Override - public void warn(String msg) - { - this.log.warn(msg); - } - - @Override - public void info(String msg) - { - this.log.info(msg); - } - - @Override - public void debug(String msg) - { - this.log.debug(msg); - } - - @Override - public void trace(String msg) - { - this.log.trace(msg); - } - -} diff --git a/src/main/java/mantle/pulsar/internal/logging/LogManager.java b/src/main/java/mantle/pulsar/internal/logging/LogManager.java deleted file mode 100644 index 16b2ba9..0000000 --- a/src/main/java/mantle/pulsar/internal/logging/LogManager.java +++ /dev/null @@ -1,53 +0,0 @@ -package mantle.pulsar.internal.logging; - -/** - * Static class for getting generic loggers. - * - * @author Arkan - */ -public class LogManager -{ - - private LogManager() - { - } // Singleton. - - private static final boolean useLog4j2; - - /* - * Detect the presence of log4j2. - * - * If it's present, we can assume we should be using the damn thing. - */ - static - { - boolean l4j = false; - try - { - Class cl = Class.forName("org.apache.logging.log4j.LogManager"); - if (cl == null) - { - throw new ClassNotFoundException("This should never happen..."); - } - l4j = true; - } - catch (ClassNotFoundException cnfe) - { - // Ignore - } - useLog4j2 = l4j; - } - - public static ILogger getLogger(String name) - { - if (useLog4j2) - { - return new Log4jLogger(name); - } - else - { - return new JULLogger(name); - } - } - -} diff --git a/src/main/java/mantle/pulsar/package-info.java b/src/main/java/mantle/pulsar/package-info.java deleted file mode 100644 index 8c4fa42..0000000 --- a/src/main/java/mantle/pulsar/package-info.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Project Pulsar - * - * This is a repackaged copy of the Pulsar project, an open source library for internal module loading. - * The upstream repository is at https://github.com/Emberwalker/Pulsar - * - * This code package is licensed under the MIT License, as below. - * - * ----- - * - * The MIT License (MIT) - * - * Copyright (c) 2014 Arkan - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of - * this software and associated documentation files (the "Software"), to deal in - * the Software without restriction, including without limitation the rights to - * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of - * the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * ----- - * - * @author Arkan - */ -package mantle.pulsar; \ No newline at end of file diff --git a/src/main/java/mantle/pulsar/pulse/Pulse.java b/src/main/java/mantle/pulsar/pulse/Pulse.java deleted file mode 100644 index ad9366c..0000000 --- a/src/main/java/mantle/pulsar/pulse/Pulse.java +++ /dev/null @@ -1,53 +0,0 @@ -package mantle.pulsar.pulse; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Metadata annotation for IPulse implementations. - * - * Pulses should use the standard Google Event Bus @Subscribe annotation to catch FML events, which are forwarded from - * the current mod container (including Pre/Init/Post events). - * - * @author Arkan - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) -@Documented -public @interface Pulse -{ - - /** - * @return This Pulses UID - Much like FML mods have mod IDs. - */ - public String id(); - - /** - * @return This Pulses description, human-readable for config files. Can be blank. - */ - public String description() default ""; - - /** - * @return Dependant mod IDs, seperated by ; as in FML. Skips checks when undefined. - */ - public String modsRequired() default ""; - - /** - * @return Dependeant Pulse IDs, seperated by ; . Skips checks when undefined. - */ - public String pulsesRequired() default ""; - - /** - * @return Whether this Pulse is mandatory or not (true -> mandatory). - */ - public boolean forced() default false; - - /** - * @return Whether a configurable Pulse should be enabled by default. Ignored where forced = true. - */ - public boolean defaultEnable() default true; - -} diff --git a/src/main/java/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/mantle/pulsar/pulse/PulseMeta.java deleted file mode 100644 index c1ef504..0000000 --- a/src/main/java/mantle/pulsar/pulse/PulseMeta.java +++ /dev/null @@ -1,53 +0,0 @@ -package mantle.pulsar.pulse; - -/** - * Metadata wrapper for parsed @Pulse metadata. - * - * @author Arkan - */ -public class PulseMeta -{ - - private String id, description; - - private boolean forced, enabled, defaultEnabled; - - public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) - { - this.id = id; - this.description = description; - this.forced = forced; - this.enabled = enabled; - this.defaultEnabled = defaultEnabled; - } - - public String getId() - { - return this.id; - } - - public String getDescription() - { - return this.description; - } - - public boolean isForced() - { - return this.forced; - } - - public boolean isEnabled() - { - return this.enabled; - } - - public void setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - public boolean isDefaultEnabled() - { - return this.defaultEnabled; - } -} diff --git a/src/main/java/mantle/utils/ItemMetaWrapper.java b/src/main/java/mantle/utils/ItemMetaWrapper.java deleted file mode 100644 index 36df03e..0000000 --- a/src/main/java/mantle/utils/ItemMetaWrapper.java +++ /dev/null @@ -1,53 +0,0 @@ -package mantle.utils; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class ItemMetaWrapper -{ - public final Item item; - - public final Integer meta; - - public ItemMetaWrapper(Item item, Integer meta) - { - this.item = item; - this.meta = meta; - } - - public ItemMetaWrapper(ItemStack stack) - { - this.item = stack.getItem(); - this.meta = stack.getItemDamage(); - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || this.getClass() != o.getClass()) - { - return false; - } - - ItemMetaWrapper itemMeta = (ItemMetaWrapper) o; - - if (this.item != null ? !(this.item == itemMeta.item) : itemMeta.item != null) - { - return false; - } - return !(this.meta != null ? !this.meta.equals(itemMeta.meta) : itemMeta.meta != null); - - } - - @Override - public int hashCode() - { - int result = this.item != null ? this.item.hashCode() : 0; - result = 31 * result + (this.meta != null ? this.meta.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/mantle/utils/ItemStackNBTWrapper.java b/src/main/java/mantle/utils/ItemStackNBTWrapper.java deleted file mode 100644 index bd78329..0000000 --- a/src/main/java/mantle/utils/ItemStackNBTWrapper.java +++ /dev/null @@ -1,40 +0,0 @@ -package mantle.utils; - -import net.minecraft.item.ItemStack; - -public class ItemStackNBTWrapper -{ - public final ItemStack stack; - - public ItemStackNBTWrapper(ItemStack stack) - { - this.stack = stack; - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || this.getClass() != o.getClass()) - { - return false; - } - - ItemStackNBTWrapper that = (ItemStackNBTWrapper) o; - - return ItemStack.areItemStacksEqual(this.stack, that.stack); - } - - @Override - public int hashCode() - { - int result = this.stack.getItem() != null ? this.stack.getItem().hashCode() : 0; - result = 31 * result + this.stack.getItemDamage(); - result = 31 * result + (this.stack.getTagCompound() != null ? this.stack.getTagCompound().hashCode() : 0); - result = 31 * result + this.stack.stackSize; - return result; - } -} diff --git a/src/main/java/mantle/utils/ItemStackWrapper.java b/src/main/java/mantle/utils/ItemStackWrapper.java deleted file mode 100644 index b8eb378..0000000 --- a/src/main/java/mantle/utils/ItemStackWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package mantle.utils; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class ItemStackWrapper extends ItemMetaWrapper -{ - public final Integer stacksize; - - public ItemStackWrapper(Item item, Integer meta, Integer stacksize) - { - super(item, meta); - this.stacksize = stacksize; - } - - public ItemStackWrapper(ItemStack stack, Integer stacksize) - { - super(stack); - this.stacksize = stacksize; - } - - @Override - public boolean equals(Object o) - { - if (this == o) - { - return true; - } - if (o == null || this.getClass() != o.getClass()) - { - return false; - } - if (!super.equals(o)) - { - return false; - } - - ItemStackWrapper that = (ItemStackWrapper) o; - - return !(this.stacksize != null ? !this.stacksize.equals(that.stacksize) : that.stacksize != null); - - } - - @Override - public int hashCode() - { - int result = super.hashCode(); - result = 31 * result + (this.stacksize != null ? this.stacksize.hashCode() : 0); - return result; - } -} diff --git a/src/main/java/mantle/world/ChunkCoord.java b/src/main/java/mantle/world/ChunkCoord.java deleted file mode 100644 index 30bbfff..0000000 --- a/src/main/java/mantle/world/ChunkCoord.java +++ /dev/null @@ -1,95 +0,0 @@ -package mantle.world; - -import java.io.Serializable; - -import net.minecraft.util.BlockPos; -import net.minecraft.world.chunk.Chunk; - -/** - * Standardized implementation for representing and manipulating Chunk Coordinates. Provides standard Java Collection interaction. - * From COFH LIB(modified to use mantle's coordtuple instead) - * @author King Lemming - * - */ -public final class ChunkCoord implements Comparable, Serializable -{ - - public int chunkX; - - public int chunkZ; - - public ChunkCoord(Chunk chunk) - { - - this.chunkX = chunk.xPosition; - this.chunkZ = chunk.zPosition; - } - - public ChunkCoord(BlockPos pos) - { - - this(pos.getX() >> 4, pos.getZ() >> 4); - } - - public ChunkCoord(int x, int z) - { - - this.chunkX = x; - this.chunkZ = z; - } - - public int getCenterX() - { - - return (this.chunkX << 4) + 8; - } - - public int getCenterZ() - { - - return (this.chunkZ << 4) + 8; - } - - public ChunkCoord copy() - { - - return new ChunkCoord(this.chunkX, this.chunkZ); - } - - @Override - public boolean equals(Object obj) - { - - if (!(obj instanceof ChunkCoord)) - { - return false; - } - ChunkCoord other = (ChunkCoord) obj; - return this.chunkX == other.chunkX && this.chunkZ == other.chunkZ; - } - - @Override - public int hashCode() - { - - int hash = this.chunkX; - hash *= 31 + this.chunkZ; - return hash; - } - - @Override - public String toString() - { - - return "[" + this.chunkX + ", " + this.chunkZ + "]"; - } - - /* Comparable */ - @Override - public int compareTo(ChunkCoord other) - { - - return this.chunkX == other.chunkX ? this.chunkZ - other.chunkZ : this.chunkX - other.chunkX; - } - -} diff --git a/src/main/java/mantle/world/CoordTuplePair.java b/src/main/java/mantle/world/CoordTuplePair.java deleted file mode 100644 index 5a59570..0000000 --- a/src/main/java/mantle/world/CoordTuplePair.java +++ /dev/null @@ -1,27 +0,0 @@ -package mantle.world; - -import net.minecraft.util.BlockPos; - -/** - * CoordTuplePair - * - * @author mDiyo - */ -public class CoordTuplePair -{ - public BlockPos a; - - public BlockPos b; - - public CoordTuplePair(BlockPos a, BlockPos b) - { - this.a = a; - this.b = b; - } - - public CoordTuplePair(int aX, int aY, int aZ, int bX, int bY, int bZ) - { - this.a = new BlockPos(aX, aY, aZ); - this.b = new BlockPos(bX, bY, bZ); - } -} diff --git a/src/main/java/mantle/world/DimensionCoordPair.java b/src/main/java/mantle/world/DimensionCoordPair.java deleted file mode 100644 index 8f8a8f6..0000000 --- a/src/main/java/mantle/world/DimensionCoordPair.java +++ /dev/null @@ -1,63 +0,0 @@ -package mantle.world; - -/** - * DimensionCoordPair - * - * @author mDiyo - */ -public class DimensionCoordPair -{ - public final int dim; - - public final int x; - - public final int z; - - public DimensionCoordPair(int worldID, int posX, int posZ) - { - this.dim = worldID; - this.x = posX; - this.z = posZ; - } - - public boolean equalCoords(int worldID, int posX, int posZ) - { - return this.dim == posX && this.x == posX && this.z == posZ; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (this.getClass() == obj.getClass()) - { - DimensionCoordPair coord = (DimensionCoordPair) obj; - if (this.dim == coord.dim && this.x == coord.x && this.z == coord.z) - { - return true; - } - } - return false; - } - - @Override - public int hashCode() - { - final int prime = 37; - int result = 1; - result = prime * result + this.dim; - result = prime * result + this.x; - result = prime * result + this.z; - return result; - } - - @Override - public String toString() - { - return "Dim: " + this.dim + ", X: " + this.x + ", Z: " + this.z; - } -} diff --git a/src/main/java/mantle/world/DimensionCoordTuple.java b/src/main/java/mantle/world/DimensionCoordTuple.java deleted file mode 100644 index b35fe04..0000000 --- a/src/main/java/mantle/world/DimensionCoordTuple.java +++ /dev/null @@ -1,65 +0,0 @@ -package mantle.world; - -/** - * DimensionCoordTuple - * - * @author mDiyo - * @author Sunstrike - */ -public class DimensionCoordTuple -{ - public final int dim; - - public final int x; - - public final int y; - - public final int z; - - public DimensionCoordTuple(int worldID, int posX, int posY, int posZ) - { - this.dim = worldID; - this.y = posY; - this.x = posX; - this.z = posZ; - } - - public boolean equalCoords(int worldID, int posX, int posY, int posZ) - { - return this.dim == worldID && this.x == posX && this.y == posY && this.z == posZ; - } - - @Override - public boolean equals(Object obj) - { - if (obj == null) - { - return false; - } - - if (this.getClass() == obj.getClass()) - { - DimensionCoordTuple coord = (DimensionCoordTuple) obj; - return this.equalCoords(coord.dim, coord.x, coord.y, coord.z); - } - return false; - } - - @Override - public int hashCode() - { - final int prime = 37; - int result = 1; - result = prime * result + this.dim; - result = prime * result + this.x; - result = prime * result + this.y; - result = prime * result + this.z; - return result; - } - - @Override - public String toString() - { - return "Dim: " + this.dim + ", X: " + this.x + ", Y: " + this.y + ", Z: " + this.z; - } -} diff --git a/src/main/java/mantle/world/DirectionUtils.java b/src/main/java/mantle/world/DirectionUtils.java deleted file mode 100644 index 5b4aa20..0000000 --- a/src/main/java/mantle/world/DirectionUtils.java +++ /dev/null @@ -1,29 +0,0 @@ -package mantle.world; - -import net.minecraft.util.EnumFacing; - -/** - * Helper functions for dealing with ForgeDirection - * - * @author Sunstrike - */ -@SuppressWarnings("unused") -public class DirectionUtils -{ - - private DirectionUtils() - { - // No instantiation - } - - public static boolean isRightAngles(EnumFacing a, EnumFacing b) - { - return a != b && a != b.getOpposite(); - } - - public static boolean isHorizontal(EnumFacing a) - { - return a == EnumFacing.EAST || a == EnumFacing.NORTH || a == EnumFacing.SOUTH || a == EnumFacing.WEST; - } - -} diff --git a/src/main/java/slimeknights/mantle/Mantle.java b/src/main/java/slimeknights/mantle/Mantle.java new file mode 100644 index 0000000..c3bd726 --- /dev/null +++ b/src/main/java/slimeknights/mantle/Mantle.java @@ -0,0 +1,34 @@ +package slimeknights.mantle; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.SidedProxy; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import slimeknights.mantle.common.CommonProxy; + +/** + * Mantle + * + * Central mod object for Mantle + * + * @author Sunstrike + */ +@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.14,)") +public class Mantle { + + public static final String modId = "mantle"; + public static final String modName = "Mantle"; + public static final String modVersion = "${version}"; + public static final Logger logger = LogManager.getLogger("Mantle"); + + /* Instance of this mod, used for grabbing prototype fields */ + @Instance("mantle") + public static Mantle instance; + + /* Proxies for sides, used for graphics processing */ + @SidedProxy(clientSide = "slimeknights.mantle.client.ClientProxy", serverSide = "slimeknights.mantle.common.CommonProxy") + public static CommonProxy proxy; +} diff --git a/src/main/java/slimeknights/mantle/block/BlockInventory.java b/src/main/java/slimeknights/mantle/block/BlockInventory.java new file mode 100644 index 0000000..4c5e173 --- /dev/null +++ b/src/main/java/slimeknights/mantle/block/BlockInventory.java @@ -0,0 +1,91 @@ +package slimeknights.mantle.block; + +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryHelper; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; +import net.minecraft.world.World; + +import slimeknights.mantle.tileentity.TileInventory; + +// Updated Version of InventoryBlock in Mantle +public abstract class BlockInventory extends BlockContainer { + + protected BlockInventory(Material material) { + super(material); + } + + // inventories usually need a tileEntity + @Override + public boolean hasTileEntity(IBlockState state) { + return true; + } + + @Override + public abstract TileEntity createNewTileEntity(World worldIn, int meta); + + /** + * Called when the block is activated. Return true if a GUI is opened, false if the block has no GUI. + */ + protected abstract boolean openGui(EntityPlayer player, World world, BlockPos pos); + + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, + float clickX, float clickY, float clickZ) { + if(player.isSneaking()) { + return false; + } + + if(!world.isRemote) { + return this.openGui(player, world, pos); + } + + return true; + } + + + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, + ItemStack stack) { + super.onBlockPlacedBy(worldIn, pos, state, placer, stack); + + // set custom name from named stack + if(stack.hasDisplayName()) { + TileEntity tileentity = worldIn.getTileEntity(pos); + + if(tileentity instanceof TileInventory) { + ((TileInventory) tileentity).setCustomName(stack.getDisplayName()); + } + } + } + + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + TileEntity tileentity = worldIn.getTileEntity(pos); + + if(tileentity instanceof TileInventory) { + InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory) tileentity); + worldIn.updateComparatorOutputLevel(pos, this); + } + + super.breakBlock(worldIn, pos, state); + } + + @Override + public int damageDropped(IBlockState state) { + return getMetaFromState(state); + } + + // BlockContainer sets this to -1, which equals invisible + // we need 3 for standard forge rendering + @Override + public int getRenderType() { + return 3; + } +} diff --git a/src/main/java/mantle/blocks/iface/IMasterLogic.java b/src/main/java/slimeknights/mantle/block/IMasterLogic.java similarity index 87% rename from src/main/java/mantle/blocks/iface/IMasterLogic.java rename to src/main/java/slimeknights/mantle/block/IMasterLogic.java index 9a9e690..92d7357 100644 --- a/src/main/java/mantle/blocks/iface/IMasterLogic.java +++ b/src/main/java/slimeknights/mantle/block/IMasterLogic.java @@ -1,4 +1,4 @@ -package mantle.blocks.iface; +package slimeknights.mantle.block; import net.minecraft.util.BlockPos; diff --git a/src/main/java/mantle/blocks/iface/IMasterNode.java b/src/main/java/slimeknights/mantle/block/IMasterNode.java similarity index 83% rename from src/main/java/mantle/blocks/iface/IMasterNode.java rename to src/main/java/slimeknights/mantle/block/IMasterNode.java index f33b884..1a49c0c 100644 --- a/src/main/java/mantle/blocks/iface/IMasterNode.java +++ b/src/main/java/slimeknights/mantle/block/IMasterNode.java @@ -1,4 +1,4 @@ -package mantle.blocks.iface; +package slimeknights.mantle.block; public interface IMasterNode extends IMasterLogic, IServantLogic { diff --git a/src/main/java/mantle/blocks/iface/IServantLogic.java b/src/main/java/slimeknights/mantle/block/IServantLogic.java similarity index 96% rename from src/main/java/mantle/blocks/iface/IServantLogic.java rename to src/main/java/slimeknights/mantle/block/IServantLogic.java index aeaf726..3adebea 100644 --- a/src/main/java/mantle/blocks/iface/IServantLogic.java +++ b/src/main/java/slimeknights/mantle/block/IServantLogic.java @@ -1,4 +1,4 @@ -package mantle.blocks.iface; +package slimeknights.mantle.block; import net.minecraft.util.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/mantle/blocks/abstracts/MultiServantLogic.java b/src/main/java/slimeknights/mantle/block/MultiServantLogic.java similarity index 79% rename from src/main/java/mantle/blocks/abstracts/MultiServantLogic.java rename to src/main/java/slimeknights/mantle/block/MultiServantLogic.java index c157281..66eb098 100644 --- a/src/main/java/mantle/blocks/abstracts/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/block/MultiServantLogic.java @@ -1,13 +1,7 @@ -package mantle.blocks.abstracts; +package slimeknights.mantle.block; -import mantle.blocks.BlockUtils; -import mantle.blocks.iface.IMasterLogic; -import mantle.blocks.iface.IServantLogic; -import mantle.debug.DebugData; -import mantle.debug.IDebuggable; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -15,8 +9,9 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameData; -public class MultiServantLogic extends TileEntity implements IServantLogic, IDebuggable +public class MultiServantLogic extends TileEntity implements IServantLogic { boolean hasMaster; @@ -122,29 +117,27 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb public void readCustomNBT(NBTTagCompound tags) { - this.hasMaster = tags.getBoolean("TiedToMaster"); + 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 = BlockUtils.getBlockFromUniqueName(tags.getString("MasterBlockName")); - // TODO: Make this a byte. + this.masterBlock = GameData.getBlockRegistry().getObject(tags.getString("MasterBlockName")); this.state = Block.getStateById(tags.getInteger("masterState")); } } public void writeCustomNBT(NBTTagCompound tags) { - tags.setBoolean("TiedToMaster", this.hasMaster); + 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", BlockUtils.getUniqueName(this.masterBlock)); - // TODO: Make this a byte. + tags.setString("MasterBlockName", (String) GameData.getBlockRegistry().getNameForObject(this.masterBlock)); tags.setInteger("masterState", Block.getStateId(this.state)); } } @@ -180,23 +173,6 @@ public class MultiServantLogic extends TileEntity implements IServantLogic, IDeb this.worldObj.markBlockForUpdate(this.pos); } - /* IDebuggable */ - @Override - public DebugData getDebugInfo(EntityPlayer player) - { - String[] strs = new String[2]; - strs[0] = "Location: x" + this.pos.getX() + ", y" + this.pos.getY() + ", z" + this.pos.getZ(); - if (this.hasMaster) - { - strs[1] = "masterBlock: " + this.masterBlock.toString() + ", masterMeat: " + this.state.toString(); - } - else - { - strs[1] = "No active master."; - } - return new DebugData(player, this.getClass(), strs); - } - @Override public World getWorld() { diff --git a/src/main/java/slimeknights/mantle/client/ClientProxy.java b/src/main/java/slimeknights/mantle/client/ClientProxy.java new file mode 100644 index 0000000..fb018d3 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/ClientProxy.java @@ -0,0 +1,6 @@ +package slimeknights.mantle.client; + +import slimeknights.mantle.common.CommonProxy; + +public class ClientProxy extends CommonProxy { +} diff --git a/src/main/java/slimeknights/mantle/client/CreativeTab.java b/src/main/java/slimeknights/mantle/client/CreativeTab.java new file mode 100644 index 0000000..0e56380 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/CreativeTab.java @@ -0,0 +1,43 @@ +package slimeknights.mantle.client; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +public class CreativeTab extends CreativeTabs { + + private ItemStack icon; + + // a vanilla icon in case the other one isn't present + public CreativeTab(String label, ItemStack backupIcon) { + super(label); + + this.icon = backupIcon; + } + + public void setDisplayIcon(ItemStack displayIcon) { + if(displayIcon != null && displayIcon.getItem() != null) { + this.icon = displayIcon; + } + } + + @SideOnly(Side.CLIENT) + @Override + public ItemStack getIconItemStack() { + return icon; + } + + @SideOnly(Side.CLIENT) + @Override + public int getIconItemDamage() { + return icon.getItemDamage(); + } + + @SideOnly(Side.CLIENT) + @Override + public Item getTabIconItem() { + return icon.getItem(); + } +} diff --git a/src/main/java/slimeknights/mantle/client/ModelHelper.java b/src/main/java/slimeknights/mantle/client/ModelHelper.java new file mode 100644 index 0000000..b375511 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/ModelHelper.java @@ -0,0 +1,170 @@ +package slimeknights.mantle.client; + +import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.reflect.TypeToken; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.IResource; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.IColoredBakedQuad; +import net.minecraftforge.client.model.IModelPart; +import net.minecraftforge.client.model.IModelState; +import net.minecraftforge.client.model.IPerspectiveState; +import net.minecraftforge.client.model.TRSRTransformation; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.lang.reflect.Type; +import java.util.Map; + +import javax.vecmath.Vector3f; + +public class ModelHelper { + + static final Type maptype = new TypeToken>() {}.getType(); + private static final Gson + GSON = + new GsonBuilder().registerTypeAdapter(maptype, ModelTextureDeserializer.INSTANCE).create(); + + public static final IPerspectiveState DEFAULT_ITEM_STATE; + public static final IPerspectiveState DEFAULT_TOOL_STATE; + + public static TextureAtlasSprite getTextureFromBlock(Block block, int meta) { + IBlockState state = block.getStateFromMeta(meta); + return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state); + } + + public static TextureAtlasSprite getTextureFromBlockstate(IBlockState state) { + return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(state); + } + + public static BakedQuad colorQuad(int color, BakedQuad quad) { + int[] data = quad.getVertexData(); + + int a = (color >> 24); + if(a == 0) { + a = 255; + } + + int c = 0; + c |= ((color >> 16) & 0xFF) << 0; // red + c |= ((color >> 8) & 0xFF) << 8; // green + c |= ((color >> 0) & 0xFF) << 16; // blue + c |= (a & 0xFF) << 24; // alpha + + // update color in the data. all 4 Vertices. + for(int i = 0; i < 4; i++) { + data[i * 7 + 3] = c; + } + + return new IColoredBakedQuad.ColoredBakedQuad(data, -1, quad.getFace()); + } + + public static Map loadTexturesFromJson(ResourceLocation location) throws IOException { + // get the json + IResource + iresource = + Minecraft.getMinecraft().getResourceManager() + .getResource(new ResourceLocation(location.getResourceDomain(), location.getResourcePath() + ".json")); + Reader reader = new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8); + + return GSON.fromJson(reader, maptype); + } + + public static ImmutableList loadTextureListFromJson(ResourceLocation location) throws IOException { + ImmutableList.Builder builder = ImmutableList.builder(); + for(String s : loadTexturesFromJson(location).values()) { + builder.add(new ResourceLocation(s)); + } + + return builder.build(); + } + + public static ResourceLocation getModelLocation(ResourceLocation location) { + return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath() + ".json"); + } + + public static ImmutableMap getTransformsFromState(IModelState state, IModelPart part) { + if(state instanceof IPerspectiveState) { + IPerspectiveState ps = (IPerspectiveState) state; + Map map = Maps.newHashMap(); + for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) { + map.put(type, ps.forPerspective(type).apply(part)); + } + return Maps.immutableEnumMap(map); + } + return ImmutableMap.of(); + } + + static { + // equals forge:default-item + IModelState thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 1f / 16, -3f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)), + new Vector3f(0.55f, 0.55f, 0.55f), + null)); + IModelState firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 4f / 16, 2f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), + new Vector3f(1.7f, 1.7f, 1.7f), + null)); + DEFAULT_ITEM_STATE = new IPerspectiveState.Impl(TRSRTransformation.identity(), ImmutableMap + .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, + ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson)); + + thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 1.25f / 16, -3.5f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, 90, -35)), + new Vector3f(0.85f, 0.85f, 0.85f), + null)); + firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 4f / 16, 2f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), + new Vector3f(1.7f, 1.7f, 1.7f), + null)); + DEFAULT_TOOL_STATE = new IPerspectiveState.Impl(TRSRTransformation.identity(), ImmutableMap + .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, + ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson)); + } + + /** + * Deseralizes a json in the format of { "textures": { "foo": "texture",... }} + * Ignores all invalid json + */ + public static class ModelTextureDeserializer implements JsonDeserializer> { + + public static final ModelTextureDeserializer INSTANCE = new ModelTextureDeserializer(); + + private static final Gson GSON = new Gson(); + + @Override + public Map deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + + JsonObject obj = json.getAsJsonObject(); + JsonElement texElem = obj.get("textures"); + + if(texElem == null) { + throw new JsonParseException("Missing textures entry in json"); + } + + return GSON.fromJson(texElem, maptype); + } + } +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiElement.java b/src/main/java/slimeknights/mantle/client/gui/GuiElement.java new file mode 100644 index 0000000..908aee9 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiElement.java @@ -0,0 +1,78 @@ +package slimeknights.mantle.client.gui; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Represents a GUI element INSIDE the graphics file. + * The coordinates all refer to the coordinates inside the graphics! + */ +@SideOnly(Side.CLIENT) +public class GuiElement { + + // this is totally completely ugly but it's a simple solution that doesn't clutter everything too much >_> + public static int defaultTexW = 256; + public static int defaultTexH = 256; + + public final int x; + public final int y; + public final int w; + public final int h; + + public int texW; + public int texH; + + public GuiElement(int x, int y, int w, int h, int texW, int texH) { + this(x, y, w, h); + setTextureSize(texW, texH); + + defaultTexW = texW; + defaultTexH = texH; + } + + public GuiElement(int x, int y, int w, int h) { + this.x = x; + this.y = y; + this.w = w; + this.h = h; + setTextureSize(defaultTexW, defaultTexH); + } + + public GuiElement setTextureSize(int w, int h) { + texW = w; + texH = h; + + return this; + } + + public GuiElement shift(int xd, int yd) { + return new GuiElement(this.x + xd, this.y + yd, this.w, this.h, this.texW, this.texH); + } + + /** + * Draws the element at the given x/y coordinates + * + * @param xPos X-Coordinate on the screen + * @param yPos Y-Coordinate on the screen + */ + public int draw(int xPos, int yPos) { + GuiScreen.drawModalRectWithCustomSizedTexture(xPos, yPos, x, y, w, h, texW, texH); + return w; + } + + public static class Builder { + + public int w; + public int h; + + public Builder(int w, int h) { + this.w = w; + this.h = h; + } + + public GuiElement get(int x, int y, int w, int h) { + return new GuiElement(x, y, w, h, this.w, this.h); + } + } +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java b/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java new file mode 100644 index 0000000..b676242 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java @@ -0,0 +1,69 @@ +package slimeknights.mantle.client.gui; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class GuiElementScalable extends GuiElement { + + public GuiElementScalable(int x, int y, int w, int h) { + super(x, y, w, h); + } + + public int drawScaledX(int xPos, int yPos, int width) { + for(int i = 0; i < width / w; i++) { + draw(xPos + i * w, yPos); + } + // remainder that doesn't fit total width + int remainder = width % w; + if(remainder > 0) { + GuiScreen.drawModalRectWithCustomSizedTexture(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH); + } + + return width; + } + + public int drawScaledY(int xPos, int yPos, int height) { + for(int i = 0; i < height / h; i++) { + draw(xPos, yPos + i * h); + } + // remainder that doesn't fit total width + int remainder = height % h; + if(remainder > 0) { + GuiScreen.drawModalRectWithCustomSizedTexture(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH); + } + + return w; + } + + public int drawScaled(int xPos, int yPos, int width, int height) { + // we draw full height row-wise + int full = height / this.h; + for(int i = 0; i < full; i++) { + drawScaledX(xPos, yPos + i * this.h, width); + } + + yPos += full * this.h; + + // and the remainder is drawn manually + int yRest = height % this.h; + // the same as drawScaledX but with the remaining height + for(int i = 0; i < width / w; i++) { + drawScaledY(xPos + i * w, yPos, yRest); + } + // remainder that doesn't fit total width + int remainder = width % w; + if(remainder > 0) { + GuiScreen.drawModalRectWithCustomSizedTexture(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH); + } + + return width; + } + + public GuiElementScalable shift(int xd, int yd) { + GuiElementScalable element = new GuiElementScalable(this.x + xd, this.y + yd, this.w, this.h); + element.setTextureSize(this.texW, texH); + return element; + } +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java new file mode 100644 index 0000000..3880520 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java @@ -0,0 +1,118 @@ +package slimeknights.mantle.client.gui; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.io.IOException; + +// 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) +public abstract class GuiModule extends GuiContainer { + + protected final GuiMultiModule parent; + + // left or right of the parent + protected final boolean right; + // top or bottom of the parent + protected final boolean bottom; + + public int yOffset = 0; + public int xOffset = 0; + + public GuiModule(GuiMultiModule parent, Container container, boolean right, boolean bottom) { + super(container); + + this.parent = parent; + this.right = right; + this.bottom = bottom; + } + + public int guiRight() { + return guiLeft + xSize; + } + + public int guiBottom() { + return guiTop + ySize; + } + + @Override + public void initGui() { + this.guiLeft = (this.width - this.xSize) / 2; + this.guiTop = (this.height - this.ySize) / 2; + } + + public void updatePosition(int parentX, int parentY, int parentSizeX, int parentSizeY) { + if(right) { + this.guiLeft = parentX + parentSizeX; + } + else { + this.guiLeft = parentX - this.xSize; + } + + if(bottom) { + this.guiTop = parentY + parentSizeY - this.ySize; + } + else { + this.guiTop = parentY; + } + + this.guiLeft += xOffset; + this.guiTop += yOffset; + } + + public boolean shouldDrawSlot(Slot slot) { + return true; + } + + /* + public void updateDragged(boolean dragSplitting, Set draggedSlots) { + this.dragSplitting = dragSplitting; + this.dragSplittingSlots.clear(); + for(Object o : draggedSlots) { + if(o instanceof SlotWrapper) + this.dragSplittingSlots.add(((SlotWrapper) o).parent); + else + this.dragSplittingSlots.add(o); + } + } + */ + public void handleDrawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { + this.drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + } + + public void handleDrawGuiContainerForegroundLayer(int mouseX, int mouseY) { + this.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + + /** + * Custom mouse click handling. + * + * @return True to prevent the main container handling the mouseclick + */ + public boolean handleMouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + return false; + } + + /** + * Custom mouse click handling. + * + * @return True to prevent the main container handling the mouseclick + */ + public boolean handleMouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + return false; + } + + /** + * Custom mouse click handling. + * + * @return True to prevent the main container handling the mouseclick + */ + public boolean handleMouseReleased(int mouseX, int mouseY, int state) { + return false; + } + +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java new file mode 100644 index 0000000..52049de --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java @@ -0,0 +1,356 @@ +package slimeknights.mantle.client.gui; + +import com.google.common.collect.Lists; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.fml.common.Optional; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.Collections; +import java.util.List; + +import codechicken.nei.LayoutManager; +import codechicken.nei.VisiblityData; +import codechicken.nei.api.INEIGuiHandler; +import codechicken.nei.api.TaggedInventoryArea; +import slimeknights.mantle.Mantle; +import slimeknights.mantle.inventory.ContainerMultiModule; +import slimeknights.mantle.inventory.SlotWrapper; + +@SideOnly(Side.CLIENT) +@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems") +public class GuiMultiModule extends GuiContainer implements INEIGuiHandler { + + // NEI-stuff >:( + private static Field NEI_Manager; + + static { + try { + NEI_Manager = GuiContainer.class.getDeclaredField("manager"); + } catch(NoSuchFieldException e) { + NEI_Manager = null; + } + } + + protected List modules = Lists.newArrayList(); + + public int cornerX; + public int cornerY; + public int realWidth; + public int realHeight; + + public GuiMultiModule(ContainerMultiModule container) { + super(container); + + realWidth = -1; + realHeight = -1; + } + + protected void addModule(GuiModule module) { + modules.add(module); + } + + @Override + public void initGui() { + if(realWidth > -1) { + // has to be reset before calling initGui so the position is getting retained + xSize = realWidth; + ySize = realHeight; + } + super.initGui(); + + this.cornerX = this.guiLeft; + this.cornerY = this.guiTop; + this.realWidth = xSize; + this.realHeight = ySize; + + for(GuiModule module : modules) { + updateSubmodule(module); + } + + //this.guiLeft = this.guiTop = 0; + //this.xSize = width; + //this.ySize = height; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { + for(GuiModule module : modules) { + module.handleDrawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + for(GuiModule module : modules) { + // set correct state for the module + GlStateManager.pushMatrix(); + GlStateManager.translate(-this.guiLeft, -this.guiTop, 0.0F); + GlStateManager.translate(module.guiLeft, module.guiTop, 0.0F); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + module.handleDrawGuiContainerForegroundLayer(mouseX, mouseY); + GlStateManager.popMatrix(); + } + + drawContainerName(); + drawPlayerInventoryName(); + } + + protected void drawContainerName() { + ContainerMultiModule multiContainer = (ContainerMultiModule) this.inventorySlots; + IChatComponent localizedName = multiContainer.getInventoryDisplayName(); + if(localizedName != null) { + this.fontRendererObj.drawString(localizedName.getUnformattedText(), 8, 6, 0x404040); + } + } + + protected void drawPlayerInventoryName() { + String localizedName = Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText(); + this.fontRendererObj.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040); + } + + @Override + public void setWorldAndResolution(Minecraft mc, int width, int height) { + super.setWorldAndResolution(mc, width, height); + + // workaround for NEIs ASM hax. sigh. + try { + for(GuiModule module : modules) { + module.setWorldAndResolution(mc, width, height); + if(NEI_Manager != null) { + NEI_Manager.set(module, NEI_Manager.get(this)); + } + updateSubmodule(module); + } + } catch(IllegalAccessException e) { + Mantle.logger.error(e); + } + } + + @Override + public void onResize(Minecraft mc, int width, int height) { + super.onResize(mc, width, height); + + for(GuiModule module : modules) { + module.onResize(mc, width, height); + updateSubmodule(module); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + int oldX = guiLeft; + int oldY = guiTop; + int oldW = xSize; + int oldH = ySize; + + guiLeft = cornerX; + guiTop = cornerY; + xSize = realWidth; + ySize = realHeight; + super.drawScreen(mouseX, mouseY, partialTicks); + guiLeft = oldX; + guiTop = oldY; + xSize = oldW; + ySize = oldH; + } + + + // needed to get the correct slot on clicking + @Override + protected boolean isPointInRegion(int left, int top, int right, int bottom, int pointX, int pointY) { + pointX -= this.cornerX; + pointY -= this.cornerY; + return pointX >= left - 1 && pointX < left + right + 1 && pointY >= top - 1 && pointY < top + bottom + 1; + } + + protected void updateSubmodule(GuiModule module) { + module.updatePosition(this.cornerX, this.cornerY, this.realWidth, this.realHeight); + + if(module.guiLeft < this.guiLeft) { + this.xSize += this.guiLeft - module.guiLeft; + this.guiLeft = module.guiLeft; + } + if(module.guiTop < this.guiTop) { + this.ySize += this.guiTop - module.guiTop; + this.guiTop = module.guiTop; + } + if(module.guiRight() > this.guiLeft + this.xSize) { + xSize = module.guiRight() - this.guiLeft; + } + if(module.guiBottom() > this.guiTop + this.ySize) { + ySize = module.guiBottom() - this.guiTop; + } + } + + @Override + public void drawSlot(Slot slotIn) { + GuiModule module = getModuleForSlot(slotIn.slotNumber); + + if(module != null) { + Slot slot = slotIn; + // unwrap for the call to the module + if(slotIn instanceof SlotWrapper) { + slot = ((SlotWrapper) slotIn).parent; + } + if(!module.shouldDrawSlot(slot)) { + return; + } + } + + // update slot positions + if(slotIn instanceof SlotWrapper) { + slotIn.xDisplayPosition = ((SlotWrapper) slotIn).parent.xDisplayPosition; + slotIn.yDisplayPosition = ((SlotWrapper) slotIn).parent.yDisplayPosition; + } + + super.drawSlot(slotIn); + } + + @Override + public boolean isMouseOverSlot(Slot slotIn, int mouseX, int mouseY) { + GuiModule module = getModuleForSlot(slotIn.slotNumber); + + // mouse inside the module of the slot? + if(module != null) { + Slot slot = slotIn; + // unwrap for the call to the module + if(slotIn instanceof SlotWrapper) { + slot = ((SlotWrapper) slotIn).parent; + } + if(!module.shouldDrawSlot(slot)) { + return false; + } + } + + return super.isMouseOverSlot(slotIn, mouseX, mouseY); + } + + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + GuiModule module = getModuleForPoint(mouseX, mouseY); + if(module != null) { + if(module.handleMouseClicked(mouseX, mouseY, mouseButton)) { + return; + } + } + super.mouseClicked(mouseX, mouseY, mouseButton); + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + GuiModule module = getModuleForPoint(mouseX, mouseY); + if(module != null) { + if(module.handleMouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick)) { + return; + } + } + + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + GuiModule module = getModuleForPoint(mouseX, mouseY); + if(module != null) { + if(module.handleMouseReleased(mouseX, mouseY, state)) { + return; + } + } + + super.mouseReleased(mouseX, mouseY, state); + } + + protected GuiModule getModuleForPoint(int x, int y) { + for(GuiModule module : modules) { + if(this.isPointInRegion(module.guiLeft, module.guiTop, module.guiRight(), module.guiBottom(), + x + this.cornerX, y + this.cornerY)) { + return module; + } + } + + return null; + } + + protected GuiModule getModuleForSlot(int slotNumber) { + return getModuleForContainer(getContainer().getSlotContainer(slotNumber)); + } + + protected GuiModule getModuleForContainer(Container container) { + for(GuiModule module : modules) { + if(module.inventorySlots == container) { + return module; + } + } + + return null; + } + + protected ContainerMultiModule getContainer() { + return (ContainerMultiModule) inventorySlots; + } + + /* NEI INTEGRATION */ + + @Override + @Optional.Method(modid = "NotEnoughItems") + public VisiblityData modifyVisiblity(GuiContainer guiContainer, VisiblityData visiblityData) { + int x = LayoutManager.stateButtons[0].x + LayoutManager.stateButtons[0].w; + int x2 = LayoutManager.timeButtons[3].x + LayoutManager.timeButtons[3].w; + int y2 = LayoutManager.heal.y + LayoutManager.heal.h; + + + for(GuiModule module : modules) { + if(x > module.guiLeft) { + visiblityData.showStateButtons = false; + } + if(x2 > module.guiLeft && y2 > module.guiTop) { + visiblityData.showUtilityButtons = false; + } + } + + return visiblityData; + } + + @Override + @Optional.Method(modid = "NotEnoughItems") + public Iterable getItemSpawnSlots(GuiContainer guiContainer, ItemStack itemStack) { + return null; + } + + @Override + @Optional.Method(modid = "NotEnoughItems") + public List getInventoryAreas(GuiContainer guiContainer) { + return Collections.EMPTY_LIST; + } + + @Override + @Optional.Method(modid = "NotEnoughItems") + public boolean handleDragNDrop(GuiContainer guiContainer, int x, int y, ItemStack itemStack, int k) { + return false; + } + + @Override + @Optional.Method(modid = "NotEnoughItems") + public boolean hideItemPanelSlot(GuiContainer guiContainer, int x, int y, int w, int h) { + for(GuiModule module : modules) { + // check if the panel overlaps the module (check totally not stolen from stackoverflow) + if(module.guiLeft < x + w && module.guiRight() > x && + module.guiTop < y + h && module.guiBottom() > y) { + return true; + } + } + + return false; + } +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidget.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidget.java new file mode 100644 index 0000000..7600d74 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidget.java @@ -0,0 +1,26 @@ +package slimeknights.mantle.client.gui; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public abstract class GuiWidget { + + public int xPos; + public int yPos; + public int height; + public int width; + + public abstract void draw(); + + /** Where the part will be drawn. Upper left corner. */ + public void setPosition(int x, int y) { + this.xPos = x; + this.yPos = y; + } + + public void setSize(int width, int height) { + this.width = width; + this.height = height; + } +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java new file mode 100644 index 0000000..227695d --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -0,0 +1,232 @@ +package slimeknights.mantle.client.gui; + +import net.minecraft.util.MathHelper; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import org.lwjgl.input.Mouse; + +// a vertical slider! +@SideOnly(Side.CLIENT) +public class GuiWidgetSlider extends GuiWidget { + + // gui info + public final GuiElement slider; + public final GuiElement sliderHighlighted; + public final GuiElement sliderDisabled; + public final GuiElement slideBarTop; + public final GuiElement slideBarBottom; + public final GuiElementScalable slideBar; + + // slider info + protected int minValue; + protected int maxValue; + protected int increment; + + // positioning info + protected int currentValue; + public int sliderOffset; // x-offset of the slider to the left edge of the slideBar + protected boolean enabled; + protected boolean hidden; + + protected boolean isScrolling; + protected boolean isHighlighted; + // where the slider was clicked on the slider itself (not on the bar, on the thing that slides) + private int clickX; + private int clickY; + private boolean clickedBar; // if the bar has already been clicked and not released + + public GuiWidgetSlider(GuiElement slider, GuiElement sliderHighlighted, GuiElement sliderDisabled, GuiElement slideBarTop, GuiElement slideBarBottom, GuiElementScalable slideBar) { + this.slider = slider; + this.sliderHighlighted = sliderHighlighted; + this.sliderDisabled = sliderDisabled; + this.slideBar = slideBar; + this.slideBarTop = slideBarTop; + this.slideBarBottom = slideBarBottom; + + height = slideBar.h; + width = slideBar.w; + currentValue = minValue = 0; + maxValue = slideBar.h; + increment = 1; + + sliderOffset = MathHelper.abs_int(slideBar.w - slider.w) / 2; + + isScrolling = false; + isHighlighted = false; + + enabled = true; + hidden = false; + } + + /** Sets the height of the whole slider and slidebar */ + public void setSize(int height) { + this.height = height; + } + + /** specifies the values that the slider represents */ + public void setSliderParameters(int min, int max, int stepsize) { + this.minValue = min; + this.maxValue = max; + this.increment = stepsize; + + // just in case + setSliderValue(currentValue); + } + + public int getValue() { + return currentValue; + } + + public void enable() { + this.enabled = true; + } + + public void disable() { + this.enabled = false; + } + + public boolean isEnabled() { + return this.enabled; + } + + public void hide() { + this.hidden = true; + } + + public void show() { + this.hidden = false; + } + + public boolean isHidden() { + return this.hidden; + } + + public void draw() { + if(hidden) { + return; + } + + // slidebar background + slideBarTop.draw(xPos, yPos); + slideBar.drawScaledY(xPos, yPos + slideBarTop.h, getUsableSlidebarHeight()); + slideBarBottom.draw(xPos, yPos + height - slideBarBottom.h); + + int x = xPos + sliderOffset; + int y = yPos + getSliderTop(); + + // the slider depending on state + if(enabled) { + if(isScrolling) { + sliderDisabled.draw(x, y); + } + else if(isHighlighted) { + sliderHighlighted.draw(x, y); + } + else { + slider.draw(x, y); + } + } + } + + public void update(int mouseX, int mouseY) { + if(!enabled || hidden) { + return; + } + + boolean mouseDown = Mouse.isButtonDown(0); // left mouse button + + // relative position inside the widget + int x = mouseX - xPos; + int y = mouseY - yPos; + + // reset click data + if(!mouseDown && clickedBar) { + clickedBar = false; + } + + // button not pressed and scrolling -> stop scrolling + if(!mouseDown && isScrolling) { + isScrolling = false; + } + // button pressed and scrolling -> update position of slider + else if(isScrolling) { + float d = maxValue - minValue; + float val = (float) (y - clickY) / (float) (getUsableSlidebarHeight() - slider.h); + val *= d; + + if(val < (float) increment / 2f) { + // < 1/2 increment + setSliderValue(minValue); + } + else if(val > maxValue - ((float) increment / 2f)) { + // > max-1/2 increment + setSliderValue(maxValue); + } + else { + // in between + setSliderValue((int) (minValue + (float) increment * Math.round(val))); + } + } + // not scrolling yet but possibly inside the slider + else if(x >= 0 && y >= getSliderTop() && + x - sliderOffset <= slider.w && y <= getSliderTop() + slider.h) { + isHighlighted = true; + if(mouseDown) { + isScrolling = true; + clickX = x - sliderOffset; + clickY = y - getSliderTop(); + } + } + // not on the slider but clicked on the bar + else if(mouseDown && !clickedBar && + x >= 0 && y >= 0 && + x <= slideBar.w && y <= height) { + if(y < getSliderTop()) { + decrement(); + } + else { + increment(); + } + + clickedBar = true; + } + else { + isHighlighted = false; + } + } + + public int increment() { + setSliderValue(currentValue + increment); + return currentValue; + } + + public int decrement() { + setSliderValue(currentValue - increment); + return currentValue; + } + + public int setSliderValue(int val) { + if(val > maxValue) { + val = maxValue; + } + else if(val < minValue) { + val = minValue; + } + + currentValue = val; + return currentValue; + } + + private int getSliderTop() { + float d = maxValue - minValue; + d = (float) (currentValue - minValue) / d; + d *= getUsableSlidebarHeight() - slider.h; + + return (int) d + slideBarTop.h; + } + + private int getUsableSlidebarHeight() { + return height - slideBarTop.h - slideBarBottom.h; + } +} diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java new file mode 100644 index 0000000..be8c438 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java @@ -0,0 +1,171 @@ +package slimeknights.mantle.client.gui; + +import com.google.common.collect.Lists; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import org.lwjgl.input.Mouse; + +import java.util.List; + +@SideOnly(Side.CLIENT) +public class GuiWidgetTabs extends GuiWidget { + + private static final ResourceLocation + creativeInventoryTabs = new ResourceLocation("textures/gui/container/creative_inventory/tabs.png"); + + private final GuiElement[] tabActive = new GuiElement[3]; + private final GuiElement[] tab = new GuiElement[3]; + + // change this if you need different tabs + public ResourceLocation tabsResource = creativeInventoryTabs; + // changes the y-offset of the tab row + public int yOffset = 4; + // space between 2 tabs + public int spacing = 2; + + public int selected; + public int highlighted; + protected List icons = Lists.newArrayList(); + + private final GuiMultiModule parent; + private boolean clicked = false; + + public GuiWidgetTabs(GuiMultiModule parent, GuiElement tabLeft, GuiElement tabCenter, GuiElement tabRight, GuiElement activeLeft, GuiElement activeCenter, GuiElement activeRight) { + this.parent = parent; + + this.tab[0] = tabLeft; + this.tab[1] = tabCenter; + this.tab[2] = tabRight; + this.tabActive[0] = activeLeft; + this.tabActive[1] = activeCenter; + this.tabActive[2] = activeRight; + + selected = 0; + } + + public void addTab(ItemStack icon) { + icons.add(icon); + } + + public void clear() { + selected = 0; + icons.clear(); + } + + public void update(int mouseX, int mouseY) { + boolean mouseDown = Mouse.isButtonDown(0); // left mouse button + + // did we click on a tab? + mouseX -= this.xPos; + mouseY -= this.yPos; + + // update highlighted + highlighted = -1; + if(mouseY >= 0 && mouseY <= tab[1].h) { + // which one did we click? + int x = 0; + for(int i = 0; i < icons.size(); i++) { + // clicking on spacing has no effect + if(mouseX >= x && mouseX < x + tab[1].w) { + highlighted = i; + break; + } + x += tab[1].w; + x += spacing; + } + } + + // already clicked + if(clicked) { + // still clicking + if(mouseDown) { + return; + } + // release click + else { + clicked = false; + return; + } + } + // new click + else if(mouseDown) { + clicked = true; + } + // no click - do nothing + else { + return; + } + + // was new click, select highlighted + if(highlighted > -1) { + selected = highlighted; + } + } + + @Override + public void draw() { + int y = yPos + yOffset; + for(int i = 0; i < icons.size(); i++) { + int x = xPos + i * tab[0].w; + + if(i > 0) { + x += i * spacing; + } + + GuiElement[] toDraw; + if(i == selected) { + toDraw = tabActive; + } + else { + toDraw = tab; + } + + GuiElement actualTab; + if(i == 0 && x == parent.cornerX) { + actualTab = toDraw[0]; + } + else if(x == parent.cornerX + parent.width) { + actualTab = toDraw[2]; + } + else { + actualTab = toDraw[1]; + } + + // todo: draw all the tabs first and then all the itemstacks so it doesn't have to switch texture in between all the time + + // rebind texture from drawing an itemstack + Minecraft.getMinecraft().getTextureManager().bindTexture(tabsResource); + actualTab.draw(x, y); + + + ItemStack icon = icons.get(i); + if(icon != null) { + RenderHelper.enableGUIStandardItemLighting(); + drawItemStack(icon, x + (actualTab.w - 16) / 2, y + (actualTab.h - 16) / 2); + RenderHelper.disableStandardItemLighting(); + //RenderHelper.enableStandardItemLighting(); + } + } + } + + // guiContainer.drawItemStack + private void drawItemStack(ItemStack stack, int x, int y) { + RenderItem itemRender = Minecraft.getMinecraft().getRenderItem(); + GlStateManager.translate(0.0F, 0.0F, 32.0F); + itemRender.zLevel = 200; + //FontRenderer font = stack.getItem().getFontRenderer(stack); + + itemRender.renderItemAndEffectIntoGUI(stack, x, y); + //this.itemRender.renderItemOverlayIntoGUI(font, stack, x, y - (this.draggedStack == null ? 0 : 8), altText); + //this.zLevel = 0.0F; + itemRender.zLevel = 0.0F; + } +} diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java new file mode 100644 index 0000000..690ea6f --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -0,0 +1,87 @@ +package slimeknights.mantle.client.model; + +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.client.model.IFlexibleBakedModel; +import net.minecraftforge.client.model.IPerspectiveAwareModel; +import net.minecraftforge.client.model.TRSRTransformation; + +import org.apache.commons.lang3.tuple.Pair; + +import java.util.List; + +import javax.vecmath.Matrix4f; +import javax.vecmath.Vector3f; + +/** + * Takes a blockmodel and applies the standard-block-perspective for third_person to it + */ +public class BlockItemModelWrapper implements IPerspectiveAwareModel, IFlexibleBakedModel { + + // copied from the forge variants V1 default-block transform + public static final Matrix4f THIRD_PERSON_BLOCK_TRANSFORM = new TRSRTransformation( + new Vector3f(0, 1.5f / 16, -2.75f / 16), // translation + TRSRTransformation.quatFromYXZDegrees(new Vector3f(10, -45, 170)), // rotation + new Vector3f(0.375f, 0.375f, 0.375f), // scale + null).getMatrix(); + + private final IFlexibleBakedModel parent; + + public BlockItemModelWrapper(IFlexibleBakedModel parent) { + this.parent = parent; + } + + @Override + public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { + Matrix4f matrix = null; + // fix transformation in hand + if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON) { + matrix = THIRD_PERSON_BLOCK_TRANSFORM; + } + + return Pair.of((IBakedModel) this, matrix); + } + + @Override + public List getFaceQuads(EnumFacing p_177551_1_) { + return parent.getFaceQuads(p_177551_1_); + } + + @Override + public List getGeneralQuads() { + return parent.getGeneralQuads(); + } + + @Override + public VertexFormat getFormat() { + return parent.getFormat(); + } + + @Override + public boolean isAmbientOcclusion() { + return false; + } + + @Override + public boolean isGui3d() { + return parent.isGui3d(); + } + + @Override + public boolean isBuiltInRenderer() { + return parent.isBuiltInRenderer(); + } + + @Override + public TextureAtlasSprite getTexture() { + return parent.getTexture(); + } + + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return parent.getItemCameraTransforms(); + } +} diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java new file mode 100644 index 0000000..b524870 --- /dev/null +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -0,0 +1,139 @@ +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.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.renderer.vertex.VertexFormat; +import net.minecraft.client.renderer.vertex.VertexFormatElement; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.client.model.IFlexibleBakedModel; +import net.minecraftforge.client.model.TRSRTransformation; + +import java.util.Arrays; +import java.util.EnumMap; +import java.util.List; + +import javax.vecmath.Vector3f; +import javax.vecmath.Vector4f; + +// for those wondering TRSR stands for Translation Rotation Scale Rotation +public class TRSRBakedModel implements IFlexibleBakedModel { + + protected final ImmutableList general; + protected final ImmutableMap> faces; + protected final IFlexibleBakedModel original; + + public TRSRBakedModel(IFlexibleBakedModel original, float x, float y, float z, float scale) { + this(original, x, y, z, 0, 0, 0, scale, scale, scale); + } + + public TRSRBakedModel(IFlexibleBakedModel original, float x, float y, float z, float rotX, float rotY, float rotZ, float scale) { + this(original, x, y, z, rotX, rotY, rotZ, scale, scale, scale); + } + + public TRSRBakedModel(IFlexibleBakedModel original, float x, float y, float z, float rotX, float rotY, float rotZ, float scaleX, float scaleY, float scaleZ) { + this(original, new TRSRTransformation(new Vector3f(x, y, z), + null, + new Vector3f(scaleX, scaleY, scaleZ), + TRSRTransformation.quatFromYXZ(rotY, rotX, rotZ))); + } + + public TRSRBakedModel(IFlexibleBakedModel original, TRSRTransformation transform) { + this.original = original; + + ImmutableList.Builder builder; + builder = ImmutableList.builder(); + + transform = TRSRTransformation.blockCenterToCorner(transform); + + // face quads + EnumMap> faces = Maps.newEnumMap(EnumFacing.class); + for(EnumFacing face : EnumFacing.values()) { + for(BakedQuad quad : original.getFaceQuads(face)) { + builder.add(transform(transform, quad, original.getFormat())); + } + //faces.put(face, builder.build()); + faces.put(face, ImmutableList.of()); + } + + // general quads + //builder = ImmutableList.builder(); + for(BakedQuad quad : original.getGeneralQuads()) { + builder.add(transform(transform, quad, original.getFormat())); + } + + this.general = builder.build(); + this.faces = Maps.immutableEnumMap(faces); + } + + public static BakedQuad transform(TRSRTransformation transform, BakedQuad quad, VertexFormat format) { + for(VertexFormatElement e : (List) format.getElements()) { + if(e.getUsage() == VertexFormatElement.EnumUsage.POSITION) { + if(e.getType() != VertexFormatElement.EnumType.FLOAT) { + throw new IllegalArgumentException("can only transform float position"); + } + int[] data = Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length); + // once for each vertex + for(int j = 0; j < 4; j++) { + int v = j * format.getNextOffset() / 4; + float[] pos = new float[]{0f, 0f, 0f, 1f}; + for(int i = 0; i < Math.min(4, e.getElementCount()); i++) { + pos[i] = Float.intBitsToFloat(data[v + e.getOffset() / 4 + i]); + } + Vector4f vec = new Vector4f(pos); + transform.getMatrix().transform(vec); + vec.get(pos); + for(int i = 0; i < Math.min(4, e.getElementCount()); i++) { + data[v + e.getOffset() / 4 + i] = Float.floatToRawIntBits(pos[i]); + } + } + return new BakedQuad(data, quad.getTintIndex(), quad.getFace()); + } + } + return quad; + } + + @Override + public List getFaceQuads(EnumFacing side) { + return faces.get(side); + } + + @Override + public List getGeneralQuads() { + return general; + } + + @Override + public boolean isAmbientOcclusion() { + return false; + } + + @Override + public boolean isGui3d() { + return original.isGui3d(); + } + + @Override + public boolean isBuiltInRenderer() { + return original.isBuiltInRenderer(); + } + + @Override + public TextureAtlasSprite getTexture() { + return original.getTexture(); + } + + @Override + public ItemCameraTransforms getItemCameraTransforms() { + return original.getItemCameraTransforms(); + } + + @Override + public VertexFormat getFormat() { + return original.getFormat(); + } +} diff --git a/src/main/java/slimeknights/mantle/common/CommonProxy.java b/src/main/java/slimeknights/mantle/common/CommonProxy.java new file mode 100644 index 0000000..e2dd4a7 --- /dev/null +++ b/src/main/java/slimeknights/mantle/common/CommonProxy.java @@ -0,0 +1,4 @@ +package slimeknights.mantle.common; + +public class CommonProxy { +} diff --git a/src/main/java/slimeknights/mantle/common/GuiHandler.java b/src/main/java/slimeknights/mantle/common/GuiHandler.java new file mode 100644 index 0000000..22bb260 --- /dev/null +++ b/src/main/java/slimeknights/mantle/common/GuiHandler.java @@ -0,0 +1,31 @@ +package slimeknights.mantle.common; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.network.IGuiHandler; + +/** + * A GuiHandler implementation that forwards the container/gui creation to the TEs, eliminating the need for GUI IDs. + */ +public class GuiHandler implements IGuiHandler { + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); + if(te instanceof IInventoryGui) { + return ((IInventoryGui) te).createContainer(player.inventory, world, new BlockPos(x, y, z)); + } + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity te = world.getTileEntity(new BlockPos(x, y, z)); + if(te instanceof IInventoryGui) { + return ((IInventoryGui) te).createGui(player.inventory, world, new BlockPos(x, y, z)); + } + return null; + } +} diff --git a/src/main/java/slimeknights/mantle/common/IInventoryGui.java b/src/main/java/slimeknights/mantle/common/IInventoryGui.java new file mode 100644 index 0000000..c4cea7d --- /dev/null +++ b/src/main/java/slimeknights/mantle/common/IInventoryGui.java @@ -0,0 +1,20 @@ +package slimeknights.mantle.common; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.util.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Used in conjunction with GuiHandler. Implement in a TE to have it open its GUI/Container. + */ +public interface IInventoryGui { + + Container createContainer(InventoryPlayer inventoryplayer, World world, BlockPos pos); + + @SideOnly(Side.CLIENT) + GuiContainer createGui(InventoryPlayer inventoryplayer, World world, BlockPos pos); +} diff --git a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java new file mode 100644 index 0000000..e6cb89f --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java @@ -0,0 +1,297 @@ +package slimeknights.mantle.inventory; + +import com.google.common.collect.Lists; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraft.world.WorldServer; + +import java.util.List; + +import slimeknights.mantle.util.SlimeknightException; + +/** Same as Container but provides some extra functionality to simplify things */ +public abstract class BaseContainer extends Container { + + protected double maxDist = 8 * 8; // 8 blocks + protected T tile; + protected final Block originalBlock; // used to check if the block we interacted with got broken + protected final BlockPos pos; + protected final World world; + + public List subContainers = Lists.newArrayList(); + + public BaseContainer(T tile) { + this.tile = tile; + + this.world = tile.getWorld(); + this.pos = tile.getPos(); + this.originalBlock = world.getBlockState(pos).getBlock(); + } + + public void syncOnOpen(EntityPlayerMP playerOpened) { + // find another player that already has the gui for this tile open + WorldServer server = playerOpened.getServerForPlayer(); + for(EntityPlayer player : (List) server.playerEntities) { + if(player == playerOpened) { + continue; + } + if(player.openContainer instanceof BaseContainer) { + if(this.sameGui((BaseContainer) player.openContainer)) { + syncWithOtherContainer((BaseContainer) player.openContainer, playerOpened); + return; + } + } + } + + // no player has a container open for the tile + syncNewContainer(playerOpened); + } + + /** + * Called when the container is opened and another player already has a container for this tile open + * Sync to the same state here. + */ + protected void syncWithOtherContainer(BaseContainer otherContainer, EntityPlayerMP player) { + } + + /** + * Called when the container is opened and no other player has it open. + * Set the default state here. + */ + protected void syncNewContainer(EntityPlayerMP player) { + } + + public boolean sameGui(BaseContainer otherContainer) { + return this.tile == otherContainer.tile; + } + + @Override + public boolean canInteractWith(EntityPlayer playerIn) { + Block block = world.getBlockState(pos).getBlock(); + // does the block we interacted with still exist? + if(block == Blocks.air || block != originalBlock) { + return false; + } + + // too far away from block? + return playerIn.getDistanceSq((double) pos.getX() + 0.5d, + (double) pos.getY() + 0.5d, + (double) pos.getZ() + 0.5d) <= maxDist; + } + + @SuppressWarnings("unchecked") + public List getInventory() { + return (List) super.getInventory(); + } + + public IChatComponent getInventoryDisplayName() { + if(tile instanceof IInventory) { + return ((IInventory) tile).getDisplayName(); + } + return null; + } + + // standard yOffset calculation for chestlike inventories: + // yOffset = (numRows - 4) * 18; (the -4 because of the 3 rows of inventory + 1 row of hotbar) + + protected int playerInventoryStart = -1; + + /** + * Draws the player inventory starting at the given position + * + * @param playerInventory The players inventory + * @param xCorner Default Value: 8 + * @param yCorner Default Value: (rows - 4) * 18 + 103 + */ + protected void addPlayerInventory(InventoryPlayer playerInventory, int xCorner, int yCorner) { + int index = 9; + + int start = this.inventorySlots.size(); + + for(int row = 0; row < 3; row++) { + for(int col = 0; col < 9; col++) { + this.addSlotToContainer(new Slot(playerInventory, index, xCorner + col * 18, yCorner + row * 18)); + index++; + } + } + + index = 0; + for(int col = 0; col < 9; col++) { + this.addSlotToContainer(new Slot(playerInventory, index, xCorner + col * 18, yCorner + 58)); + index++; + } + + playerInventoryStart = start; + } + + @Override + protected Slot addSlotToContainer(Slot slotIn) { + if(playerInventoryStart >= 0) { + throw new SlimeknightException("BaseContainer: Player inventory has to be last slots. Add all slots before adding the player inventory."); + } + return super.addSlotToContainer(slotIn); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { + // we can only support inventory <-> playerInventory + if(playerInventoryStart < 0) { + // so we don't do anything if no player inventory is present because we don't know what to do + return null; + } + + ItemStack itemstack = null; + Slot slot = (Slot) this.inventorySlots.get(index); + + // slot that was clicked on not empty? + if(slot != null && slot.getHasStack()) { + ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + int end = this.inventorySlots.size(); + + // Is it a slot in the main inventory? (aka not player inventory) + if(index < playerInventoryStart) { + // try to put it into the player inventory (if we have a player inventory) + if(!this.mergeItemStack(itemstack1, playerInventoryStart, end, true)) { + return null; + } + } + // Slot is in the player inventory (if it exists), transfer to main inventory + else if(!this.mergeItemStack(itemstack1, 0, playerInventoryStart, false)) { + return null; + } + + if(itemstack1.stackSize == 0) { + slot.putStack(null); + } + else { + slot.onSlotChanged(); + } + } + + return itemstack; + } + + // Fix for a vanilla bug: doesn't take Slot.getMaxStackSize into account + protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) { + return mergeItemStackRefill(stack, startIndex, endIndex, useEndIndex) + || mergeItemStackMove(stack, startIndex, endIndex, useEndIndex); + } + + // only refills items that are already present + protected boolean mergeItemStackRefill(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) { + if(stack.stackSize <= 0) { + return false; + } + + boolean flag1 = false; + int k = startIndex; + + if(useEndIndex) { + k = endIndex - 1; + } + + Slot slot; + ItemStack itemstack1; + + if(stack.isStackable()) { + while(stack.stackSize > 0 && (!useEndIndex && k < endIndex || useEndIndex && k >= startIndex)) { + slot = (Slot) this.inventorySlots.get(k); + itemstack1 = slot.getStack(); + + if(itemstack1 != null && itemstack1.getItem() == stack.getItem() && (!stack.getHasSubtypes() + || stack.getMetadata() == itemstack1 + .getMetadata()) && ItemStack.areItemStackTagsEqual(stack, itemstack1)) { + int l = itemstack1.stackSize + stack.stackSize; + int limit = Math.min(stack.getMaxStackSize(), slot.getItemStackLimit(stack)); + + if(l <= limit) { + stack.stackSize = 0; + itemstack1.stackSize = l; + slot.onSlotChanged(); + flag1 = true; + } + else if(itemstack1.stackSize < limit) { + stack.stackSize -= limit - itemstack1.stackSize; + itemstack1.stackSize = limit; + slot.onSlotChanged(); + flag1 = true; + } + } + + if(useEndIndex) { + --k; + } + else { + ++k; + } + } + } + + return flag1; + } + + // only moves items into empty slots + protected boolean mergeItemStackMove(ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) { + if(stack.stackSize <= 0) { + return false; + } + + boolean flag1 = false; + int k; + + if(useEndIndex) { + k = endIndex - 1; + } + else { + k = startIndex; + } + + while(!useEndIndex && k < endIndex || useEndIndex && k >= startIndex) { + Slot slot = (Slot) this.inventorySlots.get(k); + ItemStack itemstack1 = slot.getStack(); + + if(itemstack1 == null && slot.isItemValid(stack)) // Forge: Make sure to respect isItemValid in the slot. + { + int limit = slot.getItemStackLimit(stack); + ItemStack stack2 = stack.copy(); + if(stack2.stackSize > limit) { + stack2.stackSize = limit; + stack.stackSize -= limit; + } + else { + stack.stackSize = 0; + } + slot.putStack(stack2); + slot.onSlotChanged(); + flag1 = true; + + if(stack.stackSize == 0) { + break; + } + } + + if(useEndIndex) { + --k; + } + else { + ++k; + } + } + + + return flag1; + } +} diff --git a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java new file mode 100644 index 0000000..8abfcf2 --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java @@ -0,0 +1,284 @@ +package slimeknights.mantle.inventory; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; + +import org.apache.commons.lang3.ObjectUtils; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ContainerMultiModule extends BaseContainer { + + public List subContainers = Lists.newArrayList(); + + // lookup used to redirect slot specific things to the appropriate container + protected Map slotContainerMap = Maps.newHashMap(); + protected Map> subContainerSlotRanges = Maps.newHashMap(); + protected int subContainerSlotStart = -1; + protected Set shiftClickContainers = Sets.newHashSet(); + + public ContainerMultiModule(T tile) { + super(tile); + } + + + /** + * @param subcontainer The container to add + * @param preferForShiftClick If true shift clicking on slots of the main-container will try to move to this module before the player inventory + */ + public void addSubContainer(Container subcontainer, boolean preferForShiftClick) { + if(subContainers.isEmpty()) { + subContainerSlotStart = inventorySlots.size(); + } + subContainers.add(subcontainer); + + if(preferForShiftClick) { + shiftClickContainers.add(subcontainer); + } + + int begin = inventorySlots.size(); + for(Object slot : subcontainer.inventorySlots) { + SlotWrapper wrapper = new SlotWrapper((Slot) slot); + addSlotToContainer(wrapper); + slotContainerMap.put(wrapper.slotNumber, subcontainer); + } + int end = inventorySlots.size(); + subContainerSlotRanges.put(subcontainer, Pair.of(begin, end)); + } + + public TC getSubContainer(Class clazz) { + return getSubContainer(clazz, 0); + } + + public TC getSubContainer(Class clazz, int index) { + for(Container sub : subContainers) { + if(clazz.isAssignableFrom(sub.getClass())) { + index--; + } + if(index < 0) { + return (TC) sub; + } + } + + return null; + } + + public Container getSlotContainer(int slotNumber) { + if(slotContainerMap.containsKey(slotNumber)) { + return slotContainerMap.get(slotNumber); + } + + return this; + } + + @Override + public boolean canInteractWith(EntityPlayer playerIn) { + // check if subcontainers are valid + for(Container sub : subContainers) { + if(!sub.canInteractWith(playerIn)) { + return false; + } + } + + return super.canInteractWith(playerIn); + } + + + @Override + public void onContainerClosed(EntityPlayer playerIn) { + for(Container sub : subContainers) { + sub.onContainerClosed(playerIn); + } + + super.onContainerClosed(playerIn); + } + + @Override + public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer playerIn) { + if(slotId == -999 && mode == 5) { + for(Container container : subContainers) { + container.slotClick(slotId, clickedButton, mode, playerIn); + } + } +/* + if(slotContainerMap.containsKey(slotId)) { + int actualId = slotId; + if(this.inventorySlots.get(slotId) instanceof SlotWrapper) { + actualId = ((SlotWrapper) this.inventorySlots.get(slotId)).parent.slotNumber; + } + return slotContainerMap.get(slotId).slotClick(actualId, clickedButton, mode, playerIn); + }*/ + + return super.slotClick(slotId, clickedButton, mode, playerIn); + } + + // More sophisticated version of the one in BaseContainer + // Takes submodules into account when shiftclicking! + @Override + public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { + Slot slot = (Slot) this.inventorySlots.get(index); + + if(slot == null || !slot.getHasStack()) { + return null; + } + + ItemStack ret = slot.getStack().copy(); + ItemStack itemstack = slot.getStack().copy(); + + Container container = getSlotContainer(index); + + // Is the slot from a module? + if(container != this) { + // Try moving module -> tile inventory + moveToTileInventory(itemstack); + + // Try moving module -> player inventory + if(moveToPlayerInventory(itemstack)) { + return null; + } + } + // Is the slot from the tile? + else if(index < subContainerSlotStart || (index < playerInventoryStart && subContainerSlotStart < 0)) { + // Try moving tile -> preferred modules + refillAnyContainer(itemstack, subContainers); + + // Try moving module -> player inventory + moveToPlayerInventory(itemstack); + + // Try moving module -> all submodules + if(moveToAnyContainer(itemstack, subContainers)) { + return null; + } + } + // Slot is from the player inventory (if present) + else if(index >= playerInventoryStart && playerInventoryStart >= 0) { + // Try moving player -> tile inventory + moveToTileInventory(itemstack); + + // try moving player -> modules + if(moveToAnyContainer(itemstack, subContainers)) { + return null; + } + } + // you violated some assumption or something. Shame on you. + else { + return null; + } + + return notifySlotAfterTransfer(playerIn, itemstack, ret, slot); + } + + protected ItemStack notifySlotAfterTransfer(EntityPlayer player, ItemStack stack, ItemStack original, Slot slot) { + // notify slot + slot.onSlotChange(stack, original); + + if(stack.stackSize == original.stackSize) { + return null; + } + + // update slot we pulled from + slot.putStack(stack); + slot.onPickupFromSlot(player, stack); + + if(slot.getHasStack() && slot.getStack().stackSize == 0) { + slot.putStack(null); + } + + return original; + } + + protected boolean moveToTileInventory(ItemStack itemstack) { + if(itemstack == null || itemstack.stackSize == 0) { + return false; + } + + int end = subContainerSlotStart; + if(end < 0) { + end = playerInventoryStart; + } + return !this.mergeItemStack(itemstack, 0, end, false); + } + + protected boolean moveToPlayerInventory(ItemStack itemstack) { + if(itemstack == null || itemstack.stackSize == 0) { + return false; + } + + return playerInventoryStart > 0 && !this + .mergeItemStack(itemstack, playerInventoryStart, this.inventorySlots.size(), true); + } + + protected boolean moveToAnyContainer(ItemStack itemstack, Collection containers) { + if(itemstack == null || itemstack.stackSize == 0) { + return false; + } + + for(Container submodule : containers) { + if(moveToContainer(itemstack, submodule)) { + return true; + } + } + + return false; + } + + protected boolean moveToContainer(ItemStack itemstack, Container container) { + Pair range = subContainerSlotRanges.get(container); + if(!this.mergeItemStack(itemstack, range.getLeft(), range.getRight(), false)) { + return true; + } + return false; + } + + + protected boolean refillAnyContainer(ItemStack itemstack, Collection containers) { + if(itemstack == null || itemstack.stackSize == 0) { + return false; + } + + for(Container submodule : containers) { + if(refillContainer(itemstack, submodule)) { + return true; + } + } + + return false; + } + + protected boolean refillContainer(ItemStack itemstack, Container container) { + Pair range = subContainerSlotRanges.get(container); + if(!this.mergeItemStackRefill(itemstack, range.getLeft(), range.getRight(), false)) { + return true; + } + return false; + } + + /** Searches for a sidechest to display in the UI */ + public TE detectTE(Class clazz) { + return ObjectUtils.firstNonNull(detectChest(this.pos.north(), clazz), + detectChest(this.pos.east(), clazz), + detectChest(this.pos.south(), clazz), + detectChest(this.pos.west(), clazz)); + } + + private TE detectChest(BlockPos pos, Class clazz) { + TileEntity te = this.world.getTileEntity(pos); + + if(te != null && clazz.isAssignableFrom(te.getClass())) { + return (TE) te; + } + return null; + } +} diff --git a/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java b/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java new file mode 100644 index 0000000..abaee40 --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java @@ -0,0 +1,36 @@ +package slimeknights.mantle.inventory; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + +import slimeknights.mantle.tileentity.TileInventory; + +public class ContainerSimpleChest extends BaseContainer { + + public ContainerSimpleChest(TileInventory tile, int rows, int columns, InventoryPlayer playerInventory) { + super(tile); + + int index = 0; + + // chest inventory + for(int i = 0; i < rows; ++i) { + for(int j = 0; j < columns; ++j) { + // safety + if(index > tile.getSizeInventory()) { + break; + } + + this.addSlotToContainer(createSlot(tile, index, 8 + j * 18, 18 + i * 18)); + index++; + } + } + + // player inventory + addPlayerInventory(playerInventory, 17, 86); + } + + protected Slot createSlot(IInventory inventory, int index, int x, int y) { + return new Slot(inventory, index, x, y); + } +} diff --git a/src/main/java/slimeknights/mantle/inventory/IContainerCraftingCustom.java b/src/main/java/slimeknights/mantle/inventory/IContainerCraftingCustom.java new file mode 100644 index 0000000..fa97dac --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/IContainerCraftingCustom.java @@ -0,0 +1,10 @@ +package slimeknights.mantle.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + +public interface IContainerCraftingCustom { + + void onCrafting(EntityPlayer player, ItemStack output, IInventory craftMatrix); +} diff --git a/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java b/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java new file mode 100644 index 0000000..162162b --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java @@ -0,0 +1,34 @@ +package slimeknights.mantle.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.inventory.SlotCrafting; +import net.minecraft.item.ItemStack; + +public class SlotCraftingCustom extends SlotCrafting { + + private final InventoryCrafting craftMatrix; + private final IContainerCraftingCustom callback; + + /** + * @param callback Container that gets the crafting call on crafting + * @param player Player that does the crafting + * @param craftingInventory Inventory where the ingredients are taken from + * @param craftResult Inventory where the result is put + */ + public SlotCraftingCustom(IContainerCraftingCustom callback, EntityPlayer player, InventoryCrafting craftingInventory, IInventory craftResult, int slotIndex, int xPosition, int yPosition) { + super(player, craftingInventory, craftResult, slotIndex, xPosition, yPosition); + + this.craftMatrix = craftingInventory; + this.callback = callback; + } + + @Override + public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) { + net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix); + this.onCrafting(stack); + + callback.onCrafting(playerIn, stack, craftMatrix); + } +} diff --git a/src/main/java/slimeknights/mantle/inventory/SlotOut.java b/src/main/java/slimeknights/mantle/inventory/SlotOut.java new file mode 100644 index 0000000..03764b9 --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/SlotOut.java @@ -0,0 +1,18 @@ +package slimeknights.mantle.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +/** Slot that can only be taken out of */ +public class SlotOut extends Slot { + + public SlotOut(IInventory inventoryIn, int index, int xPosition, int yPosition) { + super(inventoryIn, index, xPosition, yPosition); + } + + @Override + public boolean isItemValid(ItemStack stack) { + return false; + } +} diff --git a/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java b/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java new file mode 100644 index 0000000..29cf460 --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java @@ -0,0 +1,21 @@ +package slimeknights.mantle.inventory; + +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class SlotRestrictedItem extends Slot { + + private final Item allowedItem; + + public SlotRestrictedItem(Item item, IInventory inventoryIn, int index, int xPosition, int yPosition) { + super(inventoryIn, index, xPosition, yPosition); + allowedItem = item; + } + + @Override + public boolean isItemValid(ItemStack stack) { + return stack != null && stack.getItem() == allowedItem; + } +} diff --git a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java new file mode 100644 index 0000000..3dc9d29 --- /dev/null +++ b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java @@ -0,0 +1,41 @@ +package slimeknights.mantle.inventory; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +/** + * Used to wrap the slots inside Modules/Subcontainers + */ +public class SlotWrapper extends Slot { + + public final Slot parent; + + public SlotWrapper(Slot slot) { + super(slot.inventory, slot.getSlotIndex(), slot.xDisplayPosition, slot.yDisplayPosition); + this.parent = slot; + } + + @Override + public void onSlotChange(ItemStack p_75220_1_, ItemStack p_75220_2_) { + parent.onSlotChange(p_75220_1_, p_75220_2_); + } + + @Override + public boolean isItemValid(ItemStack stack) { + return parent.isItemValid(stack); + } + + @Override + public boolean canTakeStack(EntityPlayer playerIn) { + return parent.canTakeStack(playerIn); + } + + @SideOnly(Side.CLIENT) + @Override + public boolean canBeHovered() { + return parent.canBeHovered(); + } +} diff --git a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java new file mode 100644 index 0000000..bdcdeb6 --- /dev/null +++ b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java @@ -0,0 +1,11 @@ +package slimeknights.mantle.item; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemColored; + +public class ItemBlockMeta extends ItemColored { + + public ItemBlockMeta(Block block) { + super(block, true); + } +} diff --git a/src/main/java/slimeknights/mantle/item/ItemMeta.java b/src/main/java/slimeknights/mantle/item/ItemMeta.java new file mode 100644 index 0000000..4d26058 --- /dev/null +++ b/src/main/java/slimeknights/mantle/item/ItemMeta.java @@ -0,0 +1,36 @@ +package slimeknights.mantle.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Item representing a fixed amount of different items represented by meta. + */ +public class ItemMeta extends Item { + + protected int maxMeta; + + public ItemMeta(int maxMeta) { + setHasSubtypes(true); + this.maxMeta = maxMeta; + } + + @Override + public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { + for(int i = 0; i <= maxMeta; i++) { + subItems.add(new ItemStack(itemIn, 1, i)); + } + } + + @Override + public int getMetadata(int damage) { + if(damage < 0 || damage > maxMeta) { + return 0; + } + + return damage; + } +} diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java new file mode 100644 index 0000000..79eb9e7 --- /dev/null +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -0,0 +1,62 @@ +package slimeknights.mantle.item; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Item representing a dynamic amount of different items represented by meta. + * Only returns valid metadatas. The validity is determined by a bitmask. + * Current maximum is 64 metas - that should suffice for most applications. + */ +public class ItemMetaDynamic extends ItemMeta { + + private static int MAX = Long.SIZE; + + protected long availabilityMask; + + public ItemMetaDynamic() { + super(-1); + + } + + public ItemStack addMeta(int meta) { + if(meta > MAX) { + throw new IllegalArgumentException(String + .format("Metadata too high, highest supported value is %d. Meta was %d", MAX, meta)); + } + if(meta > maxMeta) { + maxMeta = meta; + setValid(meta); + } + return new ItemStack(this, 1, meta); + } + + @Override + public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { + for(int i = 0; i <= maxMeta; i++) { + if(isValid(i)) { + subItems.add(new ItemStack(itemIn, 1, i)); + } + } + } + + @Override + public int getMetadata(int damage) { + int meta = super.getMetadata(damage); + return isValid(meta) ? meta : 0; + } + + protected void setValid(int meta) { + availabilityMask |= 1 << meta; + } + + protected boolean isValid(int meta) { + if(meta > MAX) { + return false; + } + return ((availabilityMask >> meta) & 1) == 1; + } +} diff --git a/src/main/java/slimeknights/mantle/network/AbstractPacket.java b/src/main/java/slimeknights/mantle/network/AbstractPacket.java new file mode 100644 index 0000000..dd9bd46 --- /dev/null +++ b/src/main/java/slimeknights/mantle/network/AbstractPacket.java @@ -0,0 +1,47 @@ +package slimeknights.mantle.network; + +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.util.BlockPos; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.relauncher.Side; + +import io.netty.buffer.ByteBuf; + +public abstract class AbstractPacket implements IMessage, IMessageHandler { + + @Override + public IMessage onMessage(IMessage message, MessageContext ctx) { + if(!(message instanceof AbstractPacket)) { + return null; + } + + AbstractPacket packet = (AbstractPacket) message; + + if(ctx.side == Side.SERVER) { + return packet.handleServer(ctx.getServerHandler()); + } + else { + return packet.handleClient(ctx.getClientHandler()); + } + } + + public abstract IMessage handleClient(NetHandlerPlayClient netHandler); + + public abstract IMessage handleServer(NetHandlerPlayServer netHandler); + + protected void writePos(BlockPos pos, ByteBuf buf) { + buf.writeInt(pos.getX()); + buf.writeInt(pos.getY()); + buf.writeInt(pos.getZ()); + } + + protected BlockPos readPos(ByteBuf buf) { + int x = buf.readInt(); + int y = buf.readInt(); + int z = buf.readInt(); + return new BlockPos(x, y, z); + } +} diff --git a/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java b/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java new file mode 100644 index 0000000..d055113 --- /dev/null +++ b/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java @@ -0,0 +1,41 @@ +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.network.simpleimpl.IMessage; + +/** + * Threadsafe integration of the abstract packet. + * Basically if you're doing something that has any influence on the world you should use this. + * (That's ~everything) + */ +public abstract class AbstractPacketThreadsafe extends AbstractPacket { + + @Override + public final IMessage handleClient(final NetHandlerPlayClient netHandler) { + Minecraft.getMinecraft().addScheduledTask(new Runnable() { + @Override + public void run() { + handleClientSafe(netHandler); + } + }); + return null; + } + + @Override + public final IMessage handleServer(final NetHandlerPlayServer netHandler) { + MinecraftServer.getServer().addScheduledTask(new Runnable() { + @Override + public void run() { + handleServerSafe(netHandler); + } + }); + return null; + } + + public abstract void handleClientSafe(NetHandlerPlayClient netHandler); + + public abstract void handleServerSafe(NetHandlerPlayServer netHandler); +} diff --git a/src/main/java/slimeknights/mantle/network/NetworkWrapper.java b/src/main/java/slimeknights/mantle/network/NetworkWrapper.java new file mode 100644 index 0000000..b3423e5 --- /dev/null +++ b/src/main/java/slimeknights/mantle/network/NetworkWrapper.java @@ -0,0 +1,55 @@ +package slimeknights.mantle.network; + +import com.google.common.base.Throwables; + +import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import net.minecraftforge.fml.relauncher.Side; + +/** + * A small network implementation/wrapper using AbstractPackets instead of IMessages. + * Instantiate in your mod class and register your packets accordingly. + */ +public class NetworkWrapper { + + public final SimpleNetworkWrapper network; + private int id = 0; + + public NetworkWrapper(String channelName) { + network = NetworkRegistry.INSTANCE.newSimpleChannel(channelName); + } + + /** + * Packet will be received on both cliend and server side. + */ + public void registerPacket(Class packetClazz) { + registerPacketClient(packetClazz); + registerPacketServer(packetClazz); + } + + /** + * Packet will only be received on the client side + */ + public void registerPacketClient(Class packetClazz) { + registerPacketImpl(packetClazz, Side.CLIENT); + } + + /** + * Packet will only be received on the server side + */ + public void registerPacketServer(Class packetClazz) { + registerPacketImpl(packetClazz, Side.SERVER); + } + + private void registerPacketImpl(Class packetClazz, Side side) { + IMessageHandler handler; + try { + handler = packetClazz.newInstance(); + } catch(Exception e) { + throw Throwables.propagate(e); + } + + network.registerMessage(handler, packetClazz, id++, side); + } +} diff --git a/src/main/java/slimeknights/mantle/property/PropertyString.java b/src/main/java/slimeknights/mantle/property/PropertyString.java new file mode 100644 index 0000000..4fc3f20 --- /dev/null +++ b/src/main/java/slimeknights/mantle/property/PropertyString.java @@ -0,0 +1,32 @@ +package slimeknights.mantle.property; + +import net.minecraftforge.common.property.IUnlistedProperty; + +public class PropertyString implements IUnlistedProperty { + + private final String name; + + public PropertyString(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean isValid(String value) { + return !value.isEmpty(); + } + + @Override + public Class getType() { + return String.class; + } + + @Override + public String valueToString(String value) { + return value; + } +} diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java new file mode 100644 index 0000000..d291f3d --- /dev/null +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -0,0 +1,242 @@ +package slimeknights.mantle.tileentity; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.IChatComponent; + +// Updated version of InventoryLogic in Mantle. Also contains a few bugfixes +public class TileInventory extends TileEntity implements IInventory { + + private ItemStack[] inventory; + protected String inventoryTitle; + protected boolean hasCustomName; + protected int stackSizeLimit; + + /** + * @param name Localization String for the inventory title. Can be overridden through setCustomName + */ + public TileInventory(String name, int inventorySize) { + this(name, inventorySize, 64); + } + + /** + * @param name Localization String for the inventory title. Can be overridden through setCustomName + */ + public TileInventory(String name, int inventorySize, int maxStackSize) { + this.inventory = new ItemStack[inventorySize]; + this.stackSizeLimit = maxStackSize; + this.inventoryTitle = name; + } + + /* Inventory management */ + + @Override + public ItemStack getStackInSlot(int slot) { + if(slot < 0 || slot >= inventory.length) { + return null; + } + + return inventory[slot]; + } + + public boolean isStackInSlot(int slot) { + return getStackInSlot(slot) != null; + } + + @Override + public int getSizeInventory() { + return inventory.length; + } + + @Override + public int getInventoryStackLimit() { + return stackSizeLimit; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack itemstack) { + if(slot < 0 || slot >= inventory.length) { + return; + } + + inventory[slot] = itemstack; + if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public ItemStack decrStackSize(int slot, int quantity) { + ItemStack itemStack = getStackInSlot(slot); + + if(itemStack == null) { + return null; + } + + // whole itemstack taken out + if(itemStack.stackSize <= quantity) { + setInventorySlotContents(slot, null); + this.markDirty(); + return itemStack; + } + + // split itemstack + itemStack = itemStack.splitStack(quantity); + // slot is empty, set to null + if(getStackInSlot(slot).stackSize == 0) { + setInventorySlotContents(slot, null); + } + + this.markDirty(); + // return remainder + return itemStack; + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack itemstack) { + if(slot < getSizeInventory()) { + if(inventory[slot] == null || itemstack.stackSize + inventory[slot].stackSize <= getInventoryStackLimit()) { + return true; + } + } + return false; + } + + @Override + public void clear() { + for(int i = 0; i < inventory.length; i++) { + inventory[i] = null; + } + } + + @Override + public String getCommandSenderName() { + return this.inventoryTitle; + } + + @Override + public boolean hasCustomName() { + return this.hasCustomName; + } + + public void setCustomName(String customName) { + this.hasCustomName = true; + this.inventoryTitle = customName; + } + + @Override + public IChatComponent getDisplayName() { + if(hasCustomName()) { + return new ChatComponentText(getCommandSenderName()); + } + + return new ChatComponentTranslation(getCommandSenderName()); + } + + + /* Supporting methods */ + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + // block changed/got broken? + if(worldObj.getTileEntity(pos) != this || worldObj.getBlockState(pos).getBlock() == Blocks.air) { + return false; + } + + return + entityplayer.getDistanceSq((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) + <= 64D; + } + + @Override + public void openInventory(EntityPlayer player) { + + } + + @Override + public void closeInventory(EntityPlayer player) { + + } + + /* NBT */ + @Override + public void readFromNBT(NBTTagCompound tags) { + super.readFromNBT(tags); + readInventoryFromNBT(tags); + } + + public void readInventoryFromNBT(NBTTagCompound tags) { + super.readFromNBT(tags); + readInventoryFromNBT(this, tags); + + if(tags.hasKey("CustomName", 8)) { + this.inventoryTitle = tags.getString("CustomName"); + } + } + + @Override + public void writeToNBT(NBTTagCompound tags) { + super.writeToNBT(tags); + writeInventoryToNBT(this, tags); + + if(this.hasCustomName()) { + tags.setString("CustomName", this.inventoryTitle); + } + } + + /** Writes the contents of the inventory to the tag */ + public static void writeInventoryToNBT(IInventory inventory, NBTTagCompound tag) { + NBTTagList nbttaglist = new NBTTagList(); + + for(int i = 0; i < inventory.getSizeInventory(); i++) { + if(inventory.getStackInSlot(i) != null) { + NBTTagCompound itemTag = new NBTTagCompound(); + itemTag.setByte("Slot", (byte) i); + inventory.getStackInSlot(i).writeToNBT(itemTag); + nbttaglist.appendTag(itemTag); + } + } + + tag.setTag("Items", nbttaglist); + } + + /** Reads a an inventory from the tag. Overwrites current content */ + public static void readInventoryFromNBT(IInventory inventory, NBTTagCompound tag) { + NBTTagList nbttaglist = tag.getTagList("Items", 10); + + for(int i = 0; i < nbttaglist.tagCount(); ++i) { + NBTTagCompound itemTag = nbttaglist.getCompoundTagAt(i); + int slot = itemTag.getByte("Slot") & 255; + + if(slot >= 0 && slot < inventory.getSizeInventory()) { + inventory.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(itemTag)); + } + } + } + + /* Default implementations of hardly used methods */ + public ItemStack getStackInSlotOnClosing(int slot) { + return null; + } + + @Override + public int getField(int id) { + return 0; + } + + @Override + public void setField(int id, int value) { + + } + + @Override + public int getFieldCount() { + return 0; + } +} diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java new file mode 100644 index 0000000..0f8d937 --- /dev/null +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -0,0 +1,205 @@ +package slimeknights.mantle.util; + +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import slimeknights.mantle.Mantle; + +/** + * Utility class that allows to find a specific subset of items in a list of itemstacks. + * Matches can be found through oredictionary, simple nbt-independant item-meta combinations etc. + * + * The match returned by this class can then be used to remove the found recipe match from the items. + */ +public abstract class RecipeMatch { + + + + protected final int amountNeeded; + protected final int amountMatched; + + /** + * @param amountNeeded How many of the itemstack are needed for the match + * @param amountMatched If amount needed itemstacks are present, as how many matches does this count? + */ + public RecipeMatch(int amountMatched, int amountNeeded) { + this.amountMatched = amountMatched; + this.amountNeeded = amountNeeded; + } + + public abstract Match matches(ItemStack[] stacks); + + /** Removes the match from the stacks */ + public static void removeMatch(ItemStack[] stacks, Match match) { + for(ItemStack stack : match.stacks) { + for(int i = 0; i < stacks.length; i++) { + // nbt sensitive since toolparts etc. use nbt + if(ItemStack.areItemsEqual(stack, stacks[i]) && ItemStack.areItemStackTagsEqual(stack, stacks[i])) { + if(stacks[i].stackSize < stack.stackSize) { + Mantle.logger.error("RecipeMatch has incorrect stacksize! {}", stacks[i].toString()); + } + else { + stacks[i].stackSize -= stack.stackSize; + if(stacks[i].stackSize == 0) { + stacks[i] = null; + } + } + break; + } + } + } + } + + /** A specific amount of a certain item is needed. Supports wildcard-metadata. Not NBT sensitive. */ + public static class Item extends RecipeMatch { + + private final ItemStack template; + + public Item(ItemStack template, int amountNeeded) { + this(template, amountNeeded, 1); + } + + /** + * @param template The itemstack to match + * @param amountNeeded How many of the itemstack are needed for the match + * @param amountMatched If amountneeded itemstacks are present, as how many matches does this count? + */ + public Item(ItemStack template, int amountNeeded, int amountMatched) { + super(amountMatched, amountNeeded); + this.template = template; + } + + @Override + public Match matches(ItemStack[] stacks) { + List found = Lists.newLinkedList(); + int stillNeeded = amountNeeded; + + for(ItemStack stack : stacks) { + if(OreDictionary.itemMatches(template, stack, false)) { + // add the amount found to the list + ItemStack copy = stack.copy(); + copy.stackSize = Math.min(copy.stackSize, stillNeeded); + found.add(copy); + stillNeeded -= copy.stackSize; + + // we found enough + if(stillNeeded <= 0) { + return new Match(found, amountMatched); + } + } + } + + return null; + } + } + + /** A combination of multiple items. NBT SENSITIVE! */ + public static class ItemCombination extends RecipeMatch { + + protected final ItemStack[] itemStacks; + + /** + * @param amountMatched If amount needed itemstacks are present, as how many matches does this count? + */ + public ItemCombination(int amountMatched, ItemStack... stacks) { + super(amountMatched, 0); + + this.itemStacks = stacks; + } + + @Override + public Match matches(ItemStack[] stacks) { + List found = Lists.newLinkedList(); + Set needed = Sets.newHashSet(); + + for(int i = 0; i < itemStacks.length; i++) { + if(itemStacks[i] != null) { + needed.add(i); + } + } + + for(ItemStack stack : stacks) { + Iterator iter = needed.iterator(); + while(iter.hasNext()) { + int index = iter.next(); + ItemStack template = itemStacks[index]; + if(ItemStack.areItemsEqual(template, stack) && ItemStack.areItemStackTagsEqual(template, stack)) { + // add the amount found to the list + ItemStack copy = stack.copy(); + copy.stackSize = 1; + found.add(copy); + iter.remove(); + break; + } + } + } + + if(needed.isEmpty()) { + return new Match(found, amountMatched); + } + return null; + } + } + + /** A specific amount of an oredicted material is needed to match. */ + public static class Oredict extends RecipeMatch { + + private final List oredictEntry; // todo: change this to the actual list in the oredict + + public Oredict(String oredictEntry, int amountNeeded) { + this(oredictEntry, amountNeeded, 1); + } + + public Oredict(String oredictEntry, int amountNeeded, int amountMatched) { + super(amountNeeded, amountMatched); + this.oredictEntry = OreDictionary.getOres(oredictEntry); + } + + @Override + public Match matches(ItemStack[] stacks) { + List found = Lists.newLinkedList(); + int stillNeeded = amountNeeded; + + for(ItemStack ore : oredictEntry) { + for(ItemStack stack : stacks) { + if(OreDictionary.itemMatches(ore, stack, false)) { + // add the amount found to the list + ItemStack copy = stack.copy(); + copy.stackSize = Math.min(copy.stackSize, stillNeeded); + found.add(copy); + stillNeeded -= copy.stackSize; + + // we found enough + if(stillNeeded <= 0) { + return new Match(found, amountMatched); + } + } + } + } + + return null; + } + } + + /** Represents a collection of items that match the recipies */ + public static class Match { + + /** The stacks that have to be removed to apply this match */ + public List stacks; + + /** How often the recipe is found within this match */ + public int amount; + + public Match(List stacks, int amount) { + this.stacks = stacks; + this.amount = amount; + } + } +} diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java b/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java new file mode 100644 index 0000000..8d8daf6 --- /dev/null +++ b/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java @@ -0,0 +1,133 @@ +package slimeknights.mantle.util; + +import com.google.common.collect.Lists; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.Collection; +import java.util.List; + +/** + * Contains a set of matches. Allows you to easily find if a set of itemstacks matches one of them. + */ +// MANTLE +public class RecipeMatchRegistry { + + protected final List items = Lists.newArrayList(); + + public RecipeMatch.Match matches(Collection stacks) { + return matches(stacks.toArray(new ItemStack[stacks.size()])); + } + + // looks for a match in the given itemstacks + public RecipeMatch.Match matches(ItemStack... stacks) { + for(RecipeMatch recipe : items) { + RecipeMatch.Match match = recipe.matches(stacks); + if(match != null) { + return match; + } + } + + return null; + } + + // looks for a match with at least the given amount in the given itemstacks + public RecipeMatch.Match matches(ItemStack[] stacks, int minAmount) { + stacks = copyItemStackArray(stacks); // copy so we don't modify original + + List matches = Lists.newLinkedList(); + + RecipeMatch.Match match; + int sum = 0; + while(sum < minAmount && (match = matches(stacks)) != null) { + matches.add(match); + RecipeMatch.removeMatch(stacks, match); + + sum += match.amount; + } + + // not enough found + if(sum < minAmount) { + return null; + } + + // merge all found matches into one match + List foundStacks = Lists.newLinkedList(); + for(RecipeMatch.Match m : matches) { + foundStacks.addAll(m.stacks); + } + + return new RecipeMatch.Match(foundStacks, sum); + } + + /** + * Associates an oredict entry with this material. Used for repairing and other. + * + * @param oredictItem Oredict-String + * @param amountNeeded How many of this item are needed to count as one full material item. + * @param amountMatched If both item and amount are present, how often did they match? + */ + public void addItem(String oredictItem, int amountNeeded, int amountMatched) { + items.add(new RecipeMatch.Oredict(oredictItem, amountNeeded, amountMatched)); + } + + public void addItem(String oredictItem) { + addItem(oredictItem, 1, 1); + } + + /** + * Associates a block with this material. Used for repairing and other. + * + * @param amountMatched For how many matches the block counts (e.g. redstone dust = 1 match, Redstone block = 9) + */ + public void addItem(Block block, int amountMatched) { + items.add(new RecipeMatch.Item(new ItemStack(block), 1, amountMatched)); + } + + /** + * Associates an item entry with this material. Used for repairing and other. + * + * @param item The item + * @param amountNeeded How many of this item are needed to count as one full material item. + * @param amountMatched If both item and amount are present, how often did they match? + */ + public void addItem(Item item, int amountNeeded, int amountMatched) { + items.add(new RecipeMatch.Item(new ItemStack(item), amountNeeded, amountMatched)); + } + + /** + * Associates an item entry with this material. Used for repairing and other. + * + * @param item The item + * @param amountNeeded How many of this item are needed to count as one full material item. + * @param amountMatched If both item and amount are present, how often did they match? + */ + public void addItem(ItemStack item, int amountNeeded, int amountMatched) { + items.add(new RecipeMatch.Item(item, amountNeeded, amountMatched)); + } + + /** + * Associates an item with this material. Used for repairing and other. + */ + public void addItem(Item item) { + addItem(item, 1, 1); + } + + public void addRecipeMatch(RecipeMatch match) { + items.add(match); + } + + + public static ItemStack[] copyItemStackArray(ItemStack[] in) { + ItemStack[] stacksCopy = new ItemStack[in.length]; + for(int i = 0; i < in.length; i++) { + if(in[i] != null) { + stacksCopy[i] = in[i].copy(); + } + } + + return stacksCopy; + } +} diff --git a/src/main/java/mantle/utils/RecipeRemover.java b/src/main/java/slimeknights/mantle/util/RecipeRemover.java similarity index 99% rename from src/main/java/mantle/utils/RecipeRemover.java rename to src/main/java/slimeknights/mantle/util/RecipeRemover.java index 8da1de6..c681589 100644 --- a/src/main/java/mantle/utils/RecipeRemover.java +++ b/src/main/java/slimeknights/mantle/util/RecipeRemover.java @@ -1,4 +1,4 @@ -package mantle.utils; +package slimeknights.mantle.util; import java.util.List; import java.util.Map; diff --git a/src/main/java/slimeknights/mantle/util/SlimeknightException.java b/src/main/java/slimeknights/mantle/util/SlimeknightException.java new file mode 100644 index 0000000..58b35ca --- /dev/null +++ b/src/main/java/slimeknights/mantle/util/SlimeknightException.java @@ -0,0 +1,27 @@ +package slimeknights.mantle.util; + +public class SlimeknightException extends RuntimeException { + + public SlimeknightException() { + } + + public SlimeknightException(String message) { + super(message); + } + + public SlimeknightException(String message, Object... params) { + super(String.format(message, params)); + } + + public SlimeknightException(String message, Throwable cause) { + super(message, cause); + } + + public SlimeknightException(Throwable cause) { + super(cause); + } + + public SlimeknightException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/slimeknights/mantle/util/TagHelper.java b/src/main/java/slimeknights/mantle/util/TagHelper.java new file mode 100644 index 0000000..3151e53 --- /dev/null +++ b/src/main/java/slimeknights/mantle/util/TagHelper.java @@ -0,0 +1,40 @@ +package slimeknights.mantle.util; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +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(); + + private TagHelper() { + } + + /* Generic Tag Operations */ + public static NBTTagCompound getTagSafe(ItemStack stack) { + if(stack == null || stack.getItem() == null || !stack.hasTagCompound()) { + return new NBTTagCompound(); + } + + return stack.getTagCompound(); + } + + public static NBTTagCompound getTagSafe(NBTTagCompound tag, String key) { + if(tag == null || !tag.hasKey(key)) { + return new NBTTagCompound(); + } + + return tag.getCompoundTag(key); + } + + public static NBTTagList getTagListSafe(NBTTagCompound tag, String key, int type) { + if(tag == null || !tag.hasKey(key)) { + return new NBTTagList(); + } + + return tag.getTagList(key, type); + } + +} diff --git a/src/main/resources/META-INF/Mantle_at.cfg b/src/main/resources/META-INF/Mantle_at.cfg new file mode 100644 index 0000000..c92f814 --- /dev/null +++ b/src/main/resources/META-INF/Mantle_at.cfg @@ -0,0 +1,11 @@ +# Mantle -- Access Transformer + +# GuiContainer +public net.minecraft.client.gui.inventory.GuiContainer field_146999_f #xSize +public net.minecraft.client.gui.inventory.GuiContainer field_147000_g #ySize +public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop +public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft +public net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V #renderSlot +public net.minecraft.client.gui.inventory.GuiContainer func_146981_a(Lnet/minecraft/inventory/Slot;II)Z #isMouseOverSlot +# GuiScreen +public net.minecraft.client.gui.GuiScreen field_146292_n #buttonList From 68911993fb9145b248680e21b8c0fc1ff578d4a6 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 29 Sep 2015 09:32:09 +0200 Subject: [PATCH 38/91] Move multiblock/master/server logic to separate package --- .../slimeknights/mantle/{block => multiblock}/IMasterLogic.java | 2 +- .../slimeknights/mantle/{block => multiblock}/IMasterNode.java | 2 +- .../mantle/{block => multiblock}/IServantLogic.java | 2 +- .../mantle/{block => multiblock}/MultiServantLogic.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/slimeknights/mantle/{block => multiblock}/IMasterLogic.java (85%) rename src/main/java/slimeknights/mantle/{block => multiblock}/IMasterNode.java (81%) rename src/main/java/slimeknights/mantle/{block => multiblock}/IServantLogic.java (96%) rename src/main/java/slimeknights/mantle/{block => multiblock}/MultiServantLogic.java (99%) diff --git a/src/main/java/slimeknights/mantle/block/IMasterLogic.java b/src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java similarity index 85% rename from src/main/java/slimeknights/mantle/block/IMasterLogic.java rename to src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java index 92d7357..1f66dfa 100644 --- a/src/main/java/slimeknights/mantle/block/IMasterLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/IMasterLogic.java @@ -1,4 +1,4 @@ -package slimeknights.mantle.block; +package slimeknights.mantle.multiblock; import net.minecraft.util.BlockPos; diff --git a/src/main/java/slimeknights/mantle/block/IMasterNode.java b/src/main/java/slimeknights/mantle/multiblock/IMasterNode.java similarity index 81% rename from src/main/java/slimeknights/mantle/block/IMasterNode.java rename to src/main/java/slimeknights/mantle/multiblock/IMasterNode.java index 1a49c0c..312c25d 100644 --- a/src/main/java/slimeknights/mantle/block/IMasterNode.java +++ b/src/main/java/slimeknights/mantle/multiblock/IMasterNode.java @@ -1,4 +1,4 @@ -package slimeknights.mantle.block; +package slimeknights.mantle.multiblock; public interface IMasterNode extends IMasterLogic, IServantLogic { diff --git a/src/main/java/slimeknights/mantle/block/IServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/IServantLogic.java similarity index 96% rename from src/main/java/slimeknights/mantle/block/IServantLogic.java rename to src/main/java/slimeknights/mantle/multiblock/IServantLogic.java index 3adebea..3319277 100644 --- a/src/main/java/slimeknights/mantle/block/IServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/IServantLogic.java @@ -1,4 +1,4 @@ -package slimeknights.mantle.block; +package slimeknights.mantle.multiblock; import net.minecraft.util.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/slimeknights/mantle/block/MultiServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java similarity index 99% rename from src/main/java/slimeknights/mantle/block/MultiServantLogic.java rename to src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java index 66eb098..5dcd89b 100644 --- a/src/main/java/slimeknights/mantle/block/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java @@ -1,4 +1,4 @@ -package slimeknights.mantle.block; +package slimeknights.mantle.multiblock; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; From 008bbfeeb5851db9f230b23dacc7ddb0e514d42d Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 29 Sep 2015 09:32:35 +0200 Subject: [PATCH 39/91] Expand dynamic item containing multiple items with the (unlocalized) names and a way to register models for it easily. --- .../slimeknights/mantle/item/ItemMeta.java | 36 -------------- .../mantle/item/ItemMetaDynamic.java | 49 +++++++++++++++++-- 2 files changed, 46 insertions(+), 39 deletions(-) delete mode 100644 src/main/java/slimeknights/mantle/item/ItemMeta.java diff --git a/src/main/java/slimeknights/mantle/item/ItemMeta.java b/src/main/java/slimeknights/mantle/item/ItemMeta.java deleted file mode 100644 index 4d26058..0000000 --- a/src/main/java/slimeknights/mantle/item/ItemMeta.java +++ /dev/null @@ -1,36 +0,0 @@ -package slimeknights.mantle.item; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import java.util.List; - -/** - * Item representing a fixed amount of different items represented by meta. - */ -public class ItemMeta extends Item { - - protected int maxMeta; - - public ItemMeta(int maxMeta) { - setHasSubtypes(true); - this.maxMeta = maxMeta; - } - - @Override - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { - for(int i = 0; i <= maxMeta; i++) { - subItems.add(new ItemStack(itemIn, 1, i)); - } - } - - @Override - public int getMetadata(int damage) { - if(damage < 0 || damage > maxMeta) { - return 0; - } - - return damage; - } -} diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index 79eb9e7..407d292 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -1,28 +1,48 @@ package slimeknights.mantle.item; +import gnu.trove.map.hash.TIntObjectHashMap; +import gnu.trove.procedure.TIntObjectProcedure; + +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; +import java.util.Locale; /** * Item representing a dynamic amount of different items represented by meta. * Only returns valid metadatas. The validity is determined by a bitmask. * Current maximum is 64 metas - that should suffice for most applications. */ -public class ItemMetaDynamic extends ItemMeta { +public class ItemMetaDynamic extends Item { private static int MAX = Long.SIZE; + protected int maxMeta; protected long availabilityMask; + protected TIntObjectHashMap names; public ItemMetaDynamic() { - super(-1); + maxMeta = -1; + names = new TIntObjectHashMap(); + this.setHasSubtypes(true); } - public ItemStack addMeta(int meta) { + /** + * 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. + * @return An itemstack representing the Item-Meta combination. + */ + public ItemStack addMeta(int meta, String name) { if(meta > MAX) { throw new IllegalArgumentException(String .format("Metadata too high, highest supported value is %d. Meta was %d", MAX, meta)); @@ -31,9 +51,16 @@ public class ItemMetaDynamic extends ItemMeta { maxMeta = meta; setValid(meta); } + names.put(meta, name); return new ItemStack(this, 1, meta); } + @Override + public String getUnlocalizedName(ItemStack stack) { + int meta = stack.getMetadata(); // should call getMetadata below + return super.getUnlocalizedName(stack) + "." + names.get(meta).toLowerCase(Locale.US).replaceAll(" ", ""); + } + @Override public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { for(int i = 0; i <= maxMeta; i++) { @@ -59,4 +86,20 @@ public class ItemMetaDynamic extends ItemMeta { } return ((availabilityMask >> meta) & 1) == 1; } + + @SideOnly(Side.CLIENT) + public void registerItemModels() { + final String resourceId = Loader.instance().activeModContainer().getModId().toLowerCase(); + final Item item = this; + names.forEachEntry(new TIntObjectProcedure() { + @Override + public boolean execute(int meta, String name) { + name = String.format("%s:%s", resourceId, name); + ModelBakery.addVariantName(item, name); + // tell the game which model to use for this item-meta combination + ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(name, "inventory")); + return true; + } + }); + } } From b50419cd6b7e9fffe6c7b12ccff22e0c862d8892 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 29 Sep 2015 18:15:32 +0200 Subject: [PATCH 40/91] Add property-support to ItemBlockMeta for the unlocalized names. Also add a utility function to register blocks models based on that. --- .../mantle/item/ItemBlockMeta.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java index bdcdeb6..cebb8ff 100644 --- a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java +++ b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java @@ -1,11 +1,54 @@ package slimeknights.mantle.item; import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.item.Item; import net.minecraft.item.ItemColored; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.ModelLoader; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.registry.GameData; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.Collection; +import java.util.Locale; public class ItemBlockMeta extends ItemColored { + protected IProperty mappingProperty; + public ItemBlockMeta(Block block) { super(block, true); } + + @Override + public String getUnlocalizedName(ItemStack stack) { + if(mappingProperty == null) return super.getUnlocalizedName(stack); + + IBlockState state = block.getStateFromMeta(stack.getMetadata()); + String name = state.getValue(mappingProperty).toString().toLowerCase(Locale.US); + return super.getUnlocalizedName(stack) + "." + name; + } + + public static void setMappingProperty(Block block, IProperty property) { + ((ItemBlockMeta)Item.getItemFromBlock(block)).mappingProperty = property; + } + + @SideOnly(Side.CLIENT) + public void registerItemModels() { + final Item item = this; + final ResourceLocation loc = (ResourceLocation) GameData.getBlockRegistry().getNameForObject(block); + + + 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)); + } + } } From c798d616d7d260d6721354bcfc56632fbff3a797 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 30 Sep 2015 22:54:46 +0200 Subject: [PATCH 41/91] Fix Oredict-Recipematch being messed up --- src/main/java/slimeknights/mantle/util/RecipeMatch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index 0f8d937..0e37562 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -158,7 +158,7 @@ public abstract class RecipeMatch { } public Oredict(String oredictEntry, int amountNeeded, int amountMatched) { - super(amountNeeded, amountMatched); + super(amountMatched, amountNeeded); this.oredictEntry = OreDictionary.getOres(oredictEntry); } From 6c06ee151aed7550a17037db2f8c61d3c59d8d6e Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 15 Oct 2015 00:20:57 +0200 Subject: [PATCH 42/91] Add the ability to have dynamic tooltips in the loc file for the dynamic items --- .../mantle/item/ItemMetaDynamic.java | 16 +++++++++++++- .../slimeknights/mantle/util/LocUtils.java | 21 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/main/java/slimeknights/mantle/util/LocUtils.java diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index 407d292..10602ca 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -6,8 +6,11 @@ import gnu.trove.procedure.TIntObjectProcedure; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.relauncher.Side; @@ -16,6 +19,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; import java.util.Locale; +import slimeknights.mantle.util.LocUtils; + /** * Item representing a dynamic amount of different items represented by meta. * Only returns valid metadatas. The validity is determined by a bitmask. @@ -58,7 +63,7 @@ public class ItemMetaDynamic extends Item { @Override public String getUnlocalizedName(ItemStack stack) { int meta = stack.getMetadata(); // should call getMetadata below - return super.getUnlocalizedName(stack) + "." + names.get(meta).toLowerCase(Locale.US).replaceAll(" ", ""); + return super.getUnlocalizedName(stack) + "." + LocUtils.makeLocString(names.get(meta)); } @Override @@ -102,4 +107,13 @@ public class ItemMetaDynamic extends Item { } }); } + + @Override + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + if(StatCollector.canTranslate(this.getUnlocalizedName(stack) + ".tooltip")) { + tooltip.add(EnumChatFormatting.GRAY.toString() + + LocUtils.translateRecursive(this.getUnlocalizedName(stack) + ".tooltip")); + } + super.addInformation(stack, playerIn, tooltip, advanced); + } } diff --git a/src/main/java/slimeknights/mantle/util/LocUtils.java b/src/main/java/slimeknights/mantle/util/LocUtils.java new file mode 100644 index 0000000..42f55a6 --- /dev/null +++ b/src/main/java/slimeknights/mantle/util/LocUtils.java @@ -0,0 +1,21 @@ +package slimeknights.mantle.util; + +import net.minecraft.util.StatCollector; + +import java.util.Locale; + +// localization utils +public abstract class LocUtils { + private LocUtils() {} + + /** + * Removes all whitespaces from the string and makes it lowercase. + */ + public static String makeLocString(String unclean) { + return unclean.toLowerCase(Locale.US).replaceAll(" ", ""); + } + + public static String translateRecursive(String key, Object... params) { + return StatCollector.translateToLocal(StatCollector.translateToLocalFormatted(key, params)); + } +} From 448bb9e173968a712dd37859e6a86c8ee8f19cb0 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 15 Oct 2015 20:41:35 +0200 Subject: [PATCH 43/91] Fix crash with invalid metadatas --- src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index 10602ca..062b355 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -63,7 +63,10 @@ public class ItemMetaDynamic extends Item { @Override public String getUnlocalizedName(ItemStack stack) { int meta = stack.getMetadata(); // should call getMetadata below - return super.getUnlocalizedName(stack) + "." + LocUtils.makeLocString(names.get(meta)); + if(isValid(meta)) + return super.getUnlocalizedName(stack) + "." + LocUtils.makeLocString(names.get(meta)); + else + return super.getUnlocalizedName(stack); } @Override From 858c6ed0334464f1442b25b0c4377627120bda03 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 15 Oct 2015 22:15:58 +0200 Subject: [PATCH 44/91] Try fixing shift-click duping when only the last condition for moving fails --- .../inventory/ContainerMultiModule.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java index 8abfcf2..fb6706b 100644 --- a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java +++ b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java @@ -138,45 +138,44 @@ public class ContainerMultiModule extends BaseContainer ItemStack itemstack = slot.getStack().copy(); Container container = getSlotContainer(index); + boolean nothingDone = true; // Is the slot from a module? if(container != this) { // Try moving module -> tile inventory - moveToTileInventory(itemstack); + nothingDone &= moveToTileInventory(itemstack); // Try moving module -> player inventory - if(moveToPlayerInventory(itemstack)) { - return null; - } + nothingDone &= moveToPlayerInventory(itemstack); } // Is the slot from the tile? else if(index < subContainerSlotStart || (index < playerInventoryStart && subContainerSlotStart < 0)) { // Try moving tile -> preferred modules - refillAnyContainer(itemstack, subContainers); + nothingDone &= refillAnyContainer(itemstack, subContainers); // Try moving module -> player inventory - moveToPlayerInventory(itemstack); + nothingDone &= moveToPlayerInventory(itemstack); // Try moving module -> all submodules - if(moveToAnyContainer(itemstack, subContainers)) { - return null; - } + nothingDone &= moveToAnyContainer(itemstack, subContainers); } // Slot is from the player inventory (if present) else if(index >= playerInventoryStart && playerInventoryStart >= 0) { // Try moving player -> tile inventory - moveToTileInventory(itemstack); + nothingDone &= moveToTileInventory(itemstack); // try moving player -> modules - if(moveToAnyContainer(itemstack, subContainers)) { - return null; - } + nothingDone &= moveToAnyContainer(itemstack, subContainers); } // you violated some assumption or something. Shame on you. else { return null; } + if(nothingDone) { + return null; + } + return notifySlotAfterTransfer(playerIn, itemstack, ret, slot); } From 6721bd104a455cf12803389eb7c04331e4e740db Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 17 Oct 2015 22:23:41 +0200 Subject: [PATCH 45/91] Make registration of itemmeta-dynamic models more flexible --- src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index 062b355..aadf640 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -96,13 +96,13 @@ public class ItemMetaDynamic extends Item { } @SideOnly(Side.CLIENT) - public void registerItemModels() { + public void registerItemModels(final String prefix) { final String resourceId = Loader.instance().activeModContainer().getModId().toLowerCase(); final Item item = this; names.forEachEntry(new TIntObjectProcedure() { @Override public boolean execute(int meta, String name) { - name = String.format("%s:%s", resourceId, name); + name = String.format("%s:%s%s", resourceId, prefix, name); ModelBakery.addVariantName(item, name); // tell the game which model to use for this item-meta combination ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(name, "inventory")); From 6fcd92dec9f4045058a6688a26954c6799a79206 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 22 Oct 2015 13:33:36 +0200 Subject: [PATCH 46/91] Welcome back pulsar! --- .../mantle/pulsar/config/ForgeCFG.java | 58 ++++ .../mantle/pulsar/config/IConfiguration.java | 31 ++ .../mantle/pulsar/control/PulseManager.java | 294 ++++++++++++++++++ .../mantle/pulsar/debug/EventSpy.java | 28 ++ .../mantle/pulsar/internal/Configuration.java | 253 +++++++++++++++ .../mantle/pulsar/internal/CrashHandler.java | 62 ++++ .../pulsar/internal/logging/ILogger.java | 24 ++ .../pulsar/internal/logging/JULLogger.java | 56 ++++ .../pulsar/internal/logging/Log4jLogger.java | 56 ++++ .../pulsar/internal/logging/LogManager.java | 53 ++++ .../mantle/pulsar/package-info.java | 36 +++ .../mantle/pulsar/pulse/Pulse.java | 53 ++++ .../mantle/pulsar/pulse/PulseMeta.java | 53 ++++ 13 files changed, 1057 insertions(+) create mode 100644 src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/package-info.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java create mode 100644 src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java diff --git a/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java b/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java new file mode 100644 index 0000000..c75e344 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java @@ -0,0 +1,58 @@ +package mantle.pulsar.config; + +import java.io.File; + +import mantle.pulsar.pulse.PulseMeta; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.common.Loader; + +/** + * Mantle specific pulsar addon class to support using the forge CFG format for configurations + * @author progwml6 + */ +public class ForgeCFG implements IConfiguration +{ + + private static Configuration config; + + private final String confPath; + + private final String description; + + /** + * Creates a new Configuration object. + * + * Do NOT make this the same as the overall mod configuration; it will clobber it! + * + * @param confName The config file name (without path or .cfg suffix) + * @param description The description for the group that the config entries will be placed in. + */ + public ForgeCFG(String confName, String description) + { + this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".cfg"; + this.description = description; + } + + @Override + public void load() + { + config = new Configuration(new File(this.confPath)); + config.load(); + } + + @Override + public boolean isModuleEnabled(PulseMeta meta) + { + return config.get(this.description, meta.getId(), meta.isEnabled(), meta.getDescription()).getBoolean(meta.isEnabled()); + } + + @Override + public void flush() + { + if (config.hasChanged()) + { + config.save(); + } + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java new file mode 100644 index 0000000..cf14e24 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java @@ -0,0 +1,31 @@ +package mantle.pulsar.config; + +import mantle.pulsar.pulse.PulseMeta; + +/** + * Interface for config handlers. + * + * @author Arkan + */ +public interface IConfiguration +{ + + /** + * Perform any configuration loading required. + */ + public void load(); + + /** + * Gets whether the given module is enabled in the config. + * + * @param meta The pulse metadata. + * @return Whether the module is enabled. + */ + public boolean isModuleEnabled(PulseMeta meta); + + /** + * Flush configuration to disk/database/whatever. + */ + public void flush(); + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java new file mode 100644 index 0000000..08e512a --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java @@ -0,0 +1,294 @@ +package mantle.pulsar.control; + +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import mantle.pulsar.config.IConfiguration; +import mantle.pulsar.internal.Configuration; +import mantle.pulsar.internal.CrashHandler; +import mantle.pulsar.internal.logging.ILogger; +import mantle.pulsar.internal.logging.LogManager; +import mantle.pulsar.pulse.Pulse; +import mantle.pulsar.pulse.PulseMeta; +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.FMLModContainer; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.event.FMLEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; +import com.google.common.eventbus.SubscriberExceptionContext; +import com.google.common.eventbus.SubscriberExceptionHandler; + +/** + * Manager class for a given mods Pulses. + * + * This MUST be constructed by a mod BEFORE preinit as it registers on to the mod event bus - a static block would serve + * for this. No more Pulses can be registered after preinit has been caught, so assume preinit is too late to register + * new Pulses. + * + * Each Pulsar-enabled mod should create one and only one of these to manage its Pulses. + * + * @author Arkan + */ +@SuppressWarnings("unused") +public class PulseManager +{ + + private ILogger log; + + private final boolean useConfig; + + private final LinkedHashMap pulses = new LinkedHashMap(); + + private boolean blockNewRegistrations = false; + + private boolean configLoaded = false; + + private IConfiguration conf; + + private EventBus bus; + + private String id; + + /** + * Configuration-using constructor. + * + * This form creates a PulseManager that supports configuration of Pulses by file. + * + * @param configName The config file name. + */ + public PulseManager(String configName) + { + this.init(); + this.useConfig = true; + this.conf = new Configuration(configName, this.log); + } + + /** + * Custom configuration-using constructor. + * + * Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star. + * Whatever really. See {@link mantle.pulsar.config.IConfiguration}. + * + * @param config Configuration handler. + */ + public PulseManager(IConfiguration config) + { + this.init(); + this.useConfig = true; + this.conf = config; + } + + /** + * Shared initialiser code between all the constructors. + */ + private void init() + { + String modId = Loader.instance().activeModContainer().getModId(); + this.id = modId; + this.log = LogManager.getLogger("Pulsar-" + modId); + FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this)); + // Attach us to the mods FML bus and setup our own bus + this.bus = new EventBus(new BusExceptionHandler(modId)); + this.attachToContainerEventBus(this); + } + + /** + * Register a new Pulse with the manager. + * + * This CANNOT be done after preInit() has been invoked. + * + * @param pulse The Pulse to register. + */ + public void registerPulse(Object pulse) + { + if (this.blockNewRegistrations) + { + throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " + + pulse); + } + if (!this.configLoaded) + { + this.conf.load(); + this.configLoaded = true; + } + + String id, description, deps; + boolean forced, enabled, defaultEnabled, missingDeps = false; + + try + { + Pulse p = pulse.getClass().getAnnotation(Pulse.class); + id = p.id(); + description = p.description(); + deps = p.modsRequired(); + forced = p.forced(); + enabled = p.defaultEnable(); + defaultEnabled = p.defaultEnable(); + } + catch (NullPointerException ex) + { + throw new RuntimeException("Could not parse @Pulse annotation for Pulse: " + pulse); + } + + // Work around Java not allowing default-null fields. + if (description.equals("")) + { + description = null; + } + + if (!deps.equals("")) + { + String[] parsedDeps = deps.split(";"); + for (String s : parsedDeps) + { + if (!Loader.isModLoaded(s)) + { + this.log.info("Skipping Pulse " + id + "; missing dependency: " + s); + missingDeps = true; + enabled = false; + break; + } + } + } + + PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); + meta.setEnabled(!missingDeps && this.getEnabledFromConfig(meta)); + + if (meta.isEnabled()) + { + this.pulses.put(pulse, meta); + // Attach Pulse to internal event bus + this.bus.register(pulse); + } + } + + /** + * Helper to attach a given object to the modcontainer event bus. + * + * @param obj Object to register. + */ + private void attachToContainerEventBus(Object obj) + { + ModContainer cnt = Loader.instance().activeModContainer(); + this.log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); + try + { + FMLModContainer mc = (FMLModContainer) cnt; + Field ebf = mc.getClass().getDeclaredField("eventBus"); + + boolean access = ebf.isAccessible(); + ebf.setAccessible(true); + EventBus eb = (EventBus) ebf.get(mc); + ebf.setAccessible(access); + + eb.register(obj); + } + catch (NoSuchFieldException nsfe) + { + throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?"); + } + catch (IllegalAccessException iae) + { + throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue."); + } + catch (ClassCastException cce) + { + throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage()); + } + } + + /** + * Internal (but public for EventBus use) handler for events. + * + * DO NOT CALL THIS DIRECTLY! Let EventBus handle it. + * + * @param evt An event object. + */ + @Subscribe + public void propagateEvent(FMLEvent evt) + { + if (evt instanceof FMLPreInitializationEvent) + { + this.preInit((FMLPreInitializationEvent) evt); + } + this.bus.post(evt); + } + + private boolean getEnabledFromConfig(PulseMeta meta) + { + if (meta.isForced() || !this.useConfig) + { + return true; // Forced or no config set. + } + + return this.conf.isModuleEnabled(meta); + } + + public void preInit(FMLPreInitializationEvent evt) + { + if (!this.blockNewRegistrations) + { + this.conf.flush(); // First preInit call, so flush config + } + this.blockNewRegistrations = true; + } + + /** + * Check if a given Pulse ID is loaded in this manager. + * + * @param pulseId The ID to check. + * @return Whether the ID was present. + */ + public boolean isPulseLoaded(String pulseId) + { + for (Map.Entry entry : this.pulses.entrySet()) + { + if (entry.getValue().getId().equals(pulseId)) + { + return true; + } + } + return false; + } + + public Collection getAllPulseMetadata() + { + return this.pulses.values(); + } + + /** + * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) + */ + private class BusExceptionHandler implements SubscriberExceptionHandler + { + private final String id; + + /** + * @param id Mod ID to include in exception raises. + */ + public BusExceptionHandler(String id) + { + this.id = id; + } + + @Override + public void handleException(Throwable exception, SubscriberExceptionContext ctx) + { + FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + this.id + " >> Exception uncaught in [" + + ctx.getSubscriber().getClass().getName() + ":" + ctx.getSubscriberMethod().getName() + + "] for event [" + ctx.getEvent().getClass().getSimpleName() + "]", true); + } + } + + @Override + public String toString() + { + return "PulseManager[" + this.id + "]"; + } +} diff --git a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java new file mode 100644 index 0000000..36d11aa --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java @@ -0,0 +1,28 @@ +package mantle.pulsar.debug; + +import mantle.pulsar.internal.logging.ILogger; +import mantle.pulsar.internal.logging.LogManager; +import mantle.pulsar.pulse.Pulse; +import net.minecraftforge.fml.common.Loader; + +import com.google.common.eventbus.Subscribe; + +/** + * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. + * + * @author Arkan + */ +@SuppressWarnings("unused") +@Pulse(id = "EventSpy", description = "we iz in ur buses, monitorin ur eventz", forced = true) +public class EventSpy +{ + + private final ILogger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); + + @Subscribe + public void receive(Object evt) + { + this.log.info("Received event: " + evt); + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java new file mode 100644 index 0000000..44769e9 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java @@ -0,0 +1,253 @@ +package mantle.pulsar.internal; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.util.HashMap; +import java.util.Map; + +import mantle.pulsar.config.IConfiguration; +import mantle.pulsar.internal.logging.ILogger; +import mantle.pulsar.pulse.PulseMeta; +import net.minecraftforge.fml.common.Loader; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Default Gson Configuration helper. + * + * @author Arkan + */ +public class Configuration implements IConfiguration +{ + + private static final int CONFIG_LEVEL = 1; + + private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + + private final String confPath; + + private final ILogger logger; + + private Map modules; + + /** + * Creates a new Configuration object. + * + * Do NOT make this the same as the overall mod configuration; it will clobber it! + * + * @param confName The config file name (without path or .json suffix) + * @param logger The logger to send debug info to. + */ + public Configuration(String confName, ILogger logger) + { + this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json"; + this.logger = logger; + } + + @Override + public void load() + { + this.getModulesFromJson(); + } + + @Override + public boolean isModuleEnabled(PulseMeta meta) + { + ConfigEntry entry = this.modules.get(meta.getId()); + if (entry == null) + { + this.modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); + return meta.isEnabled(); + } + else + { + return entry.getEnabled(); + } + } + + @Override + public void flush() + { + this.writeModulesToJson(); + } + + private void getModulesFromJson() + { + // Step 1: Does the file exist? + File f = new File(this.confPath); + if (!f.exists()) + { + this.logger.info("Couldn't find config file; will generate a new one later."); + this.modules = new HashMap(); + return; + } + + // Step 2: File exists. Let's make sure it's usable. + if (!(f.canRead() && f.canWrite())) + { + throw new FileNotReadWritableException("Could not read/write Pulsar config: " + this.confPath); + } + + // Step 3: Good enough. Read it. + try + { + try + { + this.modules = this.parseV1Config(f); + } + catch (Exception ex) + { + this.logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); + Map conf = this.parseV0Config(f); + this.logger.info("Found valid v0 configuration. Upgrading it."); + this.modules = conf; + this.writeModulesToJson(); + this.logger.info("Upgrade complete! Config is now in v1 format."); + } + } + catch (Exception ex) + { + this.logger.warn("Invalid config file. Discarding."); + ex.printStackTrace(); + this.modules = new HashMap(); + } + } + + private Map parseV0Config(File f) throws Exception + { + try + { + JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); + Map m = gson.fromJson(reader, new TypeToken>() + { + }.getType()); // NASTY! + if (m == null) + { + throw new NullPointerException("Gson returned null."); + } + Map out = new HashMap(); + for (Map.Entry e : m.entrySet()) + { + out.put(e.getKey(), new ConfigEntry(e.getValue())); + } + return out; + } + catch (FileNotFoundException fnfe) + { + throw new RuntimeException("This shouldn't be possible... " + fnfe); + } + } + + private Map parseV1Config(File f) throws Exception + { + try + { + JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); + GsonConfig c = gson.fromJson(reader, GsonConfig.class); + if (c.getConfigVersion() > 1) + { + throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); + } + if (c.getModules() == null) + { + throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); + } + return c.getModules(); + } + catch (FileNotFoundException fnfe) + { + throw new RuntimeException("This shouldn't be possible... " + fnfe); + } + } + + private void writeModulesToJson() + { + try + { + JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(this.confPath)))); + writer.setIndent(" "); + GsonConfig out = new GsonConfig(CONFIG_LEVEL, this.modules); + gson.toJson(out, GsonConfig.class, writer); + writer.close(); + } + catch (Exception ex) + { + this.logger.warn("Could not write config? " + this.confPath); + } + } + + /** + * Internal exception for an unreadable/unwritable config. + */ + private static class FileNotReadWritableException extends RuntimeException + { + public FileNotReadWritableException(String message) + { + super(message); + } + } + + /** + * Internal data holder, for use in the map and JSON. + */ + private static class ConfigEntry + { + + private Boolean enabled; + + private String description = null; + + public ConfigEntry(Boolean enabled) + { + this.enabled = enabled; + } + + public ConfigEntry(Boolean enabled, String description) + { + this(enabled); + this.description = description; + } + + public Boolean getEnabled() + { + return this.enabled; + } + } + + /** + * Internal representation of a version 1+ config file. + */ + private static class GsonConfig + { + + private int CONFIG_VERSION = 0; + + private Map modules; + + public GsonConfig(int version, Map modules) + { + this.CONFIG_VERSION = version; + this.modules = modules; + } + + public int getConfigVersion() + { + return this.CONFIG_VERSION; + } + + public Map getModules() + { + return this.modules; + } + + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java new file mode 100644 index 0000000..aa9233d --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java @@ -0,0 +1,62 @@ +package mantle.pulsar.internal; + +import mantle.pulsar.control.PulseManager; +import mantle.pulsar.pulse.PulseMeta; +import net.minecraftforge.fml.common.ICrashCallable; + +/** + * FML crash callable for Pulse Managers; dumps a list of loaded pulses to the error log. + * + * @author Arkan + */ +public class CrashHandler implements ICrashCallable +{ + + private String id; + + private PulseManager manager; + + public CrashHandler(String modId, PulseManager manager) + { + this.id = "Pulsar/" + modId + " loaded Pulses"; + this.manager = manager; + } + + @Override + public String getLabel() + { + return this.id; + } + + @Override + public String call() throws Exception + { + String out = "\n"; + for (PulseMeta meta : this.manager.getAllPulseMetadata()) + { + String state = getStateFromMeta(meta); + out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... + } + return out; + } + + private static String getStateFromMeta(PulseMeta meta) + { + if (meta.isForced()) + { + return "Enabled/Forced"; + } + else + { + if (meta.isEnabled()) + { + return "Enabled/Not Forced"; + } + else + { + return "Disabled/Not Forced"; + } + } + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java new file mode 100644 index 0000000..d1b38d6 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java @@ -0,0 +1,24 @@ +package mantle.pulsar.internal.logging; + +/** + * Interface for log wrappers. + * + * @author Arkan + */ +@SuppressWarnings("unused") +public interface ILogger +{ + + public void fatal(String msg); + + public void severe(String msg); + + public void warn(String msg); + + public void info(String msg); + + public void debug(String msg); + + public void trace(String msg); + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java new file mode 100644 index 0000000..b632936 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java @@ -0,0 +1,56 @@ +package mantle.pulsar.internal.logging; + +import java.util.logging.Logger; + +/** + * Java logger wrapper. + * + * @author Arkan + */ +public class JULLogger implements ILogger +{ + + private final Logger log; + + public JULLogger(String name) + { + this.log = Logger.getLogger(name); + } + + @Override + public void fatal(String msg) + { + this.log.severe(msg); // JUL doesn't -have- fatal... + } + + @Override + public void severe(String msg) + { + this.log.severe(msg); + } + + @Override + public void warn(String msg) + { + this.log.warning(msg); + } + + @Override + public void info(String msg) + { + this.log.info(msg); + } + + @Override + public void debug(String msg) + { + this.log.fine(msg); // Good enough. + } + + @Override + public void trace(String msg) + { + this.log.finest(msg); // Closest we'll get. + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java new file mode 100644 index 0000000..ab6c80d --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java @@ -0,0 +1,56 @@ +package mantle.pulsar.internal.logging; + +import org.apache.logging.log4j.Logger; + +/** + * Log4j log wrapper. + * + * @author Arkan + */ +public class Log4jLogger implements ILogger +{ + + private final Logger log; + + public Log4jLogger(String name) + { + this.log = org.apache.logging.log4j.LogManager.getLogger(name); + } + + @Override + public void fatal(String msg) + { + this.log.fatal(msg); + } + + @Override + public void severe(String msg) + { + this.log.error(msg); + } + + @Override + public void warn(String msg) + { + this.log.warn(msg); + } + + @Override + public void info(String msg) + { + this.log.info(msg); + } + + @Override + public void debug(String msg) + { + this.log.debug(msg); + } + + @Override + public void trace(String msg) + { + this.log.trace(msg); + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java new file mode 100644 index 0000000..16b2ba9 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java @@ -0,0 +1,53 @@ +package mantle.pulsar.internal.logging; + +/** + * Static class for getting generic loggers. + * + * @author Arkan + */ +public class LogManager +{ + + private LogManager() + { + } // Singleton. + + private static final boolean useLog4j2; + + /* + * Detect the presence of log4j2. + * + * If it's present, we can assume we should be using the damn thing. + */ + static + { + boolean l4j = false; + try + { + Class cl = Class.forName("org.apache.logging.log4j.LogManager"); + if (cl == null) + { + throw new ClassNotFoundException("This should never happen..."); + } + l4j = true; + } + catch (ClassNotFoundException cnfe) + { + // Ignore + } + useLog4j2 = l4j; + } + + public static ILogger getLogger(String name) + { + if (useLog4j2) + { + return new Log4jLogger(name); + } + else + { + return new JULLogger(name); + } + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/package-info.java b/src/main/java/slimeknights/mantle/pulsar/package-info.java new file mode 100644 index 0000000..8c4fa42 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/package-info.java @@ -0,0 +1,36 @@ +/** + * Project Pulsar + * + * This is a repackaged copy of the Pulsar project, an open source library for internal module loading. + * The upstream repository is at https://github.com/Emberwalker/Pulsar + * + * This code package is licensed under the MIT License, as below. + * + * ----- + * + * The MIT License (MIT) + * + * Copyright (c) 2014 Arkan + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * ----- + * + * @author Arkan + */ +package mantle.pulsar; \ No newline at end of file diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java b/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java new file mode 100644 index 0000000..ad9366c --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java @@ -0,0 +1,53 @@ +package mantle.pulsar.pulse; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Metadata annotation for IPulse implementations. + * + * Pulses should use the standard Google Event Bus @Subscribe annotation to catch FML events, which are forwarded from + * the current mod container (including Pre/Init/Post events). + * + * @author Arkan + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.TYPE }) +@Documented +public @interface Pulse +{ + + /** + * @return This Pulses UID - Much like FML mods have mod IDs. + */ + public String id(); + + /** + * @return This Pulses description, human-readable for config files. Can be blank. + */ + public String description() default ""; + + /** + * @return Dependant mod IDs, seperated by ; as in FML. Skips checks when undefined. + */ + public String modsRequired() default ""; + + /** + * @return Dependeant Pulse IDs, seperated by ; . Skips checks when undefined. + */ + public String pulsesRequired() default ""; + + /** + * @return Whether this Pulse is mandatory or not (true -> mandatory). + */ + public boolean forced() default false; + + /** + * @return Whether a configurable Pulse should be enabled by default. Ignored where forced = true. + */ + public boolean defaultEnable() default true; + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java new file mode 100644 index 0000000..c1ef504 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java @@ -0,0 +1,53 @@ +package mantle.pulsar.pulse; + +/** + * Metadata wrapper for parsed @Pulse metadata. + * + * @author Arkan + */ +public class PulseMeta +{ + + private String id, description; + + private boolean forced, enabled, defaultEnabled; + + public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) + { + this.id = id; + this.description = description; + this.forced = forced; + this.enabled = enabled; + this.defaultEnabled = defaultEnabled; + } + + public String getId() + { + return this.id; + } + + public String getDescription() + { + return this.description; + } + + public boolean isForced() + { + return this.forced; + } + + public boolean isEnabled() + { + return this.enabled; + } + + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + public boolean isDefaultEnabled() + { + return this.defaultEnabled; + } +} From bf10777128288f11788cb54a5115eff732c4dbc1 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 22 Oct 2015 13:41:44 +0200 Subject: [PATCH 47/91] Update package on the unchanged pulse files --- .../slimeknights/mantle/pulsar/config/ForgeCFG.java | 4 ++-- .../mantle/pulsar/config/IConfiguration.java | 4 ++-- .../mantle/pulsar/control/PulseManager.java | 2 +- .../slimeknights/mantle/pulsar/debug/EventSpy.java | 8 ++++---- .../mantle/pulsar/internal/Configuration.java | 8 ++++---- .../mantle/pulsar/internal/CrashHandler.java | 6 +++--- .../mantle/pulsar/internal/logging/ILogger.java | 2 +- .../mantle/pulsar/internal/logging/JULLogger.java | 2 +- .../mantle/pulsar/internal/logging/Log4jLogger.java | 2 +- .../mantle/pulsar/internal/logging/LogManager.java | 2 +- .../slimeknights/mantle/pulsar/package-info.java | 2 +- .../slimeknights/mantle/pulsar/pulse/Pulse.java | 13 ++++--------- .../slimeknights/mantle/pulsar/pulse/PulseMeta.java | 2 +- 13 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java b/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java index c75e344..6bc495e 100644 --- a/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java +++ b/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java @@ -1,8 +1,8 @@ -package mantle.pulsar.config; +package slimeknights.mantle.pulsar.config; import java.io.File; -import mantle.pulsar.pulse.PulseMeta; +import slimeknights.mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Loader; diff --git a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java index cf14e24..3cc4378 100644 --- a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java +++ b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java @@ -1,6 +1,6 @@ -package mantle.pulsar.config; +package slimeknights.mantle.pulsar.config; -import mantle.pulsar.pulse.PulseMeta; +import slimeknights.mantle.pulsar.pulse.PulseMeta; /** * Interface for config handlers. diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java index 08e512a..9fb91bd 100644 --- a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java @@ -1,4 +1,4 @@ -package mantle.pulsar.control; +package slimeknights.mantle.pulsar.control; import java.lang.reflect.Field; import java.util.Collection; diff --git a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java index 36d11aa..5458721 100644 --- a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java +++ b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java @@ -1,8 +1,8 @@ -package mantle.pulsar.debug; +package slimeknights.mantle.pulsar.debug; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.internal.logging.LogManager; -import mantle.pulsar.pulse.Pulse; +import slimeknights.mantle.pulsar.internal.logging.ILogger; +import slimeknights.mantle.pulsar.internal.logging.LogManager; +import slimeknights.mantle.pulsar.pulse.Pulse; import net.minecraftforge.fml.common.Loader; import com.google.common.eventbus.Subscribe; diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java index 44769e9..dca1972 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java @@ -1,4 +1,4 @@ -package mantle.pulsar.internal; +package slimeknights.mantle.pulsar.internal; import java.io.File; import java.io.FileInputStream; @@ -9,9 +9,9 @@ import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.Map; -import mantle.pulsar.config.IConfiguration; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.pulse.PulseMeta; +import slimeknights.mantle.pulsar.config.IConfiguration; +import slimeknights.mantle.pulsar.internal.logging.ILogger; +import slimeknights.mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.fml.common.Loader; import com.google.gson.Gson; diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java index aa9233d..81f011b 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java @@ -1,7 +1,7 @@ -package mantle.pulsar.internal; +package slimeknights.mantle.pulsar.internal; -import mantle.pulsar.control.PulseManager; -import mantle.pulsar.pulse.PulseMeta; +import slimeknights.mantle.pulsar.control.PulseManager; +import slimeknights.mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.fml.common.ICrashCallable; /** diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java index d1b38d6..7845712 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java @@ -1,4 +1,4 @@ -package mantle.pulsar.internal.logging; +package slimeknights.mantle.pulsar.internal.logging; /** * Interface for log wrappers. diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java index b632936..991b227 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java @@ -1,4 +1,4 @@ -package mantle.pulsar.internal.logging; +package slimeknights.mantle.pulsar.internal.logging; import java.util.logging.Logger; diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java index ab6c80d..0ee21ec 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java @@ -1,4 +1,4 @@ -package mantle.pulsar.internal.logging; +package slimeknights.mantle.pulsar.internal.logging; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java index 16b2ba9..db4892d 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java @@ -1,4 +1,4 @@ -package mantle.pulsar.internal.logging; +package slimeknights.mantle.pulsar.internal.logging; /** * Static class for getting generic loggers. diff --git a/src/main/java/slimeknights/mantle/pulsar/package-info.java b/src/main/java/slimeknights/mantle/pulsar/package-info.java index 8c4fa42..d3b6f3e 100644 --- a/src/main/java/slimeknights/mantle/pulsar/package-info.java +++ b/src/main/java/slimeknights/mantle/pulsar/package-info.java @@ -33,4 +33,4 @@ * * @author Arkan */ -package mantle.pulsar; \ No newline at end of file +package slimeknights.mantle.pulsar; \ No newline at end of file diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java b/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java index ad9366c..f8317b4 100644 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/Pulse.java @@ -1,10 +1,6 @@ -package mantle.pulsar.pulse; +package slimeknights.mantle.pulsar.pulse; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** * Metadata annotation for IPulse implementations. @@ -15,10 +11,9 @@ import java.lang.annotation.Target; * @author Arkan */ @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) @Documented -public @interface Pulse -{ +public @interface Pulse { /** * @return This Pulses UID - Much like FML mods have mod IDs. diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java index c1ef504..2146b50 100644 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java @@ -1,4 +1,4 @@ -package mantle.pulsar.pulse; +package slimeknights.mantle.pulsar.pulse; /** * Metadata wrapper for parsed @Pulse metadata. From 37099c953471561e1d0ac8789a4ee6630960cdf7 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 22 Oct 2015 13:47:48 +0200 Subject: [PATCH 48/91] Update pulsar and remaining package fixes --- .../mantle/pulsar/control/PulseManager.java | 79 +++++++------------ .../pulsar/internal/BusExceptionHandler.java | 28 +++++++ .../mantle/pulsar/pulse/PulseMeta.java | 7 ++ 3 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java index 9fb91bd..bbad14b 100644 --- a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java @@ -1,17 +1,8 @@ package slimeknights.mantle.pulsar.control; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; -import mantle.pulsar.config.IConfiguration; -import mantle.pulsar.internal.Configuration; -import mantle.pulsar.internal.CrashHandler; -import mantle.pulsar.internal.logging.ILogger; -import mantle.pulsar.internal.logging.LogManager; -import mantle.pulsar.pulse.Pulse; -import mantle.pulsar.pulse.PulseMeta; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLModContainer; import net.minecraftforge.fml.common.Loader; @@ -19,10 +10,19 @@ import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; -import com.google.common.eventbus.SubscriberExceptionContext; -import com.google.common.eventbus.SubscriberExceptionHandler; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + +import slimeknights.mantle.pulsar.config.IConfiguration; +import slimeknights.mantle.pulsar.internal.BusExceptionHandler; +import slimeknights.mantle.pulsar.internal.Configuration; +import slimeknights.mantle.pulsar.internal.CrashHandler; +import slimeknights.mantle.pulsar.internal.logging.ILogger; +import slimeknights.mantle.pulsar.internal.logging.LogManager; +import slimeknights.mantle.pulsar.pulse.Pulse; +import slimeknights.mantle.pulsar.pulse.PulseMeta; /** * Manager class for a given mods Pulses. @@ -73,7 +73,7 @@ public class PulseManager * Custom configuration-using constructor. * * Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star. - * Whatever really. See {@link mantle.pulsar.config.IConfiguration}. + * Whatever really. See {@link IConfiguration}. * * @param config Configuration handler. */ @@ -94,8 +94,8 @@ public class PulseManager this.log = LogManager.getLogger("Pulsar-" + modId); FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this)); // Attach us to the mods FML bus and setup our own bus - this.bus = new EventBus(new BusExceptionHandler(modId)); this.attachToContainerEventBus(this); + bus = new EventBus(new BusExceptionHandler(modId, "<*pulsar*>")); } /** @@ -163,8 +163,8 @@ public class PulseManager if (meta.isEnabled()) { this.pulses.put(pulse, meta); - // Attach Pulse to internal event bus - this.bus.register(pulse); + // Attach Pulse to its own internal event bus + meta.bus.register(pulse); } } @@ -211,13 +211,13 @@ public class PulseManager * @param evt An event object. */ @Subscribe - public void propagateEvent(FMLEvent evt) - { - if (evt instanceof FMLPreInitializationEvent) - { - this.preInit((FMLPreInitializationEvent) evt); + public void propagateEvent(FMLEvent evt) { + if (evt instanceof FMLPreInitializationEvent) preInit((FMLPreInitializationEvent) evt); + // We use individual buses due to the EventBus class using a Set rather than a List, thus losing the ordering. + // This trick is shamelessly borrowed from FML. + for (PulseMeta pulse : pulses.values()) { + pulse.bus.post(evt); } - this.bus.post(evt); } private boolean getEnabledFromConfig(PulseMeta meta) @@ -257,33 +257,8 @@ public class PulseManager return false; } - public Collection getAllPulseMetadata() - { - return this.pulses.values(); - } - - /** - * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) - */ - private class BusExceptionHandler implements SubscriberExceptionHandler - { - private final String id; - - /** - * @param id Mod ID to include in exception raises. - */ - public BusExceptionHandler(String id) - { - this.id = id; - } - - @Override - public void handleException(Throwable exception, SubscriberExceptionContext ctx) - { - FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + this.id + " >> Exception uncaught in [" - + ctx.getSubscriber().getClass().getName() + ":" + ctx.getSubscriberMethod().getName() - + "] for event [" + ctx.getEvent().getClass().getSimpleName() + "]", true); - } + public Collection getAllPulseMetadata() { + return pulses.values(); } @Override diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java new file mode 100644 index 0000000..bca7f53 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java @@ -0,0 +1,28 @@ +package slimeknights.mantle.pulsar.internal; + +import com.google.common.eventbus.SubscriberExceptionContext; +import com.google.common.eventbus.SubscriberExceptionHandler; +import net.minecraftforge.fml.common.FMLCommonHandler; + +/** + * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) + */ +public final class BusExceptionHandler implements SubscriberExceptionHandler { + private final String id, pulseId; + + /** + * @param id Mod ID to include in exception raises. + */ + public BusExceptionHandler(String id, String pulseId) { + this.id = id; + this.pulseId = pulseId; + } + + @Override + public void handleException(Throwable exception, SubscriberExceptionContext ctx) { + FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + id + "/" + pulseId + + " >> Exception uncaught in [" + ctx.getSubscriber().getClass().getName() + ":" + + ctx.getSubscriberMethod().getName() + "] for event [" + ctx.getEvent().getClass().getSimpleName() + + "]", true); + } +} diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java index 2146b50..50e21ff 100644 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java @@ -1,5 +1,10 @@ package slimeknights.mantle.pulsar.pulse; +import com.google.common.eventbus.EventBus; +import net.minecraftforge.fml.common.Loader; + +import slimeknights.mantle.pulsar.internal.BusExceptionHandler; + /** * Metadata wrapper for parsed @Pulse metadata. * @@ -11,6 +16,7 @@ public class PulseMeta private String id, description; private boolean forced, enabled, defaultEnabled; + public final EventBus bus; public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) { @@ -19,6 +25,7 @@ public class PulseMeta this.forced = forced; this.enabled = enabled; this.defaultEnabled = defaultEnabled; + this.bus = new EventBus(new BusExceptionHandler(Loader.instance().activeModContainer().getModId(), id)); } public String getId() From 1c3f99a0c62c5cb3c72271bb478faa4ab92ebd36 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 24 Oct 2015 17:27:58 +0200 Subject: [PATCH 49/91] Add the ability to have tooltips for itemblock/itemmeta items --- .../mantle/item/ItemBlockMeta.java | 18 ++++++++++++++++++ .../mantle/item/ItemMetaDynamic.java | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java index cebb8ff..914274f 100644 --- a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java +++ b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java @@ -4,10 +4,13 @@ import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.client.resources.model.ModelResourceLocation; +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.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.GameData; @@ -15,8 +18,11 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Collection; +import java.util.List; import java.util.Locale; +import slimeknights.mantle.util.LocUtils; + public class ItemBlockMeta extends ItemColored { protected IProperty mappingProperty; @@ -38,6 +44,18 @@ public class ItemBlockMeta extends ItemColored { ((ItemBlockMeta)Item.getItemFromBlock(block)).mappingProperty = property; } + @Override + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + if(StatCollector.canTranslate(this.getUnlocalizedName(stack) + ".tooltip")) { + tooltip.add(EnumChatFormatting.GRAY.toString() + + LocUtils.translateRecursive(this.getUnlocalizedName(stack) + ".tooltip")); + } + else if(StatCollector.canTranslate(super.getUnlocalizedName(stack) + ".tooltip")) { + tooltip.add(EnumChatFormatting.GRAY.toString() + LocUtils.translateRecursive(super.getUnlocalizedName(stack) + ".tooltip")); + } + super.addInformation(stack, playerIn, tooltip, advanced); + } + @SideOnly(Side.CLIENT) public void registerItemModels() { final Item item = this; diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index aadf640..758ee96 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -117,6 +117,9 @@ public class ItemMetaDynamic extends Item { tooltip.add(EnumChatFormatting.GRAY.toString() + LocUtils.translateRecursive(this.getUnlocalizedName(stack) + ".tooltip")); } + else if(StatCollector.canTranslate(super.getUnlocalizedName(stack) + ".tooltip")) { + tooltip.add(EnumChatFormatting.GRAY.toString() + LocUtils.translateRecursive(super.getUnlocalizedName(stack) + ".tooltip")); + } super.addInformation(stack, playerIn, tooltip, advanced); } } From f176b55cb28746251dd9b9a8061e6af92dead355 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 25 Oct 2015 17:30:21 +0100 Subject: [PATCH 50/91] Implementation of a block that is defined by an enumProperty. Abstracts away all the metadata setting and stuff, but requires an interface on the enum. --- .../slimeknights/mantle/block/EnumBlock.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/main/java/slimeknights/mantle/block/EnumBlock.java diff --git a/src/main/java/slimeknights/mantle/block/EnumBlock.java b/src/main/java/slimeknights/mantle/block/EnumBlock.java new file mode 100644 index 0000000..021b519 --- /dev/null +++ b/src/main/java/slimeknights/mantle/block/EnumBlock.java @@ -0,0 +1,76 @@ +package slimeknights.mantle.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.List; + +public class EnumBlock & EnumBlock.IEnumMeta> extends Block { + public final PropertyEnum prop; + private final E[] values; + + private static PropertyEnum tmp; + + public EnumBlock(Material material, PropertyEnum prop, Class clazz) { + super(preInit(material, prop)); + this.prop = prop; + values = clazz.getEnumConstants(); + } + + private static Material preInit(Material material, PropertyEnum property) { + tmp=property; + return material; + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { + for(E type : values) { + list.add(new ItemStack(this, 1, type.getMeta())); + } + } + + @Override + protected BlockState createBlockState() { + if(prop == null) { + return new BlockState(this, tmp); + } + return new BlockState(this, prop); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + return this.getDefaultState().withProperty(prop, fromMeta(meta)); + } + + @Override + public int getMetaFromState(IBlockState state) { + return ((E) state.getValue(prop)).getMeta(); + } + + @Override + public int damageDropped(IBlockState state) { + return getMetaFromState(state); + } + + protected E fromMeta(int meta) { + if(meta < 0 || meta >= values.length) { + meta = 0; + } + + return values[meta]; + } + + public interface IEnumMeta { + int getMeta(); + } +} + From a4190ad47e068a0292c6dacd3e0a1ae5176cd7d2 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Sun, 1 Nov 2015 15:17:17 -0500 Subject: [PATCH 51/91] shade configurate, change group name to match class path --- build.gradle | 20 +++++++++++++++++++- build.properties | 3 ++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 162ddf1..82b66a6 100644 --- a/build.gradle +++ b/build.gradle @@ -42,7 +42,7 @@ repositories { } } -group = 'mantle' +group = 'slimeknights.mantle' sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -90,10 +90,19 @@ minecraft { replace '${version}', project.version } +configurations { + shade + compile.extendsFrom shade +} + dependencies { compile "codechicken:CodeChickenLib:${config.minecraft_version}-${config.CCLIB_version}:dev" compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.ccc_version}:dev" compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.NEI_version}:dev" + // Configuration + shade "ninja.leaping.configurate:configurate-hocon:${config.configurate_version}" + shade "ninja.leaping.configurate:configurate-gson:${config.configurate_version}" + } processResources @@ -112,6 +121,15 @@ processResources } } +jar { + // Shading + configurations.shade.each { dep -> + from(project.zipTree(dep)){ + exclude 'META-INF', 'META-INF/**' + } + } + +} // because the normal output has been made to be obfuscated task deobfJar(type: Jar) { from sourceSets.main.output diff --git a/build.properties b/build.properties index 330a922..5a032e7 100644 --- a/build.properties +++ b/build.properties @@ -5,4 +5,5 @@ mappings=snapshot_20150918 CCLIB_version=1.1.2.133 ccc_version=1.0.5.36 -NEI_version=1.0.5.104 \ No newline at end of file +NEI_version=1.0.5.104 +configurate_version=2.0 \ No newline at end of file From a9daf7502367d320d9751ecadfc0fccd21dd3c88 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 1 Nov 2015 21:54:16 +0100 Subject: [PATCH 52/91] Update forge --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 5a032e7..2eccd2c 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ mod_version=0.5 minecraft_version=1.8 -forge_version=11.14.3.1514 +forge_version=11.14.3.1543 mappings=snapshot_20150918 CCLIB_version=1.1.2.133 From db887e7dbe3b3e63b4dc10d14574eb7b1b713be1 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 1 Nov 2015 21:54:30 +0100 Subject: [PATCH 53/91] Change TRSR Model to use the Vertex Pipeline --- .../mantle/client/model/TRSRBakedModel.java | 83 ++++++++++++------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java index b524870..fa9529a 100644 --- a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -12,11 +12,14 @@ import net.minecraft.client.renderer.vertex.VertexFormatElement; import net.minecraft.util.EnumFacing; import net.minecraftforge.client.model.IFlexibleBakedModel; import net.minecraftforge.client.model.TRSRTransformation; +import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad; +import net.minecraftforge.client.model.pipeline.VertexTransformer; -import java.util.Arrays; import java.util.EnumMap; import java.util.List; +import javax.vecmath.Matrix3f; +import javax.vecmath.Matrix4f; import javax.vecmath.Vector3f; import javax.vecmath.Vector4f; @@ -54,7 +57,9 @@ public class TRSRBakedModel implements IFlexibleBakedModel { EnumMap> faces = Maps.newEnumMap(EnumFacing.class); for(EnumFacing face : EnumFacing.values()) { for(BakedQuad quad : original.getFaceQuads(face)) { - builder.add(transform(transform, quad, original.getFormat())); + Transformer transformer = new Transformer(transform, original.getFormat()); + quad.pipe(transformer); + builder.add(transformer.build()); } //faces.put(face, builder.build()); faces.put(face, ImmutableList.of()); @@ -63,40 +68,15 @@ public class TRSRBakedModel implements IFlexibleBakedModel { // general quads //builder = ImmutableList.builder(); for(BakedQuad quad : original.getGeneralQuads()) { - builder.add(transform(transform, quad, original.getFormat())); + Transformer transformer = new Transformer(transform, original.getFormat()); + quad.pipe(transformer); + builder.add(transformer.build()); } this.general = builder.build(); this.faces = Maps.immutableEnumMap(faces); } - public static BakedQuad transform(TRSRTransformation transform, BakedQuad quad, VertexFormat format) { - for(VertexFormatElement e : (List) format.getElements()) { - if(e.getUsage() == VertexFormatElement.EnumUsage.POSITION) { - if(e.getType() != VertexFormatElement.EnumType.FLOAT) { - throw new IllegalArgumentException("can only transform float position"); - } - int[] data = Arrays.copyOf(quad.getVertexData(), quad.getVertexData().length); - // once for each vertex - for(int j = 0; j < 4; j++) { - int v = j * format.getNextOffset() / 4; - float[] pos = new float[]{0f, 0f, 0f, 1f}; - for(int i = 0; i < Math.min(4, e.getElementCount()); i++) { - pos[i] = Float.intBitsToFloat(data[v + e.getOffset() / 4 + i]); - } - Vector4f vec = new Vector4f(pos); - transform.getMatrix().transform(vec); - vec.get(pos); - for(int i = 0; i < Math.min(4, e.getElementCount()); i++) { - data[v + e.getOffset() / 4 + i] = Float.floatToRawIntBits(pos[i]); - } - } - return new BakedQuad(data, quad.getTintIndex(), quad.getFace()); - } - } - return quad; - } - @Override public List getFaceQuads(EnumFacing side) { return faces.get(side); @@ -136,4 +116,47 @@ public class TRSRBakedModel implements IFlexibleBakedModel { public VertexFormat getFormat() { return original.getFormat(); } + + public static class Transformer extends VertexTransformer { + + protected Matrix4f transformation; + protected Matrix3f normalTransformation; + + public Transformer(TRSRTransformation transformation, VertexFormat format) { + super(new UnpackedBakedQuad.Builder(format)); + // position transform + this.transformation = transformation.getMatrix(); + // normal transform + this.normalTransformation = new Matrix3f(); + this.transformation.getRotationScale(this.normalTransformation); + this.normalTransformation.invert(); + this.normalTransformation.transpose(); + } + + @Override + public void put(int element, float... data) { + VertexFormatElement.EnumUsage usage = parent.getVertexFormat().getElement(element).getUsage(); + + // transform normals and position + if(usage == VertexFormatElement.EnumUsage.POSITION) { + Vector4f vec = new Vector4f(data); + vec.setW(1.0f); + transformation.transform(vec); + data = new float[4]; + vec.get(data); + } + else if(usage == VertexFormatElement.EnumUsage.NORMAL) { + Vector3f vec = new Vector3f(data); + normalTransformation.transform(vec); + vec.normalize(); + data = new float[4]; + vec.get(data); + } + super.put(element, data); + } + + public UnpackedBakedQuad build() { + return ((UnpackedBakedQuad.Builder)parent).build(); + } + } } From ebe8798ed8a7cb4008180d642ffc52ee869cee1c Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 9 Nov 2015 19:12:56 +0100 Subject: [PATCH 54/91] Fix dynamic items not behaving correctly if metada wasn't registered in ascending order --- .../java/slimeknights/mantle/item/ItemMetaDynamic.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index 758ee96..ff98235 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -48,14 +48,14 @@ public class ItemMetaDynamic extends Item { * @return An itemstack representing the Item-Meta combination. */ public ItemStack addMeta(int meta, String name) { - if(meta > MAX) { + if(meta > MAX || isValid(meta)) { throw new IllegalArgumentException(String .format("Metadata too high, highest supported value is %d. Meta was %d", MAX, meta)); } if(meta > maxMeta) { maxMeta = meta; - setValid(meta); } + setValid(meta); names.put(meta, name); return new ItemStack(this, 1, meta); } @@ -97,8 +97,12 @@ public class ItemMetaDynamic extends Item { @SideOnly(Side.CLIENT) public void registerItemModels(final String prefix) { + registerItemModels(prefix, this); + } + + @SideOnly(Side.CLIENT) + protected void registerItemModels(final String prefix, final Item item) { final String resourceId = Loader.instance().activeModContainer().getModId().toLowerCase(); - final Item item = this; names.forEachEntry(new TIntObjectProcedure() { @Override public boolean execute(int meta, String name) { From b4be5592da93a38d9bbb4a9c013bdf8ff2deb744 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 9 Nov 2015 19:13:10 +0100 Subject: [PATCH 55/91] Add a base item for edible items. Supports multiple effects too. --- .../slimeknights/mantle/item/ItemEdible.java | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/main/java/slimeknights/mantle/item/ItemEdible.java diff --git a/src/main/java/slimeknights/mantle/item/ItemEdible.java b/src/main/java/slimeknights/mantle/item/ItemEdible.java new file mode 100644 index 0000000..7f67e72 --- /dev/null +++ b/src/main/java/slimeknights/mantle/item/ItemEdible.java @@ -0,0 +1,110 @@ +package slimeknights.mantle.item; + +import gnu.trove.map.hash.TIntFloatHashMap; +import gnu.trove.map.hash.TIntIntHashMap; +import gnu.trove.map.hash.TIntObjectHashMap; + +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import java.util.List; + +public class ItemEdible extends ItemFood { + + // we use this so we don't have to copy all the logic + private ItemMetaDynamic dynamic; + + protected TIntIntHashMap foodLevels; + protected TIntFloatHashMap saturations; + protected TIntObjectHashMap potionEffects; + + public ItemEdible() { + super(0, 0, false); + this.setHasSubtypes(true); + + dynamic = new ItemMetaDynamic(); + foodLevels = new TIntIntHashMap(); + saturations = new TIntFloatHashMap(); + potionEffects = new TIntObjectHashMap(); + } + + /** + * 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 + * @return Itemstack containing the registered item + */ + public ItemStack addFood(int meta, int food, float saturation, String name, PotionEffect... effects) { + dynamic.addMeta(meta, name); + foodLevels.put(meta, food); + saturations.put(meta, saturation); + potionEffects.put(meta, effects); + + return new ItemStack(this, 1, meta); + } + + @Override + public float getSaturationModifier(ItemStack stack) { + return saturations.get(stack.getMetadata()); // should call getMetadata below + // default value if meta not present is 0 + } + + @Override + public int getHealAmount(ItemStack stack) { + return foodLevels.get(stack.getMetadata()); // should call getMetadata below + // default value if meta not present is 0 + } + + @Override + protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { + if (!worldIn.isRemote) + { + for(PotionEffect potion : potionEffects.get(stack.getMetadata())) { + player.addPotionEffect(new PotionEffect(potion.getPotionID(), potion.getDuration(), potion.getAmplifier(), potion.getIsAmbient(), potion.getIsShowParticles())); + } + } + } + + /* ItemMetaDynamic Functionality */ + @Override + public Item setUnlocalizedName(String unlocalizedName) { + dynamic.setUnlocalizedName(unlocalizedName); + return super.setUnlocalizedName(unlocalizedName); + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return dynamic.getUnlocalizedName(stack); + } + + @Override + public int getMetadata(ItemStack stack) { + return dynamic.getMetadata(stack); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + dynamic.addInformation(stack, playerIn, tooltip, advanced); + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { + dynamic.getSubItems(itemIn, tab, subItems); + } + + @SideOnly(Side.CLIENT) + public void registerItemModels(final String prefix) { + dynamic.registerItemModels(prefix, this); + } +} From 9323d898ab095468248016a417baadf8264b33db Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 15 Nov 2015 17:19:22 +0100 Subject: [PATCH 56/91] Better error messages for metadynamic --- .../java/slimeknights/mantle/item/ItemMetaDynamic.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index ff98235..a2bd15d 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -48,10 +48,13 @@ public class ItemMetaDynamic extends Item { * @return An itemstack representing the Item-Meta combination. */ public ItemStack addMeta(int meta, String name) { - if(meta > MAX || isValid(meta)) { - throw new IllegalArgumentException(String - .format("Metadata too high, highest supported value is %d. Meta was %d", MAX, meta)); + if(meta > MAX) { + 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))); + } + if(meta > maxMeta) { maxMeta = meta; } From 392ea28047a2497b98481cca43865bdfbd68db47 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 15 Nov 2015 21:12:42 +0100 Subject: [PATCH 57/91] Fix incorrect positions in multiblock logic --- .../slimeknights/mantle/multiblock/MultiServantLogic.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java index 5dcd89b..c29b3c2 100644 --- a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java @@ -8,6 +8,7 @@ import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameData; @@ -110,7 +111,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic { if (this.hasValidMaster()) { - IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.pos); + IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master); logic.notifyChange(this, this.pos); } } @@ -124,7 +125,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic int yCenter = tags.getInteger("yCenter"); int zCenter = tags.getInteger("zCenter"); this.master = new BlockPos(xCenter, yCenter, zCenter); - this.masterBlock = GameData.getBlockRegistry().getObject(tags.getString("MasterBlockName")); + this.masterBlock = GameData.getBlockRegistry().getObject(new ResourceLocation(tags.getString("MasterBlockName"))); this.state = Block.getStateById(tags.getInteger("masterState")); } } @@ -137,7 +138,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic tags.setInteger("xCenter", this.master.getX()); tags.setInteger("yCenter", this.master.getY()); tags.setInteger("zCenter", this.master.getZ()); - tags.setString("MasterBlockName", (String) GameData.getBlockRegistry().getNameForObject(this.masterBlock)); + tags.setString("MasterBlockName", GameData.getBlockRegistry().getNameForObject(this.masterBlock).toString()); tags.setInteger("masterState", Block.getStateId(this.state)); } } From 8d547a08662c9b254eb57d390f0c762afb694f7b Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 16 Nov 2015 15:17:36 +0100 Subject: [PATCH 58/91] Allow resizing of inventory blocks --- .../java/slimeknights/mantle/tileentity/TileInventory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index d291f3d..fd7983a 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -11,6 +11,8 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IChatComponent; +import java.util.Arrays; + // Updated version of InventoryLogic in Mantle. Also contains a few bugfixes public class TileInventory extends TileEntity implements IInventory { @@ -50,6 +52,10 @@ public class TileInventory extends TileEntity implements IInventory { return getStackInSlot(slot) != null; } + public void resize(int size) { + inventory = Arrays.copyOf(inventory, size); + } + @Override public int getSizeInventory() { return inventory.length; From 3c0bd7a25e887bfe17c0c6c3d1d0bea2732f628d Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 16 Nov 2015 15:17:47 +0100 Subject: [PATCH 59/91] Move general background drawing into mantle --- .../slimeknights/mantle/client/gui/GuiMultiModule.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java index 52049de..cb8e919 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java @@ -9,6 +9,7 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.IChatComponent; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -105,6 +106,12 @@ public class GuiMultiModule extends GuiContainer implements INEIGuiHandler { drawPlayerInventoryName(); } + protected void drawBackground(ResourceLocation background) { + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(background); + this.drawTexturedModalRect(cornerX, cornerY, 0, 0, realWidth, realHeight); + } + protected void drawContainerName() { ContainerMultiModule multiContainer = (ContainerMultiModule) this.inventorySlots; IChatComponent localizedName = multiContainer.getInventoryDisplayName(); From 767db355661409185d74d6154434389202e38217 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 16 Nov 2015 15:18:01 +0100 Subject: [PATCH 60/91] Expose recipematch parameters --- src/main/java/slimeknights/mantle/util/RecipeMatch.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index 0e37562..912f152 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -20,10 +20,8 @@ import slimeknights.mantle.Mantle; */ public abstract class RecipeMatch { - - - protected final int amountNeeded; - protected final int amountMatched; + public final int amountNeeded; + public final int amountMatched; /** * @param amountNeeded How many of the itemstack are needed for the match From b07c30ef31eb2b1d17ca774fae4c0a392f9dd7dd Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 16 Nov 2015 19:19:18 +0100 Subject: [PATCH 61/91] Save inventory size for Tiles with inventory, since we also allow resizing now --- .../java/slimeknights/mantle/tileentity/TileInventory.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index fd7983a..94ac585 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -179,6 +179,9 @@ public class TileInventory extends TileEntity implements IInventory { public void readInventoryFromNBT(NBTTagCompound tags) { super.readFromNBT(tags); + + this.resize(tags.getInteger("InventorySize")); + readInventoryFromNBT(this, tags); if(tags.hasKey("CustomName", 8)) { @@ -189,6 +192,9 @@ public class TileInventory extends TileEntity implements IInventory { @Override public void writeToNBT(NBTTagCompound tags) { super.writeToNBT(tags); + + tags.setInteger("InventorySize", inventory.length); + writeInventoryToNBT(this, tags); if(this.hasCustomName()) { From 40b55f9f06e16e5c766a47622389f400a7c77a35 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 16 Nov 2015 19:19:32 +0100 Subject: [PATCH 62/91] Mouse wheel support for sliders! Just don't have 2 in one screen. --- .../mantle/client/gui/GuiWidgetSlider.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java index 227695d..a3fb1dc 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -135,6 +135,16 @@ public class GuiWidgetSlider extends GuiWidget { } boolean mouseDown = Mouse.isButtonDown(0); // left mouse button + int wheel = Mouse.getDWheel(); + + if(wheel > 0) { + decrement(); + return; + } + else if(wheel < 0) { + increment(); + return; + } // relative position inside the widget int x = mouseX - xPos; From 97931ac9f04041b1828e5a030903739f7e39e38c Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 18 Nov 2015 18:42:18 +0100 Subject: [PATCH 63/91] Support for arbitrarily texture-sizes for scaled elements --- .../slimeknights/mantle/client/gui/GuiElementScalable.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java b/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java index b676242..b9a12ca 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java @@ -7,6 +7,10 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiElementScalable extends GuiElement { + public GuiElementScalable(int x, int y, int w, int h, int texW, int texH) { + super(x, y, w, h, texW, texH); + } + public GuiElementScalable(int x, int y, int w, int h) { super(x, y, w, h); } From 94bf46a187d0568ff7d2c2708c3ab352a259f9e2 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 18 Nov 2015 18:42:35 +0100 Subject: [PATCH 64/91] Add a parameter for mousewheel scrolling and helper functions for slider --- .../mantle/client/gui/GuiModule.java | 15 +++++++++++++++ .../mantle/client/gui/GuiWidgetSlider.java | 18 ++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java index 3880520..21e2e4c 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java @@ -7,6 +7,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; 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) @@ -67,6 +68,20 @@ public abstract class GuiModule extends GuiContainer { return true; } + public boolean isMouseInModule(int mouseX, int mouseY) { + return mouseX >= this.guiLeft && mouseX < this.guiRight() && + mouseY >= this.guiTop && mouseY < this.guiBottom(); + } + + public boolean isMouseOverFullSlot(int mouseX, int mouseY) { + for(Slot slot : (List)inventorySlots.inventorySlots) { + if(parent.isMouseOverSlot(slot, mouseX, mouseY) && slot.getHasStack()) { + return true; + } + } + return false; + } + /* public void updateDragged(boolean dragSplitting, Set draggedSlots) { this.dragSplitting = dragSplitting; diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java index a3fb1dc..c0940ba 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -129,7 +129,7 @@ public class GuiWidgetSlider extends GuiWidget { } } - public void update(int mouseX, int mouseY) { + public void update(int mouseX, int mouseY, boolean useMouseWheel) { if(!enabled || hidden) { return; } @@ -137,13 +137,15 @@ public class GuiWidgetSlider extends GuiWidget { boolean mouseDown = Mouse.isButtonDown(0); // left mouse button int wheel = Mouse.getDWheel(); - if(wheel > 0) { - decrement(); - return; - } - else if(wheel < 0) { - increment(); - return; + if(useMouseWheel) { + if(wheel > 0) { + decrement(); + return; + } + else if(wheel < 0) { + increment(); + return; + } } // relative position inside the widget From 766c2cd92da23b5c10ec8a32a133b1c978d8da3e Mon Sep 17 00:00:00 2001 From: Zach Date: Sat, 21 Nov 2015 13:43:04 -0500 Subject: [PATCH 65/91] Update Mantle.java --- src/main/java/slimeknights/mantle/Mantle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/Mantle.java b/src/main/java/slimeknights/mantle/Mantle.java index c3bd726..ce708f3 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.14,)") +@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.14,)", mcversion="[1.8,1.8.8]") public class Mantle { public static final String modId = "mantle"; From 628a4c1c90639b4f6208e369b9f800c206098c6f Mon Sep 17 00:00:00 2001 From: Zach Date: Sat, 21 Nov 2015 13:45:18 -0500 Subject: [PATCH 66/91] fix variable name for mc versions --- src/main/java/slimeknights/mantle/Mantle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/Mantle.java b/src/main/java/slimeknights/mantle/Mantle.java index ce708f3..872655e 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.14,)", mcversion="[1.8,1.8.8]") +@Mod(modid = Mantle.modId, name = Mantle.modName, version = Mantle.modVersion, dependencies = "required-after:Forge@[11.14,)", acceptedMinecraftVersions="[1.8,1.8.8]") public class Mantle { public static final String modId = "mantle"; From 08f1501810ab5b16e01de5d560636c574bc9c8ab Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 23 Nov 2015 21:46:05 +0100 Subject: [PATCH 67/91] Update to 1.8.8 and disable NEI integration (for now) --- build.gradle | 10 +++++----- build.properties | 6 +++--- .../mantle/client/gui/GuiMultiModule.java | 11 +++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 82b66a6..32a4548 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' } } apply plugin: 'net.minecraftforge.gradle.forge' @@ -75,7 +75,7 @@ task buildInfo { } ext.artifact_version = 'NFG' if (System.getenv().ARTIFACT_VERSION == null) { - artifact_version = "${config.mod_version}.${project.buildInfo.buildNum}" + artifact_version = "${config.mod_version}" } if (System.getenv().ARTIFACT_VERSION != null) { artifact_version = "${system.getenv().ARTIFACT_VERSION}" @@ -96,9 +96,9 @@ configurations { } dependencies { - compile "codechicken:CodeChickenLib:${config.minecraft_version}-${config.CCLIB_version}:dev" - compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.ccc_version}:dev" - compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.NEI_version}:dev" + //compile "codechicken:CodeChickenLib:${config.minecraft_version}-${config.CCLIB_version}:dev" + //compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.ccc_version}:dev" + //compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.NEI_version}:dev" // Configuration shade "ninja.leaping.configurate:configurate-hocon:${config.configurate_version}" shade "ninja.leaping.configurate:configurate-gson:${config.configurate_version}" diff --git a/build.properties b/build.properties index 2eccd2c..997b44b 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ mod_version=0.5 -minecraft_version=1.8 -forge_version=11.14.3.1543 -mappings=snapshot_20150918 +minecraft_version=1.8.8 +forge_version=11.14.4.1576-1.8.8 +mappings=snapshot_20151122 CCLIB_version=1.1.2.133 ccc_version=1.0.5.36 diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java index cb8e919..30ade5e 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java @@ -19,17 +19,14 @@ import java.lang.reflect.Field; import java.util.Collections; import java.util.List; -import codechicken.nei.LayoutManager; -import codechicken.nei.VisiblityData; -import codechicken.nei.api.INEIGuiHandler; -import codechicken.nei.api.TaggedInventoryArea; import slimeknights.mantle.Mantle; import slimeknights.mantle.inventory.ContainerMultiModule; import slimeknights.mantle.inventory.SlotWrapper; @SideOnly(Side.CLIENT) @Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems") -public class GuiMultiModule extends GuiContainer implements INEIGuiHandler { +// todo: NEI +public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler { // NEI-stuff >:( private static Field NEI_Manager; @@ -308,7 +305,8 @@ public class GuiMultiModule extends GuiContainer implements INEIGuiHandler { } /* NEI INTEGRATION */ - + // todo: NEI +/* @Override @Optional.Method(modid = "NotEnoughItems") public VisiblityData modifyVisiblity(GuiContainer guiContainer, VisiblityData visiblityData) { @@ -360,4 +358,5 @@ public class GuiMultiModule extends GuiContainer implements INEIGuiHandler { return false; } + */ } From 002954bd1d0ae0739df4ad38466b1455c017905b Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 24 Nov 2015 20:34:59 +0100 Subject: [PATCH 68/91] Fix missing build nr --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 32a4548..894dae1 100644 --- a/build.gradle +++ b/build.gradle @@ -75,7 +75,7 @@ task buildInfo { } ext.artifact_version = 'NFG' if (System.getenv().ARTIFACT_VERSION == null) { - artifact_version = "${config.mod_version}" + artifact_version = "${config.mod_version}.${project.buildInfo.buildNum}" } if (System.getenv().ARTIFACT_VERSION != null) { artifact_version = "${system.getenv().ARTIFACT_VERSION}" From 2889c24f65ca5ba885851d38cd99c3fe41e24a6c Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 24 Nov 2015 21:17:08 +0100 Subject: [PATCH 69/91] Add unlisted direction property --- .../property/PropertyUnlistedDirection.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java diff --git a/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java b/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java new file mode 100644 index 0000000..9a4579a --- /dev/null +++ b/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java @@ -0,0 +1,38 @@ +package slimeknights.mantle.property; + +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; +import com.google.common.collect.Lists; + +import net.minecraft.block.properties.PropertyDirection; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.property.IUnlistedProperty; + +import java.util.Collection; + +public class PropertyUnlistedDirection extends PropertyDirection implements IUnlistedProperty { + + public PropertyUnlistedDirection(String name, Collection values) { + super(name, values); + } + + public PropertyUnlistedDirection(String name, Predicate filter) { + this(name, Collections2.filter(Lists.newArrayList(EnumFacing.values()), filter)); + } + + @Override + public boolean isValid(EnumFacing value) { + return true; + } + + @Override + public Class getType() { + return this.getValueClass(); + } + + @Override + public String valueToString(EnumFacing value) { + return getName(value); + } + +} From c6963535fdebe9a4a19ff473c62065e6c8baef2f Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 5 Dec 2015 19:23:43 +0100 Subject: [PATCH 70/91] Update mappings --- build.properties | 4 ++-- .../mantle/client/model/BlockItemModelWrapper.java | 4 ++-- .../mantle/client/model/TRSRBakedModel.java | 4 ++-- .../mantle/tileentity/TileInventory.java | 13 ++++++++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/build.properties b/build.properties index 997b44b..2138119 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ mod_version=0.5 minecraft_version=1.8.8 -forge_version=11.14.4.1576-1.8.8 -mappings=snapshot_20151122 +forge_version=11.15.0.1609-1.8.8 +mappings=snapshot_20151204 CCLIB_version=1.1.2.133 ccc_version=1.0.5.36 diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java index 690ea6f..4c6e691 100644 --- a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -76,8 +76,8 @@ public class BlockItemModelWrapper implements IPerspectiveAwareModel, IFlexibleB } @Override - public TextureAtlasSprite getTexture() { - return parent.getTexture(); + public TextureAtlasSprite getParticleTexture() { + return parent.getParticleTexture(); } @Override diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java index fa9529a..bdeb9f0 100644 --- a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -103,8 +103,8 @@ public class TRSRBakedModel implements IFlexibleBakedModel { } @Override - public TextureAtlasSprite getTexture() { - return original.getTexture(); + public TextureAtlasSprite getParticleTexture() { + return original.getParticleTexture(); } @Override diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index 94ac585..f64df61 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -105,6 +105,13 @@ public class TileInventory extends TileEntity implements IInventory { return itemStack; } + @Override + public ItemStack removeStackFromSlot(int slot) { + ItemStack itemStack = getStackInSlot(slot); + setInventorySlotContents(slot, null); + return itemStack; + } + @Override public boolean isItemValidForSlot(int slot, ItemStack itemstack) { if(slot < getSizeInventory()) { @@ -123,7 +130,7 @@ public class TileInventory extends TileEntity implements IInventory { } @Override - public String getCommandSenderName() { + public String getName() { return this.inventoryTitle; } @@ -140,10 +147,10 @@ public class TileInventory extends TileEntity implements IInventory { @Override public IChatComponent getDisplayName() { if(hasCustomName()) { - return new ChatComponentText(getCommandSenderName()); + return new ChatComponentText(getName()); } - return new ChatComponentTranslation(getCommandSenderName()); + return new ChatComponentTranslation(getName()); } From 13da0c4be13787cdb6f4c4feecf55e32a5d7b539 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 17 Dec 2015 19:02:13 +0100 Subject: [PATCH 71/91] Update to forge model changes --- build.properties | 4 +- .../mantle/client/ModelHelper.java | 75 ++++++++----------- .../client/model/BlockItemModelWrapper.java | 4 +- 3 files changed, 36 insertions(+), 47 deletions(-) diff --git a/build.properties b/build.properties index 2138119..a14d236 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ mod_version=0.5 minecraft_version=1.8.8 -forge_version=11.15.0.1609-1.8.8 -mappings=snapshot_20151204 +forge_version=11.15.0.1635-1.8.8 +mappings=snapshot_20151212 CCLIB_version=1.1.2.133 ccc_version=1.0.5.36 diff --git a/src/main/java/slimeknights/mantle/client/ModelHelper.java b/src/main/java/slimeknights/mantle/client/ModelHelper.java index b375511..94370b6 100644 --- a/src/main/java/slimeknights/mantle/client/ModelHelper.java +++ b/src/main/java/slimeknights/mantle/client/ModelHelper.java @@ -1,6 +1,7 @@ package slimeknights.mantle.client; import com.google.common.base.Charsets; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; @@ -24,7 +25,7 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.IColoredBakedQuad; import net.minecraftforge.client.model.IModelPart; import net.minecraftforge.client.model.IModelState; -import net.minecraftforge.client.model.IPerspectiveState; +import net.minecraftforge.client.model.SimpleModelState; import net.minecraftforge.client.model.TRSRTransformation; import java.io.IOException; @@ -42,8 +43,8 @@ public class ModelHelper { GSON = new GsonBuilder().registerTypeAdapter(maptype, ModelTextureDeserializer.INSTANCE).create(); - public static final IPerspectiveState DEFAULT_ITEM_STATE; - public static final IPerspectiveState DEFAULT_TOOL_STATE; + public static final Optional DEFAULT_ITEM_STATE; + public static final Optional DEFAULT_TOOL_STATE; public static TextureAtlasSprite getTextureFromBlock(Block block, int meta) { IBlockState state = block.getStateFromMeta(meta); @@ -100,47 +101,35 @@ public class ModelHelper { return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath() + ".json"); } - public static ImmutableMap getTransformsFromState(IModelState state, IModelPart part) { - if(state instanceof IPerspectiveState) { - IPerspectiveState ps = (IPerspectiveState) state; - Map map = Maps.newHashMap(); - for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) { - map.put(type, ps.forPerspective(type).apply(part)); - } - return Maps.immutableEnumMap(map); - } - return ImmutableMap.of(); - } - static { - // equals forge:default-item - IModelState thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1f / 16, -3f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)), - new Vector3f(0.55f, 0.55f, 0.55f), - null)); - IModelState firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 4f / 16, 2f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), - new Vector3f(1.7f, 1.7f, 1.7f), - null)); - DEFAULT_ITEM_STATE = new IPerspectiveState.Impl(TRSRTransformation.identity(), ImmutableMap - .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, - ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson)); - - thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 1.25f / 16, -3.5f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, 90, -35)), - new Vector3f(0.85f, 0.85f, 0.85f), - null)); - firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( - new Vector3f(0, 4f / 16, 2f / 16), - TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), - new Vector3f(1.7f, 1.7f, 1.7f), - null)); - DEFAULT_TOOL_STATE = new IPerspectiveState.Impl(TRSRTransformation.identity(), ImmutableMap - .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, - ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson)); + { + // equals forge:default-item + TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 1f / 16, -3f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)), + new Vector3f(0.55f, 0.55f, 0.55f), + null)); + TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 4f / 16, 2f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), + new Vector3f(1.7f, 1.7f, 1.7f), + null)); + DEFAULT_ITEM_STATE = Optional.of(new SimpleModelState(ImmutableMap.of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson))); + } + { + TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 1.25f / 16, -3.5f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, 90, -35)), + new Vector3f(0.85f, 0.85f, 0.85f), + null)); + TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation( + new Vector3f(0, 4f / 16, 2f / 16), + TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)), + new Vector3f(1.7f, 1.7f, 1.7f), + null)); + DEFAULT_TOOL_STATE = Optional.of(new SimpleModelState(ImmutableMap + .of(ItemCameraTransforms.TransformType.THIRD_PERSON, thirdperson, ItemCameraTransforms.TransformType.FIRST_PERSON, firstperson))); + } } /** diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java index 4c6e691..032be4c 100644 --- a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -35,14 +35,14 @@ public class BlockItemModelWrapper implements IPerspectiveAwareModel, IFlexibleB } @Override - public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { + public Pair handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { Matrix4f matrix = null; // fix transformation in hand if(cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON) { matrix = THIRD_PERSON_BLOCK_TRANSFORM; } - return Pair.of((IBakedModel) this, matrix); + return Pair.of(this, matrix); } @Override From d7dff0e26c18ea1fa323e690ce0a6ad9559506aa Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 19 Dec 2015 08:03:40 +0100 Subject: [PATCH 72/91] Don't access TESR models in TRSRBakedModel --- .../mantle/client/model/TRSRBakedModel.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java index bdeb9f0..b22652a 100644 --- a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -56,10 +56,12 @@ public class TRSRBakedModel implements IFlexibleBakedModel { // face quads EnumMap> faces = Maps.newEnumMap(EnumFacing.class); for(EnumFacing face : EnumFacing.values()) { - for(BakedQuad quad : original.getFaceQuads(face)) { - Transformer transformer = new Transformer(transform, original.getFormat()); - quad.pipe(transformer); - builder.add(transformer.build()); + if(!original.isBuiltInRenderer()) { + for(BakedQuad quad : original.getFaceQuads(face)) { + Transformer transformer = new Transformer(transform, original.getFormat()); + quad.pipe(transformer); + builder.add(transformer.build()); + } } //faces.put(face, builder.build()); faces.put(face, ImmutableList.of()); @@ -67,10 +69,12 @@ public class TRSRBakedModel implements IFlexibleBakedModel { // general quads //builder = ImmutableList.builder(); - for(BakedQuad quad : original.getGeneralQuads()) { - Transformer transformer = new Transformer(transform, original.getFormat()); - quad.pipe(transformer); - builder.add(transformer.build()); + if(!original.isBuiltInRenderer()) { + for(BakedQuad quad : original.getGeneralQuads()) { + Transformer transformer = new Transformer(transform, original.getFormat()); + quad.pipe(transformer); + builder.add(transformer.build()); + } } this.general = builder.build(); From c71c1dc1f2b236e96783d56a1d377c3ec2c8fe74 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 19 Dec 2015 15:24:39 +0100 Subject: [PATCH 73/91] Change ItemMetaDynamic to support a wider meta range --- .../mantle/item/ItemMetaDynamic.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index a2bd15d..5a4b1bb 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -16,6 +16,7 @@ import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -28,14 +29,13 @@ import slimeknights.mantle.util.LocUtils; */ public class ItemMetaDynamic extends Item { - private static int MAX = Long.SIZE; + private static int MAX = (2 << 16) - 1; - protected int maxMeta; - protected long availabilityMask; + protected boolean[] availabilityMask; // boolean[] actually is much more performant for our case than BitSet protected TIntObjectHashMap names; public ItemMetaDynamic() { - maxMeta = -1; + availabilityMask = new boolean[1]; names = new TIntObjectHashMap(); this.setHasSubtypes(true); @@ -55,8 +55,8 @@ public class ItemMetaDynamic extends Item { throw new IllegalArgumentException(String.format("Metadata for %s is already taken. Meta %d is %s", name, meta, names.get(meta))); } - if(meta > maxMeta) { - maxMeta = meta; + while(meta >= availabilityMask.length) { + availabilityMask = Arrays.copyOf(availabilityMask, availabilityMask.length*2); } setValid(meta); names.put(meta, name); @@ -74,7 +74,7 @@ public class ItemMetaDynamic extends Item { @Override public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { - for(int i = 0; i <= maxMeta; i++) { + for(int i = 0; i <= availabilityMask.length; i++) { if(isValid(i)) { subItems.add(new ItemStack(itemIn, 1, i)); } @@ -88,14 +88,14 @@ public class ItemMetaDynamic extends Item { } protected void setValid(int meta) { - availabilityMask |= 1 << meta; + availabilityMask[meta] = true; } protected boolean isValid(int meta) { - if(meta > MAX) { + if(meta > MAX || meta >= availabilityMask.length) { return false; } - return ((availabilityMask >> meta) & 1) == 1; + return availabilityMask[meta]; } @SideOnly(Side.CLIENT) From f2bc0a38b186c1ec658009cc68f910bbd82ca517 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 21 Dec 2015 17:06:34 +0100 Subject: [PATCH 74/91] Convenience functions for slider and draw disabled button if disabled but shown --- .../mantle/client/gui/GuiWidgetSlider.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java index c0940ba..316fcd8 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -78,6 +78,10 @@ public class GuiWidgetSlider extends GuiWidget { return currentValue; } + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + public void enable() { this.enabled = true; } @@ -90,6 +94,10 @@ public class GuiWidgetSlider extends GuiWidget { return this.enabled; } + public void setHidden(boolean hidden) { + this.hidden = hidden; + } + public void hide() { this.hidden = true; } @@ -127,6 +135,9 @@ public class GuiWidgetSlider extends GuiWidget { slider.draw(x, y); } } + else { + sliderDisabled.draw(x, y); + } } public void update(int mouseX, int mouseY, boolean useMouseWheel) { From ed8c5b9656b548cbbb3dd1a10a993c003c11181d Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 21 Dec 2015 17:06:49 +0100 Subject: [PATCH 75/91] Forward onSlotChanged from slotwrapper --- src/main/java/slimeknights/mantle/inventory/SlotWrapper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java index 3dc9d29..8d7fbf0 100644 --- a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java +++ b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java @@ -23,6 +23,11 @@ public class SlotWrapper extends Slot { parent.onSlotChange(p_75220_1_, p_75220_2_); } + @Override + public void onSlotChanged() { + parent.onSlotChanged(); + } + @Override public boolean isItemValid(ItemStack stack) { return parent.isItemValid(stack); From 38caa161becc507e722b5b2ff186ee95e0552fe4 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 21 Dec 2015 17:06:58 +0100 Subject: [PATCH 76/91] Convenience getTile for basecontainer --- .../java/slimeknights/mantle/inventory/BaseContainer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java index e6cb89f..9675994 100644 --- a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java +++ b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java @@ -59,6 +59,10 @@ public abstract class BaseContainer extends Container { syncNewContainer(playerOpened); } + public T getTile() { + return tile; + } + /** * Called when the container is opened and another player already has a container for this tile open * Sync to the same state here. From d2d4c368cee0e81365d4ed50d7f36430d4583155 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 21 Dec 2015 18:16:43 +0100 Subject: [PATCH 77/91] Ensure inventories are present for containers --- src/main/java/slimeknights/mantle/inventory/BaseContainer.java | 2 +- .../slimeknights/mantle/inventory/ContainerMultiModule.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java index 9675994..d2b43b1 100644 --- a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java +++ b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java @@ -22,7 +22,7 @@ import java.util.List; import slimeknights.mantle.util.SlimeknightException; /** Same as Container but provides some extra functionality to simplify things */ -public abstract class BaseContainer extends Container { +public abstract class BaseContainer extends Container { protected double maxDist = 8 * 8; // 8 blocks protected T tile; diff --git a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java index fb6706b..61b998c 100644 --- a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java +++ b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java @@ -6,6 +6,7 @@ import com.google.common.collect.Sets; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -19,7 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -public class ContainerMultiModule extends BaseContainer { +public class ContainerMultiModule extends BaseContainer { public List subContainers = Lists.newArrayList(); From 05c7b3f85f4a1ee184ca950543dac6745337ae86 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 22 Dec 2015 22:09:05 +0100 Subject: [PATCH 78/91] Update ForgeCFG to be usable for ingame GUIs --- .../mantle/pulsar/config/ForgeCFG.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java b/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java index 6bc495e..3efecf6 100644 --- a/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java +++ b/src/main/java/slimeknights/mantle/pulsar/config/ForgeCFG.java @@ -1,9 +1,13 @@ package slimeknights.mantle.pulsar.config; import java.io.File; +import java.util.Locale; import slimeknights.mantle.pulsar.pulse.PulseMeta; + +import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; import net.minecraftforge.fml.common.Loader; /** @@ -13,7 +17,7 @@ import net.minecraftforge.fml.common.Loader; public class ForgeCFG implements IConfiguration { - private static Configuration config; + private Configuration config; private final String confPath; @@ -30,20 +34,22 @@ public class ForgeCFG implements IConfiguration public ForgeCFG(String confName, String description) { this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".cfg"; - this.description = description; + this.description = description.toLowerCase(Locale.US); } @Override public void load() { - config = new Configuration(new File(this.confPath)); + config = new Configuration(new File(this.confPath), "1"); config.load(); } @Override public boolean isModuleEnabled(PulseMeta meta) { - return config.get(this.description, meta.getId(), meta.isEnabled(), meta.getDescription()).getBoolean(meta.isEnabled()); + Property prop = config.get(this.description, meta.getId(), meta.isEnabled(), meta.getDescription()); + prop.setRequiresMcRestart(true); + return prop.getBoolean(meta.isEnabled()); } @Override @@ -55,4 +61,11 @@ public class ForgeCFG implements IConfiguration } } + public Configuration getConfig() { + return config; + } + + public ConfigCategory getCategory() { + return config.getCategory(this.description); + } } From ac6e5d286198fdd418f4e092f2946f3dbebf75f3 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 22 Dec 2015 23:44:35 +0100 Subject: [PATCH 79/91] Add generics information from forge where possible --- .../java/slimeknights/mantle/block/EnumBlock.java | 14 ++++++++------ .../mantle/client/model/BlockItemModelWrapper.java | 5 +++-- .../slimeknights/mantle/item/ItemBlockMeta.java | 4 ++-- .../java/slimeknights/mantle/item/ItemEdible.java | 4 ++-- .../slimeknights/mantle/item/ItemMetaDynamic.java | 4 ++-- .../mantle/property/PropertyUnlistedDirection.java | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/java/slimeknights/mantle/block/EnumBlock.java b/src/main/java/slimeknights/mantle/block/EnumBlock.java index 021b519..0405870 100644 --- a/src/main/java/slimeknights/mantle/block/EnumBlock.java +++ b/src/main/java/slimeknights/mantle/block/EnumBlock.java @@ -8,31 +8,33 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IStringSerializable; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class EnumBlock & EnumBlock.IEnumMeta> extends Block { - public final PropertyEnum prop; +public class EnumBlock & EnumBlock.IEnumMeta & IStringSerializable> extends Block { + public final PropertyEnum prop; private final E[] values; - private static PropertyEnum tmp; + private static PropertyEnum tmp; - public EnumBlock(Material material, PropertyEnum prop, Class clazz) { + public EnumBlock(Material material, PropertyEnum prop, Class clazz) { super(preInit(material, prop)); this.prop = prop; values = clazz.getEnumConstants(); } - private static Material preInit(Material material, PropertyEnum property) { + @SuppressWarnings("unchecked") + private static Material preInit(Material material, PropertyEnum property) { tmp=property; return material; } @SideOnly(Side.CLIENT) @Override - public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { + public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { for(E type : values) { list.add(new ItemStack(this, 1, type.getMeta())); } diff --git a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java index 032be4c..7ec36d9 100644 --- a/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java +++ b/src/main/java/slimeknights/mantle/client/model/BlockItemModelWrapper.java @@ -1,5 +1,6 @@ package slimeknights.mantle.client.model; +import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.vertex.VertexFormat; @@ -46,12 +47,12 @@ public class BlockItemModelWrapper implements IPerspectiveAwareModel, IFlexibleB } @Override - public List getFaceQuads(EnumFacing p_177551_1_) { + public List getFaceQuads(EnumFacing p_177551_1_) { return parent.getFaceQuads(p_177551_1_); } @Override - public List getGeneralQuads() { + public List getGeneralQuads() { return parent.getGeneralQuads(); } diff --git a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java index 914274f..6e22a82 100644 --- a/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java +++ b/src/main/java/slimeknights/mantle/item/ItemBlockMeta.java @@ -40,12 +40,12 @@ public class ItemBlockMeta extends ItemColored { return super.getUnlocalizedName(stack) + "." + name; } - public static void setMappingProperty(Block block, IProperty property) { + public static void setMappingProperty(Block block, IProperty property) { ((ItemBlockMeta)Item.getItemFromBlock(block)).mappingProperty = property; } @Override - public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { if(StatCollector.canTranslate(this.getUnlocalizedName(stack) + ".tooltip")) { tooltip.add(EnumChatFormatting.GRAY.toString() + LocUtils.translateRecursive(this.getUnlocalizedName(stack) + ".tooltip")); diff --git a/src/main/java/slimeknights/mantle/item/ItemEdible.java b/src/main/java/slimeknights/mantle/item/ItemEdible.java index 7f67e72..877ebd6 100644 --- a/src/main/java/slimeknights/mantle/item/ItemEdible.java +++ b/src/main/java/slimeknights/mantle/item/ItemEdible.java @@ -93,13 +93,13 @@ public class ItemEdible extends ItemFood { } @Override - public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { dynamic.addInformation(stack, playerIn, tooltip, advanced); } @SideOnly(Side.CLIENT) @Override - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { + public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { dynamic.getSubItems(itemIn, tab, subItems); } diff --git a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java index 5a4b1bb..fae5f15 100644 --- a/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java +++ b/src/main/java/slimeknights/mantle/item/ItemMetaDynamic.java @@ -73,7 +73,7 @@ public class ItemMetaDynamic extends Item { } @Override - public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { + public void getSubItems(Item itemIn, CreativeTabs tab, List subItems) { for(int i = 0; i <= availabilityMask.length; i++) { if(isValid(i)) { subItems.add(new ItemStack(itemIn, 1, i)); @@ -119,7 +119,7 @@ public class ItemMetaDynamic extends Item { } @Override - public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { + public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { if(StatCollector.canTranslate(this.getUnlocalizedName(stack) + ".tooltip")) { tooltip.add(EnumChatFormatting.GRAY.toString() + LocUtils.translateRecursive(this.getUnlocalizedName(stack) + ".tooltip")); diff --git a/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java b/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java index 9a4579a..8f4bd5a 100644 --- a/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java +++ b/src/main/java/slimeknights/mantle/property/PropertyUnlistedDirection.java @@ -12,7 +12,7 @@ import java.util.Collection; public class PropertyUnlistedDirection extends PropertyDirection implements IUnlistedProperty { - public PropertyUnlistedDirection(String name, Collection values) { + public PropertyUnlistedDirection(String name, Collection values) { super(name, values); } From ac6e3ef7bd2d8cdb18ecfcedd866545f64bf2a4d Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 23 Dec 2015 19:02:40 +0100 Subject: [PATCH 80/91] Change abstract packet to have one handler that handles all abstract packages and calls their methods. No changes on the implementation side of them. --- build.properties | 2 +- .../mantle/network/AbstractPacket.java | 18 +------------ .../network/AbstractPacketThreadsafe.java | 1 + .../mantle/network/NetworkWrapper.java | 25 ++++++++++++------- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/build.properties b/build.properties index a14d236..9551321 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ mod_version=0.5 minecraft_version=1.8.8 -forge_version=11.15.0.1635-1.8.8 +forge_version=11.15.0.1641-1.8.8 mappings=snapshot_20151212 CCLIB_version=1.1.2.133 diff --git a/src/main/java/slimeknights/mantle/network/AbstractPacket.java b/src/main/java/slimeknights/mantle/network/AbstractPacket.java index dd9bd46..2ef620b 100644 --- a/src/main/java/slimeknights/mantle/network/AbstractPacket.java +++ b/src/main/java/slimeknights/mantle/network/AbstractPacket.java @@ -10,23 +10,7 @@ import net.minecraftforge.fml.relauncher.Side; import io.netty.buffer.ByteBuf; -public abstract class AbstractPacket implements IMessage, IMessageHandler { - - @Override - public IMessage onMessage(IMessage message, MessageContext ctx) { - if(!(message instanceof AbstractPacket)) { - return null; - } - - AbstractPacket packet = (AbstractPacket) message; - - if(ctx.side == Side.SERVER) { - return packet.handleServer(ctx.getServerHandler()); - } - else { - return packet.handleClient(ctx.getClientHandler()); - } - } +public abstract class AbstractPacket implements IMessage { public abstract IMessage handleClient(NetHandlerPlayClient netHandler); diff --git a/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java b/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java index d055113..8e9a563 100644 --- a/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java +++ b/src/main/java/slimeknights/mantle/network/AbstractPacketThreadsafe.java @@ -4,6 +4,7 @@ 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 b3423e5..cfa3ea3 100644 --- a/src/main/java/slimeknights/mantle/network/NetworkWrapper.java +++ b/src/main/java/slimeknights/mantle/network/NetworkWrapper.java @@ -1,9 +1,9 @@ package slimeknights.mantle.network; -import com.google.common.base.Throwables; - import net.minecraftforge.fml.common.network.NetworkRegistry; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; @@ -14,10 +14,12 @@ import net.minecraftforge.fml.relauncher.Side; public class NetworkWrapper { public final SimpleNetworkWrapper network; + protected final AbstactPacketHandler handler; private int id = 0; public NetworkWrapper(String channelName) { network = NetworkRegistry.INSTANCE.newSimpleChannel(channelName); + handler = new AbstactPacketHandler(); } /** @@ -43,13 +45,18 @@ public class NetworkWrapper { } private void registerPacketImpl(Class packetClazz, Side side) { - IMessageHandler handler; - try { - handler = packetClazz.newInstance(); - } catch(Exception e) { - throw Throwables.propagate(e); - } - network.registerMessage(handler, packetClazz, id++, side); } + + public static class AbstactPacketHandler implements IMessageHandler { + @Override + public IMessage onMessage(AbstractPacket packet, MessageContext ctx) { + if(ctx.side == Side.SERVER) { + return packet.handleServer(ctx.getServerHandler()); + } + else { + return packet.handleClient(ctx.getClientHandler()); + } + } + } } From 0425504a373f715fc9a8666080571591f17edf97 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 24 Dec 2015 15:29:59 +0100 Subject: [PATCH 81/91] Update mantle requirements --- build.properties | 2 +- src/main/java/slimeknights/mantle/Mantle.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index 9551321..14fd54e 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -mod_version=0.5 +mod_version=0.6 minecraft_version=1.8.8 forge_version=11.15.0.1641-1.8.8 mappings=snapshot_20151212 diff --git a/src/main/java/slimeknights/mantle/Mantle.java b/src/main/java/slimeknights/mantle/Mantle.java index 872655e..715843b 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.14,)", acceptedMinecraftVersions="[1.8,1.8.8]") +@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"; From 728afebd1d4d38c186e3651622a80f5354e3a186 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 29 Dec 2015 22:37:02 +0100 Subject: [PATCH 82/91] Add static creation functions for recipematch --- .../slimeknights/mantle/util/RecipeMatch.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index 912f152..ff05aa4 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -3,6 +3,8 @@ package slimeknights.mantle.util; 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; @@ -34,6 +36,46 @@ public abstract class RecipeMatch { public abstract Match matches(ItemStack[] stacks); + public static RecipeMatch of(String oredict) { + return of(oredict, 1); + } + + public static RecipeMatch of(String oredict, int matched) { + return of(oredict, 1, matched); + } + + public static RecipeMatch of(String oredict, int amount, int matched) { + return new RecipeMatch.Oredict(oredict, amount, matched); + } + + public static RecipeMatch of(net.minecraft.item.Item item) { + return of(item, 1); + } + + public static RecipeMatch of(net.minecraft.item.Item item, int matched) { + return of(item, 1, matched); + } + + public static RecipeMatch of(net.minecraft.item.Item item, int amount, int matched) { + return new RecipeMatch.Item(new ItemStack(item), amount, matched); + } + + public static RecipeMatch of(Block block) { + return of(block, 1); + } + + public static RecipeMatch of(Block block, int matched) { + return of(block, 1, matched); + } + + public static RecipeMatch of(Block block, int amount, int matched) { + return new RecipeMatch.Item(new ItemStack(block), amount, matched); + } + + public static RecipeMatch ofNBT(ItemStack stack) { + return new RecipeMatch.ItemCombination(1, stack); + } + /** Removes the match from the stacks */ public static void removeMatch(ItemStack[] stacks, Match match) { for(ItemStack stack : match.stacks) { From f66c66fc57ad1ce6a49d3796f54a313eda99d7dc Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Tue, 29 Dec 2015 17:19:49 -0500 Subject: [PATCH 83/91] update to latest pulsar, add its dep flightpath --- build.properties | 4 +- .../mantle/pulsar/config/IConfiguration.java | 6 +- .../mantle/pulsar/control/PulseManager.java | 203 ++++++++--------- .../mantle/pulsar/debug/EventSpy.java | 13 +- .../mantle/pulsar/flightpath/Airdrop.java | 15 ++ .../mantle/pulsar/flightpath/Flightpath.java | 101 +++++++++ .../pulsar/flightpath/IExceptionHandler.java | 25 +++ .../pulsar/flightpath/ISubscriberLocator.java | 18 ++ .../flightpath/lib/AnnotationLocator.java | 38 ++++ .../lib/BlackholeExceptionHandler.java | 25 +++ .../pulsar/internal/BusExceptionHandler.java | 34 +-- .../mantle/pulsar/internal/Configuration.java | 204 +++++++----------- .../mantle/pulsar/internal/CrashHandler.java | 37 ++-- .../pulsar/internal/logging/ILogger.java | 3 +- .../pulsar/internal/logging/JULLogger.java | 38 ++-- .../pulsar/internal/logging/Log4jLogger.java | 38 ++-- .../pulsar/internal/logging/LogManager.java | 32 +-- .../mantle/pulsar/pulse/PulseMeta.java | 49 ++--- 18 files changed, 498 insertions(+), 385 deletions(-) create mode 100755 src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java create mode 100755 src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java create mode 100755 src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java create mode 100755 src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java create mode 100755 src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java create mode 100755 src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java diff --git a/build.properties b/build.properties index 14fd54e..99a72fc 100644 --- a/build.properties +++ b/build.properties @@ -1,9 +1,9 @@ mod_version=0.6 minecraft_version=1.8.8 -forge_version=11.15.0.1641-1.8.8 +forge_version=11.15.0.1650-1.8.8 mappings=snapshot_20151212 CCLIB_version=1.1.2.133 ccc_version=1.0.5.36 NEI_version=1.0.5.104 -configurate_version=2.0 \ No newline at end of file +configurate_version=2.0 diff --git a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java index 3cc4378..9f40530 100644 --- a/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java +++ b/src/main/java/slimeknights/mantle/pulsar/config/IConfiguration.java @@ -2,13 +2,15 @@ package slimeknights.mantle.pulsar.config; import slimeknights.mantle.pulsar.pulse.PulseMeta; +import javax.annotation.ParametersAreNonnullByDefault; + /** * Interface for config handlers. * * @author Arkan */ -public interface IConfiguration -{ +@ParametersAreNonnullByDefault +public interface IConfiguration { /** * Perform any configuration loading required. diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java index bbad14b..bace851 100644 --- a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java @@ -1,8 +1,15 @@ package slimeknights.mantle.pulsar.control; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; + import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; - +import slimeknights.mantle.pulsar.flightpath.Flightpath; +import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; +import slimeknights.mantle.pulsar.flightpath.lib.AnnotationLocator; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLModContainer; import net.minecraftforge.fml.common.Loader; @@ -10,19 +17,16 @@ import net.minecraftforge.fml.common.ModContainer; import net.minecraftforge.fml.common.event.FMLEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; - import slimeknights.mantle.pulsar.config.IConfiguration; import slimeknights.mantle.pulsar.internal.BusExceptionHandler; import slimeknights.mantle.pulsar.internal.Configuration; import slimeknights.mantle.pulsar.internal.CrashHandler; +import slimeknights.mantle.pulsar.pulse.PulseMeta; import slimeknights.mantle.pulsar.internal.logging.ILogger; import slimeknights.mantle.pulsar.internal.logging.LogManager; import slimeknights.mantle.pulsar.pulse.Pulse; -import slimeknights.mantle.pulsar.pulse.PulseMeta; + +import javax.annotation.ParametersAreNonnullByDefault; /** * Manager class for a given mods Pulses. @@ -36,23 +40,19 @@ import slimeknights.mantle.pulsar.pulse.PulseMeta; * @author Arkan */ @SuppressWarnings("unused") -public class PulseManager -{ +@ParametersAreNonnullByDefault +public class PulseManager { private ILogger log; - private final boolean useConfig; private final LinkedHashMap pulses = new LinkedHashMap(); + // Use the Google @Subscribe to avoid confusion/breaking changes. + private final Flightpath flightpath = new Flightpath(new AnnotationLocator(Subscribe.class)); private boolean blockNewRegistrations = false; - private boolean configLoaded = false; - private IConfiguration conf; - - private EventBus bus; - private String id; /** @@ -62,67 +62,67 @@ public class PulseManager * * @param configName The config file name. */ - public PulseManager(String configName) - { - this.init(); - this.useConfig = true; - this.conf = new Configuration(configName, this.log); + public PulseManager(String configName) { + init(); + useConfig = true; + conf = new Configuration(configName, log); } /** * Custom configuration-using constructor. * * Don't like JSON? Heathen. Lets you handle configuration, to whatever media you like - File, database, death star. - * Whatever really. See {@link IConfiguration}. + * Whatever really. See {@link slimeknights.mantle.pulsar.config.IConfiguration}. * * @param config Configuration handler. */ - public PulseManager(IConfiguration config) - { - this.init(); - this.useConfig = true; - this.conf = config; + public PulseManager(IConfiguration config) { + init(); + useConfig = true; + conf = config; } /** * Shared initialiser code between all the constructors. */ - private void init() - { + private void init() { String modId = Loader.instance().activeModContainer().getModId(); this.id = modId; - this.log = LogManager.getLogger("Pulsar-" + modId); + log = LogManager.getLogger("Pulsar-" + modId); + flightpath.setExceptionHandler(new BusExceptionHandler(modId)); FMLCommonHandler.instance().registerCrashCallable(new CrashHandler(modId, this)); - // Attach us to the mods FML bus and setup our own bus - this.attachToContainerEventBus(this); - bus = new EventBus(new BusExceptionHandler(modId, "<*pulsar*>")); + // Attach us to the mods FML bus + attachToContainerEventBus(this); + } + + /** + * Overrides Pulsars default behaviour when a pulse emits an exception. See Flightpath's documentation. + * + * @param handler The Flightpath-compatible exception handler to use. + */ + public void setPulseExceptionHandler(IExceptionHandler handler) { + flightpath.setExceptionHandler(handler); } /** * Register a new Pulse with the manager. * - * This CANNOT be done after preInit() has been invoked. + * This CANNOT be done after preinit has been invoked. * * @param pulse The Pulse to register. */ - public void registerPulse(Object pulse) - { - if (this.blockNewRegistrations) - { - throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " - + pulse); - } - if (!this.configLoaded) - { - this.conf.load(); - this.configLoaded = true; + public void registerPulse(Object pulse) { + if (blockNewRegistrations) throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " + + pulse); + if (!configLoaded) { + conf.load(); + configLoaded = true; } String id, description, deps; boolean forced, enabled, defaultEnabled, missingDeps = false; - try - { + try { Pulse p = pulse.getClass().getAnnotation(Pulse.class); id = p.id(); description = p.description(); @@ -130,26 +130,18 @@ public class PulseManager forced = p.forced(); enabled = p.defaultEnable(); defaultEnabled = p.defaultEnable(); - } - catch (NullPointerException ex) - { + } catch (NullPointerException ex) { throw new RuntimeException("Could not parse @Pulse annotation for Pulse: " + pulse); } // Work around Java not allowing default-null fields. - if (description.equals("")) - { - description = null; - } + if (description.equals("")) description = null; - if (!deps.equals("")) - { + if (!deps.equals("")) { String[] parsedDeps = deps.split(";"); - for (String s : parsedDeps) - { - if (!Loader.isModLoaded(s)) - { - this.log.info("Skipping Pulse " + id + "; missing dependency: " + s); + for (String s : parsedDeps) { + if (!Loader.isModLoaded(s)) { + log.info("Skipping Pulse " + id + "; missing dependency: " + s); missingDeps = true; enabled = false; break; @@ -158,47 +150,38 @@ public class PulseManager } PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); - meta.setEnabled(!missingDeps && this.getEnabledFromConfig(meta)); + meta.setMissingDeps(missingDeps); + meta.setEnabled(getEnabledFromConfig(meta)); - if (meta.isEnabled()) - { - this.pulses.put(pulse, meta); - // Attach Pulse to its own internal event bus - meta.bus.register(pulse); + if (meta.isEnabled()) { + pulses.put(pulse, meta); + flightpath.register(pulse); } } /** - * Helper to attach a given object to the modcontainer event bus. + * Helper to attach a given object to the mod container event bus. * * @param obj Object to register. */ - private void attachToContainerEventBus(Object obj) - { - ModContainer cnt = Loader.instance().activeModContainer(); - this.log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); - try - { - FMLModContainer mc = (FMLModContainer) cnt; + private void attachToContainerEventBus(Object obj) { + ModContainer cnt = Loader.instance().activeModContainer(); + log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); + try { + FMLModContainer mc = (FMLModContainer)cnt; Field ebf = mc.getClass().getDeclaredField("eventBus"); boolean access = ebf.isAccessible(); ebf.setAccessible(true); - EventBus eb = (EventBus) ebf.get(mc); + EventBus eb = (EventBus)ebf.get(mc); ebf.setAccessible(access); eb.register(obj); - } - catch (NoSuchFieldException nsfe) - { + } catch (NoSuchFieldException nsfe) { throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?"); - } - catch (IllegalAccessException iae) - { + } catch (IllegalAccessException iae) { throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue."); - } - catch (ClassCastException cce) - { + } catch (ClassCastException cce) { throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage()); } } @@ -211,32 +194,36 @@ public class PulseManager * @param evt An event object. */ @Subscribe - public void propagateEvent(FMLEvent evt) { + public void propagateEvent(Object evt) { if (evt instanceof FMLPreInitializationEvent) preInit((FMLPreInitializationEvent) evt); // We use individual buses due to the EventBus class using a Set rather than a List, thus losing the ordering. // This trick is shamelessly borrowed from FML. - for (PulseMeta pulse : pulses.values()) { - pulse.bus.post(evt); - } + flightpath.post(evt); } - private boolean getEnabledFromConfig(PulseMeta meta) - { - if (meta.isForced() || !this.useConfig) - { - return true; // Forced or no config set. - } + private boolean getEnabledFromConfig(PulseMeta meta) { + if (meta.isForced() || !useConfig) return true; // Forced or no config set. - return this.conf.isModuleEnabled(meta); + return conf.isModuleEnabled(meta); } - public void preInit(FMLPreInitializationEvent evt) - { - if (!this.blockNewRegistrations) - { - this.conf.flush(); // First preInit call, so flush config + private void preInit(FMLPreInitializationEvent evt) { + if (!blockNewRegistrations) conf.flush(); // First preInit call, so flush config + blockNewRegistrations = true; + } + + private boolean hasRequiredPulses(Map.Entry entry) { + String deps = entry.getKey().getClass().getAnnotation(Pulse.class).pulsesRequired(); + if (!deps.equals("")) { + String[] parsedDeps = deps.split(";"); + for (String s : parsedDeps) { + if (!isPulseLoaded(s)) { + log.info("Skipping Pulse " + entry.getValue().getId() + "; missing pulse: " + s); + return false; + } + } } - this.blockNewRegistrations = true; + return true; } /** @@ -245,12 +232,9 @@ public class PulseManager * @param pulseId The ID to check. * @return Whether the ID was present. */ - public boolean isPulseLoaded(String pulseId) - { - for (Map.Entry entry : this.pulses.entrySet()) - { - if (entry.getValue().getId().equals(pulseId)) - { + public boolean isPulseLoaded(String pulseId) { + for(Map.Entry entry : pulses.entrySet()) { + if (entry.getValue().getId().equals(pulseId)) { return true; } } @@ -262,8 +246,7 @@ public class PulseManager } @Override - public String toString() - { - return "PulseManager[" + this.id + "]"; + public String toString() { + return "PulseManager[" + id + "]"; } } diff --git a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java index 5458721..fbc53ea 100644 --- a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java +++ b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java @@ -1,28 +1,25 @@ package slimeknights.mantle.pulsar.debug; +import com.google.common.eventbus.Subscribe; import slimeknights.mantle.pulsar.internal.logging.ILogger; import slimeknights.mantle.pulsar.internal.logging.LogManager; import slimeknights.mantle.pulsar.pulse.Pulse; import net.minecraftforge.fml.common.Loader; -import com.google.common.eventbus.Subscribe; - /** * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. * * @author Arkan */ @SuppressWarnings("unused") -@Pulse(id = "EventSpy", description = "we iz in ur buses, monitorin ur eventz", forced = true) -public class EventSpy -{ +@Pulse(id="EventSpy", description="we iz in ur buses, monitorin ur eventz", forced=true) +public class EventSpy { private final ILogger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); @Subscribe - public void receive(Object evt) - { - this.log.info("Received event: " + evt); + public void receive(Object evt) { + log.info("Received event: " + evt); } } diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java new file mode 100755 index 0000000..9299344 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/Airdrop.java @@ -0,0 +1,15 @@ +package slimeknights.mantle.pulsar.flightpath; + +import java.lang.annotation.*; + +/** + * Default annotation for Flightpath subscriptions. + * + * We don't use @Subscriber, as too many frameworks use it (which may lead to import hell) + * + * @author Arkan + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Airdrop {} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java new file mode 100755 index 0000000..909c39c --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java @@ -0,0 +1,101 @@ +package slimeknights.mantle.pulsar.flightpath; + +import slimeknights.mantle.pulsar.flightpath.lib.AnnotationLocator; +import slimeknights.mantle.pulsar.flightpath.lib.BlackholeExceptionHandler; + +import javax.annotation.ParametersAreNonnullByDefault; +import java.lang.reflect.Method; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +/** + * Flightpath - an ordered event bus implementation. + * + * @author Arkan + */ +@ParametersAreNonnullByDefault +@SuppressWarnings({"unused","unchecked"}) +public class Flightpath { + + private final ISubscriberLocator locator; + // Note we *MUST* use a linked map, otherwise order is lost. + private final LinkedHashMap>> subscribers = new LinkedHashMap>>(); + // Anything that manipulates state *MUST* acquire this lock. It prevents awkward issues when iterating. + private final Object lock = new Object(); + + private IExceptionHandler exceptionHandler = new BlackholeExceptionHandler(); + + /** + * Generates a plain old Flightpath, using the default @Airdrop annotation. + */ + public Flightpath() { + this.locator = new AnnotationLocator(Airdrop.class); + } + + /** + * Generates a Flightpath using a different locator implementation. + * + * Pass a custom constructed instance of AnnotationLocator to use alternative annotations. + * + * @param locator The locator to be applied to new objects. + */ + public Flightpath(ISubscriberLocator locator) { + this.locator = locator; + } + + /** + * Used to change exception handling behaviour. + * + * @param handler The handler to use. + */ + public void setExceptionHandler(IExceptionHandler handler) { + synchronized (lock) { + this.exceptionHandler = handler; + } + } + + /** + * Registers a given object onto the bus. + * + * @param obj Object to attach to the bus. + */ + public void register(Object obj) { + synchronized (lock) { + if (subscribers.containsKey(obj)) return; // Nothing to do. + subscribers.put(obj, locator.findSubscribers(obj)); + } + } + + /** + * Posts the given event on the bus. + * + * By default this blackholes exceptions. If you need different behaviour, see setExceptionHandler. + * + * @param evt The event to post. + */ + public void post(Object evt) { + synchronized (lock) { + for (Map.Entry>> ent : subscribers.entrySet()) { + for (Map.Entry> objEnt: ent.getValue().entrySet()) { + if (!objEnt.getKey().isAssignableFrom(evt.getClass())) continue; + Set ms = objEnt.getValue(); + for (Method m : ms) { + try { + boolean access = m.isAccessible(); + m.setAccessible(true); + m.invoke(ent.getKey(), evt); + m.setAccessible(access); + } catch (Exception ex) { + exceptionHandler.handle(ex); + } + } + } + } + exceptionHandler.flush(); + } + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java new file mode 100755 index 0000000..782a05a --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/IExceptionHandler.java @@ -0,0 +1,25 @@ +package slimeknights.mantle.pulsar.flightpath; + +import javax.annotation.ParametersAreNonnullByDefault; + +/** + * General interface for an exception handler. + * + * @author Arkan + */ +@ParametersAreNonnullByDefault +public interface IExceptionHandler { + + /** + * Handle a given exception. + * + * @param ex The exception (duh) + */ + void handle(Exception ex); + + /** + * Called after all methods have been invoked for cleanup or coalescing. + */ + void flush(); + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java new file mode 100755 index 0000000..6129148 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/ISubscriberLocator.java @@ -0,0 +1,18 @@ +package slimeknights.mantle.pulsar.flightpath; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +import java.lang.reflect.Method; +import java.util.Map; +import java.util.Set; + +/** + * Interface for defining custom subscriber scanners. + */ +@ParametersAreNonnullByDefault +public interface ISubscriberLocator { + + @Nonnull + Map> findSubscribers(Object obj); + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java new file mode 100755 index 0000000..19963a3 --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java @@ -0,0 +1,38 @@ +package slimeknights.mantle.pulsar.flightpath.lib; + +import slimeknights.mantle.pulsar.flightpath.ISubscriberLocator; + +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.*; + +/** + * Default implementation of ISubscriberLocator + * + * @author Arkan + */ +@ParametersAreNonnullByDefault +public class AnnotationLocator implements ISubscriberLocator { + + private final Class annotation; + + public AnnotationLocator(Class annotation) { + this.annotation = annotation; + } + + @Override + public @Nonnull Map> findSubscribers(Object obj) { + Map> methods = new HashMap>(); + for (Method m : obj.getClass().getMethods()) { + if (m.isAnnotationPresent(annotation) && m.getParameterCount() == 1) { + Class param = m.getParameterTypes()[0]; + if (!methods.containsKey(param)) methods.put(param, new HashSet()); + methods.get(param).add(m); + } + } + return methods; + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java new file mode 100755 index 0000000..60f5f1b --- /dev/null +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/BlackholeExceptionHandler.java @@ -0,0 +1,25 @@ +package slimeknights.mantle.pulsar.flightpath.lib; + +import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; + +import javax.annotation.ParametersAreNonnullByDefault; + +/** + * Default exception handler when Flightpath has been asked to ignore errors. + * + * @author Arkan + */ +@ParametersAreNonnullByDefault +public class BlackholeExceptionHandler implements IExceptionHandler { + + @Override + public void handle(Exception ex) { + // NO-OP + } + + @Override + public void flush() { + // NO-OP + } + +} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java index bca7f53..00c66bc 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java @@ -1,28 +1,36 @@ package slimeknights.mantle.pulsar.internal; -import com.google.common.eventbus.SubscriberExceptionContext; -import com.google.common.eventbus.SubscriberExceptionHandler; -import net.minecraftforge.fml.common.FMLCommonHandler; +import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; +import slimeknights.mantle.pulsar.internal.logging.ILogger; +import slimeknights.mantle.pulsar.internal.logging.LogManager; + +import javax.annotation.ParametersAreNonnullByDefault; /** - * Needed because Google EventBus is a derp and by default swallows exceptions (dafuq guys?) + * Custom exception catcher that logs events. */ -public final class BusExceptionHandler implements SubscriberExceptionHandler { - private final String id, pulseId; +@ParametersAreNonnullByDefault +public final class BusExceptionHandler implements IExceptionHandler { + + private final String id; + private final ILogger logger; /** * @param id Mod ID to include in exception raises. */ - public BusExceptionHandler(String id, String pulseId) { + public BusExceptionHandler(String id) { this.id = id; - this.pulseId = pulseId; + this.logger = LogManager.getLogger(id + "-Pulsar-Flightpath"); } @Override - public void handleException(Throwable exception, SubscriberExceptionContext ctx) { - FMLCommonHandler.instance().raiseException(exception, "Pulsar/" + id + "/" + pulseId - + " >> Exception uncaught in [" + ctx.getSubscriber().getClass().getName() + ":" - + ctx.getSubscriberMethod().getName() + "] for event [" + ctx.getEvent().getClass().getSimpleName() - + "]", true); + public void handle(Exception ex) { + this.logger.severe("Exception caught from a pulse on flightpath for mod ID " + id + ": " + ex); } + + @Override + public void flush() { + // NO-OP + } + } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java index dca1972..3b56e94 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java @@ -1,39 +1,32 @@ package slimeknights.mantle.pulsar.internal; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.util.HashMap; -import java.util.Map; - -import slimeknights.mantle.pulsar.config.IConfiguration; -import slimeknights.mantle.pulsar.internal.logging.ILogger; -import slimeknights.mantle.pulsar.pulse.PulseMeta; -import net.minecraftforge.fml.common.Loader; +import java.io.*; +import java.util.*; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import net.minecraftforge.fml.common.Loader; +import slimeknights.mantle.pulsar.config.IConfiguration; +import slimeknights.mantle.pulsar.internal.logging.ILogger; +import slimeknights.mantle.pulsar.pulse.PulseMeta; + +import javax.annotation.ParametersAreNonnullByDefault; /** * Default Gson Configuration helper. * * @author Arkan */ -public class Configuration implements IConfiguration -{ +@ParametersAreNonnullByDefault +public class Configuration implements IConfiguration { private static final int CONFIG_LEVEL = 1; private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - private final String confPath; - private final ILogger logger; private Map modules; @@ -46,151 +39,111 @@ public class Configuration implements IConfiguration * @param confName The config file name (without path or .json suffix) * @param logger The logger to send debug info to. */ - public Configuration(String confName, ILogger logger) - { + public Configuration(String confName, ILogger logger) { this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json"; this.logger = logger; } @Override - public void load() - { - this.getModulesFromJson(); + public void load() { + getModulesFromJson(); } @Override - public boolean isModuleEnabled(PulseMeta meta) - { - ConfigEntry entry = this.modules.get(meta.getId()); - if (entry == null) - { - this.modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); + public boolean isModuleEnabled(PulseMeta meta) { + ConfigEntry entry = modules.get(meta.getId()); + if (entry == null) { + modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); return meta.isEnabled(); - } - else - { + } else { return entry.getEnabled(); } } @Override - public void flush() - { - this.writeModulesToJson(); + public void flush() { + writeModulesToJson(); } - private void getModulesFromJson() - { + private void getModulesFromJson() { // Step 1: Does the file exist? - File f = new File(this.confPath); - if (!f.exists()) - { - this.logger.info("Couldn't find config file; will generate a new one later."); - this.modules = new HashMap(); + File f = new File(confPath); + if (!f.exists()) { + logger.info("Couldn't find config file; will generate a new one later."); + modules = new HashMap(); return; } // Step 2: File exists. Let's make sure it's usable. - if (!(f.canRead() && f.canWrite())) - { - throw new FileNotReadWritableException("Could not read/write Pulsar config: " + this.confPath); + if (!(f.canRead() && f.canWrite())) { + throw new FileNotReadWritableException("Could not read/write Pulsar config: " + confPath); } // Step 3: Good enough. Read it. - try - { - try - { - this.modules = this.parseV1Config(f); + try { + try { + modules = parseV1Config(f); + } catch (Exception ex) { + logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); + Map conf = parseV0Config(f); + logger.info("Found valid v0 configuration. Upgrading it."); + modules = conf; + writeModulesToJson(); + logger.info("Upgrade complete! Config is now in v1 format."); } - catch (Exception ex) - { - this.logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); - Map conf = this.parseV0Config(f); - this.logger.info("Found valid v0 configuration. Upgrading it."); - this.modules = conf; - this.writeModulesToJson(); - this.logger.info("Upgrade complete! Config is now in v1 format."); - } - } - catch (Exception ex) - { - this.logger.warn("Invalid config file. Discarding."); + } catch (Exception ex) { + logger.warn("Invalid config file. Discarding."); ex.printStackTrace(); - this.modules = new HashMap(); + modules = new HashMap(); } } - private Map parseV0Config(File f) throws Exception - { - try - { + private Map parseV0Config(File f) throws Exception { + try { JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); - Map m = gson.fromJson(reader, new TypeToken>() - { - }.getType()); // NASTY! - if (m == null) - { + Map m = gson.fromJson(reader, new TypeToken>(){}.getType()); // NASTY! + if (m == null) { throw new NullPointerException("Gson returned null."); } Map out = new HashMap(); - for (Map.Entry e : m.entrySet()) - { + for (Map.Entry e : m.entrySet()) { out.put(e.getKey(), new ConfigEntry(e.getValue())); } return out; - } - catch (FileNotFoundException fnfe) - { + } catch (FileNotFoundException fnfe) { throw new RuntimeException("This shouldn't be possible... " + fnfe); } } - private Map parseV1Config(File f) throws Exception - { - try - { + private Map parseV1Config(File f) throws Exception { + try { JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(f))); GsonConfig c = gson.fromJson(reader, GsonConfig.class); - if (c.getConfigVersion() > 1) - { - throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); - } - if (c.getModules() == null) - { - throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); - } + if (c.getConfigVersion() > 1) throw new RuntimeException("Pulsar config is from a newer version! Remove it! " + f.getAbsolutePath()); + if (c.getModules() == null) throw new IllegalArgumentException("Not a valid GsonConfig. Try v0 parsing."); return c.getModules(); - } - catch (FileNotFoundException fnfe) - { + } catch (FileNotFoundException fnfe) { throw new RuntimeException("This shouldn't be possible... " + fnfe); } } - private void writeModulesToJson() - { - try - { - JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(this.confPath)))); + private void writeModulesToJson() { + try { + JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(confPath)))); writer.setIndent(" "); - GsonConfig out = new GsonConfig(CONFIG_LEVEL, this.modules); + GsonConfig out = new GsonConfig(CONFIG_LEVEL, modules); gson.toJson(out, GsonConfig.class, writer); writer.close(); - } - catch (Exception ex) - { - this.logger.warn("Could not write config? " + this.confPath); + } catch (Exception ex) { + logger.warn("Could not write config? " + confPath); } } /** * Internal exception for an unreadable/unwritable config. */ - private static class FileNotReadWritableException extends RuntimeException - { - public FileNotReadWritableException(String message) - { + private static class FileNotReadWritableException extends RuntimeException { + public FileNotReadWritableException(String message) { super(message); } } @@ -198,54 +151,53 @@ public class Configuration implements IConfiguration /** * Internal data holder, for use in the map and JSON. */ - private static class ConfigEntry - { + private static class ConfigEntry { private Boolean enabled; - private String description = null; - public ConfigEntry(Boolean enabled) - { + public ConfigEntry(Boolean enabled) { this.enabled = enabled; } - public ConfigEntry(Boolean enabled, String description) - { + public ConfigEntry(Boolean enabled, String description) { this(enabled); this.description = description; } - public Boolean getEnabled() - { - return this.enabled; + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public String getDescription() { + return description; } } /** * Internal representation of a version 1+ config file. */ - private static class GsonConfig - { + private static class GsonConfig { private int CONFIG_VERSION = 0; private Map modules; - public GsonConfig(int version, Map modules) - { + public GsonConfig(int version, Map modules) { this.CONFIG_VERSION = version; this.modules = modules; } - public int getConfigVersion() - { - return this.CONFIG_VERSION; + public int getConfigVersion() { + return CONFIG_VERSION; } - public Map getModules() - { - return this.modules; + public Map getModules() { + return modules; } } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java index 81f011b..c45b4e9 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java @@ -1,59 +1,46 @@ package slimeknights.mantle.pulsar.internal; +import net.minecraftforge.fml.common.ICrashCallable; import slimeknights.mantle.pulsar.control.PulseManager; import slimeknights.mantle.pulsar.pulse.PulseMeta; -import net.minecraftforge.fml.common.ICrashCallable; /** * FML crash callable for Pulse Managers; dumps a list of loaded pulses to the error log. * * @author Arkan */ -public class CrashHandler implements ICrashCallable -{ +public class CrashHandler implements ICrashCallable { private String id; - private PulseManager manager; - public CrashHandler(String modId, PulseManager manager) - { + public CrashHandler(String modId, PulseManager manager) { this.id = "Pulsar/" + modId + " loaded Pulses"; this.manager = manager; } @Override - public String getLabel() - { - return this.id; + public String getLabel() { + return id; } @Override - public String call() throws Exception - { + public String call() throws Exception { String out = "\n"; - for (PulseMeta meta : this.manager.getAllPulseMetadata()) - { + for (PulseMeta meta : manager.getAllPulseMetadata()) { String state = getStateFromMeta(meta); out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... } return out; } - private static String getStateFromMeta(PulseMeta meta) - { - if (meta.isForced()) - { + private static String getStateFromMeta(PulseMeta meta) { + if (meta.isForced()) { return "Enabled/Forced"; - } - else - { - if (meta.isEnabled()) - { + } else { + if (meta.isEnabled()) { return "Enabled/Not Forced"; - } - else - { + } else { return "Disabled/Not Forced"; } } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java index 7845712..ef47f51 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java @@ -6,8 +6,7 @@ package slimeknights.mantle.pulsar.internal.logging; * @author Arkan */ @SuppressWarnings("unused") -public interface ILogger -{ +public interface ILogger { public void fatal(String msg); diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java index 991b227..1f3497e 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java @@ -7,50 +7,42 @@ import java.util.logging.Logger; * * @author Arkan */ -public class JULLogger implements ILogger -{ +public class JULLogger implements ILogger { private final Logger log; - public JULLogger(String name) - { - this.log = Logger.getLogger(name); + public JULLogger(String name) { + log = Logger.getLogger(name); } @Override - public void fatal(String msg) - { - this.log.severe(msg); // JUL doesn't -have- fatal... + public void fatal(String msg) { + log.severe(msg); // JUL doesn't -have- fatal... } @Override - public void severe(String msg) - { - this.log.severe(msg); + public void severe(String msg) { + log.severe(msg); } @Override - public void warn(String msg) - { - this.log.warning(msg); + public void warn(String msg) { + log.warning(msg); } @Override - public void info(String msg) - { - this.log.info(msg); + public void info(String msg) { + log.info(msg); } @Override - public void debug(String msg) - { - this.log.fine(msg); // Good enough. + public void debug(String msg) { + log.fine(msg); // Good enough. } @Override - public void trace(String msg) - { - this.log.finest(msg); // Closest we'll get. + public void trace(String msg) { + log.finest(msg); // Closest we'll get. } } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java index 0ee21ec..d061bf7 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java @@ -7,50 +7,42 @@ import org.apache.logging.log4j.Logger; * * @author Arkan */ -public class Log4jLogger implements ILogger -{ +public class Log4jLogger implements ILogger { private final Logger log; - public Log4jLogger(String name) - { - this.log = org.apache.logging.log4j.LogManager.getLogger(name); + public Log4jLogger(String name) { + log = org.apache.logging.log4j.LogManager.getLogger(name); } @Override - public void fatal(String msg) - { - this.log.fatal(msg); + public void fatal(String msg) { + log.fatal(msg); } @Override - public void severe(String msg) - { - this.log.error(msg); + public void severe(String msg) { + log.error(msg); } @Override - public void warn(String msg) - { - this.log.warn(msg); + public void warn(String msg) { + log.warn(msg); } @Override - public void info(String msg) - { - this.log.info(msg); + public void info(String msg) { + log.info(msg); } @Override - public void debug(String msg) - { - this.log.debug(msg); + public void debug(String msg) { + log.debug(msg); } @Override - public void trace(String msg) - { - this.log.trace(msg); + public void trace(String msg) { + log.trace(msg); } } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java index db4892d..47369bb 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java @@ -5,12 +5,9 @@ package slimeknights.mantle.pulsar.internal.logging; * * @author Arkan */ -public class LogManager -{ +public class LogManager { - private LogManager() - { - } // Singleton. + private LogManager() {} // Singleton. private static final boolean useLog4j2; @@ -19,33 +16,22 @@ public class LogManager * * If it's present, we can assume we should be using the damn thing. */ - static - { + static { boolean l4j = false; - try - { + try { Class cl = Class.forName("org.apache.logging.log4j.LogManager"); - if (cl == null) - { - throw new ClassNotFoundException("This should never happen..."); - } + if (cl == null) throw new ClassNotFoundException("This should never happen..."); l4j = true; - } - catch (ClassNotFoundException cnfe) - { + } catch (ClassNotFoundException cnfe) { // Ignore } useLog4j2 = l4j; } - public static ILogger getLogger(String name) - { - if (useLog4j2) - { + public static ILogger getLogger(String name) { + if (useLog4j2) { return new Log4jLogger(name); - } - else - { + } else { return new JULLogger(name); } } diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java index 50e21ff..81fc979 100644 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java @@ -1,60 +1,53 @@ package slimeknights.mantle.pulsar.pulse; -import com.google.common.eventbus.EventBus; -import net.minecraftforge.fml.common.Loader; - -import slimeknights.mantle.pulsar.internal.BusExceptionHandler; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; /** * Metadata wrapper for parsed @Pulse metadata. * * @author Arkan */ -public class PulseMeta -{ +@ParametersAreNonnullByDefault +public class PulseMeta { private String id, description; - private boolean forced, enabled, defaultEnabled; - public final EventBus bus; + private boolean missingDeps = false; - public PulseMeta(String id, String description, boolean forced, boolean enabled, boolean defaultEnabled) - { + public PulseMeta(String id, @Nullable String description, boolean forced, boolean enabled, boolean defaultEnabled) { this.id = id; this.description = description; this.forced = forced; this.enabled = enabled; this.defaultEnabled = defaultEnabled; - this.bus = new EventBus(new BusExceptionHandler(Loader.instance().activeModContainer().getModId(), id)); } - public String getId() - { - return this.id; + public String getId() { + return id; } - public String getDescription() - { - return this.description; + public String getDescription() { + return description; } - public boolean isForced() - { - return this.forced; + public boolean isForced() { + return !missingDeps && forced; } - public boolean isEnabled() - { - return this.enabled; + public boolean isEnabled() { + return !missingDeps && enabled; } - public void setEnabled(boolean enabled) - { + public void setEnabled(boolean enabled) { this.enabled = enabled; } - public boolean isDefaultEnabled() - { - return this.defaultEnabled; + public void setMissingDeps(boolean missing) { + missingDeps = missing; + } + + public boolean isDefaultEnabled() { + return defaultEnabled; } } From 7a692130e70bb5eff3c5a7e88b6b4013053deda1 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 30 Dec 2015 22:15:32 +0100 Subject: [PATCH 84/91] More recipematch stuff --- src/main/java/slimeknights/mantle/util/RecipeMatch.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index ff05aa4..ab5702d 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -73,7 +73,11 @@ public abstract class RecipeMatch { } public static RecipeMatch ofNBT(ItemStack stack) { - return new RecipeMatch.ItemCombination(1, stack); + return ofNBT(stack, 1); + } + + public static RecipeMatch ofNBT(ItemStack stack, int matched) { + return new RecipeMatch.ItemCombination(matched, stack); } /** Removes the match from the stacks */ From c49810c24d235b59653b659c400de7fd944b849c Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 30 Dec 2015 22:25:10 +0100 Subject: [PATCH 85/91] Update to 1.8.9 --- build.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.properties b/build.properties index 99a72fc..183280a 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ mod_version=0.6 -minecraft_version=1.8.8 -forge_version=11.15.0.1650-1.8.8 +minecraft_version=1.8.9 +forge_version=11.15.0.1663 mappings=snapshot_20151212 CCLIB_version=1.1.2.133 From 4267584e00da5d9ce462d316d8dfddc93ce9261e Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Thu, 31 Dec 2015 14:17:26 +0100 Subject: [PATCH 86/91] Expand recipeMatch so it can be used for displaying purposes --- .../slimeknights/mantle/util/RecipeMatch.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index ab5702d..cd981a6 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -1,5 +1,6 @@ package slimeknights.mantle.util; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -34,6 +35,11 @@ public abstract class RecipeMatch { this.amountNeeded = amountNeeded; } + /** + * Return all possible inputs that are a single item, if applicable. + */ + public abstract List getInputs(); + public abstract Match matches(ItemStack[] stacks); public static RecipeMatch of(String oredict) { @@ -120,6 +126,11 @@ public abstract class RecipeMatch { this.template = template; } + @Override + public List getInputs() { + return ImmutableList.of(template); + } + @Override public Match matches(ItemStack[] stacks) { List found = Lists.newLinkedList(); @@ -158,6 +169,14 @@ public abstract class RecipeMatch { this.itemStacks = stacks; } + @Override + public List getInputs() { + if(itemStacks.length == 0 || itemStacks.length > 1) { + return ImmutableList.of(); + } + return ImmutableList.of(itemStacks[0]); + } + @Override public Match matches(ItemStack[] stacks) { List found = Lists.newLinkedList(); @@ -206,6 +225,11 @@ public abstract class RecipeMatch { this.oredictEntry = OreDictionary.getOres(oredictEntry); } + @Override + public List getInputs() { + return oredictEntry; + } + @Override public Match matches(ItemStack[] stacks) { List found = Lists.newLinkedList(); From 162ca7510264913b52342a68ae2da0548f48b41a Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 2 Jan 2016 19:20:23 +0100 Subject: [PATCH 87/91] Update to Flightpath 0.0.3, fixes J8 dep --- .../mantle/pulsar/flightpath/lib/AnnotationLocator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java index 19963a3..298fda2 100755 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java @@ -26,7 +26,7 @@ public class AnnotationLocator implements ISubscriberLocator { public @Nonnull Map> findSubscribers(Object obj) { Map> methods = new HashMap>(); for (Method m : obj.getClass().getMethods()) { - if (m.isAnnotationPresent(annotation) && m.getParameterCount() == 1) { + if (m.isAnnotationPresent(annotation) && m.getParameterTypes().length == 1) { Class param = m.getParameterTypes()[0]; if (!methods.containsKey(param)) methods.put(param, new HashSet()); methods.get(param).add(m); From 8a29cbcbddfa5a1f0ac4198b11048f55c0359c87 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 4 Jan 2016 10:08:27 +0100 Subject: [PATCH 88/91] Check if the vertextransformer pipe actually passes the data in --- .../java/slimeknights/mantle/client/model/TRSRBakedModel.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java index b22652a..f32ef74 100644 --- a/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java +++ b/src/main/java/slimeknights/mantle/client/model/TRSRBakedModel.java @@ -142,14 +142,14 @@ public class TRSRBakedModel implements IFlexibleBakedModel { VertexFormatElement.EnumUsage usage = parent.getVertexFormat().getElement(element).getUsage(); // transform normals and position - if(usage == VertexFormatElement.EnumUsage.POSITION) { + if(usage == VertexFormatElement.EnumUsage.POSITION && data.length >= 3) { Vector4f vec = new Vector4f(data); vec.setW(1.0f); transformation.transform(vec); data = new float[4]; vec.get(data); } - else if(usage == VertexFormatElement.EnumUsage.NORMAL) { + else if(usage == VertexFormatElement.EnumUsage.NORMAL && data.length >= 3) { Vector3f vec = new Vector3f(data); normalTransformation.transform(vec); vec.normalize(); From 65c75c0babacf8ad77edd948e3f80e1ff7704152 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 5 Jan 2016 17:52:59 +0100 Subject: [PATCH 89/91] Update pulsar for better logging --- .../mantle/pulsar/control/PulseManager.java | 33 ++++++------- .../mantle/pulsar/debug/EventSpy.java | 11 +++-- .../pulsar/internal/BusExceptionHandler.java | 9 ++-- .../mantle/pulsar/internal/Configuration.java | 8 ++-- .../pulsar/internal/logging/ILogger.java | 23 --------- .../pulsar/internal/logging/JULLogger.java | 48 ------------------- .../pulsar/internal/logging/Log4jLogger.java | 48 ------------------- .../pulsar/internal/logging/LogManager.java | 39 --------------- 8 files changed, 34 insertions(+), 185 deletions(-) delete mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java delete mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java delete mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java delete mode 100644 src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java index bace851..3524b00 100644 --- a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java @@ -1,32 +1,33 @@ package slimeknights.mantle.pulsar.control; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + +import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.fml.common.FMLModContainer; +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.lang.reflect.Field; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Map; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; +import javax.annotation.ParametersAreNonnullByDefault; + +import slimeknights.mantle.pulsar.config.IConfiguration; import slimeknights.mantle.pulsar.flightpath.Flightpath; import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; import slimeknights.mantle.pulsar.flightpath.lib.AnnotationLocator; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.FMLModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.event.FMLEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -import slimeknights.mantle.pulsar.config.IConfiguration; import slimeknights.mantle.pulsar.internal.BusExceptionHandler; import slimeknights.mantle.pulsar.internal.Configuration; import slimeknights.mantle.pulsar.internal.CrashHandler; -import slimeknights.mantle.pulsar.pulse.PulseMeta; -import slimeknights.mantle.pulsar.internal.logging.ILogger; -import slimeknights.mantle.pulsar.internal.logging.LogManager; import slimeknights.mantle.pulsar.pulse.Pulse; - -import javax.annotation.ParametersAreNonnullByDefault; +import slimeknights.mantle.pulsar.pulse.PulseMeta; /** * Manager class for a given mods Pulses. @@ -43,7 +44,7 @@ import javax.annotation.ParametersAreNonnullByDefault; @ParametersAreNonnullByDefault public class PulseManager { - private ILogger log; + private Logger log; private final boolean useConfig; private final LinkedHashMap pulses = new LinkedHashMap(); diff --git a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java index fbc53ea..aa74275 100644 --- a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java +++ b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java @@ -1,11 +1,14 @@ package slimeknights.mantle.pulsar.debug; import com.google.common.eventbus.Subscribe; -import slimeknights.mantle.pulsar.internal.logging.ILogger; -import slimeknights.mantle.pulsar.internal.logging.LogManager; -import slimeknights.mantle.pulsar.pulse.Pulse; + import net.minecraftforge.fml.common.Loader; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import slimeknights.mantle.pulsar.pulse.Pulse; + /** * Debug Pulse to 'eavesdrop' on the PulseManager event bus traffic. * @@ -15,7 +18,7 @@ import net.minecraftforge.fml.common.Loader; @Pulse(id="EventSpy", description="we iz in ur buses, monitorin ur eventz", forced=true) public class EventSpy { - private final ILogger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); + private final Logger log = LogManager.getLogger("EventSpy/" + Loader.instance().activeModContainer().getModId()); @Subscribe public void receive(Object evt) { diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java index 00c66bc..0d16a7d 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java @@ -1,8 +1,9 @@ package slimeknights.mantle.pulsar.internal; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import slimeknights.mantle.pulsar.flightpath.IExceptionHandler; -import slimeknights.mantle.pulsar.internal.logging.ILogger; -import slimeknights.mantle.pulsar.internal.logging.LogManager; import javax.annotation.ParametersAreNonnullByDefault; @@ -13,7 +14,7 @@ import javax.annotation.ParametersAreNonnullByDefault; public final class BusExceptionHandler implements IExceptionHandler { private final String id; - private final ILogger logger; + private final Logger logger; /** * @param id Mod ID to include in exception raises. @@ -25,7 +26,7 @@ public final class BusExceptionHandler implements IExceptionHandler { @Override public void handle(Exception ex) { - this.logger.severe("Exception caught from a pulse on flightpath for mod ID " + id + ": " + ex); + this.logger.error("Exception caught from a pulse on flightpath for mod ID " + id + ": ", ex); } @Override diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java index 3b56e94..78deff7 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java @@ -9,8 +9,10 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import net.minecraftforge.fml.common.Loader; + +import org.apache.logging.log4j.Logger; + import slimeknights.mantle.pulsar.config.IConfiguration; -import slimeknights.mantle.pulsar.internal.logging.ILogger; import slimeknights.mantle.pulsar.pulse.PulseMeta; import javax.annotation.ParametersAreNonnullByDefault; @@ -27,7 +29,7 @@ public class Configuration implements IConfiguration { private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); private final String confPath; - private final ILogger logger; + private final Logger logger; private Map modules; @@ -39,7 +41,7 @@ public class Configuration implements IConfiguration { * @param confName The config file name (without path or .json suffix) * @param logger The logger to send debug info to. */ - public Configuration(String confName, ILogger logger) { + public Configuration(String confName, Logger logger) { this.confPath = Loader.instance().getConfigDir().toString() + File.separator + confName + ".json"; this.logger = logger; } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java deleted file mode 100644 index ef47f51..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/ILogger.java +++ /dev/null @@ -1,23 +0,0 @@ -package slimeknights.mantle.pulsar.internal.logging; - -/** - * Interface for log wrappers. - * - * @author Arkan - */ -@SuppressWarnings("unused") -public interface ILogger { - - public void fatal(String msg); - - public void severe(String msg); - - public void warn(String msg); - - public void info(String msg); - - public void debug(String msg); - - public void trace(String msg); - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java deleted file mode 100644 index 1f3497e..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/JULLogger.java +++ /dev/null @@ -1,48 +0,0 @@ -package slimeknights.mantle.pulsar.internal.logging; - -import java.util.logging.Logger; - -/** - * Java logger wrapper. - * - * @author Arkan - */ -public class JULLogger implements ILogger { - - private final Logger log; - - public JULLogger(String name) { - log = Logger.getLogger(name); - } - - @Override - public void fatal(String msg) { - log.severe(msg); // JUL doesn't -have- fatal... - } - - @Override - public void severe(String msg) { - log.severe(msg); - } - - @Override - public void warn(String msg) { - log.warning(msg); - } - - @Override - public void info(String msg) { - log.info(msg); - } - - @Override - public void debug(String msg) { - log.fine(msg); // Good enough. - } - - @Override - public void trace(String msg) { - log.finest(msg); // Closest we'll get. - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java deleted file mode 100644 index d061bf7..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/Log4jLogger.java +++ /dev/null @@ -1,48 +0,0 @@ -package slimeknights.mantle.pulsar.internal.logging; - -import org.apache.logging.log4j.Logger; - -/** - * Log4j log wrapper. - * - * @author Arkan - */ -public class Log4jLogger implements ILogger { - - private final Logger log; - - public Log4jLogger(String name) { - log = org.apache.logging.log4j.LogManager.getLogger(name); - } - - @Override - public void fatal(String msg) { - log.fatal(msg); - } - - @Override - public void severe(String msg) { - log.error(msg); - } - - @Override - public void warn(String msg) { - log.warn(msg); - } - - @Override - public void info(String msg) { - log.info(msg); - } - - @Override - public void debug(String msg) { - log.debug(msg); - } - - @Override - public void trace(String msg) { - log.trace(msg); - } - -} diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java b/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java deleted file mode 100644 index 47369bb..0000000 --- a/src/main/java/slimeknights/mantle/pulsar/internal/logging/LogManager.java +++ /dev/null @@ -1,39 +0,0 @@ -package slimeknights.mantle.pulsar.internal.logging; - -/** - * Static class for getting generic loggers. - * - * @author Arkan - */ -public class LogManager { - - private LogManager() {} // Singleton. - - private static final boolean useLog4j2; - - /* - * Detect the presence of log4j2. - * - * If it's present, we can assume we should be using the damn thing. - */ - static { - boolean l4j = false; - try { - Class cl = Class.forName("org.apache.logging.log4j.LogManager"); - if (cl == null) throw new ClassNotFoundException("This should never happen..."); - l4j = true; - } catch (ClassNotFoundException cnfe) { - // Ignore - } - useLog4j2 = l4j; - } - - public static ILogger getLogger(String name) { - if (useLog4j2) { - return new Log4jLogger(name); - } else { - return new JULLogger(name); - } - } - -} From 0fe940c90a085bde4954d897b5d9a1fd92db9c2b Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Tue, 5 Jan 2016 17:57:47 +0100 Subject: [PATCH 90/91] Have flightpath rethrow errors because we WANT it to crash if something goes terribly wrong --- .../mantle/pulsar/internal/BusExceptionHandler.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java index 0d16a7d..148456e 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/BusExceptionHandler.java @@ -27,6 +27,9 @@ public final class BusExceptionHandler implements IExceptionHandler { @Override public void handle(Exception ex) { this.logger.error("Exception caught from a pulse on flightpath for mod ID " + id + ": ", ex); + if(ex instanceof RuntimeException) { + throw (RuntimeException)ex; + } } @Override From dbca52d9eb84317b2a2b8baad990f2bbdeb1a8c4 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Fri, 8 Jan 2016 16:39:53 +0100 Subject: [PATCH 91/91] Expand recipematch constructors --- .../slimeknights/mantle/util/RecipeMatch.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index cd981a6..f6651ba 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -54,6 +54,18 @@ public abstract class RecipeMatch { return new RecipeMatch.Oredict(oredict, amount, matched); } + public static RecipeMatch of(List oredict) { + return of(oredict, 1); + } + + public static RecipeMatch of(List oredict, int matched) { + return of(oredict, 1, matched); + } + + public static RecipeMatch of(List oredict, int amount, int matched) { + return new RecipeMatch.Oredict(oredict, amount, matched); + } + public static RecipeMatch of(net.minecraft.item.Item item) { return of(item, 1); } @@ -216,6 +228,15 @@ public abstract class RecipeMatch { private final List oredictEntry; // todo: change this to the actual list in the oredict + public Oredict(List oredictEntry, int amountNeeded) { + this(oredictEntry, amountNeeded, 1); + } + + public Oredict(List oredictEntry, int amountNeeded, int amountMatched) { + super(amountMatched, amountNeeded); + this.oredictEntry = oredictEntry; + } + public Oredict(String oredictEntry, int amountNeeded) { this(oredictEntry, amountNeeded, 1); }