diff --git a/src/main/java/adventurebackpack/api/FluidEffect.java b/src/main/java/adventurebackpack/api/FluidEffect.java index a8a48796..809098b2 100644 --- a/src/main/java/adventurebackpack/api/FluidEffect.java +++ b/src/main/java/adventurebackpack/api/FluidEffect.java @@ -6,12 +6,13 @@ import net.minecraftforge.fluids.FluidRegistry; /** - * A Class you must extend to add player effects when drinking different fluids. - * The timeInSeconds and timeInSeconds in ticks may serve to set the duration of the effect. + * A Class you must extend to add player effects when drinking different fluids. The timeInSeconds and timeInSeconds in + * ticks may serve to set the duration of the effect. * * @author Darkona */ public abstract class FluidEffect { + public Fluid fluid; public int timeInSeconds; public int timeInTicks; @@ -51,9 +52,8 @@ public int getEffectID() { } /** - * This method determines what will happen to the player (or world!) when drinking the - * corresponding fluid. For example set potion effects, set player on fire, - * heal, fill hunger, etc. You can use the world parameter to make + * This method determines what will happen to the player (or world!) when drinking the corresponding fluid. For + * example set potion effects, set player on fire, heal, fill hunger, etc. You can use the world parameter to make * conditions based on where the player is. * * @param world The World. diff --git a/src/main/java/com/darkona/adventurebackpack/AdventureBackpack.java b/src/main/java/com/darkona/adventurebackpack/AdventureBackpack.java index e87f8d72..4ac8d72c 100644 --- a/src/main/java/com/darkona/adventurebackpack/AdventureBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/AdventureBackpack.java @@ -1,5 +1,7 @@ package com.darkona.adventurebackpack; +import net.minecraftforge.common.MinecraftForge; + import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; import com.darkona.adventurebackpack.handlers.ClientEventHandler; @@ -19,6 +21,7 @@ import com.darkona.adventurebackpack.reference.LoadedMods; import com.darkona.adventurebackpack.reference.ModInfo; import com.darkona.adventurebackpack.reference.WailaTileAdventureBackpack; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; @@ -26,7 +29,6 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; -import net.minecraftforge.common.MinecraftForge; /** * Created on 10/10/2014 @@ -40,6 +42,7 @@ guiFactory = ModInfo.GUI_FACTORY_CLASS, dependencies = "required-after:CodeChickenCore@[1.0.7.47,)") public class AdventureBackpack { + @SidedProxy(clientSide = ModInfo.MOD_CLIENT_PROXY, serverSide = ModInfo.MOD_SERVER_PROXY) public static IProxy proxy; diff --git a/src/main/java/com/darkona/adventurebackpack/CreativeTabAB.java b/src/main/java/com/darkona/adventurebackpack/CreativeTabAB.java index 5ae1948b..be8e22ed 100644 --- a/src/main/java/com/darkona/adventurebackpack/CreativeTabAB.java +++ b/src/main/java/com/darkona/adventurebackpack/CreativeTabAB.java @@ -1,17 +1,20 @@ package com.darkona.adventurebackpack; -import com.darkona.adventurebackpack.init.ModItems; -import com.darkona.adventurebackpack.reference.ModInfo; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.reference.ModInfo; + /** * Created on 11/10/2014. * * @author Javier Darkona */ public class CreativeTabAB { + public static final CreativeTabs TAB_AB = new CreativeTabs(ModInfo.MOD_ID) { + @Override public Item getTabIconItem() { return ModItems.machete; diff --git a/src/main/java/com/darkona/adventurebackpack/block/BackpackMaterial.java b/src/main/java/com/darkona/adventurebackpack/block/BackpackMaterial.java index cef4d1dd..62715525 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/BackpackMaterial.java +++ b/src/main/java/com/darkona/adventurebackpack/block/BackpackMaterial.java @@ -9,6 +9,7 @@ * @author Darkona */ public class BackpackMaterial extends Material { + public BackpackMaterial() { super(MapColor.brownColor); } diff --git a/src/main/java/com/darkona/adventurebackpack/block/BlockAdventureBackpack.java b/src/main/java/com/darkona/adventurebackpack/block/BlockAdventureBackpack.java index 7301b88a..d003f12a 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/BlockAdventureBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/block/BlockAdventureBackpack.java @@ -6,18 +6,8 @@ import static com.darkona.adventurebackpack.reference.BackpackTypes.REDSTONE; import static com.darkona.adventurebackpack.reference.BackpackTypes.UNKNOWN; -import com.darkona.adventurebackpack.AdventureBackpack; -import com.darkona.adventurebackpack.client.Icons; -import com.darkona.adventurebackpack.handlers.GuiHandler; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.reference.GeneralReference; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.CoordsUtils; -import cpw.mods.fml.common.network.internal.FMLNetworkHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.client.renderer.texture.IIconRegister; @@ -42,12 +32,26 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.darkona.adventurebackpack.AdventureBackpack; +import com.darkona.adventurebackpack.client.Icons; +import com.darkona.adventurebackpack.handlers.GuiHandler; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.reference.GeneralReference; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.CoordsUtils; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 12/10/2014. * * @author Javier Darkona */ public class BlockAdventureBackpack extends BlockContainer { + public BlockAdventureBackpack() { super(new BackpackMaterial()); setHardness(1.0f); @@ -171,7 +175,7 @@ public String getUnlocalizedName() { @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) // TODO why this is HERE? - { + { Icons.milkStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.milk"); Icons.melonJuiceStill = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.melonJuiceStill"); Icons.melonJuiceFlowing = iconRegister.registerIcon(ModInfo.MOD_ID + ":fluid.melonJuiceFlowing"); @@ -183,12 +187,12 @@ public void registerBlockIcons(IIconRegister iconRegister) // TODO why this is H public int getLightValue(IBlockAccess world, int x, int y, int z) { if (getAssociatedTileBackpackType(world, x, y, z) == GLOWSTONE) { return 15; - } else if (world.getTileEntity(x, y, z) != null - && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { - return ((TileAdventureBackpack) world.getTileEntity(x, y, z)).getLuminosity(); - } else { - return 0; - } + } else + if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { + return ((TileAdventureBackpack) world.getTileEntity(x, y, z)).getLuminosity(); + } else { + return 0; + } } @Override @@ -202,8 +206,8 @@ public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int s } @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, + float hitY, float hitZ) { if (!world.isRemote && GeneralReference.isDimensionAllowed(player)) { FMLNetworkHandler.openGui(player, AdventureBackpack.instance, GuiHandler.BACKPACK_TILE, world, x, y, z); return true; @@ -304,12 +308,7 @@ public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, } @Override - public boolean canReplace( - World p_149705_1_, - int p_149705_2_, - int p_149705_3_, - int p_149705_4_, - int p_149705_5_, + public boolean canReplace(World p_149705_1_, int p_149705_2_, int p_149705_3_, int p_149705_4_, int p_149705_5_, ItemStack p_149705_6_) { return false; } @@ -319,8 +318,7 @@ public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, i TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileAdventureBackpack && !world.isRemote && player != null) { - if ((player.isSneaking()) - ? ((TileAdventureBackpack) tile).equip(world, player, x, y, z) + if ((player.isSneaking()) ? ((TileAdventureBackpack) tile).equip(world, player, x, y, z) : ((TileAdventureBackpack) tile).drop(world, player, x, y, z)) { return world.func_147480_a(x, y, z, false); } diff --git a/src/main/java/com/darkona/adventurebackpack/block/BlockCampFire.java b/src/main/java/com/darkona/adventurebackpack/block/BlockCampFire.java index ecc04254..f2fa0ada 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/BlockCampFire.java +++ b/src/main/java/com/darkona/adventurebackpack/block/BlockCampFire.java @@ -1,11 +1,7 @@ package com.darkona.adventurebackpack.block; -import com.darkona.adventurebackpack.CreativeTabAB; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.CoordsUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Random; + import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -17,12 +13,20 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import com.darkona.adventurebackpack.CreativeTabAB; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.CoordsUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 05/01/2015 * * @author Darkona */ public class BlockCampFire extends BlockContainer { + private IIcon icon; public BlockCampFire() { @@ -131,8 +135,8 @@ public boolean isBed(IBlockAccess world, int x, int y, int z, EntityLivingBase p @Override public ChunkCoordinates getBedSpawnPosition(IBlockAccess world, int x, int y, int z, EntityPlayer player) { for (int i = y - 5; i <= y + 5; i++) { - ChunkCoordinates spawn = - CoordsUtils.getNearestEmptyChunkCoordinatesSpiral(world, x, z, x, i, z, 8, true, 1, (byte) 0, true); + ChunkCoordinates spawn = CoordsUtils + .getNearestEmptyChunkCoordinatesSpiral(world, x, z, x, i, z, 8, true, 1, (byte) 0, true); if (spawn != null) { return spawn; diff --git a/src/main/java/com/darkona/adventurebackpack/block/BlockSleepingBag.java b/src/main/java/com/darkona/adventurebackpack/block/BlockSleepingBag.java index 9dba1979..ec485ee2 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/BlockSleepingBag.java +++ b/src/main/java/com/darkona/adventurebackpack/block/BlockSleepingBag.java @@ -1,17 +1,8 @@ package com.darkona.adventurebackpack.block; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.init.ModBlocks; -import com.darkona.adventurebackpack.inventory.InventoryBackpack; -import com.darkona.adventurebackpack.playerProperties.BackpackProperty; -import com.darkona.adventurebackpack.util.CoordsUtils; -import com.darkona.adventurebackpack.util.LogHelper; -import com.darkona.adventurebackpack.util.Resources; -import com.darkona.adventurebackpack.util.Wearing; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Iterator; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.material.Material; @@ -31,13 +22,26 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.init.ModBlocks; +import com.darkona.adventurebackpack.inventory.InventoryBackpack; +import com.darkona.adventurebackpack.playerProperties.BackpackProperty; +import com.darkona.adventurebackpack.util.CoordsUtils; +import com.darkona.adventurebackpack.util.LogHelper; +import com.darkona.adventurebackpack.util.Resources; +import com.darkona.adventurebackpack.util.Wearing; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 14/10/2014 * * @author Darkona */ public class BlockSleepingBag extends BlockDirectional { - private static final int[][] footBlockToHeadBlockMap = new int[][] {{0, 1}, {-1, 0}, {0, -1}, {1, 0}}; + + private static final int[][] footBlockToHeadBlockMap = new int[][] { { 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 } }; private static final String TAG_STORED_SPAWN = "storedSpawn"; private static final String TAG_SPAWN_POS_X = "posX"; @@ -62,8 +66,7 @@ public BlockSleepingBag() { @Override @SideOnly(Side.CLIENT) protected String getTextureName() { - return this.textureName == null - ? "MISSING_ICON_BLOCK_" + getIdFromBlock(this) + "_" + getUnlocalizedName() + return this.textureName == null ? "MISSING_ICON_BLOCK_" + getIdFromBlock(this) + "_" + getUnlocalizedName() : this.textureName; } @@ -104,8 +107,12 @@ public static void storeOriginalSpawn(EntityPlayer player, NBTTagCompound tag) { storedSpawn.setInteger(TAG_SPAWN_POS_Y, spawn.posY); storedSpawn.setInteger(TAG_SPAWN_POS_Z, spawn.posZ); tag.setTag(TAG_STORED_SPAWN, storedSpawn); - LogHelper.info("Stored spawn data for " + player.getDisplayName() + ": " + spawn.toString() + " dimID: " - + player.worldObj.provider.dimensionId); + LogHelper.info( + "Stored spawn data for " + player.getDisplayName() + + ": " + + spawn.toString() + + " dimID: " + + player.worldObj.provider.dimensionId); } else { LogHelper.warn("Cannot store spawn data for " + player.getDisplayName()); } @@ -120,8 +127,12 @@ public static void restoreOriginalSpawn(EntityPlayer player, NBTTagCompound tag) storedSpawn.getInteger(TAG_SPAWN_POS_Z)); player.setSpawnChunk(coords, false, player.worldObj.provider.dimensionId); tag.removeTag(TAG_STORED_SPAWN); - LogHelper.info("Restored spawn data for " + player.getDisplayName() + ": " + coords.toString() + " dimID: " - + player.worldObj.provider.dimensionId); + LogHelper.info( + "Restored spawn data for " + player.getDisplayName() + + ": " + + coords.toString() + + " dimID: " + + player.worldObj.provider.dimensionId); } else { LogHelper.warn("No spawn data to restore for " + player.getDisplayName()); } @@ -135,8 +146,8 @@ public void onPortableBlockActivated(World world, EntityPlayer player, int cX, i } @Override - public boolean onBlockActivated( - World world, int x, int y, int z, EntityPlayer player, int id, float f1, float f2, float f3) { + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int id, float f1, float f2, + float f3) { if (world.isRemote) { return true; } else { @@ -165,8 +176,7 @@ public boolean onBlockActivated( if (entityplayer2.isPlayerSleeping()) { ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation; - if (chunkcoordinates.posX == x - && chunkcoordinates.posY == y + if (chunkcoordinates.posX == x && chunkcoordinates.posY == y && chunkcoordinates.posZ == z) { entityplayer1 = entityplayer2; } @@ -190,14 +200,13 @@ public boolean onBlockActivated( // and the bed location isn't set until then, normally. if (isSleepingInPortableBag(player)) { - storeOriginalSpawn( - player, Wearing.getWearingBackpackInv(player).getExtendedProperties()); + storeOriginalSpawn(player, Wearing.getWearingBackpackInv(player).getExtendedProperties()); player.setSpawnChunk(new ChunkCoordinates(x, y, z), true, player.dimension); } else { player.setSpawnChunk(new ChunkCoordinates(x, y, z), true, player.dimension); LogHelper.info("Looking for a campfire nearby..."); - ChunkCoordinates campfire = - CoordsUtils.findBlock3D(world, x, y, z, ModBlocks.blockCampFire, 8, 2); + ChunkCoordinates campfire = CoordsUtils + .findBlock3D(world, x, y, z, ModBlocks.blockCampFire, 8, 2); if (campfire != null) { LogHelper.info("Campfire Found, saving coordinates. " + campfire.toString()); BackpackProperty.get(player).setCampFire(campfire); @@ -268,14 +277,14 @@ public void onNeighborBlockChange(World world, int x, int y, int z, Block block) if (world.getBlock(x - footBlockToHeadBlockMap[dir][0], y, z - footBlockToHeadBlockMap[dir][1]) != this) { world.setBlockToAir(x, y, z); } - } else if (world.getBlock(x + footBlockToHeadBlockMap[dir][0], y, z + footBlockToHeadBlockMap[dir][1]) - != this) { - world.setBlockToAir(x, y, z); + } else + if (world.getBlock(x + footBlockToHeadBlockMap[dir][0], y, z + footBlockToHeadBlockMap[dir][1]) != this) { + world.setBlockToAir(x, y, z); - if (!world.isRemote) { - this.dropBlockAsItem(world, x, y, z, meta, 0); + if (!world.isRemote) { + this.dropBlockAsItem(world, x, y, z, meta, 0); + } } - } } @Override @@ -365,25 +374,16 @@ public IIcon getIcon(int side, int meta) { @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.topIcons = new IIcon[] { - iconRegister.registerIcon( - Resources.blockTextures("sleepingBag_feet_top").toString()), - iconRegister.registerIcon( - Resources.blockTextures("sleepingBag_head_top").toString()) - }; + iconRegister.registerIcon(Resources.blockTextures("sleepingBag_feet_top").toString()), + iconRegister.registerIcon(Resources.blockTextures("sleepingBag_head_top").toString()) }; this.endIcons = new IIcon[] { - iconRegister.registerIcon( - Resources.blockTextures("sleepingBag_feet_end").toString()), - iconRegister.registerIcon( - Resources.blockTextures("sleepingBag_head_end").toString()) - }; + iconRegister.registerIcon(Resources.blockTextures("sleepingBag_feet_end").toString()), + iconRegister.registerIcon(Resources.blockTextures("sleepingBag_head_end").toString()) }; this.sideIcons = new IIcon[] { - iconRegister.registerIcon( - Resources.blockTextures("sleepingBag_feet_side").toString()), - iconRegister.registerIcon( - Resources.blockTextures("sleepingBag_head_side").toString()) - }; + iconRegister.registerIcon(Resources.blockTextures("sleepingBag_feet_side").toString()), + iconRegister.registerIcon(Resources.blockTextures("sleepingBag_head_side").toString()) }; } @Override diff --git a/src/main/java/com/darkona/adventurebackpack/block/TileAdventure.java b/src/main/java/com/darkona/adventurebackpack/block/TileAdventure.java index 2073dc65..2d5e0437 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/TileAdventure.java +++ b/src/main/java/com/darkona/adventurebackpack/block/TileAdventure.java @@ -2,14 +2,16 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_SLOT; -import com.darkona.adventurebackpack.inventory.IInventoryTanks; import javax.annotation.Nullable; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import com.darkona.adventurebackpack.inventory.IInventoryTanks; + /** * Created on 26.02.2018 * diff --git a/src/main/java/com/darkona/adventurebackpack/block/TileAdventureBackpack.java b/src/main/java/com/darkona/adventurebackpack/block/TileAdventureBackpack.java index a8d72f75..8f9c23b5 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/TileAdventureBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/block/TileAdventureBackpack.java @@ -15,20 +15,6 @@ import static com.darkona.adventurebackpack.common.Constants.TOOL_LOWER; import static com.darkona.adventurebackpack.common.Constants.TOOL_UPPER; -import com.darkona.adventurebackpack.common.BackpackAbilities; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.init.ModBlocks; -import com.darkona.adventurebackpack.inventory.IInventoryBackpack; -import com.darkona.adventurebackpack.inventory.InventoryActions; -import com.darkona.adventurebackpack.inventory.SlotBackpack; -import com.darkona.adventurebackpack.inventory.SlotTool; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.reference.GeneralReference; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.CoordsUtils; -import com.darkona.adventurebackpack.util.Utils; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; @@ -45,10 +31,26 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.BackpackAbilities; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.init.ModBlocks; +import com.darkona.adventurebackpack.inventory.IInventoryBackpack; +import com.darkona.adventurebackpack.inventory.InventoryActions; +import com.darkona.adventurebackpack.inventory.SlotBackpack; +import com.darkona.adventurebackpack.inventory.SlotTool; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.reference.GeneralReference; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.CoordsUtils; +import com.darkona.adventurebackpack.util.Utils; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created by Darkona on 12/10/2014. */ public class TileAdventureBackpack extends TileAdventure implements IInventoryBackpack, ISidedInventory { + private static final int[] MAIN_INVENTORY_SLOTS = Utils.createSlotArray(0, Constants.INVENTORY_MAIN_SIZE); private BackpackTypes type = BackpackTypes.STANDARD; @@ -96,12 +98,12 @@ public FluidTank getRightTank() { @Override public FluidTank[] getTanksArray() { - return new FluidTank[] {leftTank, rightTank}; + return new FluidTank[] { leftTank, rightTank }; } @Override public int[] getSlotsOnClosing() { - return new int[] {BUCKET_IN_LEFT, BUCKET_IN_RIGHT, BUCKET_OUT_LEFT, BUCKET_OUT_RIGHT}; + return new int[] { BUCKET_IN_LEFT, BUCKET_IN_RIGHT, BUCKET_OUT_LEFT, BUCKET_OUT_RIGHT }; } @Override @@ -218,10 +220,9 @@ public boolean equip(World world, EntityPlayer player, int x, int y, int z) { if (BackpackUtils.equipWearable(stacky, player) != BackpackUtils.Reasons.SUCCESSFUL) { Wearing.WearableType wtype = Wearing.getWearingWearableType(player); - if (wtype != Wearing.WearableType.UNKNOWN) - player.addChatComponentMessage( - new ChatComponentTranslation("adventurebackpack:messages.already.equipped." - + wtype.name().toLowerCase())); + if (wtype != Wearing.WearableType.UNKNOWN) player.addChatComponentMessage( + new ChatComponentTranslation( + "adventurebackpack:messages.already.equipped." + wtype.name().toLowerCase())); if (!player.inventory.addItemStackToInventory(stacky)) return drop(world, player, x, y, z); } @@ -313,8 +314,8 @@ public boolean canExtractItem(int slot, ItemStack item, int side) { } /** - * Send sync packet. This is necessary for the TileEntity to load the nbt as soon as it is loaded - * and be rendered properly when the custom renderer reads it + * Send sync packet. This is necessary for the TileEntity to load the nbt as soon as it is loaded and be rendered + * properly when the custom renderer reads it */ @Override public Packet getDescriptionPacket() { @@ -324,8 +325,8 @@ public Packet getDescriptionPacket() { } /** - * Receive sync packet. This is necessary for the TileEntity to load the nbt as soon as it is loaded - * and be rendered properly when the custom renderer reads it + * Receive sync packet. This is necessary for the TileEntity to load the nbt as soon as it is loaded and be rendered + * properly when the custom renderer reads it */ @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { @@ -344,12 +345,8 @@ public void updateEntity() { // Check for backpack luminosity and a deployed sleeping bag, just in case because i'm super paranoid. if (checkTime == 0) { int lastLumen = luminosity; - int left = (leftTank.getFluid() != null) - ? leftTank.getFluid().getFluid().getLuminosity() - : 0; - int right = (rightTank.getFluid() != null) - ? rightTank.getFluid().getFluid().getLuminosity() - : 0; + int left = (leftTank.getFluid() != null) ? leftTank.getFluid().getFluid().getLuminosity() : 0; + int right = (rightTank.getFluid() != null) ? rightTank.getFluid().getFluid().getLuminosity() : 0; luminosity = Math.max(left, right); if (luminosity != lastLumen) { int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); @@ -371,7 +368,7 @@ public int getLuminosity() { } private void convertFromOldNBTFormat(NBTTagCompound compound) // backwards compatibility - { + { NBTTagCompound oldBackpackTag = compound.getCompoundTag("backpackData"); NBTTagList oldItems = oldBackpackTag.getTagList("ABPItems", NBT.TAG_COMPOUND); leftTank.readFromNBT(oldBackpackTag.getCompoundTag("leftTank")); diff --git a/src/main/java/com/darkona/adventurebackpack/block/TileCampfire.java b/src/main/java/com/darkona/adventurebackpack/block/TileCampfire.java index 71a4ab54..35f04ece 100644 --- a/src/main/java/com/darkona/adventurebackpack/block/TileCampfire.java +++ b/src/main/java/com/darkona/adventurebackpack/block/TileCampfire.java @@ -9,6 +9,7 @@ * @author Darkona */ public class TileCampfire extends TileEntity { + private int burnTicks; private ItemStack[] foodCooking = new ItemStack[4]; diff --git a/src/main/java/com/darkona/adventurebackpack/client/ClientActions.java b/src/main/java/com/darkona/adventurebackpack/client/ClientActions.java index d6197591..358bee3e 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/ClientActions.java +++ b/src/main/java/com/darkona/adventurebackpack/client/ClientActions.java @@ -1,5 +1,9 @@ package com.darkona.adventurebackpack.client; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; + import com.darkona.adventurebackpack.client.audio.BoilingBoilerSound; import com.darkona.adventurebackpack.client.audio.CopterPackSound; import com.darkona.adventurebackpack.client.audio.JetpackSoundOn; @@ -8,12 +12,10 @@ import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; import com.darkona.adventurebackpack.network.messages.EntitySoundPacket; + import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.audio.SoundHandler; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; /** * Created on 11/10/2014 @@ -24,6 +26,7 @@ * @see com.darkona.adventurebackpack.common.BackpackAbilities */ public class ClientActions { + @SideOnly(Side.CLIENT) public static void showParticlesAtEntity(Entity entity, byte particleCode) { if (entity instanceof EntityPlayer) { diff --git a/src/main/java/com/darkona/adventurebackpack/client/Icons.java b/src/main/java/com/darkona/adventurebackpack/client/Icons.java index 94bfd51a..fa631e90 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/Icons.java +++ b/src/main/java/com/darkona/adventurebackpack/client/Icons.java @@ -8,6 +8,7 @@ * @author Darkona */ public class Icons { + public static IIcon milkFlowing; public static IIcon milkStill; diff --git a/src/main/java/com/darkona/adventurebackpack/client/Visuals.java b/src/main/java/com/darkona/adventurebackpack/client/Visuals.java index c25acf36..233b21f2 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/Visuals.java +++ b/src/main/java/com/darkona/adventurebackpack/client/Visuals.java @@ -1,6 +1,5 @@ package com.darkona.adventurebackpack.client; -import com.darkona.adventurebackpack.entity.fx.SteamFX; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFX; import net.minecraft.entity.player.EntityPlayer; @@ -8,12 +7,15 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; +import com.darkona.adventurebackpack.entity.fx.SteamFX; + /** * Created on 17/10/2014 * * @author Darkona */ public class Visuals { + public static void NyanParticles(EntityPlayer player, World world) { int i = 2; for (int j = 0; j < i * 3; ++j) { @@ -40,7 +42,13 @@ public static void SlimeParticles(EntityPlayer player, World world) { float f2 = MathHelper.sin(f) * i * 0.5F * f1; float f3 = MathHelper.cos(f) * i * 0.5F * f1; world.spawnParticle( - "slime", player.posX + f2, player.boundingBox.minY, player.posZ + f3, 0.0D, 0.0625D, 0.0D); + "slime", + player.posX + f2, + player.boundingBox.minY, + player.posZ + f3, + 0.0D, + 0.0625D, + 0.0D); } } @@ -83,8 +91,8 @@ public static void JetpackParticles(EntityPlayer player, World world) { private static Minecraft mc = Minecraft.getMinecraft(); private static World theWorld = mc.theWorld; - public static EntityFX spawnParticle( - String particleName, double x, double y, double z, double motionX, double motionY, double motionZ) { + public static EntityFX spawnParticle(String particleName, double x, double y, double z, double motionX, + double motionY, double motionZ) { if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) { int particleSetting = mc.gameSettings.particleSetting; diff --git a/src/main/java/com/darkona/adventurebackpack/client/audio/BoilingBoilerSound.java b/src/main/java/com/darkona/adventurebackpack/client/audio/BoilingBoilerSound.java index f5a4dd9a..4b131b5c 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/audio/BoilingBoilerSound.java +++ b/src/main/java/com/darkona/adventurebackpack/client/audio/BoilingBoilerSound.java @@ -1,18 +1,20 @@ package com.darkona.adventurebackpack.client.audio; -import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.client.audio.MovingSound; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 16/01/2015 * * @author Darkona */ public class BoilingBoilerSound extends MovingSound { + private EntityPlayer thePlayer; private boolean repeat = true; private int repeatDelay = 0; @@ -38,8 +40,7 @@ public boolean isDonePlaying() { @Override public void update() { - if (thePlayer == null - || thePlayer.isDead + if (thePlayer == null || thePlayer.isDead || thePlayer.worldObj == null || !Wearing.isWearingJetpack(thePlayer)) { setDonePlaying(); diff --git a/src/main/java/com/darkona/adventurebackpack/client/audio/CopterPackSound.java b/src/main/java/com/darkona/adventurebackpack/client/audio/CopterPackSound.java index 4b91d3b8..bf2794f7 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/audio/CopterPackSound.java +++ b/src/main/java/com/darkona/adventurebackpack/client/audio/CopterPackSound.java @@ -2,15 +2,16 @@ import static com.darkona.adventurebackpack.common.Constants.Copter.TAG_STATUS; +import net.minecraft.client.audio.MovingSound; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + import com.darkona.adventurebackpack.item.ItemCopterPack; import com.darkona.adventurebackpack.reference.ModInfo; import com.darkona.adventurebackpack.util.BackpackUtils; import com.darkona.adventurebackpack.util.LogHelper; import com.darkona.adventurebackpack.util.Wearing; -import net.minecraft.client.audio.MovingSound; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ResourceLocation; /** * Created on 16/10/2014 @@ -18,6 +19,7 @@ * @author Darkona */ public class CopterPackSound extends MovingSound { + private EntityPlayer thePlayer; private boolean repeat = true; private int repeatDelay = 0; @@ -50,8 +52,7 @@ public boolean isDonePlaying() { public void update() { ItemStack copter = Wearing.getWearingCopter(thePlayer); byte status = 0; - if (thePlayer == null - || thePlayer.isDead + if (thePlayer == null || thePlayer.isDead || thePlayer.worldObj == null || copter == null || !(copter.getItem() instanceof ItemCopterPack)) { diff --git a/src/main/java/com/darkona/adventurebackpack/client/audio/JetpackSoundOn.java b/src/main/java/com/darkona/adventurebackpack/client/audio/JetpackSoundOn.java index 8f953442..622fbaf9 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/audio/JetpackSoundOn.java +++ b/src/main/java/com/darkona/adventurebackpack/client/audio/JetpackSoundOn.java @@ -1,18 +1,20 @@ package com.darkona.adventurebackpack.client.audio; -import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.client.audio.MovingSound; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 16/01/2015 * * @author Darkona */ public class JetpackSoundOn extends MovingSound { + private EntityPlayer thePlayer; private boolean repeat = true; private int repeatDelay = 0; @@ -38,8 +40,7 @@ public boolean isDonePlaying() { @Override public void update() { - if (thePlayer == null - || thePlayer.isDead + if (thePlayer == null || thePlayer.isDead || thePlayer.worldObj == null || !Wearing.isWearingJetpack(thePlayer)) { setDonePlaying(); diff --git a/src/main/java/com/darkona/adventurebackpack/client/audio/LeakingBoilerSound.java b/src/main/java/com/darkona/adventurebackpack/client/audio/LeakingBoilerSound.java index a9cdc2e0..e17c80ad 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/audio/LeakingBoilerSound.java +++ b/src/main/java/com/darkona/adventurebackpack/client/audio/LeakingBoilerSound.java @@ -1,18 +1,20 @@ package com.darkona.adventurebackpack.client.audio; -import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.client.audio.MovingSound; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 16/01/2015 * * @author Darkona */ public class LeakingBoilerSound extends MovingSound { + private EntityPlayer thePlayer; private boolean repeat = true; private int repeatDelay = 0; @@ -38,8 +40,7 @@ public boolean isDonePlaying() { @Override public void update() { - if (thePlayer == null - || thePlayer.isDead + if (thePlayer == null || thePlayer.isDead || thePlayer.worldObj == null || !Wearing.isWearingJetpack(thePlayer)) { setDonePlaying(); diff --git a/src/main/java/com/darkona/adventurebackpack/client/audio/NyanMovingSound.java b/src/main/java/com/darkona/adventurebackpack/client/audio/NyanMovingSound.java index 7df654be..a3e9d30c 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/audio/NyanMovingSound.java +++ b/src/main/java/com/darkona/adventurebackpack/client/audio/NyanMovingSound.java @@ -1,18 +1,20 @@ package com.darkona.adventurebackpack.client.audio; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.client.audio.MovingSound; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 16/10/2014 * * @author Darkona */ public class NyanMovingSound extends MovingSound { + public static NyanMovingSound instance = new NyanMovingSound(); private EntityPlayer player; diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java index 4b2bd38d..57cc72a1 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiAdvBackpack.java @@ -1,7 +1,21 @@ package com.darkona.adventurebackpack.client.gui; +import java.util.List; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidTank; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerTooltipHandler; + import com.darkona.adventurebackpack.block.TileAdventureBackpack; import com.darkona.adventurebackpack.common.Constants; import com.darkona.adventurebackpack.common.Constants.Source; @@ -15,18 +29,9 @@ import com.darkona.adventurebackpack.reference.LoadedMods; import com.darkona.adventurebackpack.util.Resources; import com.darkona.adventurebackpack.util.TinkersUtils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.List; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidTank; -import org.lwjgl.input.Keyboard; -import org.lwjgl.opengl.GL11; /** * Created on 12/10/2014 @@ -35,6 +40,7 @@ */ @SideOnly(Side.CLIENT) public class GuiAdvBackpack extends GuiWithTanks { + private static final ResourceLocation TEXTURE = Resources.guiTextures("guiBackpackNew"); private static final int TINKERS_SLOT = 38; // ContainerBackpack.CRAFT_MATRIX_EMULATION[4] @@ -125,8 +131,8 @@ protected void mouseClicked(int mouseX, int mouseY, int button) { if (isBedButtonCase() && bedButton.inButton(this, mouseX, mouseY)) { if (source == Source.TILE) { TileAdventureBackpack te = (TileAdventureBackpack) inventory; - ModNetwork.net.sendToServer( - new SleepingBagPacket.SleepingBagMessage(true, te.xCoord, te.yCoord, te.zCoord)); + ModNetwork.net + .sendToServer(new SleepingBagPacket.SleepingBagMessage(true, te.xCoord, te.yCoord, te.zCoord)); } else { int posX = MathHelper.floor_double(player.posX); int posY = MathHelper.floor_double(player.posY) - 1; @@ -151,8 +157,8 @@ public void updateScreen() { } else { if (!Keyboard.isKeyDown(Keyboard.KEY_SPACE)) { isHoldingSpace = false; - ModNetwork.net.sendToServer( - new PlayerActionPacket.ActionMessage(PlayerActionPacket.GUI_NOT_HOLDING_SPACE)); + ModNetwork.net + .sendToServer(new PlayerActionPacket.ActionMessage(PlayerActionPacket.GUI_NOT_HOLDING_SPACE)); inventory.getExtendedProperties().removeTag(Constants.TAG_HOLDING_SPACE); } } @@ -191,8 +197,8 @@ public List handleItemDisplayName(GuiContainer gui, ItemStack itemstack, * Required by IContainerTooltipHandler implementation but not needed here */ @Override - public List handleItemTooltip( - GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List currenttip) { + public List handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, + List currenttip) { return currenttip; } } diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCoalJetpack.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCoalJetpack.java index c887869a..f70e104e 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCoalJetpack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCoalJetpack.java @@ -1,24 +1,27 @@ package com.darkona.adventurebackpack.client.gui; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.common.Constants.Source; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.inventory.ContainerJetpack; -import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidTank; + import org.apache.commons.lang3.text.WordUtils; import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.common.Constants.Source; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.inventory.ContainerJetpack; +import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; +import com.darkona.adventurebackpack.util.Resources; + /** * Created on 15/01/2015 * * @author Darkona */ public class GuiCoalJetpack extends GuiWithTanks { + private static final ResourceLocation TEXTURE = Resources.guiTextures("guiCoalJetpack"); private static GuiImageButtonNormal equipButton = new GuiImageButtonNormal(150, 64, 18, 18); @@ -83,8 +86,8 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.drawTexturedModalRect(78, 48 + 12 - i1, 176, 12 - i1, 14, i1 + 1); } - int H = Math.round( - ((float) 72 / (float) Constants.Jetpack.MAX_TEMPERATURE) * (float) inventory.getTemperature()); + int H = Math + .round(((float) 72 / (float) Constants.Jetpack.MAX_TEMPERATURE) * (float) inventory.getTemperature()); drawTexturedModalRect(139, 8 + (72 - H), 40, 167 + (72 - H), 5, H); GL11.glDisable(GL11.GL_BLEND); @@ -96,10 +99,8 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { float factor = 0.7f; - String show = ((water.getFluidAmount() > 0) - ? WordUtils.capitalize(FluidRegistry.getFluidName(water.getFluid())) - : "None") - + "-" + water.getFluidAmount(); + String show = ((water.getFluidAmount() > 0) ? WordUtils.capitalize(FluidRegistry.getFluidName(water.getFluid())) + : "None") + "-" + water.getFluidAmount(); GL11.glPushMatrix(); GL11.glTranslatef(70, 10, 0); @@ -108,10 +109,8 @@ protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { GL11.glScalef(1, 1, 1); GL11.glPopMatrix(); - show = ((steam.getFluidAmount() > 0) - ? WordUtils.capitalize(FluidRegistry.getFluidName(steam.getFluid())) - : "None") - + "-" + steam.getFluidAmount(); + show = ((steam.getFluidAmount() > 0) ? WordUtils.capitalize(FluidRegistry.getFluidName(steam.getFluid())) + : "None") + "-" + steam.getFluidAmount(); GL11.glPushMatrix(); GL11.glTranslatef(70, 20, 0); diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCopterPack.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCopterPack.java index 4d6eaf69..15fd3660 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCopterPack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiCopterPack.java @@ -1,16 +1,18 @@ package com.darkona.adventurebackpack.client.gui; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidTank; + +import org.apache.commons.lang3.text.WordUtils; +import org.lwjgl.opengl.GL11; + import com.darkona.adventurebackpack.common.Constants.Source; import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.inventory.ContainerCopter; import com.darkona.adventurebackpack.inventory.InventoryCopterPack; import com.darkona.adventurebackpack.reference.GeneralReference; import com.darkona.adventurebackpack.util.Resources; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fluids.FluidTank; -import org.apache.commons.lang3.text.WordUtils; -import org.lwjgl.opengl.GL11; /** * Created on 03/01/2015 @@ -18,6 +20,7 @@ * @author Darkona */ public class GuiCopterPack extends GuiWithTanks { + private static final ResourceLocation TEXTURE = Resources.guiTextures("guiCopterPack"); private static GuiImageButtonNormal equipButton = new GuiImageButtonNormal(150, 64, 18, 18); diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiFactory.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiFactory.java index a0c14f02..a1472742 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiFactory.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiFactory.java @@ -1,16 +1,19 @@ package com.darkona.adventurebackpack.client.gui; -import cpw.mods.fml.client.IModGuiFactory; import java.util.Set; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; +import cpw.mods.fml.client.IModGuiFactory; + /** * Created on 10/10/2014 * * @author Darkona */ public class GuiFactory implements IModGuiFactory { + @Override public void initialize(Minecraft minecraftInstance) {} diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiImageButtonNormal.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiImageButtonNormal.java index abc16073..5966c623 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiImageButtonNormal.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiImageButtonNormal.java @@ -6,6 +6,7 @@ * @author Darkona */ public class GuiImageButtonNormal { + private int X; private int Y; private int W; diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiOverlay.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiOverlay.java index 32c7afc4..19d73cff 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiOverlay.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiOverlay.java @@ -1,18 +1,8 @@ package com.darkona.adventurebackpack.client.gui; -import codechicken.lib.render.TextureUtils; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.inventory.IInventoryTanks; -import com.darkona.adventurebackpack.item.ItemHose; -import com.darkona.adventurebackpack.reference.LoadedMods; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.reference.ToolHandler; -import com.darkona.adventurebackpack.util.*; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.Collection; import java.util.Iterator; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; @@ -31,18 +21,35 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; + import org.lwjgl.opengl.GL11; +import codechicken.lib.render.TextureUtils; + +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.inventory.IInventoryTanks; +import com.darkona.adventurebackpack.item.ItemHose; +import com.darkona.adventurebackpack.reference.LoadedMods; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.reference.ToolHandler; +import com.darkona.adventurebackpack.util.*; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + /** * Created on 09/01/2015 * * @author Darkona */ public class GuiOverlay extends Gui { + private static final ResourceLocation GUI_ICONS = new ResourceLocation("textures/gui/icons.png"); private static final ResourceLocation GUI_INVENTORY = new ResourceLocation("textures/gui/container/inventory.png"); - private static final ResourceLocation TANKS_OVERLAY = - new ResourceLocation(ModInfo.MOD_ID, "textures/gui/overlay.png"); + private static final ResourceLocation TANKS_OVERLAY = new ResourceLocation( + ModInfo.MOD_ID, + "textures/gui/overlay.png"); private static final int BUFF_ICON_SIZE = 18; private static final int BUFF_ICON_SPACING = 2; // 2 pixels between buff icons private static final int BUFF_ICON_BASE_U_OFFSET = 0; @@ -84,18 +91,14 @@ public void onRenderExperienceBar(RenderGameOverlayEvent.Post event) { } if (ConfigHandler.statusOverlay) { - int xStep = ConfigHandler.statusOverlayLeft - ? BUFF_ICON_SIZE + BUFF_ICON_SPACING + int xStep = ConfigHandler.statusOverlayLeft ? BUFF_ICON_SIZE + BUFF_ICON_SPACING : -BUFF_ICON_SIZE - BUFF_ICON_SPACING; - int xPos = ConfigHandler.statusOverlayLeft - ? ConfigHandler.statusOverlayIndentH + int xPos = ConfigHandler.statusOverlayLeft ? ConfigHandler.statusOverlayIndentH : screenWidth - BUFF_ICON_SIZE - ConfigHandler.statusOverlayIndentH; - int yPos = ConfigHandler.statusOverlayTop - ? ConfigHandler.statusOverlayIndentV + int yPos = ConfigHandler.statusOverlayTop ? ConfigHandler.statusOverlayIndentV : screenHeight - BUFF_ICON_SIZE - ConfigHandler.statusOverlayIndentV; - if (LoadedMods.THAUMCRAFT - && ConfigHandler.statusOverlayThaumcraft + if (LoadedMods.THAUMCRAFT && ConfigHandler.statusOverlayThaumcraft && ConfigHandler.statusOverlayLeft && ConfigHandler.statusOverlayTop == !ThaumcraftUtils.DIAL_BOTTOM && ThaumcraftUtils.isTool(player.inventory.getCurrentItem())) { @@ -160,10 +163,10 @@ public void onRenderExperienceBar(RenderGameOverlayEvent.Post event) { tankX += textureWidth; } if (Wearing.isWearingBackpack(player)) { - int[] u = {10, 10}; - int[] v = {0, 0}; - int[] xStart = {xPos, xPos + textureWidth + 1}; - int[] yStart = {yPos, yPos}; + int[] u = { 10, 10 }; + int[] v = { 0, 0 }; + int[] xStart = { xPos, xPos + textureWidth + 1 }; + int[] yStart = { yPos, yPos }; short tank = -1; if (Wearing.isHoldingHose(player)) { tank = (short) (ItemHose.getHoseTank(player.getHeldItem())); @@ -276,8 +279,8 @@ private void drawBossBar() { this.drawTexturedModalRect(posX, posY, 0, 74, barWidth, 5); if (bossHealthWidth > 0) this.drawTexturedModalRect(posX, posY, 0, 79, bossHealthWidth, 5); String s = BossStatus.bossName; - fontRenderer.drawStringWithShadow( - s, screenWidth / 2 - fontRenderer.getStringWidth(s) / 2, posY - 10, 16777215); + fontRenderer + .drawStringWithShadow(s, screenWidth / 2 - fontRenderer.getStringWidth(s) / 2, posY - 10, 16777215); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); } diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java index 06050db9..d616c20c 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiTank.java @@ -1,24 +1,29 @@ package com.darkona.adventurebackpack.client.gui; -import codechicken.lib.render.TextureUtils; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.util.LogHelper; -import com.darkona.adventurebackpack.util.TipUtils; import java.util.ArrayList; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; + import org.lwjgl.opengl.GL11; +import codechicken.lib.render.TextureUtils; + +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.util.LogHelper; +import com.darkona.adventurebackpack.util.TipUtils; + /** * Created by Darkona on 12/10/2014. */ public class GuiTank { + private int height; private int width; private int startX; @@ -37,10 +42,9 @@ public class GuiTank { * @param Y The startY coordinate to start drawing from. * @param H The height in pixels of the tank. * @param W The width in pixels of the tank. - * @param resolution The resolution of the fluid painted in the tank. Higher values - * mean smaller and more numerous boxes. Values can be 1, 2, 4, - * 8, 16. Other values are untested, but i guess they should - * always be integer divisors of the width, with modulus 0; + * @param resolution The resolution of the fluid painted in the tank. Higher values mean smaller and more numerous + * boxes. Values can be 1, 2, 4, 8, 16. Other values are untested, but i guess they should always + * be integer divisors of the width, with modulus 0; */ public GuiTank(int X, int Y, int H, int W, int resolution) { this.startX = X; @@ -157,8 +161,7 @@ private void drawMethodThree() { public boolean inTank(GuiWithTanks gui, int mouseX, int mouseY) { mouseX -= gui.getLeft(); mouseY -= gui.getTop(); - return startX <= mouseX - && mouseX <= (startX + offsetX) + width + return startX <= mouseX && mouseX <= (startX + offsetX) + width && (startY + offsetY) <= mouseY && mouseY <= (startY + offsetY) + height; } @@ -176,8 +179,8 @@ public boolean inTank(GuiWithTanks gui, int mouseX, int mouseY) { * @param srcW The width of the selection in the icon to draw from. Starts at 0. * @param srcH The height of the selection in the icon to draw from. Starts at 0. */ - public static void drawFluidPixelFromIcon( - int x, int y, IIcon icon, int w, int h, int srcX, int srcY, int srcW, int srcH, float zLevel) { + public static void drawFluidPixelFromIcon(int x, int y, IIcon icon, int w, int h, int srcX, int srcY, int srcW, + int srcH, float zLevel) { double minU = icon.getMinU(); double maxU = icon.getMaxU(); double minV = icon.getMinV(); diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiWithTanks.java b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiWithTanks.java index f7c21dd3..93423c21 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/GuiWithTanks.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/GuiWithTanks.java @@ -1,20 +1,23 @@ package com.darkona.adventurebackpack.client.gui; -import com.darkona.adventurebackpack.common.Constants.Source; -import com.darkona.adventurebackpack.config.Keybindings; -import com.darkona.adventurebackpack.init.ModNetwork; -import com.darkona.adventurebackpack.network.EquipUnequipBackWearablePacket; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; + import org.lwjgl.input.Mouse; +import com.darkona.adventurebackpack.common.Constants.Source; +import com.darkona.adventurebackpack.config.Keybindings; +import com.darkona.adventurebackpack.init.ModNetwork; +import com.darkona.adventurebackpack.network.EquipUnequipBackWearablePacket; + /** * Created on 06/01/2015 * * @author Darkona */ public abstract class GuiWithTanks extends GuiContainer { + protected EntityPlayer player; protected Source source; diff --git a/src/main/java/com/darkona/adventurebackpack/client/gui/ModGuiConfig.java b/src/main/java/com/darkona/adventurebackpack/client/gui/ModGuiConfig.java index 4812695d..eb9a8b61 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/gui/ModGuiConfig.java +++ b/src/main/java/com/darkona/adventurebackpack/client/gui/ModGuiConfig.java @@ -1,20 +1,24 @@ package com.darkona.adventurebackpack.client.gui; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.reference.ModInfo; -import cpw.mods.fml.client.config.GuiConfig; -import cpw.mods.fml.client.config.IConfigElement; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigCategory; import net.minecraftforge.common.config.ConfigElement; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.reference.ModInfo; + +import cpw.mods.fml.client.config.GuiConfig; +import cpw.mods.fml.client.config.IConfigElement; + /** * Created by Darkona on 10/10/2014. */ public class ModGuiConfig extends GuiConfig { + public ModGuiConfig(GuiScreen guiScreen) { super(guiScreen, getConfigElements(), ModInfo.MOD_ID, false, false, ModInfo.MOD_NAME); } @@ -22,8 +26,8 @@ public ModGuiConfig(GuiScreen guiScreen) { private static List getConfigElements() { List configElements = new ArrayList<>(); - List topCategories = - Arrays.asList("gameplay", "graphics", "sound", "items", "worldgen", "experimental"); + List topCategories = Arrays + .asList("gameplay", "graphics", "sound", "items", "worldgen", "experimental"); for (String categoryName : topCategories) { ConfigCategory category = ConfigHandler.config.getCategory(categoryName); configElements.add(new ConfigElement(category)); diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelAdventureHat.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelAdventureHat.java index 32da3625..82be84a2 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelAdventureHat.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelAdventureHat.java @@ -5,6 +5,7 @@ import net.minecraft.entity.Entity; public class ModelAdventureHat extends ModelBiped { + private ModelRenderer wing; private ModelRenderer top; private ModelRenderer thing; diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackArmor.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackArmor.java index 34924be4..d13050fb 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackArmor.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackArmor.java @@ -2,18 +2,22 @@ import static com.darkona.adventurebackpack.reference.BackpackTypes.*; +import java.util.List; + +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; + +import org.lwjgl.opengl.GL11; + import codechicken.lib.vec.Vector3; + import com.darkona.adventurebackpack.client.render.RendererStack; import com.darkona.adventurebackpack.common.Constants; import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.inventory.InventoryBackpack; import com.darkona.adventurebackpack.reference.BackpackTypes; import com.darkona.adventurebackpack.reference.ToolHandler; -import java.util.List; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; /** * Created on 17/12/2014 @@ -21,6 +25,7 @@ * @author Darkona */ public class ModelBackpackArmor extends ModelWearable { + public static final ModelBackpackArmor instance = new ModelBackpackArmor(); public ModelRenderer mainBody; @@ -311,21 +316,26 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glColor4f(1, 1, 1, 1); if (bipedBody.rotateAngleX == 0.0F && bipedBody.rotateAngleY == 0.0F && bipedBody.rotateAngleZ == 0.0F) { - if (bipedBody.rotationPointX == 0.0F - && bipedBody.rotationPointY == 0.0F + if (bipedBody.rotationPointX == 0.0F && bipedBody.rotationPointY == 0.0F && bipedBody.rotationPointZ == 0.0F) { renderBackpack(scale); } else { GL11.glTranslatef( - bipedBody.rotationPointX * f5, bipedBody.rotationPointY * f5, bipedBody.rotationPointZ * f5); + bipedBody.rotationPointX * f5, + bipedBody.rotationPointY * f5, + bipedBody.rotationPointZ * f5); renderBackpack(scale); GL11.glTranslatef( - -bipedBody.rotationPointX * f5, -bipedBody.rotationPointY * f5, -bipedBody.rotationPointZ * f5); + -bipedBody.rotationPointX * f5, + -bipedBody.rotationPointY * f5, + -bipedBody.rotationPointZ * f5); } } else { GL11.glPushMatrix(); GL11.glTranslatef( - bipedBody.rotationPointX * f5, bipedBody.rotationPointY * f5, bipedBody.rotationPointZ * f5); + bipedBody.rotationPointX * f5, + bipedBody.rotationPointY * f5, + bipedBody.rotationPointZ * f5); if (bipedBody.rotateAngleZ != 0.0F) { GL11.glRotatef(bipedBody.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F); diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackBlock.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackBlock.java index 4094b6f2..ee07deab 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackBlock.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelBackpackBlock.java @@ -2,18 +2,21 @@ import static com.darkona.adventurebackpack.reference.BackpackTypes.*; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraftforge.fluids.FluidTank; + +import org.lwjgl.opengl.GL11; + import codechicken.lib.render.CCRenderState; import codechicken.lib.render.RenderUtils; import codechicken.lib.vec.Cuboid6; import codechicken.lib.vec.Vector3; + import com.darkona.adventurebackpack.common.Constants; import com.darkona.adventurebackpack.inventory.IInventoryBackpack; import com.darkona.adventurebackpack.reference.BackpackTypes; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.entity.Entity; -import net.minecraftforge.fluids.FluidTank; -import org.lwjgl.opengl.GL11; /** * Created on 17/12/2014 @@ -21,6 +24,7 @@ * @author Darkona */ public class ModelBackpackBlock extends ModelBase { + public ModelRenderer mainBody; public ModelRenderer lampLight; public ModelRenderer tankLeftTop; @@ -264,8 +268,8 @@ public ModelBackpackBlock() { this.pigNose.addBox(0.0F, 0.0F, 0.0F, 4, 3, 1); } - public void render( - Entity entity, float f, float f1, float f2, float f3, float f4, float scale, IInventoryBackpack backpack) { + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float scale, + IInventoryBackpack backpack) { // scale*=0.9; boolean sleepingbag = backpack.isSleepingBagDeployed(); FluidTank tankLeft = backpack.getLeftTank(); @@ -277,9 +281,7 @@ public void render( // renderFluidsInTanks(backpack.getLeftTank(),backpack.getRightTank(),scale); GL11.glPopMatrix(); - if (tankLeft != null - && tankLeft.getFluid() != null - && tankLeft.getFluid().getFluid().getIcon() != null) { + if (tankLeft != null && tankLeft.getFluid() != null && tankLeft.getFluid().getFluid().getIcon() != null) { Vector3 victor = new Vector3( (tankLeftTop.rotationPointX * 0.1f - 0.22f), (tankLeftTop.rotationPointY * 0.1f + 0.05f), @@ -296,9 +298,7 @@ public void render( GL11.glPopMatrix(); } - if (tankRight != null - && tankRight.getFluid() != null - && tankRight.getFluid().getFluid().getIcon() != null) { + if (tankRight != null && tankRight.getFluid() != null && tankRight.getFluid().getFluid().getIcon() != null) { Vector3 victor = new Vector3( (tankRightTop.rotationPointX * 0.1f + 0.48f), (tankRightTop.rotationPointY * 0.1f + 0.05f), @@ -327,9 +327,7 @@ private void renderFluidsInTanks(FluidTank tankLeft, FluidTank tankRight, float float maxY = 0f; float maxZ = 0.17f; - if (tankLeft != null - && tankLeft.getFluid() != null - && tankLeft.getFluid().getFluid().getIcon() != null) { + if (tankLeft != null && tankLeft.getFluid() != null && tankLeft.getFluid().getFluid().getIcon() != null) { // 0.5F, -0.1F, -0.25F - Rotation Points of the top // X++ to the right, X-- to the left // Z-- to the front, Z++ to the back @@ -351,9 +349,7 @@ private void renderFluidsInTanks(FluidTank tankLeft, FluidTank tankRight, float 0.2); } - if (tankRight != null - && tankRight.getFluid() != null - && tankRight.getFluid().getFluid().getIcon() != null) { + if (tankRight != null && tankRight.getFluid() != null && tankRight.getFluid().getFluid().getIcon() != null) { // -0.9F, -0.1F, -0.25F - Rotation points of the top // X-- to the right, X++ to the left // Z-- to the front, Z++ to the back @@ -408,15 +404,11 @@ private void renderBackpack(IInventoryBackpack backpack, float scale) { ocelotNose.render(scale); } - /*if(type == STANDARD) - { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glEnable(GL11.GL_CULL_FACE); - this.lampPole1.render(scale); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - }*/ + /* + * if(type == STANDARD) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, + * GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_CULL_FACE); this.lampPole1.render(scale); + * GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); } + */ GL11.glPopAttrib(); } diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelCampFire.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelCampFire.java index ffedea75..1b105b94 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelCampFire.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelCampFire.java @@ -5,10 +5,10 @@ import net.minecraft.entity.Entity; /** - * campFire - Darkona - * Created using Tabula 4.1.0 + * campFire - Darkona Created using Tabula 4.1.0 */ public class ModelCampFire extends ModelBase { + public ModelRenderer rock1; public ModelRenderer rock2; public ModelRenderer rock3; diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelClockworkCrossbow.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelClockworkCrossbow.java index ca233509..5f3a97c6 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelClockworkCrossbow.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelClockworkCrossbow.java @@ -1,20 +1,22 @@ package com.darkona.adventurebackpack.client.models; -import com.darkona.adventurebackpack.client.render.RendererStack; -import com.darkona.adventurebackpack.reference.ToolHandler; -import com.darkona.adventurebackpack.util.Utils; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.client.render.RendererStack; +import com.darkona.adventurebackpack.reference.ToolHandler; +import com.darkona.adventurebackpack.util.Utils; + /** - * clockworkCrossbow - Darkona - * Created using Tabula 4.1.0 + * clockworkCrossbow - Darkona Created using Tabula 4.1.0 */ public class ModelClockworkCrossbow extends ModelBase { + public ModelRenderer xbowBody; public ModelRenderer leftArc1; public ModelRenderer rightArc1; @@ -213,7 +215,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f this.handle.render(1 / 18f); this.magazine.render(f5); - ModelRenderer[] arrows = {arrow1, arrow2, arrow3}; + ModelRenderer[] arrows = { arrow1, arrow2, arrow3 }; setRotateAngle(arrow, Utils.degreesToRadians(-90), Utils.degreesToRadians(0), Utils.degreesToRadians(0)); for (ModelRenderer model : arrows) { diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelCoalJetpack.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelCoalJetpack.java index 094e3eaf..a60e9d4b 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelCoalJetpack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelCoalJetpack.java @@ -1,15 +1,20 @@ package com.darkona.adventurebackpack.client.models; -import codechicken.lib.vec.Vector3; -import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; import java.util.List; + import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + import org.lwjgl.opengl.GL11; +import codechicken.lib.vec.Vector3; + +import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; + public class ModelCoalJetpack extends ModelWearable { + public ModelRenderer base; public ModelRenderer tubeStraightLeft; public ModelRenderer tubeStraightRight; @@ -132,8 +137,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glColor4f(1, 1, 1, 1); if (bipedBody.rotateAngleX == 0.0F && bipedBody.rotateAngleY == 0.0F && bipedBody.rotateAngleZ == 0.0F) { - if (bipedBody.rotationPointX == 0.0F - && bipedBody.rotationPointY == 0.0F + if (bipedBody.rotationPointX == 0.0F && bipedBody.rotationPointY == 0.0F && bipedBody.rotationPointZ == 0.0F) { renderCoalJetpack(f5); } else { @@ -150,7 +154,9 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f } else { GL11.glPushMatrix(); GL11.glTranslatef( - bipedBody.rotationPointX * f5, bipedBody.rotationPointY * f5, bipedBody.rotationPointZ * f5); + bipedBody.rotationPointX * f5, + bipedBody.rotationPointY * f5, + bipedBody.rotationPointZ * f5); if (bipedBody.rotateAngleZ != 0.0F) { GL11.glRotatef(bipedBody.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F); diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelCopterPack.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelCopterPack.java index 4b9ae78e..4e8b1484 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelCopterPack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelCopterPack.java @@ -2,24 +2,29 @@ import static com.darkona.adventurebackpack.common.Constants.Copter.TAG_STATUS; -import codechicken.lib.vec.Vector3; -import com.darkona.adventurebackpack.inventory.InventoryCopterPack; -import com.darkona.adventurebackpack.item.ItemCopterPack; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.Utils; import java.util.List; + import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; + import org.lwjgl.opengl.GL11; +import codechicken.lib.vec.Vector3; + +import com.darkona.adventurebackpack.inventory.InventoryCopterPack; +import com.darkona.adventurebackpack.item.ItemCopterPack; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.Utils; + /** * Created on 31/12/2014 * * @author Darkona */ public class ModelCopterPack extends ModelWearable { + public static ModelCopterPack instance = new ModelCopterPack(); public ModelRenderer Base; public ModelRenderer EngineBody; @@ -223,8 +228,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f GL11.glColor4f(1, 1, 1, 1); if (bipedBody.rotateAngleX == 0.0F && bipedBody.rotateAngleY == 0.0F && bipedBody.rotateAngleZ == 0.0F) { - if (bipedBody.rotationPointX == 0.0F - && bipedBody.rotationPointY == 0.0F + if (bipedBody.rotationPointX == 0.0F && bipedBody.rotationPointY == 0.0F && bipedBody.rotationPointZ == 0.0F) { renderCopterPack(entity, f5); @@ -242,7 +246,9 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f } else { GL11.glPushMatrix(); GL11.glTranslatef( - bipedBody.rotationPointX * f5, bipedBody.rotationPointY * f5, bipedBody.rotationPointZ * f5); + bipedBody.rotationPointX * f5, + bipedBody.rotationPointY * f5, + bipedBody.rotationPointZ * f5); if (bipedBody.rotateAngleZ != 0.0F) { GL11.glRotatef(bipedBody.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F); diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelFullArmor.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelFullArmor.java index a168b853..55237fb9 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelFullArmor.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelFullArmor.java @@ -12,6 +12,7 @@ * @author Darkona */ public class ModelFullArmor extends ModelBiped { + public ModelFullArmor() { super(0.2F); } @@ -27,8 +28,7 @@ public void render(Entity entity, float f, float f1, float f2, float f3, float f this.isRiding = entity.isRiding(); if (owner instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) owner; - this.aimedBow = player.isUsingItem() - && player.getItemInUse() != null + this.aimedBow = player.isUsingItem() && player.getItemInUse() != null && player.getItemInUse().getItemUseAction() == EnumAction.bow; this.heldItemRight = (player.getCurrentEquippedItem() != null) ? 1 : 0; } diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelInflatableBoat.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelInflatableBoat.java index 36160f3b..fbb0a432 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelInflatableBoat.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelInflatableBoat.java @@ -1,16 +1,18 @@ package com.darkona.adventurebackpack.client.models; -import com.darkona.adventurebackpack.entity.EntityInflatableBoat; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.entity.EntityInflatableBoat; + /** - * InflatableBoat - Darkona - * Created using Tabula 4.1.0 + * InflatableBoat - Darkona Created using Tabula 4.1.0 */ public class ModelInflatableBoat extends ModelBase { + public ModelRenderer boatSides1; public ModelRenderer boatSides2; public ModelRenderer boatSides3; diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelSleepingBag.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelSleepingBag.java index ddd2368e..22cda125 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelSleepingBag.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelSleepingBag.java @@ -11,6 +11,7 @@ import net.minecraft.entity.Entity; public class ModelSleepingBag extends ModelBase { + ModelRenderer footer; ModelRenderer header; ModelRenderer pillow; diff --git a/src/main/java/com/darkona/adventurebackpack/client/models/ModelWearable.java b/src/main/java/com/darkona/adventurebackpack/client/models/ModelWearable.java index ab7f339f..9bca7eab 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/models/ModelWearable.java +++ b/src/main/java/com/darkona/adventurebackpack/client/models/ModelWearable.java @@ -1,21 +1,24 @@ package com.darkona.adventurebackpack.client.models; -import codechicken.lib.render.RenderUtils; -import codechicken.lib.vec.Cuboid6; -import codechicken.lib.vec.Vector3; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidTank; + import org.lwjgl.opengl.GL11; +import codechicken.lib.render.RenderUtils; +import codechicken.lib.vec.Cuboid6; +import codechicken.lib.vec.Vector3; + /** * Created on 10/01/2015 * * @author Darkona */ public abstract class ModelWearable extends ModelBiped { + protected void startBlending() { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); @@ -43,14 +46,12 @@ public void setRotationPoints(ModelRenderer modelRenderer, float x, float y, flo modelRenderer.rotationPointZ = z; } - public abstract void render( - Entity entity, float f, float f1, float f2, float f3, float f4, float f5, ItemStack stack); + public abstract void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5, + ItemStack stack); - public void renderFluidInTank( - FluidTank tank, Vector3 minCoords, Vector3 maxCoords, Vector3 offset, ModelRenderer parent) { - if (tank != null - && tank.getFluid() != null - && tank.getFluid().getFluid().getIcon() != null) { + public void renderFluidInTank(FluidTank tank, Vector3 minCoords, Vector3 maxCoords, Vector3 offset, + ModelRenderer parent) { + if (tank != null && tank.getFluid() != null && tank.getFluid().getFluid().getIcon() != null) { Vector3 victor = new Vector3( (parent.rotationPointX * 0.1f + parent.offsetX * 0.1 + offset.x), // (parent.rotationPointY * 0.1f + parent.offsetY * 0.1 + offset.y), diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/CopygirlRenderUtils.java b/src/main/java/com/darkona/adventurebackpack/client/render/CopygirlRenderUtils.java index 70ad26b5..e0a70362 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/CopygirlRenderUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/CopygirlRenderUtils.java @@ -1,7 +1,5 @@ package com.darkona.adventurebackpack.client.render; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -11,34 +9,34 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * The MIT License (MIT) * * Copyright (c) 2014 copygirl * - * 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: + * 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 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. + * 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. */ @SideOnly(Side.CLIENT) public final class CopygirlRenderUtils { + private static final ResourceLocation glint = new ResourceLocation("textures/misc/enchanted_item_glint.png"); private CopygirlRenderUtils() {} @@ -62,8 +60,7 @@ public static void renderItemIn3d(ItemStack stack) { int passes = item.getRenderPasses(stack.getItemDamage()); for (int pass = 0; pass < passes; pass++) { textureManager.bindTexture( - ((stack.getItemSpriteNumber() == 0) - ? TextureMap.locationBlocksTexture + ((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture)); IIcon icon = item.getIcon(stack, pass); if (icon != null) { @@ -73,7 +70,14 @@ public static void renderItemIn3d(ItemStack stack) { float maxV = icon.getMaxV(); CopygirlRenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass)); ItemRenderer.renderItemIn2D( - tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + tessellator, + maxU, + minV, + minU, + maxV, + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); } } @@ -115,8 +119,8 @@ public static void setColorFromInt(int color) { GL11.glColor4f(r, g, b, 1.0F); } - public static void drawTexturedModalRect( - int x, int y, int u, int v, int width, int height, float zLevel, int textureWidth, int textureHeight) { + public static void drawTexturedModalRect(int x, int y, int u, int v, int width, int height, float zLevel, + int textureWidth, int textureHeight) { float xScale = 1.0F / textureWidth; float yScale = 1.0F / textureHeight; Tessellator tess = Tessellator.instance; diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RenderRideableSpider.java b/src/main/java/com/darkona/adventurebackpack/client/render/RenderRideableSpider.java index c1ba4474..13afd08c 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RenderRideableSpider.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RenderRideableSpider.java @@ -1,17 +1,21 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.entity.EntityFriendlySpider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelSpider; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.entity.EntityFriendlySpider; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) public class RenderRideableSpider extends RenderLiving { + private static final ResourceLocation spiderEyesTextures = new ResourceLocation("textures/entity/spider_eyes.png"); private static final ResourceLocation spiderTextures = new ResourceLocation("textures/entity/spider/spider.png"); private static final String __OBFID = "CL_00001027"; diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererAdventureBackpackBlock.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererAdventureBackpackBlock.java index d2d03c89..cd260725 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererAdventureBackpackBlock.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererAdventureBackpackBlock.java @@ -1,20 +1,23 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.block.TileAdventureBackpack; -import com.darkona.adventurebackpack.client.models.ModelBackpackBlock; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import com.darkona.adventurebackpack.block.TileAdventureBackpack; +import com.darkona.adventurebackpack.client.models.ModelBackpackBlock; +import com.darkona.adventurebackpack.util.Resources; + /** * Created on 12/10/2014 * * @author Darkona */ public class RendererAdventureBackpackBlock extends TileEntitySpecialRenderer { + private ModelBackpackBlock model; public RendererAdventureBackpackBlock() { diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererCampFire.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererCampFire.java index 6477985b..ceef6321 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererCampFire.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererCampFire.java @@ -1,19 +1,22 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.client.models.ModelCampFire; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import com.darkona.adventurebackpack.client.models.ModelCampFire; +import com.darkona.adventurebackpack.util.Resources; + /** * Created on 05/01/2015 * * @author Darkona */ public class RendererCampFire extends TileEntitySpecialRenderer { + private ModelCampFire model; public RendererCampFire() { @@ -28,14 +31,14 @@ public void renderTileEntityAt(TileEntity te, double x, double y, double z, floa GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.2f, (float) z + 0.5F); - // GL11.glPushMatrix(); + // GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); bindTexture(modelTexture); model.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1 / 20F); GL11.glDisable(GL12.GL_RESCALE_NORMAL); - // GL11.glPopMatrix(); + // GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopAttrib(); diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererHose.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererHose.java index 60414a00..bc7d5d05 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererHose.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererHose.java @@ -1,20 +1,23 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.config.ConfigHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.config.ConfigHandler; + /** * Created on 13/10/2014 * * @author Darkona */ public class RendererHose implements IItemRenderer { + private static RenderItem renderHose = new RenderItem(); private FontRenderer fontRenderer; diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererInflatableBoat.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererInflatableBoat.java index 52e56978..12e2f0d5 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererInflatableBoat.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererInflatableBoat.java @@ -1,20 +1,23 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.client.models.ModelInflatableBoat; -import com.darkona.adventurebackpack.entity.EntityInflatableBoat; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.client.models.ModelInflatableBoat; +import com.darkona.adventurebackpack.entity.EntityInflatableBoat; +import com.darkona.adventurebackpack.util.Resources; + /** * Created on 05/01/2015 * * @author Darkona */ public class RendererInflatableBoat extends Render { + private ResourceLocation boatTexture = Resources.modelTextures("inflatableBoat"); private ModelInflatableBoat boatModel = new ModelInflatableBoat(); @@ -35,7 +38,10 @@ public void doRender(EntityInflatableBoat entity, double x, double y, double z, if (f2 > 0.0F) { GL11.glRotatef( - MathHelper.sin(f2) * f2 * f3 / 10.0F * (float) entity.getForwardDirection(), 1.0F, 0.0F, 0.0F); + MathHelper.sin(f2) * f2 * f3 / 10.0F * (float) entity.getForwardDirection(), + 1.0F, + 0.0F, + 0.0F); } float f4 = 0.75F; diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureBackpack.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureBackpack.java index ca1317b7..ff437346 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureBackpack.java @@ -1,21 +1,24 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.client.models.ModelBackpackBlock; -import com.darkona.adventurebackpack.inventory.InventoryBackpack; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.client.models.ModelBackpackBlock; +import com.darkona.adventurebackpack.inventory.InventoryBackpack; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.Resources; + /** * Created on 12/10/2014 * * @author Darkona */ public class RendererItemAdventureBackpack implements IItemRenderer { + private final ModelBackpackBlock model; public RendererItemAdventureBackpack() { @@ -40,8 +43,8 @@ public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType typ } @Override - public boolean shouldUseRenderHelper( - IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, + IItemRenderer.ItemRendererHelper helper) { switch (type) { case INVENTORY: return true; @@ -64,51 +67,49 @@ public void renderItem(IItemRenderer.ItemRenderType renderType, ItemStack backpa switch (renderType) { case INVENTORY: - Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 128); + Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 128); - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5f, 0f, -0.5f); + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5f, 0f, -0.5f); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glPushMatrix(); - GL11.glScalef(1.9f, 1.9f, 1.9f); + GL11.glPushMatrix(); + GL11.glScalef(1.9f, 1.9f, 1.9f); - model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F, inv); + model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F, inv); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } break; case ENTITY: - Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 128); + Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 128); - GL11.glPushMatrix(); - GL11.glTranslatef(0f, 1f, 0f); + GL11.glPushMatrix(); + GL11.glTranslatef(0f, 1f, 0f); - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glPushMatrix(); - GL11.glScalef(1.2f, 1.2f, 1.2f); + GL11.glPushMatrix(); + GL11.glScalef(1.2f, 1.2f, 1.2f); - model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F, inv); + model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F, inv); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } break; case EQUIPPED: diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureHat.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureHat.java index 51a02a6e..57a74574 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureHat.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemAdventureHat.java @@ -1,18 +1,21 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.client.models.ModelAdventureHat; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.client.models.ModelAdventureHat; +import com.darkona.adventurebackpack.util.Resources; + /** * Created by Darkona on 11/10/2014. */ public class RendererItemAdventureHat implements IItemRenderer { + private final ModelAdventureHat model; public RendererItemAdventureHat() { @@ -37,8 +40,8 @@ public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType typ } @Override - public boolean shouldUseRenderHelper( - IItemRenderer.ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, + IItemRenderer.ItemRendererHelper helper) { switch (type) { case INVENTORY: return true; @@ -59,50 +62,48 @@ public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object ResourceLocation modelTexture = Resources.modelTextures("adventureHat_texture"); Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); switch (type) { - case INVENTORY: - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 128); - - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5f, -1.0f, -0.5f); - - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glPushMatrix(); - GL11.glScalef(1.5f, 1.5f, 1.5f); - - model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); - - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } + case INVENTORY: { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 128); + + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5f, -1.0f, -0.5f); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glPushMatrix(); + GL11.glScalef(1.5f, 1.5f, 1.5f); + + model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); + + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } break; case ENTITY: - Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 128); + Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 128); - GL11.glPushMatrix(); - GL11.glTranslatef(0f, 0f, 0f); + GL11.glPushMatrix(); + GL11.glTranslatef(0f, 0f, 0f); - GL11.glPushMatrix(); - GL11.glRotatef(180, 0, 0, 1); + GL11.glPushMatrix(); + GL11.glRotatef(180, 0, 0, 1); - GL11.glPushMatrix(); - GL11.glScalef(1.0f, 1.0f, 1.0f); + GL11.glPushMatrix(); + GL11.glScalef(1.0f, 1.0f, 1.0f); - model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); + model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } break; case EQUIPPED: Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemClockworkCrossbow.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemClockworkCrossbow.java index 7e3185f7..1c720446 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemClockworkCrossbow.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererItemClockworkCrossbow.java @@ -1,18 +1,21 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.client.models.ModelClockworkCrossbow; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.client.models.ModelClockworkCrossbow; +import com.darkona.adventurebackpack.util.Resources; + /** * Created by Darkona on 11/10/2014. */ public class RendererItemClockworkCrossbow implements IItemRenderer { + private final ModelClockworkCrossbow model; private ResourceLocation modelTexture = Resources.modelTextures("clockworkCrossbow"); @@ -32,50 +35,48 @@ public void renderItem(ItemRenderType type, ItemStack item, Object... data) { Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); EntityPlayer player; switch (type) { - case INVENTORY: - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 128); - - GL11.glPushMatrix(); - GL11.glTranslatef(-0.5f, -.5f, -0.5f); - - GL11.glPushMatrix(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glPushMatrix(); - GL11.glScalef(0.7f, 0.7f, 0.7f); - - model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); - - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } + case INVENTORY: { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 128); + + GL11.glPushMatrix(); + GL11.glTranslatef(-0.5f, -.5f, -0.5f); + + GL11.glPushMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glPushMatrix(); + GL11.glScalef(0.7f, 0.7f, 0.7f); + + model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); + + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } break; case ENTITY: - Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 128); + Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 128); - GL11.glPushMatrix(); - GL11.glTranslatef(0f, .50f, 0f); + GL11.glPushMatrix(); + GL11.glTranslatef(0f, .50f, 0f); - GL11.glPushMatrix(); - GL11.glRotatef(180, 0, 0, 1); + GL11.glPushMatrix(); + GL11.glRotatef(180, 0, 0, 1); - GL11.glPushMatrix(); - GL11.glScalef(1.0f, 1.0f, 1.0f); + GL11.glPushMatrix(); + GL11.glScalef(1.0f, 1.0f, 1.0f); - model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); + model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } break; case EQUIPPED: Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererStack.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererStack.java index bd0b7864..e3a2ca82 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererStack.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererStack.java @@ -1,20 +1,24 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.reference.ToolHandler; -import com.darkona.adventurebackpack.util.GregtechUtils; -import com.darkona.adventurebackpack.util.ThaumcraftUtils; -import com.darkona.adventurebackpack.util.TinkersUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import com.darkona.adventurebackpack.reference.ToolHandler; +import com.darkona.adventurebackpack.util.GregtechUtils; +import com.darkona.adventurebackpack.util.ThaumcraftUtils; +import com.darkona.adventurebackpack.util.TinkersUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class RendererStack extends ModelRenderer { + private static final Minecraft MC = Minecraft.getMinecraft(); private boolean isLowerSlot; @@ -33,6 +37,7 @@ public void setStack(ItemStack stack, ToolHandler toolHandler) { } private class Thing extends ModelRenderer { + public Thing(ModelBase modelBase) { super(modelBase); } diff --git a/src/main/java/com/darkona/adventurebackpack/client/render/RendererWearableEquipped.java b/src/main/java/com/darkona/adventurebackpack/client/render/RendererWearableEquipped.java index bc80c6dd..22cd448f 100644 --- a/src/main/java/com/darkona/adventurebackpack/client/render/RendererWearableEquipped.java +++ b/src/main/java/com/darkona/adventurebackpack/client/render/RendererWearableEquipped.java @@ -1,7 +1,5 @@ package com.darkona.adventurebackpack.client.render; -import com.darkona.adventurebackpack.item.IBackWearableItem; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderManager; @@ -11,15 +9,20 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; +import com.darkona.adventurebackpack.item.IBackWearableItem; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 25/12/2014 * * @author Darkona */ public class RendererWearableEquipped extends RendererLivingEntity { + public ResourceLocation texture; public ModelBiped modelBipedMain; @@ -33,8 +36,8 @@ protected ResourceLocation getEntityTexture(Entity par1Entity) { return texture; } - public void render( - Entity entity, double x, double y, double z, float rotX, float rotY, float rotZ, float yaw, float pitch) { + public void render(Entity entity, double x, double y, double z, float rotX, float rotY, float rotZ, float yaw, + float pitch) { final ItemStack wearable = Wearing.getWearingWearable((EntityPlayer) entity); if (wearable == null) { return; @@ -50,19 +53,12 @@ public void render( try { GL11.glEnable(GL12.GL_RESCALE_NORMAL); renderMainModel((EntityPlayer) entity, 0, 0, 0, 0, 0, 0.0625f); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} GL11.glPopAttrib(); } - protected void renderMainModel( - EntityLivingBase entity, - float limbSwing1, - float limbswing2, - float z, - float yaw, - float whatever, - float scale) { + protected void renderMainModel(EntityLivingBase entity, float limbSwing1, float limbswing2, float z, float yaw, + float whatever, float scale) { GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_TEXTURE_BIT); bindTexture(this.texture); diff --git a/src/main/java/com/darkona/adventurebackpack/common/BackpackAbilities.java b/src/main/java/com/darkona/adventurebackpack/common/BackpackAbilities.java index 5f8a6a10..cdf0d865 100644 --- a/src/main/java/com/darkona/adventurebackpack/common/BackpackAbilities.java +++ b/src/main/java/com/darkona/adventurebackpack/common/BackpackAbilities.java @@ -1,18 +1,8 @@ package com.darkona.adventurebackpack.common; -import com.darkona.adventurebackpack.block.TileAdventureBackpack; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.entity.ai.EntityAIAvoidPlayerWithBackpack; -import com.darkona.adventurebackpack.init.ModFluids; -import com.darkona.adventurebackpack.init.ModNetwork; -import com.darkona.adventurebackpack.inventory.InventoryBackpack; -import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.LogHelper; -import com.darkona.adventurebackpack.util.Utils; -import com.darkona.adventurebackpack.util.Wearing; import java.util.Iterator; import java.util.List; + import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.ai.EntityAIBase; @@ -30,6 +20,18 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import com.darkona.adventurebackpack.block.TileAdventureBackpack; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.entity.ai.EntityAIAvoidPlayerWithBackpack; +import com.darkona.adventurebackpack.init.ModFluids; +import com.darkona.adventurebackpack.init.ModNetwork; +import com.darkona.adventurebackpack.inventory.InventoryBackpack; +import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.LogHelper; +import com.darkona.adventurebackpack.util.Utils; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 12/10/2014 * @@ -40,6 +42,7 @@ */ @SuppressWarnings("unused") public class BackpackAbilities { + public static BackpackAbilities backpackAbilities = new BackpackAbilities(); public static BackpackRemovals backpackRemovals = new BackpackRemovals(); @@ -50,8 +53,7 @@ public void executeAbility(EntityPlayer player, World world, ItemStack backpack) String skinName = BackpackTypes.getSkinName(backpack); try { // This is black magic and shouldn't be attempted by the faint of heart. - this.getClass() - .getMethod("item" + skinName, EntityPlayer.class, World.class, ItemStack.class) + this.getClass().getMethod("item" + skinName, EntityPlayer.class, World.class, ItemStack.class) .invoke(backpackAbilities, player, world, backpack); } catch (Exception oops) { // NOBODY CARES @@ -62,15 +64,12 @@ public void executeTileAbility(World world, TileAdventureBackpack backpack) { String skinName = BackpackTypes.getSkinName(backpack.getType()); try { /* - This is witchery, witchery I say! - But seriously, if you want to know how this works just pay very close attention: - invoke will execute any method of a given class, okay? so this should be obvious. - Look at the names of the methods in this class and you'll figure it out. - You have to indicate exactly the classes that the method should use as parameters so - be very careful with "getMethod". - */ - this.getClass() - .getMethod("tile" + skinName, World.class, TileAdventureBackpack.class) + * This is witchery, witchery I say! But seriously, if you want to know how this works just pay very close + * attention: invoke will execute any method of a given class, okay? so this should be obvious. Look at the + * names of the methods in this class and you'll figure it out. You have to indicate exactly the classes + * that the method should use as parameters so be very careful with "getMethod". + */ + this.getClass().getMethod("tile" + skinName, World.class, TileAdventureBackpack.class) .invoke(backpackAbilities, world, backpack); } catch (Exception oops) { // Seriously, nobody cares if this can't work, this is just so the game won't explode. @@ -81,9 +80,7 @@ public void executeRemoval(EntityPlayer player, World world, ItemStack backpack) String skinName = BackpackTypes.getSkinName(backpack); try { // This is black magic and shouldn't be attempted by the faint of heart. - backpackRemovals - .getClass() - .getMethod("item" + skinName, EntityPlayer.class, World.class, ItemStack.class) + backpackRemovals.getClass().getMethod("item" + skinName, EntityPlayer.class, World.class, ItemStack.class) .invoke(backpackRemovals, player, world, backpack); } catch (Exception oops) { LogHelper.error("---Something bad happened when removing a backpack---"); @@ -100,9 +97,9 @@ public void executeRemoval(EntityPlayer player, World world, ItemStack backpack) */ private boolean isUnderRain(EntityPlayer player) { return player.worldObj.canLightningStrikeAt( - MathHelper.floor_double(player.posX), - MathHelper.floor_double(player.posY), - MathHelper.floor_double(player.posZ)) + MathHelper.floor_double(player.posX), + MathHelper.floor_double(player.posY), + MathHelper.floor_double(player.posZ)) || player.worldObj.canLightningStrikeAt( MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY + player.height), @@ -116,9 +113,8 @@ public void itemSunflower(EntityPlayer player, World world, ItemStack backpack) InventoryBackpack inv = new InventoryBackpack(backpack); if (inv.getLastTime() <= 0) { - if (world.isDaytime() - && - /*!world.isRemote &&*/ + if (world.isDaytime() && + /* !world.isRemote && */ world.canBlockSeeTheSky( MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY + 1), @@ -159,8 +155,8 @@ public void itemSquid(EntityPlayer player, World world, ItemStack backpack) { itemBat(player, world, backpack); } else if (player.isPotionActive(Potion.waterBreathing.id) && player.getActivePotionEffect(Potion.waterBreathing).getAmplifier() == -1) { - backpackRemovals.itemSquid(player, world, backpack); - } + backpackRemovals.itemSquid(player, world, backpack); + } } public void itemPigman(EntityPlayer player, World world, ItemStack backpack) { @@ -189,8 +185,12 @@ public void itemDragon(EntityPlayer player, World world, ItemStack backpack) { } if (player.getHealth() < player.getMaxHealth()) { if (potion == null || potion.getDuration() < 20) { - player.addPotionEffect(new PotionEffect( - Potion.regeneration.getId(), 900, ConfigHandler.dragonBackpackRegen - 1, true)); + player.addPotionEffect( + new PotionEffect( + Potion.regeneration.getId(), + 900, + ConfigHandler.dragonBackpackRegen - 1, + true)); } } else if (potion != null && potion.getAmplifier() == ConfigHandler.dragonBackpackRegen - 1) { if (player.worldObj.isRemote) { @@ -206,8 +206,12 @@ public void itemDragon(EntityPlayer player, World world, ItemStack backpack) { potion = player.getActivePotionEffect(Potion.damageBoost); } if (potion == null || potion.getDuration() < 222) { - player.addPotionEffect(new PotionEffect( - Potion.damageBoost.getId(), 239, ConfigHandler.dragonBackpackDamage - 1, true)); + player.addPotionEffect( + new PotionEffect( + Potion.damageBoost.getId(), + 239, + ConfigHandler.dragonBackpackDamage - 1, + true)); } } } @@ -230,7 +234,8 @@ public void itemRainbow(EntityPlayer player, World world, ItemStack backpack) { // Visuals.NyanParticles(player, world); if (!world.isRemote) { ModNetwork.sendToNearby( - new EntityParticlePacket.Message(EntityParticlePacket.NYAN_PARTICLE, player), player); + new EntityParticlePacket.Message(EntityParticlePacket.NYAN_PARTICLE, player), + player); } } } @@ -252,14 +257,13 @@ public void itemIronGolem(EntityPlayer player, World world, ItemStack backpack) /** * Mirroring real life cactii, the Cactus Backpack fills with water slowly or rapidly depending where is the player. - * If it's raining it will fill 1milibucket of water each tick. - * If the player is in water it will fill 2milibuckets of water each tick. - * The quantities can be combined. + * If it's raining it will fill 1milibucket of water each tick. If the player is in water it will fill 2milibuckets + * of water each tick. The quantities can be combined. * * @param player The player. No, seriously. * @param world The world the player is in. - * @param backpack The backpack the player is wearing. This should be rechecked like 20 times by now, so - * I'm not checking. + * @param backpack The backpack the player is wearing. This should be rechecked like 20 times by now, so I'm not + * checking. */ public void itemCactus(EntityPlayer player, World world, ItemStack backpack) { // lastTime is in ticks for this backpack. @@ -288,8 +292,8 @@ public void itemCactus(EntityPlayer player, World world, ItemStack backpack) { /** * The Pig Backpack will annoy you and your friends! This beautiful design by 豚, will do as the pigs do when they * are frolicking around in the green pastures and terrifying slaughterhouses of the Minecraft world, after a random - * number of seconds. It's not so frequent as I'd like. - * Translation for pigs: Oink oink oink Oink! squee oink oink Minecraft Oink oink. "Oink" oink oink. + * number of seconds. It's not so frequent as I'd like. Translation for pigs: Oink oink oink Oink! squee oink oink + * Minecraft Oink oink. "Oink" oink oink. * * @param player The player * @param world The world object @@ -330,10 +334,14 @@ public void itemSlime(EntityPlayer player, World world, ItemStack backpack) { if (slimeTime <= 0) { if (!world.isRemote) { ModNetwork.sendToNearby( - new EntityParticlePacket.Message(EntityParticlePacket.SLIME_PARTICLE, player), player); + new EntityParticlePacket.Message(EntityParticlePacket.SLIME_PARTICLE, player), + player); } world.playSoundAtEntity( - player, "mob.slime.small", 0.6F, (world.rand.nextFloat() - world.rand.nextFloat()) * 1F); + player, + "mob.slime.small", + 0.6F, + (world.rand.nextFloat() - world.rand.nextFloat()) * 1F); slimeTime = 5; } inv.setLastTime(slimeTime); @@ -358,8 +366,8 @@ public void itemChicken(EntityPlayer player, World world, ItemStack backpack) { } /** - * The Melon Backpack, like his cousin the Cactus Backpack, will fill itself, but with delicious - * and refreshing Melon Juice, if the backpack is wet in any way. + * The Melon Backpack, like his cousin the Cactus Backpack, will fill itself, but with delicious and refreshing + * Melon Juice, if the backpack is wet in any way. */ public void itemMelon(EntityPlayer player, World world, ItemStack backpack) { // lastTime is in ticks for this backpack. @@ -386,9 +394,9 @@ public void itemMelon(EntityPlayer player, World world, ItemStack backpack) { } /** - * Sneaky! Scare your friends! Or your enemies! - * Sneak on another player to make them jump in confusion as they think one of those green bastards is behind him/her. - * You can only do it once every so often. A couple of minutes. Remember, you must be sneaking. + * Sneaky! Scare your friends! Or your enemies! Sneak on another player to make them jump in confusion as they think + * one of those green bastards is behind him/her. You can only do it once every so often. A couple of minutes. + * Remember, you must be sneaking. * * @see com.darkona.adventurebackpack.handlers.PlayerEventHandler */ @@ -404,13 +412,12 @@ public void itemCreeper(EntityPlayer player, World world, ItemStack backpack) { List entities = player.worldObj.getEntitiesWithinAABBExcludingEntity( player, AxisAlignedBB.getBoundingBox( - player.posX, - player.posY, - player.posZ, - player.posX + 1.0D, - player.posY + 1.0D, - player.posZ + 1.0D) - .expand(5.0D, 1.0D, 5.0D)); + player.posX, + player.posY, + player.posZ, + player.posX + 1.0D, + player.posY + 1.0D, + player.posZ + 1.0D).expand(5.0D, 1.0D, 5.0D)); if (entities.isEmpty()) { pssstTime -= 1; return; @@ -440,8 +447,8 @@ public void itemCreeper(EntityPlayer player, World world, ItemStack backpack) { * when it is being worn. For not-player related milk generation go get a cow. Moo! */ public void itemCow(EntityPlayer player, World world, ItemStack backpack) { - if (world.isRemote) - return; // TODO not syncing properly with client if GUI is open (see unused CowAbilityPacket?) + if (world.isRemote) return; // TODO not syncing properly with client if GUI is open (see unused + // CowAbilityPacket?) InventoryBackpack inv = new InventoryBackpack(backpack); inv.openInventory(); @@ -562,13 +569,12 @@ public void itemWolf(EntityPlayer player, World world, ItemStack backpack) { List wolves = world.getEntitiesWithinAABB( EntityWolf.class, AxisAlignedBB.getBoundingBox( - player.posX, - player.posY, - player.posZ, - player.posX + 1.0D, - player.posY + 1.0D, - player.posZ + 1.0D) - .expand(16.0D, 4.0D, 16.0D)); + player.posX, + player.posY, + player.posZ, + player.posX + 1.0D, + player.posY + 1.0D, + player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D)); if (wolves.isEmpty()) return; for (EntityWolf wolf : wolves) { @@ -596,7 +602,8 @@ public void itemBlaze(EntityPlayer player, World world, ItemStack backpack) {} /** * Like actual Ocelots and Cats, the Ocelot Backpack will scare the hell out of Creepers, so they won't creep on you - * while you're busy doing something else, paying no attention whatsoever at your surroundings like a mindless chicken. + * while you're busy doing something else, paying no attention whatsoever at your surroundings like a mindless + * chicken. */ @SuppressWarnings("unchecked") public void itemOcelot(EntityPlayer player, World world, ItemStack backpack) { @@ -608,18 +615,22 @@ public void itemOcelot(EntityPlayer player, World world, ItemStack backpack) { List creepers = player.worldObj.getEntitiesWithinAABB( EntityCreeper.class, AxisAlignedBB.getBoundingBox( - player.posX, - player.posY, - player.posZ, - player.posX + 1.0D, - player.posY + 1.0D, - player.posZ + 1.0D) - .expand(16.0D, 4.0D, 16.0D)); + player.posX, + player.posY, + player.posZ, + player.posX + 1.0D, + player.posY + 1.0D, + player.posZ + 1.0D).expand(16.0D, 4.0D, 16.0D)); for (EntityCreeper creeper : creepers) { boolean set = true; EntityAIAvoidPlayerWithBackpack task = new EntityAIAvoidPlayerWithBackpack( - creeper, EntityPlayer.class, 10.0F, 1.0, 1.3, BackpackTypes.OCELOT); + creeper, + EntityPlayer.class, + 10.0F, + 1.0, + 1.3, + BackpackTypes.OCELOT); for (Object entry : creeper.tasks.taskEntries) { if (((EntityAITasks.EntityAITaskEntry) entry).action instanceof EntityAIAvoidPlayerWithBackpack) { set = false; @@ -637,7 +648,7 @@ public void itemOcelot(EntityPlayer player, World world, ItemStack backpack) { inv.markDirty(); } - /* ==================================== TILE ABILITIES ==========================================*/ + /* ==================================== TILE ABILITIES ========================================== */ private void fillWithRain(World world, TileAdventureBackpack backpack, FluidStack fluid, int time) { if (world.isRaining() && world.canBlockSeeTheSky(backpack.xCoord, backpack.yCoord, backpack.zCoord)) { @@ -663,8 +674,8 @@ public void tileMelon(World world, TileAdventureBackpack backpack) { fillWithRain(world, backpack, new FluidStack(ModFluids.melonJuice, 2), 5); } - /*public void tileCow(World world, TileAdventureBackpack backpack) - { - IInventoryBackpack inv = backpack; //TODO make CowBackpack (and others) working in tile form - }*/ + /* + * public void tileCow(World world, TileAdventureBackpack backpack) { IInventoryBackpack inv = backpack; //TODO make + * CowBackpack (and others) working in tile form } + */ } diff --git a/src/main/java/com/darkona/adventurebackpack/common/BackpackRemovals.java b/src/main/java/com/darkona/adventurebackpack/common/BackpackRemovals.java index 7fc3642c..f1cd5107 100644 --- a/src/main/java/com/darkona/adventurebackpack/common/BackpackRemovals.java +++ b/src/main/java/com/darkona/adventurebackpack/common/BackpackRemovals.java @@ -1,20 +1,22 @@ package com.darkona.adventurebackpack.common; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.inventory.InventoryBackpack; -import com.darkona.adventurebackpack.util.Wearing; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.inventory.InventoryBackpack; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 09/01/2015 * * @author Darkona */ public class BackpackRemovals { + public void itemBat(EntityPlayer player, World world, ItemStack backpack) { PotionEffect potion = null; if (player.isPotionActive(Potion.nightVision.id)) { diff --git a/src/main/java/com/darkona/adventurebackpack/common/Constants.java b/src/main/java/com/darkona/adventurebackpack/common/Constants.java index 157cb5d4..d40689aa 100644 --- a/src/main/java/com/darkona/adventurebackpack/common/Constants.java +++ b/src/main/java/com/darkona/adventurebackpack/common/Constants.java @@ -8,6 +8,7 @@ * @author Javier Darkona */ public class Constants { + public enum Source // TODO move to separate class? { TILE, @@ -25,7 +26,7 @@ public enum Source // TODO move to separate class? public static final String TAG_SLOT = "Slot"; /** - * ### Adventure Backpack ### + * ### Adventure Backpack ### */ public static final int BASIC_TANK_CAPACITY = BUCKET * 4; // public static final int ADVANCED_TANK_CAPACITY = BUCKET * 8; // upgrade system? @@ -57,8 +58,9 @@ public enum Source // TODO move to separate class? public static final String TAG_SLEEPING_IN_BAG = "sleepingInBag"; public class Jetpack { + /** - * ### Coal Jetpack ### + * ### Coal Jetpack ### */ public static final int MAX_TEMPERATURE = 200; @@ -77,8 +79,9 @@ public class Jetpack { } public class Copter { + /** - * ### Copter Pack ### + * ### Copter Pack ### */ public static final int FUEL_CAPACITY = BUCKET * 16; diff --git a/src/main/java/com/darkona/adventurebackpack/common/ServerActions.java b/src/main/java/com/darkona/adventurebackpack/common/ServerActions.java index 061ca3d5..4e08d8d0 100644 --- a/src/main/java/com/darkona/adventurebackpack/common/ServerActions.java +++ b/src/main/java/com/darkona/adventurebackpack/common/ServerActions.java @@ -5,6 +5,23 @@ import static com.darkona.adventurebackpack.common.Constants.TOOL_LOWER; import static com.darkona.adventurebackpack.common.Constants.TOOL_UPPER; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTank; + import com.darkona.adventurebackpack.block.BlockSleepingBag; import com.darkona.adventurebackpack.block.TileAdventureBackpack; import com.darkona.adventurebackpack.config.ConfigHandler; @@ -23,21 +40,6 @@ import com.darkona.adventurebackpack.util.BackpackUtils; import com.darkona.adventurebackpack.util.CoordsUtils; import com.darkona.adventurebackpack.util.Wearing; -import java.util.Random; -import net.minecraft.block.Block; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.projectile.EntityArrow; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatComponentTranslation; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; /** * Created on 23/12/2014 @@ -45,12 +47,13 @@ * @author Darkona */ public class ServerActions { + public static final boolean HOSE_SWITCH = false; public static final boolean HOSE_TOGGLE = true; /** - * Cycles tools. In a cycle. The tool in your hand with the tools in the special tool playerSlot of the backpack, - * to be precise. + * Cycles tools. In a cycle. The tool in your hand with the tools in the special tool playerSlot of the backpack, to + * be precise. * * @param player Duh * @param isWheelUp A boolean indicating the direction of the switch. Nobody likes to swith always in the same @@ -70,10 +73,10 @@ public static void cycleTool(EntityPlayer player, boolean isWheelUp) { } /** - * @param world The world. Like, the WHOLE world. That's a lot of stuff. Do stuff with it, like detecting biomes - * or whatever. - * @param player Is a player. To whom the nice or evil effects you're going to apply will affect. - * See? I know the proper use of the words "effect" & "affect". + * @param world The world. Like, the WHOLE world. That's a lot of stuff. Do stuff with it, like detecting biomes or + * whatever. + * @param player Is a player. To whom the nice or evil effects you're going to apply will affect. See? I know the + * proper use of the words "effect" & "affect". * @param tank The tank that holds the fluid, whose effect will affect the player that's in the world. * @return If the effect can be applied, and it is actually applied, returns true. */ @@ -89,8 +92,8 @@ public static boolean setFluidEffect(World world, EntityPlayer player, FluidTank /** * @param player Duh! * @param isWheelUp The direction in which the hose modes will switch. - * @param action The type of the action to be performed on the hose. - * Can be HOSE_SWITCH for mode or HOSE_TOGGLE for tank + * @param action The type of the action to be performed on the hose. Can be HOSE_SWITCH for mode or HOSE_TOGGLE + * for tank */ public static void switchHose(EntityPlayer player, boolean isWheelUp, boolean action) { if (Wearing.isHoldingHose(player)) { @@ -175,17 +178,13 @@ public static void leakArrow(EntityPlayer player, ItemStack bow, int charge) { entityarrow.canBePickedUp = 2; } else { /* - * From here, instead of leaking an arrow to the player inventory, which may be full and then it would be - * pointless, leak an arrow straight from the backpack ^_^ - * - * It could be possible to switch a whole stack with the player inventory, fire the arrow, and then - * switch back, but that's stupid. - * - * That's how you make a quiver (for vanilla bows at least, or anything that uses the events and vanilla - * arrows) Until we have an event that fires when a player consumes items in his/her inventory. - * - * I should make a pull request. Too lazy, though. - * */ + * From here, instead of leaking an arrow to the player inventory, which may be full and then it would + * be pointless, leak an arrow straight from the backpack ^_^ It could be possible to switch a whole + * stack with the player inventory, fire the arrow, and then switch back, but that's stupid. That's how + * you make a quiver (for vanilla bows at least, or anything that uses the events and vanilla arrows) + * Until we have an event that fires when a player consumes items in his/her inventory. I should make a + * pull request. Too lazy, though. + */ backpack.consumeInventoryItem(Items.arrow); backpack.dirtyInventory(); } @@ -242,9 +241,8 @@ public static void toggleSleepingBag(EntityPlayer player, boolean isTile, int cX } /** - * Adds vertical inertia to the movement in the Y axis of the player, and makes Newton's Laws cry. - * In other words, makes you jump higher. - * Also it plays a nice sound effect that will probably get annoying after a while. + * Adds vertical inertia to the movement in the Y axis of the player, and makes Newton's Laws cry. In other words, + * makes you jump higher. Also it plays a nice sound effect that will probably get annoying after a while. * * @param player - The player performing the jump. */ @@ -257,9 +255,7 @@ public static void pistonBootsJump(EntityPlayer player) { } public static void copterSoundAtLogin(EntityPlayer player) { - byte status = BackpackUtils.getWearableCompound( - BackpackProperty.get(player).getWearable()) - .getByte(TAG_STATUS); + byte status = BackpackUtils.getWearableCompound(BackpackProperty.get(player).getWearable()).getByte(TAG_STATUS); if (!player.worldObj.isRemote && status != ItemCopterPack.OFF_MODE) { ModNetwork.sendToNearby(new EntitySoundPacket.Message(EntitySoundPacket.COPTER_SOUND, player), player); @@ -267,15 +263,15 @@ public static void copterSoundAtLogin(EntityPlayer player) { } public static void jetpackSoundAtLogin(EntityPlayer player) { - boolean isBoiling = BackpackUtils.getWearableCompound( - BackpackProperty.get(player).getWearable()) + boolean isBoiling = BackpackUtils.getWearableCompound(BackpackProperty.get(player).getWearable()) .getBoolean("boiling"); if (!player.worldObj.isRemote && isBoiling) { // ModNetwork.sendToNearby(new EntitySoundPacket.Message(EntitySoundPacket.BOILING_BUBBLES, player), // player); //TODO difference? ModNetwork.net.sendTo( - new EntitySoundPacket.Message(EntitySoundPacket.BOILING_BUBBLES, player), (EntityPlayerMP) player); + new EntitySoundPacket.Message(EntitySoundPacket.BOILING_BUBBLES, player), + (EntityPlayerMP) player); } } @@ -292,7 +288,8 @@ public static void toggleCopterPack(EntityPlayer player, ItemStack copter, byte actionPerformed = true; if (!player.worldObj.isRemote) { ModNetwork.sendToNearby( - new EntitySoundPacket.Message(EntitySoundPacket.COPTER_SOUND, player), player); + new EntitySoundPacket.Message(EntitySoundPacket.COPTER_SOUND, player), + player); } } else { newMode = ItemCopterPack.OFF_MODE; diff --git a/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java b/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java index 8707fd30..4336c1bf 100644 --- a/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/config/ConfigHandler.java @@ -1,10 +1,13 @@ package com.darkona.adventurebackpack.config; +import java.io.File; + +import net.minecraftforge.common.config.Configuration; + import com.darkona.adventurebackpack.reference.ModInfo; + import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import java.io.File; -import net.minecraftforge.common.config.Configuration; /** * Created on 10/10/2014. @@ -12,6 +15,7 @@ * @author Javier Darkona */ public class ConfigHandler { + public static Configuration config; public static boolean allowSoulBound = true; @@ -50,22 +54,9 @@ public class ConfigHandler { public static boolean enableItemFilters = false; public static String[] forbiddenDimensions; public static String[] copterFuels; - private static String[] defaultFuels = { - "biodiesel, 1.0", - "biofuel, 1.0", - "bioethanol, 1.5", - "creosote, 7.0", - "fuel, 0.8", - "lava, 5.0", - "liquid_light_oil, 3.0", - "liquid_medium_oil, 3.0", - "liquid_heavy_oil, 3.0", - "liquid_light_fuel, 1.0", - "liquid_heavy_fuel, 1.3", - "nitrofuel, 0.4", - "oil, 3.0", - "rocket_fuel, 0.8" - }; + private static String[] defaultFuels = { "biodiesel, 1.0", "biofuel, 1.0", "bioethanol, 1.5", "creosote, 7.0", + "fuel, 0.8", "lava, 5.0", "liquid_light_oil, 3.0", "liquid_medium_oil, 3.0", "liquid_heavy_oil, 3.0", + "liquid_light_fuel, 1.0", "liquid_heavy_fuel, 1.3", "nitrofuel, 0.4", "oil, 3.0", "rocket_fuel, 0.8" }; public static String[] nameLocalized; public static String[] nameInternalID; @@ -111,23 +102,23 @@ public static void init(File configFile) { private static void loadConfiguration() { // Gameplay - allowSoulBound = - config.getBoolean("Allow SoulBound", "gameplay", true, "Allow SoulBound enchant on wearable packs"); + allowSoulBound = config + .getBoolean("Allow SoulBound", "gameplay", true, "Allow SoulBound enchant on wearable packs"); backpackAbilities = config.getBoolean( "Backpack Abilities", "gameplay", true, "Allow the backpacks to execute their special abilities, or be only cosmetic (Doesn't affect lightning transformation) Must be " + "disabled in both Client and Server to work properly"); - backpackDeathPlace = - config.getBoolean("Backpack Death Place", "gameplay", true, "Place backpacks as a block when you die?"); + backpackDeathPlace = config + .getBoolean("Backpack Death Place", "gameplay", true, "Place backpacks as a block when you die?"); fixLead = config.getBoolean( "Fix Vanilla Lead", "gameplay", true, "Fix the vanilla Lead? (Checks mobs falling on a leash to not die of fall damage if they're not falling so fast)"); - enableCampfireSpawn = config.getBoolean( - "Enable Campfire Spawn", "gameplay", false, "Enable/Disable ability to spawn at campfire"); + enableCampfireSpawn = config + .getBoolean("Enable Campfire Spawn", "gameplay", false, "Enable/Disable ability to spawn at campfire"); enableHoseDrink = config.getBoolean("Enable Hose Drink", "gameplay", true, "Enable/Disable hose drink mode"); enableToolsCycling = config.getBoolean("Enable Tools Cycling", "gameplay", true, "Enable/Disable tool cycling"); portableSleepingBag = config.getBoolean( @@ -155,24 +146,30 @@ private static void loadConfiguration() { false, "Enable durability bar showing fullness of backpacks inventory"); enableTemperatureBar = config.getBoolean( - "Enable Temperature Bar", "graphics", false, "Enable durability bar showing temperature of jetpack"); + "Enable Temperature Bar", + "graphics", + false, + "Enable durability bar showing temperature of jetpack"); enableToolsRender = config.getBoolean( - "Enable Tools Render", "graphics", true, "Enable rendering for tools in the backpack tool slots"); + "Enable Tools Render", + "graphics", + true, + "Enable rendering for tools in the backpack tool slots"); tanksHoveringText = config.getBoolean("Hovering Text", "graphics", true, "Show hovering text on fluid tanks?"); // Graphics.Status - statusOverlay = - config.getBoolean("Enable Overlay", "graphics.status", true, "Show player status effects on screen?"); + statusOverlay = config + .getBoolean("Enable Overlay", "graphics.status", true, "Show player status effects on screen?"); statusOverlayLeft = config.getBoolean( "Stick To Left", "graphics.status", true, "Stick to left? Icons will appears from left to right. If false: stick to right, icons will appears from right to left"); statusOverlayTop = config.getBoolean("Stick To Top", "graphics.status", true, "Stick to top?"); - statusOverlayIndentH = config.getInt( - "Indent Horizontal", "graphics.status", 2, 0, 1000, "Horizontal indent from the window border"); - statusOverlayIndentV = config.getInt( - "Indent Vertical", "graphics.status", 2, 0, 500, "Vertical indent from the window border"); + statusOverlayIndentH = config + .getInt("Indent Horizontal", "graphics.status", 2, 0, 1000, "Horizontal indent from the window border"); + statusOverlayIndentV = config + .getInt("Indent Vertical", "graphics.status", 2, 0, 500, "Vertical indent from the window border"); statusOverlayThaumcraft = config.getBoolean( "Respect Thaumcraft", "graphics.status", @@ -181,13 +178,16 @@ private static void loadConfiguration() { // Graphics.Tanks tanksOverlay = config.getBoolean( - "Enable Overlay", "graphics.tanks", true, "Show the different wearable overlays on screen?"); + "Enable Overlay", + "graphics.tanks", + true, + "Show the different wearable overlays on screen?"); tanksOverlayRight = config.getBoolean("Stick To Right", "graphics.tanks", true, "Stick to right?"); tanksOverlayBottom = config.getBoolean("Stick To Bottom", "graphics.tanks", true, "Stick to bottom?"); - tanksOverlayIndentH = config.getInt( - "Indent Horizontal", "graphics.tanks", 2, 0, 1000, "Horizontal indent from the window border"); - tanksOverlayIndentV = - config.getInt("Indent Vertical", "graphics.tanks", 1, 0, 500, "Vertical indent from the window border"); + tanksOverlayIndentH = config + .getInt("Indent Horizontal", "graphics.tanks", 2, 0, 1000, "Horizontal indent from the window border"); + tanksOverlayIndentV = config + .getInt("Indent Vertical", "graphics.tanks", 1, 0, 500, "Vertical indent from the window border"); // Sound allowSoundCopter = config.getBoolean( @@ -203,8 +203,8 @@ private static void loadConfiguration() { allowSoundPiston = config.getBoolean("Piston Boots", "sound", true, "Allow playing the PistonBoots sound"); // Items - enableItemFilters = - config.getBoolean("Enable Item Filters", "items", true, "Enable filters from Disallow category"); + enableItemFilters = config + .getBoolean("Enable Item Filters", "items", true, "Enable filters from Disallow category"); forbiddenDimensions = config.getStringList( "Forbidden Dimensions", "items", @@ -240,43 +240,64 @@ private static void loadConfiguration() { // Items.Recipes consumeDragonEgg = config.getBoolean( - "Consume Dragon Egg", "items.recipes", false, "Consume Dragon Egg when Dragon backpack crafted?"); + "Consume Dragon Egg", + "items.recipes", + false, + "Consume Dragon Egg when Dragon backpack crafted?"); recipeAdventuresSet = config.getBoolean( - "Adventures Set", "items.recipes", true, "Enable/Disable recipe for Adventure's Hat, Suit and Pants"); - recipeInflatableBoat = config.getBoolean( - "Inflatable Boat", "items.recipes", true, "Enable/Disable recipe for Inflatable Boat"); + "Adventures Set", + "items.recipes", + true, + "Enable/Disable recipe for Adventure's Hat, Suit and Pants"); + recipeInflatableBoat = config + .getBoolean("Inflatable Boat", "items.recipes", true, "Enable/Disable recipe for Inflatable Boat"); recipeInflatableBoatM = config.getBoolean( "Inflatable Boat Motorized", "items.recipes", false, "Enable/Disable recipe for Inflatable Boat (motorized). For aesthetic only, not fully implemented (yet?)"); - recipeClockCrossbow = config.getBoolean( - "Clockwork Crossbow", "items.recipes", true, "Enable/Disable Clockwork Crossbow recipe"); + recipeClockCrossbow = config + .getBoolean("Clockwork Crossbow", "items.recipes", true, "Enable/Disable Clockwork Crossbow recipe"); recipeCopterPack = config.getBoolean("Copter Pack", "items.recipes", true, "Enable/Disable CopterPack recipe"); - recipeCoalJetpack = - config.getBoolean("Coal Jetpack", "items.recipes", true, "Enable/Disable CoalJetpack recipe"); - recipePitonBoots = - config.getBoolean("Piston Boots", "items.recipes", true, "Enable/Disable PistonBoots recipe"); + recipeCoalJetpack = config + .getBoolean("Coal Jetpack", "items.recipes", true, "Enable/Disable CoalJetpack recipe"); + recipePitonBoots = config + .getBoolean("Piston Boots", "items.recipes", true, "Enable/Disable PistonBoots recipe"); recipeSaddle = config.getBoolean("Saddle", "items.recipes", true, "Add recipe for saddle?"); recipeMachete = config.getBoolean("Machete", "items.recipes", true, "Enable/Disable Machete recipe"); // Items.Settings - pistonBootsAutoStep = config.getBoolean( - "Piston Boots Auto Step", "items.settings", true, "Allow Piston Boots auto step blocks"); - pistonBootsJumpHeight = config.getInt( - "Piston Boots Jump Height", "items.settings", 3, 1, 8, "Piston Boots jump height in blocks"); - pistonBootsSprintBoost = config.getInt( - "Piston Boots Sprint", "items.settings", 1, 0, 4, "Piston Boots sprint boost. 0 - disable"); + pistonBootsAutoStep = config + .getBoolean("Piston Boots Auto Step", "items.settings", true, "Allow Piston Boots auto step blocks"); + pistonBootsJumpHeight = config + .getInt("Piston Boots Jump Height", "items.settings", 3, 1, 8, "Piston Boots jump height in blocks"); + pistonBootsSprintBoost = config + .getInt("Piston Boots Sprint", "items.settings", 1, 0, 4, "Piston Boots sprint boost. 0 - disable"); dragonBackpackRegen = config.getInt( - "Dragon Regeneration", "items.settings", 1, 0, 4, "Dragon Backpack regeneration level. 0 - disable"); - dragonBackpackDamage = config.getInt( - "Dragon Damage Boost", "items.settings", 2, 0, 4, "Dragon Backpack damage boost. 0 - disable"); - rainbowBackpackSpeed = - config.getInt("Rainbow Speed", "items.settings", 1, 0, 4, "Rainbow Backpack speed boost. 0 - disable"); + "Dragon Regeneration", + "items.settings", + 1, + 0, + 4, + "Dragon Backpack regeneration level. 0 - disable"); + dragonBackpackDamage = config + .getInt("Dragon Damage Boost", "items.settings", 2, 0, 4, "Dragon Backpack damage boost. 0 - disable"); + rainbowBackpackSpeed = config + .getInt("Rainbow Speed", "items.settings", 1, 0, 4, "Rainbow Backpack speed boost. 0 - disable"); rainbowBackpackSSpeed = config.getInt( - "Rainbow Special Speed", "items.settings", 3, 0, 4, "Rainbow Backpack special speed. 0 - disable"); + "Rainbow Special Speed", + "items.settings", + 3, + 0, + 4, + "Rainbow Backpack special speed. 0 - disable"); rainbowBackpackSJump = config.getInt( - "Rainbow Special Jump", "items.settings", 1, 0, 4, "Rainbow Backpack special jump. 0 - disable"); + "Rainbow Special Jump", + "items.settings", + 1, + 0, + 4, + "Rainbow Backpack special jump. 0 - disable"); // WorldGen allowBatGen = config.getBoolean( @@ -285,7 +306,10 @@ private static void loadConfiguration() { true, "Allow generation of Bat Backpacks in dungeon and mineshaft loot. It cannot be obtained by crafting"); allowBonusGen = config.getBoolean( - "Bonus Backpack", "worldgen", false, "Include a Standard Adventure Backpack in bonus chest?"); + "Bonus Backpack", + "worldgen", + false, + "Include a Standard Adventure Backpack in bonus chest?"); allowGolemGen = config.getBoolean( "IronGolem Backpacks", "worldgen", @@ -305,8 +329,8 @@ private static void loadConfiguration() { 0, 500, "Boss health bar indent from top border, 0 = standard Forge render"); - chatSpam = - config.getBoolean("Chat Spam", "experimental", true, "Set this to false to greatly reduce chat spam."); + chatSpam = config + .getBoolean("Chat Spam", "experimental", true, "Set this to false to greatly reduce chat spam."); if (config.hasChanged()) { config.save(); diff --git a/src/main/java/com/darkona/adventurebackpack/config/Keybindings.java b/src/main/java/com/darkona/adventurebackpack/config/Keybindings.java index b6d8d90d..c29c7514 100644 --- a/src/main/java/com/darkona/adventurebackpack/config/Keybindings.java +++ b/src/main/java/com/darkona/adventurebackpack/config/Keybindings.java @@ -2,6 +2,7 @@ import net.minecraft.client.settings.GameSettings; import net.minecraft.client.settings.KeyBinding; + import org.lwjgl.input.Keyboard; /** @@ -10,6 +11,7 @@ * @author Darkona */ public class Keybindings { + private static final String KEYS_CATEGORY = "keys.adventureBackpack.category"; private static final String OPEN_INVENTORY = "keys.adventureBackpack.openInventory"; private static final String TOGGLE_ACTIONS = "keys.adventureBackpack.toggleActions"; diff --git a/src/main/java/com/darkona/adventurebackpack/entity/EntityBolt.java b/src/main/java/com/darkona/adventurebackpack/entity/EntityBolt.java index 357e98f5..02a86513 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/EntityBolt.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/EntityBolt.java @@ -11,6 +11,7 @@ * @author Darkona */ public class EntityBolt extends Entity implements IProjectile { + public EntityBolt(World world) { super(world); } diff --git a/src/main/java/com/darkona/adventurebackpack/entity/EntityCrossbowProjectile.java b/src/main/java/com/darkona/adventurebackpack/entity/EntityCrossbowProjectile.java index 8b611e24..c52d24f4 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/EntityCrossbowProjectile.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/EntityCrossbowProjectile.java @@ -11,6 +11,7 @@ * @author Darkona */ public class EntityCrossbowProjectile extends Entity implements IProjectile { + public EntityCrossbowProjectile(World p_i1776_1_) { super(p_i1776_1_); } @@ -34,6 +35,6 @@ protected void writeEntityToNBT(NBTTagCompound p_70014_1_) {} * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. */ @Override - public void setThrowableHeading( - double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_) {} + public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, + float p_70186_8_) {} } diff --git a/src/main/java/com/darkona/adventurebackpack/entity/EntityFriendlySpider.java b/src/main/java/com/darkona/adventurebackpack/entity/EntityFriendlySpider.java index 6811bf53..2c28cab2 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/EntityFriendlySpider.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/EntityFriendlySpider.java @@ -1,8 +1,7 @@ package com.darkona.adventurebackpack.entity; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.Wearing; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; @@ -25,12 +24,16 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 11/01/2015 * * @author Darkona */ public class EntityFriendlySpider extends EntityCreature { + private float prevRearingAmount; private int jumpTicks; private EntityPlayer owner; @@ -347,8 +350,8 @@ public void moveEntityWithHeading(float strafe, float forward) { this.jumpMovementFactor = this.getAIMoveSpeed() * 0.2F; if (!this.worldObj.isRemote) { - this.setAIMoveSpeed((float) this.getEntityAttribute(SharedMonsterAttributes.movementSpeed) - .getAttributeValue()); + this.setAIMoveSpeed( + (float) this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()); super.moveEntityWithHeading(strafe, forward); } @@ -391,12 +394,13 @@ public void updateRiderPosition() { } public void spiderJump() // TODO - { + { this.getJumpHelper().setJumping(); // this.getJumpHelper().doJump(); } public static class GroupData implements IEntityLivingData { + public int field_111105_a; private static final String __OBFID = "CL_00001700"; diff --git a/src/main/java/com/darkona/adventurebackpack/entity/EntityInflatableBoat.java b/src/main/java/com/darkona/adventurebackpack/entity/EntityInflatableBoat.java index 49e36bd5..dc9e1fd7 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/EntityInflatableBoat.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/EntityInflatableBoat.java @@ -1,11 +1,7 @@ package com.darkona.adventurebackpack.entity; -import com.darkona.adventurebackpack.init.ModItems; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import io.netty.buffer.ByteBuf; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; @@ -23,12 +19,20 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.init.ModItems; + +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; + /** * Created on 05/01/2015 * * @author Darkona */ -public class EntityInflatableBoat extends EntityBoat implements /*IInventoryTanks, */ IEntityAdditionalSpawnData { +public class EntityInflatableBoat extends EntityBoat implements /* IInventoryTanks, */ IEntityAdditionalSpawnData { + private FluidTank fuelTank; private boolean isBoatEmpty; private double speedMultiplier; @@ -105,7 +109,12 @@ public void onUpdate() { double d1 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (i + 0) / b0 - 0.125D; double d3 = this.boundingBox.minY + (this.boundingBox.maxY - this.boundingBox.minY) * (i + 1) / b0 - 0.125D; AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox( - this.boundingBox.minX, d1, this.boundingBox.minZ, this.boundingBox.maxX, d3, this.boundingBox.maxZ); + this.boundingBox.minX, + d1, + this.boundingBox.minZ, + this.boundingBox.maxX, + d3, + this.boundingBox.maxZ); if (this.worldObj.isAABBInMaterial(axisalignedbb, Material.water)) { d0 += 1.0D / (double) b0; @@ -131,12 +140,24 @@ public void onUpdate() { d8 = this.posX - d2 * d5 * 0.8D + d4 * d6; d9 = this.posZ - d4 * d5 * 0.8D - d2 * d6; this.worldObj.spawnParticle( - "splash", d8, this.posY - 0.125D, d9, this.motionX, this.motionY, this.motionZ); + "splash", + d8, + this.posY - 0.125D, + d9, + this.motionX, + this.motionY, + this.motionZ); } else { d8 = this.posX + d2 + d4 * d5 * 0.7D; d9 = this.posZ + d4 - d2 * d5 * 0.7D; this.worldObj.spawnParticle( - "splash", d8, this.posY - 0.125D, d9, this.motionX, this.motionY, this.motionZ); + "splash", + d8, + this.posY - 0.125D, + d9, + this.motionX, + this.motionY, + this.motionZ); } } } @@ -187,12 +208,10 @@ public void onUpdate() { if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase) this.riddenByEntity; float f = this.riddenByEntity.rotationYaw + -entitylivingbase.moveStrafing * 90.0F; - this.motionX += -Math.sin((double) (f * (float) Math.PI / 180.0F)) - * this.speedMultiplier + this.motionX += -Math.sin((double) (f * (float) Math.PI / 180.0F)) * this.speedMultiplier * (double) entitylivingbase.moveForward * 0.05000000074505806D; - this.motionZ += Math.cos((double) (f * (float) Math.PI / 180.0F)) - * this.speedMultiplier + this.motionZ += Math.cos((double) (f * (float) Math.PI / 180.0F)) * this.speedMultiplier * (double) entitylivingbase.moveForward * 0.05000000074505806D; } @@ -248,29 +267,12 @@ public void onUpdate() { this.moveEntity(this.motionX, this.motionY, this.motionZ); - /* if (this.isCollidedHorizontally && d10 > 0.2D) - { - if (!this.worldObj.isRemote && !this.isDead) - { - this.setDead(); - - for (l = 0; l < 3; ++l) - { - this.func_145778_a(Item.getItemFromBlock(Blocks.planks), 1, 0.0F); - } - - for (l = 0; l < 2; ++l) - { - this.func_145778_a(Items.stick, 1, 0.0F); - } - } - } - else - { - this.motionX *= 0.9900000095367432D; - this.motionY *= 0.949999988079071D; - this.motionZ *= 0.9900000095367432D; - }*/ + /* + * if (this.isCollidedHorizontally && d10 > 0.2D) { if (!this.worldObj.isRemote && !this.isDead) { + * this.setDead(); for (l = 0; l < 3; ++l) { this.func_145778_a(Item.getItemFromBlock(Blocks.planks), 1, + * 0.0F); } for (l = 0; l < 2; ++l) { this.func_145778_a(Items.stick, 1, 0.0F); } } } else { this.motionX *= + * 0.9900000095367432D; this.motionY *= 0.949999988079071D; this.motionZ *= 0.9900000095367432D; } + */ this.rotationPitch = 0.0F; d4 = (double) this.rotationYaw; @@ -296,7 +298,8 @@ public void onUpdate() { if (!this.worldObj.isRemote) { List list = this.worldObj.getEntitiesWithinAABBExcludingEntity( - this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); + this, + this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D)); if (list != null && !list.isEmpty()) { for (int k1 = 0; k1 < list.size(); ++k1) { @@ -353,8 +356,7 @@ public EntityItem func_145778_a(Item item, int quantity, float someFloat) { @Override public boolean interactFirst(EntityPlayer p_130002_1_) { if (inflation < 1.0f) return false; - if (this.riddenByEntity != null - && this.riddenByEntity instanceof EntityPlayer + if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != p_130002_1_) { return true; } else { diff --git a/src/main/java/com/darkona/adventurebackpack/entity/ai/AvoidEntitySelector.java b/src/main/java/com/darkona/adventurebackpack/entity/ai/AvoidEntitySelector.java index b47a553f..126a1967 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/ai/AvoidEntitySelector.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/ai/AvoidEntitySelector.java @@ -4,6 +4,7 @@ import net.minecraft.entity.Entity; public class AvoidEntitySelector implements IEntitySelector { + final EntityAIAvoidPlayerWithBackpack entityAvoiderAI; AvoidEntitySelector(EntityAIAvoidPlayerWithBackpack par1EntityAIAvoidEntity) { @@ -12,9 +13,7 @@ public class AvoidEntitySelector implements IEntitySelector { @Override public boolean isEntityApplicable(Entity par1Entity) { - return par1Entity.isEntityAlive() - && EntityAIAvoidPlayerWithBackpack.func_98217_a(this.entityAvoiderAI) - .getEntitySenses() - .canSee(par1Entity); + return par1Entity.isEntityAlive() && EntityAIAvoidPlayerWithBackpack.func_98217_a(this.entityAvoiderAI) + .getEntitySenses().canSee(par1Entity); } } diff --git a/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIAvoidPlayerWithBackpack.java b/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIAvoidPlayerWithBackpack.java index 7b3c7be7..3a643a9c 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIAvoidPlayerWithBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIAvoidPlayerWithBackpack.java @@ -1,8 +1,7 @@ package com.darkona.adventurebackpack.entity.ai; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.Wearing; import java.util.List; + import net.minecraft.command.IEntitySelector; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCreature; @@ -14,10 +13,14 @@ import net.minecraft.pathfinding.PathNavigate; import net.minecraft.util.Vec3; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created by Darkona on 12/10/2014. */ public class EntityAIAvoidPlayerWithBackpack extends EntityAIBase { + private BackpackTypes type; public final IEntitySelector field_98218_a = new AvoidEntitySelector(this); @@ -47,13 +50,8 @@ public class EntityAIAvoidPlayerWithBackpack extends EntityAIBase { */ private Class targetEntityClass; - public EntityAIAvoidPlayerWithBackpack( - EntityCreature par1EntityCreature, - Class par2Class, - float par3, - double par4, - double par6, - BackpackTypes type) { + public EntityAIAvoidPlayerWithBackpack(EntityCreature par1EntityCreature, Class par2Class, float par3, double par4, + double par6, BackpackTypes type) { this.theEntity = par1EntityCreature; this.targetEntityClass = par2Class; this.distanceFromEntity = par3; @@ -103,11 +101,12 @@ public boolean shouldExecute() { return false; } else if (this.closestLivingEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) { - return false; - } else { - this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord); - return this.entityPathEntity != null && this.entityPathEntity.isDestinationSame(vec3); - } + return false; + } else { + this.entityPathEntity = this.entityPathNavigate + .getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord); + return this.entityPathEntity != null && this.entityPathEntity.isDestinationSame(vec3); + } } return false; } diff --git a/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIHorseFollowOwner.java b/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIHorseFollowOwner.java index c3ad6137..a0541ebc 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIHorseFollowOwner.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/ai/EntityAIHorseFollowOwner.java @@ -1,20 +1,23 @@ package com.darkona.adventurebackpack.entity.ai; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.Wearing; import java.util.UUID; + import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.pathfinding.PathNavigate; import net.minecraft.world.World; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.Wearing; + /** * Created on 09/01/2015 * * @author Darkona */ public class EntityAIHorseFollowOwner extends EntityAIBase { + private EntityHorse theHorse; private EntityPlayer theOwner; World theWorld; @@ -61,8 +64,7 @@ public boolean shouldExecute() { @Override public boolean continueExecuting() { - return (Wearing.isWearingTheRightBackpack(theOwner, BackpackTypes.HORSE) - && !this.petPathfinder.noPath() + return (Wearing.isWearingTheRightBackpack(theOwner, BackpackTypes.HORSE) && !this.petPathfinder.noPath() && theHorse.getDistanceSqToEntity(theOwner) > this.maxDist * this.maxDist * 2); } diff --git a/src/main/java/com/darkona/adventurebackpack/entity/fx/SteamFX.java b/src/main/java/com/darkona/adventurebackpack/entity/fx/SteamFX.java index ba099c59..20aeba77 100644 --- a/src/main/java/com/darkona/adventurebackpack/entity/fx/SteamFX.java +++ b/src/main/java/com/darkona/adventurebackpack/entity/fx/SteamFX.java @@ -1,11 +1,12 @@ package com.darkona.adventurebackpack.entity.fx; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 19/01/2015 * @@ -13,6 +14,7 @@ */ @SideOnly(Side.CLIENT) public class SteamFX extends EntityFX { + private float smokeParticleScale; public SteamFX(World world, double x, double y, double z, double velX, double velY, double velZ) { @@ -39,8 +41,8 @@ public SteamFX(World world, double x, double y, double z, double velX, double ve } @Override - public void renderParticle( - Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7) { + public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, + float par7) { float age = (this.particleAge + par2) / this.particleMaxAge * 32.0F; if (age < 0.0F) { age = 0.0F; diff --git a/src/main/java/com/darkona/adventurebackpack/events/WearableEvent.java b/src/main/java/com/darkona/adventurebackpack/events/WearableEvent.java index 7f70e5b8..3c766dab 100644 --- a/src/main/java/com/darkona/adventurebackpack/events/WearableEvent.java +++ b/src/main/java/com/darkona/adventurebackpack/events/WearableEvent.java @@ -10,6 +10,7 @@ * @author Darkona */ public class WearableEvent extends PlayerEvent { + public final ItemStack wearable; public WearableEvent(EntityPlayer player, ItemStack wearable) { @@ -18,12 +19,14 @@ public WearableEvent(EntityPlayer player, ItemStack wearable) { } public static class UnequipWearableEvent extends WearableEvent { + public UnequipWearableEvent(EntityPlayer player, ItemStack wearable) { super(player, wearable); } } public static class EquipWearableEvent extends WearableEvent { + public EquipWearableEvent(EntityPlayer player, ItemStack wearable) { super(player, wearable); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/FluidEffectRegistry.java b/src/main/java/com/darkona/adventurebackpack/fluids/FluidEffectRegistry.java index 192889e2..ffffc16e 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/FluidEffectRegistry.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/FluidEffectRegistry.java @@ -1,6 +1,14 @@ package com.darkona.adventurebackpack.fluids; +import java.util.ArrayList; +import java.util.Map; + +import net.minecraft.entity.Entity; +import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; + import adventurebackpack.api.FluidEffect; + import com.darkona.adventurebackpack.fluids.effects.LavaEffect; import com.darkona.adventurebackpack.fluids.effects.MelonJuiceEffect; import com.darkona.adventurebackpack.fluids.effects.MilkEffect; @@ -9,11 +17,6 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.Map; -import net.minecraft.entity.Entity; -import net.minecraft.world.World; -import net.minecraftforge.fluids.Fluid; /** * Created on 12/10/2014 @@ -21,6 +24,7 @@ * @author Darkona */ public class FluidEffectRegistry { + static BiMap EFFECT_REGISTRY = HashBiMap.create(); public static FluidEffect LAVA_EFFECT; @@ -43,8 +47,12 @@ public static int registerFluidEffect(FluidEffect effect) { if (!EFFECT_REGISTRY.containsKey(className) && effect.fluid != null) { EFFECT_REGISTRY.put(className, effect); effect.setEffectID(effectIDCounter); - LogHelper.info("Registered the class " + className + " as a FluidEffect for " + effect.fluid.getName() - + " with the ID " + effectIDCounter); + LogHelper.info( + "Registered the class " + className + + " as a FluidEffect for " + + effect.fluid.getName() + + " with the ID " + + effectIDCounter); effectIDCounter++; return effectIDCounter; } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/FluidMelonJuice.java b/src/main/java/com/darkona/adventurebackpack/fluids/FluidMelonJuice.java index d11dd049..a65c3d5f 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/FluidMelonJuice.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/FluidMelonJuice.java @@ -1,15 +1,17 @@ package com.darkona.adventurebackpack.fluids; -import com.darkona.adventurebackpack.client.Icons; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import com.darkona.adventurebackpack.client.Icons; + /** * Created by Darkona on 12/10/2014. */ public class FluidMelonJuice extends Fluid { + public FluidMelonJuice() { super("melonJuice"); setUnlocalizedName("melonJuice"); diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/FluidMilk.java b/src/main/java/com/darkona/adventurebackpack/fluids/FluidMilk.java index 86154f16..119bf7e0 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/FluidMilk.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/FluidMilk.java @@ -1,17 +1,19 @@ package com.darkona.adventurebackpack.fluids; -import com.darkona.adventurebackpack.client.Icons; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import com.darkona.adventurebackpack.client.Icons; + /** * Created on 12/10/2014. * * @author Javier Darkona */ public class FluidMilk extends Fluid { + public FluidMilk() { super("milk"); setDensity(1200); diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/FluidMushroomStew.java b/src/main/java/com/darkona/adventurebackpack/fluids/FluidMushroomStew.java index c99e41c7..35aec1d9 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/FluidMushroomStew.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/FluidMushroomStew.java @@ -1,17 +1,19 @@ package com.darkona.adventurebackpack.fluids; -import com.darkona.adventurebackpack.client.Icons; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; +import com.darkona.adventurebackpack.client.Icons; + /** * Created on 11/01/2015 * * @author Darkona */ public class FluidMushroomStew extends Fluid { + public FluidMushroomStew() { super("mushroomStew"); setDensity(1200); diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/TankWrapper.java b/src/main/java/com/darkona/adventurebackpack/fluids/TankWrapper.java index bbb7c20d..a5b88396 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/TankWrapper.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/TankWrapper.java @@ -10,6 +10,7 @@ * @author Darkona */ public class TankWrapper extends FluidTank { + public TankWrapper(int capacity) { super(capacity); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/effects/FuelEffect.java b/src/main/java/com/darkona/adventurebackpack/fluids/effects/FuelEffect.java index cc8e16a1..e9ab343e 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/effects/FuelEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/effects/FuelEffect.java @@ -1,7 +1,5 @@ package com.darkona.adventurebackpack.fluids.effects; -import adventurebackpack.api.FluidEffect; -import com.darkona.adventurebackpack.util.Utils; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; @@ -9,12 +7,17 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import adventurebackpack.api.FluidEffect; + +import com.darkona.adventurebackpack.util.Utils; + /** * Created on 12/10/2014 * * @author Darkona */ public class FuelEffect extends FluidEffect { + public FuelEffect() { super(FluidRegistry.getFluid("fuel"), 20); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/effects/LavaEffect.java b/src/main/java/com/darkona/adventurebackpack/fluids/effects/LavaEffect.java index 04f3072d..1e497f21 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/effects/LavaEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/effects/LavaEffect.java @@ -1,6 +1,5 @@ package com.darkona.adventurebackpack.fluids.effects; -import adventurebackpack.api.FluidEffect; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; @@ -8,10 +7,13 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import adventurebackpack.api.FluidEffect; + /** * Created by Darkona on 12/10/2014. */ public class LavaEffect extends FluidEffect { + public LavaEffect() { super(FluidRegistry.LAVA, 15); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/effects/MelonJuiceEffect.java b/src/main/java/com/darkona/adventurebackpack/fluids/effects/MelonJuiceEffect.java index 43ff0666..4bea85d5 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/effects/MelonJuiceEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/effects/MelonJuiceEffect.java @@ -1,18 +1,21 @@ package com.darkona.adventurebackpack.fluids.effects; -import adventurebackpack.api.FluidEffect; -import com.darkona.adventurebackpack.init.ModFluids; -import com.darkona.adventurebackpack.util.Utils; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; +import adventurebackpack.api.FluidEffect; + +import com.darkona.adventurebackpack.init.ModFluids; +import com.darkona.adventurebackpack.util.Utils; + /** * Created by Darkona on 12/10/2014. */ public class MelonJuiceEffect extends FluidEffect { + public MelonJuiceEffect() { super(ModFluids.melonJuice, 30); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/effects/MilkEffect.java b/src/main/java/com/darkona/adventurebackpack/fluids/effects/MilkEffect.java index f1103e45..330b3c0d 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/effects/MilkEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/effects/MilkEffect.java @@ -1,17 +1,19 @@ package com.darkona.adventurebackpack.fluids.effects; -import adventurebackpack.api.FluidEffect; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import adventurebackpack.api.FluidEffect; + /** * Created on 12/10/2014. * * @author Javier Darkona */ public class MilkEffect extends FluidEffect { + public MilkEffect() { super(FluidRegistry.getFluid("milk"), 7); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/effects/MushroomStewEffect.java b/src/main/java/com/darkona/adventurebackpack/fluids/effects/MushroomStewEffect.java index d5bae204..d37e6149 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/effects/MushroomStewEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/effects/MushroomStewEffect.java @@ -1,17 +1,19 @@ package com.darkona.adventurebackpack.fluids.effects; -import adventurebackpack.api.FluidEffect; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import adventurebackpack.api.FluidEffect; + /** * Created on 11/01/2015 * * @author Darkona */ public class MushroomStewEffect extends FluidEffect { + public MushroomStewEffect() { super(FluidRegistry.getFluid("mushroomstew")); } diff --git a/src/main/java/com/darkona/adventurebackpack/fluids/effects/OilEffect.java b/src/main/java/com/darkona/adventurebackpack/fluids/effects/OilEffect.java index dc79bd61..c09b6b78 100644 --- a/src/main/java/com/darkona/adventurebackpack/fluids/effects/OilEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/fluids/effects/OilEffect.java @@ -1,6 +1,5 @@ package com.darkona.adventurebackpack.fluids.effects; -import adventurebackpack.api.FluidEffect; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; @@ -8,10 +7,13 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import adventurebackpack.api.FluidEffect; + /** * Created by Darkona on 12/10/2014. */ public class OilEffect extends FluidEffect { + public OilEffect() { super(FluidRegistry.getFluid("oil"), 20); } diff --git a/src/main/java/com/darkona/adventurebackpack/handlers/ClientEventHandler.java b/src/main/java/com/darkona/adventurebackpack/handlers/ClientEventHandler.java index d4b38462..abc89db8 100644 --- a/src/main/java/com/darkona/adventurebackpack/handlers/ClientEventHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/handlers/ClientEventHandler.java @@ -1,5 +1,12 @@ package com.darkona.adventurebackpack.handlers; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityClientPlayerMP; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.MouseEvent; + import com.darkona.adventurebackpack.common.ServerActions; import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.init.ModItems; @@ -8,15 +15,10 @@ import com.darkona.adventurebackpack.network.CycleToolPacket; import com.darkona.adventurebackpack.reference.BackpackTypes; import com.darkona.adventurebackpack.util.Wearing; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityClientPlayerMP; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.client.event.MouseEvent; /** * Created on 17/10/2014 @@ -24,10 +26,11 @@ * @author Darkona */ public class ClientEventHandler { + @SubscribeEvent @SideOnly(Side.CLIENT) public void mouseWheelDetect(MouseEvent event) { - /*Special thanks go to MachineMuse, both for inspiration and the event. God bless you girl.*/ + /* Special thanks go to MachineMuse, both for inspiration and the event. God bless you girl. */ EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; if (event.dwheel == 0 || player == null || player.isDead || !player.isSneaking()) return; @@ -38,19 +41,19 @@ public void mouseWheelDetect(MouseEvent event) { boolean isWheelUp = event.dwheel > 0; Item theItem = heldItem.getItem(); - if (ConfigHandler.enableToolsCycling - && !Wearing.getWearingBackpackInv(player).getDisableCycling() - && SlotTool.isValidTool(heldItem) - || BackpackTypes.getType(backpack) == BackpackTypes.SKELETON - && theItem.equals(Items.bow)) // TODO add bow case to server + if (ConfigHandler.enableToolsCycling && !Wearing.getWearingBackpackInv(player).getDisableCycling() + && SlotTool.isValidTool(heldItem) + || BackpackTypes.getType(backpack) == BackpackTypes.SKELETON && theItem.equals(Items.bow)) // TODO add + // bow case + // to server { - ModNetwork.net.sendToServer( - new CycleToolPacket.CycleToolMessage(isWheelUp, CycleToolPacket.CYCLE_TOOL_ACTION)); + ModNetwork.net + .sendToServer(new CycleToolPacket.CycleToolMessage(isWheelUp, CycleToolPacket.CYCLE_TOOL_ACTION)); ServerActions.cycleTool(player, isWheelUp); event.setCanceled(true); } else if (theItem == ModItems.hose) { - ModNetwork.net.sendToServer( - new CycleToolPacket.CycleToolMessage(isWheelUp, CycleToolPacket.SWITCH_HOSE_ACTION)); + ModNetwork.net + .sendToServer(new CycleToolPacket.CycleToolMessage(isWheelUp, CycleToolPacket.SWITCH_HOSE_ACTION)); ServerActions.switchHose(player, isWheelUp, ServerActions.HOSE_SWITCH); event.setCanceled(true); } diff --git a/src/main/java/com/darkona/adventurebackpack/handlers/GeneralEventHandler.java b/src/main/java/com/darkona/adventurebackpack/handlers/GeneralEventHandler.java index d8016d25..1081335f 100644 --- a/src/main/java/com/darkona/adventurebackpack/handlers/GeneralEventHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/handlers/GeneralEventHandler.java @@ -1,17 +1,7 @@ package com.darkona.adventurebackpack.handlers; -import com.darkona.adventurebackpack.common.ServerActions; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.entity.ai.EntityAIHorseFollowOwner; -import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; -import com.darkona.adventurebackpack.init.ModNetwork; -import com.darkona.adventurebackpack.inventory.InventoryBackpack; -import com.darkona.adventurebackpack.network.messages.EntitySoundPacket; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.Utils; -import com.darkona.adventurebackpack.util.Wearing; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import java.util.UUID; + import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAITasks; import net.minecraft.entity.passive.EntityHorse; @@ -27,12 +17,25 @@ import net.minecraftforge.event.entity.player.PlayerUseItemEvent; import net.minecraftforge.fluids.FluidRegistry; +import com.darkona.adventurebackpack.common.ServerActions; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.entity.ai.EntityAIHorseFollowOwner; +import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; +import com.darkona.adventurebackpack.init.ModNetwork; +import com.darkona.adventurebackpack.inventory.InventoryBackpack; +import com.darkona.adventurebackpack.network.messages.EntitySoundPacket; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.Utils; +import com.darkona.adventurebackpack.util.Wearing; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + /** * Created on 17/10/2014 * * @author Darkona */ public class GeneralEventHandler { + @SubscribeEvent public void eatGoldenApple(PlayerUseItemEvent.Finish event) { EntityPlayer player = event.entityPlayer; @@ -48,8 +51,8 @@ public void eatGoldenApple(PlayerUseItemEvent.Finish event) { if (!player.worldObj.isRemote) { String nyanString = Utils.makeItRainbow("NYANCAT"); player.addChatComponentMessage(new ChatComponentText(nyanString)); - ModNetwork.sendToNearby( - new EntitySoundPacket.Message(EntitySoundPacket.NYAN_SOUND, player), player); + ModNetwork + .sendToNearby(new EntitySoundPacket.Message(EntitySoundPacket.NYAN_SOUND, player), player); } } } @@ -114,8 +117,7 @@ public void makeHorsesFollowOwner(EntityJoinWorldEvent event) { horse.tasks.addTask(4, new EntityAIHorseFollowOwner(horse, 1.5d, 2.0f, 20.0f)); if (horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) != null) { - horse.getAttributeMap() - .getAttributeInstance(SharedMonsterAttributes.followRange) + horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) .setBaseValue(100.0D); } } @@ -124,15 +126,12 @@ public void makeHorsesFollowOwner(EntityJoinWorldEvent event) { } } - /*@SubscribeEvent - public void backpackUnequipped(WearableEvent.UnequipWearableEvent event) - { - - }*/ + /* + * @SubscribeEvent public void backpackUnequipped(WearableEvent.UnequipWearableEvent event) { } + */ - /*@SubscribeEvent - public void listFluids(FluidRegistry.FluidRegisterEvent event) - { - LogHelper.info("Registered fluid " + event.fluidName + " with id " + event.fluidID); - }*/ + /* + * @SubscribeEvent public void listFluids(FluidRegistry.FluidRegisterEvent event) { + * LogHelper.info("Registered fluid " + event.fluidName + " with id " + event.fluidID); } + */ } diff --git a/src/main/java/com/darkona/adventurebackpack/handlers/GuiHandler.java b/src/main/java/com/darkona/adventurebackpack/handlers/GuiHandler.java index a3313dbe..57368374 100644 --- a/src/main/java/com/darkona/adventurebackpack/handlers/GuiHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/handlers/GuiHandler.java @@ -1,5 +1,8 @@ package com.darkona.adventurebackpack.handlers; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + import com.darkona.adventurebackpack.block.TileAdventureBackpack; import com.darkona.adventurebackpack.client.gui.GuiAdvBackpack; import com.darkona.adventurebackpack.client.gui.GuiCoalJetpack; @@ -13,8 +16,6 @@ import com.darkona.adventurebackpack.inventory.InventoryCopterPack; import com.darkona.adventurebackpack.util.Wearing; import cpw.mods.fml.common.network.IGuiHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; /** * Created on 12/10/2014 @@ -22,6 +23,7 @@ * @author Darkona */ public class GuiHandler implements IGuiHandler { + public static final byte JETPACK_WEARING = 6; public static final byte JETPACK_HOLDING = 5; public static final byte COPTER_WEARING = 4; @@ -39,43 +41,57 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { return new ContainerBackpack( - player, (TileAdventureBackpack) world.getTileEntity(x, y, z), Source.TILE); + player, + (TileAdventureBackpack) world.getTileEntity(x, y, z), + Source.TILE); } break; case BACKPACK_HOLDING: if (Wearing.isHoldingBackpack(player)) { return new ContainerBackpack( - player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), Source.HOLDING); + player, + new InventoryBackpack(Wearing.getHoldingBackpack(player)), + Source.HOLDING); } break; case BACKPACK_WEARING: if (Wearing.isWearingBackpack(player)) { return new ContainerBackpack( - player, new InventoryBackpack(Wearing.getWearingBackpack(player)), Source.WEARING); + player, + new InventoryBackpack(Wearing.getWearingBackpack(player)), + Source.WEARING); } break; case COPTER_HOLDING: if (Wearing.isHoldingCopter(player)) { return new ContainerCopter( - player, new InventoryCopterPack(Wearing.getHoldingCopter(player)), Source.HOLDING); + player, + new InventoryCopterPack(Wearing.getHoldingCopter(player)), + Source.HOLDING); } break; case COPTER_WEARING: if (Wearing.isWearingCopter(player)) { return new ContainerCopter( - player, new InventoryCopterPack(Wearing.getWearingCopter(player)), Source.WEARING); + player, + new InventoryCopterPack(Wearing.getWearingCopter(player)), + Source.WEARING); } break; case JETPACK_HOLDING: if (Wearing.isHoldingJetpack(player)) { return new ContainerJetpack( - player, new InventoryCoalJetpack(Wearing.getHoldingJetpack(player)), Source.HOLDING); + player, + new InventoryCoalJetpack(Wearing.getHoldingJetpack(player)), + Source.HOLDING); } break; case JETPACK_WEARING: if (Wearing.isWearingJetpack(player)) { return new ContainerJetpack( - player, new InventoryCoalJetpack(Wearing.getWearingJetpack(player)), Source.WEARING); + player, + new InventoryCoalJetpack(Wearing.getWearingJetpack(player)), + Source.WEARING); } break; default: @@ -93,43 +109,57 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int if (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileAdventureBackpack) { return new GuiAdvBackpack( - player, (TileAdventureBackpack) world.getTileEntity(x, y, z), Source.TILE); + player, + (TileAdventureBackpack) world.getTileEntity(x, y, z), + Source.TILE); } break; case BACKPACK_HOLDING: if (Wearing.isHoldingBackpack(player)) { return new GuiAdvBackpack( - player, new InventoryBackpack(Wearing.getHoldingBackpack(player)), Source.HOLDING); + player, + new InventoryBackpack(Wearing.getHoldingBackpack(player)), + Source.HOLDING); } break; case BACKPACK_WEARING: if (Wearing.isWearingBackpack(player)) { return new GuiAdvBackpack( - player, new InventoryBackpack(Wearing.getWearingBackpack(player)), Source.WEARING); + player, + new InventoryBackpack(Wearing.getWearingBackpack(player)), + Source.WEARING); } break; case COPTER_HOLDING: if (Wearing.isHoldingCopter(player)) { return new GuiCopterPack( - player, new InventoryCopterPack(Wearing.getHoldingCopter(player)), Source.HOLDING); + player, + new InventoryCopterPack(Wearing.getHoldingCopter(player)), + Source.HOLDING); } break; case COPTER_WEARING: if (Wearing.isWearingCopter(player)) { return new GuiCopterPack( - player, new InventoryCopterPack(Wearing.getWearingCopter(player)), Source.WEARING); + player, + new InventoryCopterPack(Wearing.getWearingCopter(player)), + Source.WEARING); } break; case JETPACK_HOLDING: if (Wearing.isHoldingJetpack(player)) { return new GuiCoalJetpack( - player, new InventoryCoalJetpack(Wearing.getHoldingJetpack(player)), Source.HOLDING); + player, + new InventoryCoalJetpack(Wearing.getHoldingJetpack(player)), + Source.HOLDING); } break; case JETPACK_WEARING: if (Wearing.isWearingJetpack(player)) { return new GuiCoalJetpack( - player, new InventoryCoalJetpack(Wearing.getWearingJetpack(player)), Source.WEARING); + player, + new InventoryCoalJetpack(Wearing.getWearingJetpack(player)), + Source.WEARING); } break; default: diff --git a/src/main/java/com/darkona/adventurebackpack/handlers/KeyInputEventHandler.java b/src/main/java/com/darkona/adventurebackpack/handlers/KeyInputEventHandler.java index 47d9d3a8..ddb6577e 100644 --- a/src/main/java/com/darkona/adventurebackpack/handlers/KeyInputEventHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/handlers/KeyInputEventHandler.java @@ -1,5 +1,8 @@ package com.darkona.adventurebackpack.handlers; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; + import com.darkona.adventurebackpack.common.ServerActions; import com.darkona.adventurebackpack.config.Keybindings; import com.darkona.adventurebackpack.entity.EntityFriendlySpider; @@ -11,15 +14,15 @@ import com.darkona.adventurebackpack.network.WearableModePacket; import com.darkona.adventurebackpack.reference.BackpackTypes; import com.darkona.adventurebackpack.util.Wearing; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; /** * Created by Darkona on 11/10/2014. */ public class KeyInputEventHandler { + public enum Key { UNKNOWN, INVENTORY, @@ -61,8 +64,7 @@ public void handleKeyInputEvent(InputEvent.KeyInputEvent event) { ServerActions.switchHose(player, false, ServerActions.HOSE_TOGGLE); } else if (Wearing.isWearingBackpack(player)) { if (player.isSneaking()) { - if (BackpackTypes.isNightVision( - Wearing.getWearingBackpackInv(player).getType())) { + if (BackpackTypes.isNightVision(Wearing.getWearingBackpackInv(player).getType())) { sendWearableModePacket(WearableModePacket.NIGHTVISION_ON_OFF); ServerActions.toggleNightVision(player, Wearing.getWearingBackpack(player)); } @@ -74,11 +76,15 @@ public void handleKeyInputEvent(InputEvent.KeyInputEvent event) { if (player.isSneaking()) { sendWearableModePacket(WearableModePacket.COPTER_ON_OFF); ServerActions.toggleCopterPack( - player, Wearing.getWearingCopter(player), WearableModePacket.COPTER_ON_OFF); + player, + Wearing.getWearingCopter(player), + WearableModePacket.COPTER_ON_OFF); } else { sendWearableModePacket(WearableModePacket.COPTER_TOGGLE); ServerActions.toggleCopterPack( - player, Wearing.getWearingCopter(player), WearableModePacket.COPTER_TOGGLE); + player, + Wearing.getWearingCopter(player), + WearableModePacket.COPTER_TOGGLE); } } else if (Wearing.isWearingJetpack(player)) { if (player.isSneaking()) { diff --git a/src/main/java/com/darkona/adventurebackpack/handlers/PlayerEventHandler.java b/src/main/java/com/darkona/adventurebackpack/handlers/PlayerEventHandler.java index 4b68c883..ff10f92a 100644 --- a/src/main/java/com/darkona/adventurebackpack/handlers/PlayerEventHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/handlers/PlayerEventHandler.java @@ -1,25 +1,5 @@ package com.darkona.adventurebackpack.handlers; -import com.darkona.adventurebackpack.block.BlockSleepingBag; -import com.darkona.adventurebackpack.common.ServerActions; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.entity.EntityFriendlySpider; -import com.darkona.adventurebackpack.entity.ai.EntityAIHorseFollowOwner; -import com.darkona.adventurebackpack.init.ModBlocks; -import com.darkona.adventurebackpack.init.ModItems; -import com.darkona.adventurebackpack.item.IBackWearableItem; -import com.darkona.adventurebackpack.item.ItemAdventureBackpack; -import com.darkona.adventurebackpack.playerProperties.BackpackProperty; -import com.darkona.adventurebackpack.proxy.ServerProxy; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.EnchUtils; -import com.darkona.adventurebackpack.util.LogHelper; -import com.darkona.adventurebackpack.util.Wearing; -import cpw.mods.fml.common.eventhandler.Event; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent; -import cpw.mods.fml.common.gameevent.TickEvent; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.item.EntityItem; @@ -41,14 +21,36 @@ import net.minecraftforge.event.entity.player.PlayerDropsEvent; import net.minecraftforge.event.entity.player.PlayerWakeUpEvent; +import com.darkona.adventurebackpack.block.BlockSleepingBag; +import com.darkona.adventurebackpack.common.ServerActions; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.entity.EntityFriendlySpider; +import com.darkona.adventurebackpack.entity.ai.EntityAIHorseFollowOwner; +import com.darkona.adventurebackpack.init.ModBlocks; +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.item.IBackWearableItem; +import com.darkona.adventurebackpack.item.ItemAdventureBackpack; +import com.darkona.adventurebackpack.playerProperties.BackpackProperty; +import com.darkona.adventurebackpack.proxy.ServerProxy; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.EnchUtils; +import com.darkona.adventurebackpack.util.LogHelper; +import com.darkona.adventurebackpack.util.Wearing; + +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; +import cpw.mods.fml.common.gameevent.TickEvent; + /** - * Created on 11/10/2014 - * Handle ALL the events! + * Created on 11/10/2014 Handle ALL the events! * * @author Darkona * @see com.darkona.adventurebackpack.client.ClientActions */ public class PlayerEventHandler { + @SubscribeEvent public void registerBackpackProperty(EntityEvent.EntityConstructing event) { if (event.entity instanceof EntityPlayer && BackpackProperty.get((EntityPlayer) event.entity) == null) { @@ -134,8 +136,7 @@ public void onFall(LivingFallEvent event) { if (event.entity != null) { if (event.entityLiving instanceof EntityCreature && ConfigHandler.fixLead) { EntityCreature creature = (EntityCreature) event.entityLiving; - if (creature.getLeashed() - && creature.getLeashedToEntity() != null + if (creature.getLeashed() && creature.getLeashedToEntity() != null && creature.getLeashedToEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) creature.getLeashedToEntity(); if (creature.motionY > -2.0f && player.motionY > -2.0f) { @@ -227,8 +228,9 @@ public void playerRespawn(PlayerEvent.PlayerRespawnEvent event) { @SubscribeEvent public void playerCraftsBackpack(PlayerEvent.ItemCraftedEvent event) { if (event.crafting != null && event.crafting.getItem() == ModItems.adventureBackpack) { - LogHelper.info("Player crafted a backpack, and that backpack's appearance is: " - + BackpackTypes.getSkinName(event.crafting)); + LogHelper.info( + "Player crafted a backpack, and that backpack's appearance is: " + + BackpackTypes.getSkinName(event.crafting)); if (!ConfigHandler.consumeDragonEgg && BackpackTypes.getType(event.crafting) == BackpackTypes.DRAGON) { event.player.dropPlayerItemWithRandomChoice(new ItemStack(Blocks.dragon_egg, 1), false); @@ -260,22 +262,19 @@ public void interactWithCreatures(EntityInteractEvent event) { EntityHorse horse = (EntityHorse) event.target; ItemStack stack = player.getCurrentEquippedItem(); - if (stack != null - && stack.getItem() != null + if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemNameTag && stack.hasDisplayName()) { - if (horse.getCustomNameTag() == null - || horse.getCustomNameTag().equals("") && horse.isTame()) { + if (horse.getCustomNameTag() == null || horse.getCustomNameTag().equals("") && horse.isTame()) { horse.setTamedBy(player); horse.tasks.addTask(4, new EntityAIHorseFollowOwner(horse, 1.5d, 2.0f, 20.0f)); if (horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) != null) { - horse.getAttributeMap() - .getAttributeInstance(SharedMonsterAttributes.followRange) + horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) .setBaseValue(100.0D); - LogHelper.info("The horse follow range is now: " - + horse.getEntityAttribute(SharedMonsterAttributes.followRange) - .getBaseValue()); + LogHelper.info( + "The horse follow range is now: " + horse + .getEntityAttribute(SharedMonsterAttributes.followRange).getBaseValue()); } } } @@ -290,9 +289,8 @@ public void playerWokeUp(PlayerWakeUpEvent event) { EntityPlayer player = event.entityPlayer; ChunkCoordinates bedLocation = player.getBedLocation(player.dimension); - if (bedLocation != null - && player.worldObj.getBlock(bedLocation.posX, bedLocation.posY, bedLocation.posZ) - == ModBlocks.blockSleepingBag) { + if (bedLocation != null && player.worldObj.getBlock(bedLocation.posX, bedLocation.posY, bedLocation.posZ) + == ModBlocks.blockSleepingBag) { // If the player wakes up in one of those super confortable SleepingBags (tm) (Patent Pending) if (BlockSleepingBag.isSleepingInPortableBag(player)) { BlockSleepingBag.packPortableSleepingBag(player); @@ -320,7 +318,8 @@ public void tickPlayer(TickEvent.PlayerTickEvent event) { if (!player.worldObj.isRemote) { if (BackpackProperty.get(player).isWakingUpInPortableBag() && Wearing.isWearingBackpack(player)) { BlockSleepingBag.restoreOriginalSpawn( - player, Wearing.getWearingBackpackInv(player).getExtendedProperties()); + player, + Wearing.getWearingBackpackInv(player).getExtendedProperties()); BackpackProperty.get(player).setWakingUpInPortableBag(false); } } diff --git a/src/main/java/com/darkona/adventurebackpack/handlers/RenderHandler.java b/src/main/java/com/darkona/adventurebackpack/handlers/RenderHandler.java index 2dee017c..439610f4 100644 --- a/src/main/java/com/darkona/adventurebackpack/handlers/RenderHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/handlers/RenderHandler.java @@ -1,10 +1,12 @@ package com.darkona.adventurebackpack.handlers; +import net.minecraftforge.client.event.RenderPlayerEvent; + import com.darkona.adventurebackpack.proxy.ClientProxy; + import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.client.event.RenderPlayerEvent; /** * Created on 25/12/2014 @@ -12,6 +14,7 @@ * @author Darkona */ public class RenderHandler { + @SubscribeEvent @SideOnly(Side.CLIENT) public void playerSpecialsRendering(RenderPlayerEvent.Specials.Pre event) { diff --git a/src/main/java/com/darkona/adventurebackpack/init/ConditionalFluidEffect.java b/src/main/java/com/darkona/adventurebackpack/init/ConditionalFluidEffect.java index 1a6c997f..bc6e3aee 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ConditionalFluidEffect.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ConditionalFluidEffect.java @@ -1,6 +1,7 @@ package com.darkona.adventurebackpack.init; import adventurebackpack.api.FluidEffect; + import com.darkona.adventurebackpack.fluids.effects.FuelEffect; import com.darkona.adventurebackpack.fluids.effects.OilEffect; import com.darkona.adventurebackpack.reference.LoadedMods; @@ -11,6 +12,7 @@ * @author Darkona */ public class ConditionalFluidEffect { + public static FluidEffect oilEffect; public static FluidEffect fuelEffect; diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModBlocks.java b/src/main/java/com/darkona/adventurebackpack/init/ModBlocks.java index a5768722..08cf94d3 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModBlocks.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModBlocks.java @@ -11,6 +11,7 @@ * Created by Darkona on 12/10/2014. */ public class ModBlocks { + public static BlockAdventureBackpack blockBackpack = new BlockAdventureBackpack(); public static BlockSleepingBag blockSleepingBag = new BlockSleepingBag(); public static BlockCampFire blockCampFire = new BlockCampFire(); diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModDates.java b/src/main/java/com/darkona/adventurebackpack/init/ModDates.java index 8447f03a..507311f8 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModDates.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModDates.java @@ -6,6 +6,7 @@ * Created by Ugachaga on 06.07.2017. */ public class ModDates { + private static String holiday; private static int year = Calendar.getInstance().get(Calendar.YEAR); @@ -23,18 +24,11 @@ public static String getHoliday() { private static String setHoliday() { // here and below commented lines: textures are missing. - /*if (ChineseCalendar.isChineseNewYear(year, month, day)) - { - return "ChinaNewYear"; - } - if (JewishCalendar.isHannukah(year, month, day)) - { - return "Hannukah"; - } - if (month == calculateEaster(year)[0] && day == calculateEaster(year)[1]) - { - return "Easter"; - }*/ + /* + * if (ChineseCalendar.isChineseNewYear(year, month, day)) { return "ChinaNewYear"; } if + * (JewishCalendar.isHannukah(year, month, day)) { return "Hannukah"; } if (month == calculateEaster(year)[0] && + * day == calculateEaster(year)[1]) { return "Easter"; } + */ String result = "Standard"; if (month == 1) { @@ -85,20 +79,10 @@ private static String setHoliday() { } private static int[] calculateEaster(int year) { - int a = year % 19, - b = year / 100, - c = year % 100, - d = b / 4, - e = b % 4, - g = (8 * b + 13) / 25, - h = (19 * a + b - d - g + 15) % 30, - j = c / 4, - k = c % 4, - m = (a + 11 * h) / 319, - r = (2 * e + 2 * j - k - h + m + 32) % 7, - n = (h - m + r + 90) / 25, - p = (h - m + r + n + 19) % 32; + int a = year % 19, b = year / 100, c = year % 100, d = b / 4, e = b % 4, g = (8 * b + 13) / 25, + h = (19 * a + b - d - g + 15) % 30, j = c / 4, k = c % 4, m = (a + 11 * h) / 319, + r = (2 * e + 2 * j - k - h + m + 32) % 7, n = (h - m + r + 90) / 25, p = (h - m + r + n + 19) % 32; - return new int[] {n, p}; + return new int[] { n, p }; } } diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModEntities.java b/src/main/java/com/darkona/adventurebackpack/init/ModEntities.java index 9d95061e..a8474d68 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModEntities.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModEntities.java @@ -11,11 +11,24 @@ * @author Darkona */ public class ModEntities { + public static void init() { int counter = 0; EntityRegistry.registerModEntity( - EntityInflatableBoat.class, "inflatableBoat", counter++, AdventureBackpack.instance, 64, 1, true); + EntityInflatableBoat.class, + "inflatableBoat", + counter++, + AdventureBackpack.instance, + 64, + 1, + true); EntityRegistry.registerModEntity( - EntityFriendlySpider.class, "rideableSpider", counter++, AdventureBackpack.instance, 64, 2, true); + EntityFriendlySpider.class, + "rideableSpider", + counter++, + AdventureBackpack.instance, + 64, + 2, + true); } } diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModFluids.java b/src/main/java/com/darkona/adventurebackpack/init/ModFluids.java index 7dddf530..02449e48 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModFluids.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModFluids.java @@ -1,19 +1,21 @@ package com.darkona.adventurebackpack.init; -import com.darkona.adventurebackpack.fluids.FluidMelonJuice; -import com.darkona.adventurebackpack.fluids.FluidMilk; -import com.darkona.adventurebackpack.fluids.FluidMushroomStew; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; +import com.darkona.adventurebackpack.fluids.FluidMelonJuice; +import com.darkona.adventurebackpack.fluids.FluidMilk; +import com.darkona.adventurebackpack.fluids.FluidMushroomStew; + /** * Created on 12/10/2014. * * @author Javier Darkona */ public class ModFluids { + public static FluidMilk milk; public static FluidMelonJuice melonJuice; public static FluidMushroomStew mushroomStew; @@ -24,15 +26,17 @@ public static void init() { mushroomStew = new FluidMushroomStew(); FluidRegistry.registerFluid(milk); - FluidContainerRegistry.registerFluidContainer( - milk, new ItemStack(Items.milk_bucket), FluidContainerRegistry.EMPTY_BUCKET); + FluidContainerRegistry + .registerFluidContainer(milk, new ItemStack(Items.milk_bucket), FluidContainerRegistry.EMPTY_BUCKET); FluidRegistry.registerFluid(melonJuice); FluidContainerRegistry.registerFluidContainer( - melonJuice, new ItemStack(ModItems.melonJuiceBottle), FluidContainerRegistry.EMPTY_BOTTLE); + melonJuice, + new ItemStack(ModItems.melonJuiceBottle), + FluidContainerRegistry.EMPTY_BOTTLE); FluidRegistry.registerFluid(mushroomStew); - FluidContainerRegistry.registerFluidContainer( - mushroomStew, new ItemStack(Items.mushroom_stew), new ItemStack(Items.bowl)); + FluidContainerRegistry + .registerFluidContainer(mushroomStew, new ItemStack(Items.mushroom_stew), new ItemStack(Items.bowl)); } } diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModItems.java b/src/main/java/com/darkona/adventurebackpack/init/ModItems.java index 6dd74f34..90844076 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModItems.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModItems.java @@ -21,6 +21,7 @@ * @author Darkona */ public class ModItems { + public static final ItemMachete machete = new ItemMachete(); public static final ItemCrossbow cwxbow = new ItemCrossbow(); public static final ArmorAB adventureHat = new ItemAdventureHat(); @@ -50,16 +51,8 @@ public static void init() { GameRegistry.registerItem(melonJuiceBottle, "melonJuiceBottle"); } - /*public static void conditionalInit() - { - if (LoadedMods.BUILDCRAFT) - { - GameRegistry.registerItem(copterPack, "copterPack"); - } - - if (LoadedMods.RAILCRAFT) - { - GameRegistry.registerItem(steamJetpack, "steamJetpack"); - } - }*/ + /* + * public static void conditionalInit() { if (LoadedMods.BUILDCRAFT) { GameRegistry.registerItem(copterPack, + * "copterPack"); } if (LoadedMods.RAILCRAFT) { GameRegistry.registerItem(steamJetpack, "steamJetpack"); } } + */ } diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModMaterials.java b/src/main/java/com/darkona/adventurebackpack/init/ModMaterials.java index 7a67ac08..ec3fb428 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModMaterials.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModMaterials.java @@ -10,7 +10,8 @@ * @author Darkona */ public class ModMaterials { + public static Item.ToolMaterial ruggedIron = EnumHelper.addToolMaterial("RUGGED_IRON", 2, 350, 6.5F, 5.2F, 10); - public static ItemArmor.ArmorMaterial ruggedLeather = - EnumHelper.addArmorMaterial("RUGGED_LEATHER", 15, new int[] {2, 5, 4, 2}, 12); + public static ItemArmor.ArmorMaterial ruggedLeather = EnumHelper + .addArmorMaterial("RUGGED_LEATHER", 15, new int[] { 2, 5, 4, 2 }, 12); } diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModNetwork.java b/src/main/java/com/darkona/adventurebackpack/init/ModNetwork.java index c7acda0e..00b15d59 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModNetwork.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModNetwork.java @@ -1,5 +1,8 @@ package com.darkona.adventurebackpack.init; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.WorldServer; + import com.darkona.adventurebackpack.network.CowAbilityPacket; import com.darkona.adventurebackpack.network.CycleToolPacket; import com.darkona.adventurebackpack.network.EquipUnequipBackWearablePacket; @@ -12,12 +15,11 @@ import com.darkona.adventurebackpack.network.messages.EntitySoundPacket; import com.darkona.adventurebackpack.playerProperties.BackpackProperty; import com.darkona.adventurebackpack.reference.ModInfo; + import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.WorldServer; /** * Created on 12/10/2014 @@ -25,6 +27,7 @@ * @author Darkona */ public class ModNetwork { + public static SimpleNetworkWrapper net; public static int messages = 0; @@ -60,8 +63,7 @@ private static void registerMessage(Class handler, Class message) { public static void sendToNearby(IMessage message, EntityPlayer player) { if (player != null && player.worldObj instanceof WorldServer) { try { - ((WorldServer) player.worldObj) - .getEntityTracker() + ((WorldServer) player.worldObj).getEntityTracker() .func_151248_b(player, ModNetwork.net.getPacketFrom(message)); } catch (Exception ex) { ex.printStackTrace(); diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModRecipes.java b/src/main/java/com/darkona/adventurebackpack/init/ModRecipes.java index a27299e2..aa376e64 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModRecipes.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModRecipes.java @@ -1,5 +1,12 @@ package com.darkona.adventurebackpack.init; +import java.lang.reflect.Field; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.ShapedOreRecipe; + import com.darkona.adventurebackpack.config.ConfigHandler; import com.darkona.adventurebackpack.init.recipes.BackpackRecipesList; import com.darkona.adventurebackpack.init.recipes.ShapedBackpackRecipe; @@ -7,11 +14,6 @@ import com.darkona.adventurebackpack.util.BackpackUtils; import com.darkona.adventurebackpack.util.LogHelper; import cpw.mods.fml.common.registry.GameRegistry; -import java.lang.reflect.Field; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.ShapedOreRecipe; /** * Created on 20/10/2014 @@ -19,16 +21,34 @@ * @author Darkona */ public class ModRecipes { + public static void init() { if (ConfigHandler.recipeSaddle) { // Saddle GameRegistry.addRecipe( - new ItemStack(Items.saddle), "LLL", "L L", "I I", 'L', Items.leather, 'I', Items.iron_ingot); + new ItemStack(Items.saddle), + "LLL", + "L L", + "I I", + 'L', + Items.leather, + 'I', + Items.iron_ingot); } // CampFire - GameRegistry.addRecipe(new ShapedOreRecipe( - ModBlocks.blockCampFire, " S ", "SxS", "ccc", 'S', "stickWood", 'x', Items.coal, 'c', "cobblestone")); + GameRegistry.addRecipe( + new ShapedOreRecipe( + ModBlocks.blockCampFire, + " S ", + "SxS", + "ccc", + 'S', + "stickWood", + 'x', + Items.coal, + 'c', + "cobblestone")); if (ConfigHandler.recipeCopterPack) { // Copter Pack @@ -205,12 +225,19 @@ public static void init() { new ItemStack(Items.dye, 1, 2)); // Sleeping Bag - GameRegistry.addRecipe( - new ItemStack(ModItems.component, 1, 1), " X", "CCC", 'X', Blocks.wool, 'C', Blocks.carpet); + GameRegistry + .addRecipe(new ItemStack(ModItems.component, 1, 1), " X", "CCC", 'X', Blocks.wool, 'C', Blocks.carpet); // Backpack Tank GameRegistry.addRecipe( - new ItemStack(ModItems.component, 1, 2), "GIG", "GGG", "GIG", 'G', Blocks.glass, 'I', Items.iron_ingot); + new ItemStack(ModItems.component, 1, 2), + "GIG", + "GGG", + "GIG", + 'G', + Blocks.glass, + 'I', + Items.iron_ingot); if (ConfigHandler.recipeCopterPack) { // Copter Engine @@ -249,7 +276,14 @@ public static void init() { if (ConfigHandler.recipeInflatableBoat) { // Inflatable Boat GameRegistry.addRecipe( - new ItemStack(ModItems.component, 1, 7), " ", "w w", "sws", 'w', Blocks.wool, 's', Blocks.sand); + new ItemStack(ModItems.component, 1, 7), + " ", + "w w", + "sws", + 'w', + Blocks.wool, + 's', + Blocks.sand); if (ConfigHandler.recipeInflatableBoatM) { // Inflatable Boat (Motorized) @@ -284,13 +318,16 @@ public static void init() { for (Field field : BackpackRecipesList.class.getFields()) { try { if (field.getName().equals(BackpackTypes.getSkinName(type))) { - GameRegistry.addRecipe(new ShapedBackpackRecipe( - BackpackUtils.createBackpackStack(type), (Object[]) field.get(br))); + GameRegistry.addRecipe( + new ShapedBackpackRecipe( + BackpackUtils.createBackpackStack(type), + (Object[]) field.get(br))); counter++; } } catch (Exception oops) { - LogHelper.error("Huge mistake during reflection. Some bad things might happen: " - + oops.getClass().getName()); + LogHelper.error( + "Huge mistake during reflection. Some bad things might happen: " + + oops.getClass().getName()); oops.printStackTrace(); } } @@ -298,11 +335,7 @@ public static void init() { LogHelper.info("Loaded " + counter + " backpack recipes."); } - /*public static void conditionalInit() - { - if (LoadedMods.BUILDCRAFT) - { - - } - }*/ + /* + * public static void conditionalInit() { if (LoadedMods.BUILDCRAFT) { } } + */ } diff --git a/src/main/java/com/darkona/adventurebackpack/init/ModWorldGen.java b/src/main/java/com/darkona/adventurebackpack/init/ModWorldGen.java index 3063a24c..604cd413 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/ModWorldGen.java +++ b/src/main/java/com/darkona/adventurebackpack/init/ModWorldGen.java @@ -6,11 +6,8 @@ import static com.darkona.adventurebackpack.reference.BackpackTypes.STANDARD; import static com.darkona.adventurebackpack.reference.BackpackTypes.VILLAGER; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.BackpackUtils; -import cpw.mods.fml.common.registry.VillagerRegistry; import java.util.Random; + import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -19,12 +16,18 @@ import net.minecraft.village.MerchantRecipeList; import net.minecraftforge.common.ChestGenHooks; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.BackpackUtils; +import cpw.mods.fml.common.registry.VillagerRegistry; + /** * Created on 24/12/2014 * * @author Darkona */ public class ModWorldGen { + public static void init() { { ItemStack backpack = BackpackUtils.createBackpackStack(VILLAGER); @@ -43,8 +46,8 @@ public static void init() { } if (ConfigHandler.allowPigmanGen) { ItemStack backpack = BackpackUtils.createBackpackStack(PIGMAN); - ChestGenHooks.addItem( - ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(backpack, 1, 1, 12)); + ChestGenHooks + .addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(backpack, 1, 1, 12)); VillagerRegistry.instance() .registerVillageTradeHandler(BackpackTypes.getMeta(PIGMAN), new ModWorldGen.TradeHandler(backpack)); } @@ -55,6 +58,7 @@ public static void init() { } public static class TradeHandler implements VillagerRegistry.IVillageTradeHandler { + ItemStack backpack; TradeHandler(ItemStack backpack) { diff --git a/src/main/java/com/darkona/adventurebackpack/init/recipes/AbstractBackpackRecipeTwo.java b/src/main/java/com/darkona/adventurebackpack/init/recipes/AbstractBackpackRecipeTwo.java index a83640a5..65c02f7f 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/recipes/AbstractBackpackRecipeTwo.java +++ b/src/main/java/com/darkona/adventurebackpack/init/recipes/AbstractBackpackRecipeTwo.java @@ -2,14 +2,15 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_TYPE; -import com.darkona.adventurebackpack.init.ModItems; -import com.darkona.adventurebackpack.reference.BackpackTypes; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.reference.BackpackTypes; + /** * Created on 24/12/2014 * @@ -17,6 +18,7 @@ */ public class AbstractBackpackRecipeTwo implements IRecipe // TODO unused class { + private ItemStack result; private ItemStack[] recipe; private BackpackTypes type; diff --git a/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipe.java b/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipe.java index 6e860171..a554abc9 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipe.java +++ b/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipe.java @@ -1,14 +1,16 @@ package com.darkona.adventurebackpack.init.recipes; -import com.darkona.adventurebackpack.reference.BackpackTypes; import net.minecraft.item.ItemStack; +import com.darkona.adventurebackpack.reference.BackpackTypes; + /** * Created on 24/12/2014 * * @author Darkona */ public class BackpackRecipe { + public ItemStack[] array; public BackpackTypes type; diff --git a/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipesList.java b/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipesList.java index f59cc5e0..de7bfc04 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipesList.java +++ b/src/main/java/com/darkona/adventurebackpack/init/recipes/BackpackRecipesList.java @@ -1,23 +1,26 @@ package com.darkona.adventurebackpack.init.recipes; -import com.darkona.adventurebackpack.init.ModItems; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.BackpackUtils; import java.util.List; + import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.BackpackUtils; + /** * Created on 20/10/2014 * * @author Darkona */ public class BackpackRecipesList { + public List recipes; public BackpackRecipesList() { - String[] covered = {"XXX", "XaX", "XXX"}; + String[] covered = { "XXX", "XaX", "XXX" }; ItemStack backpack = BackpackUtils.createBackpackStack(BackpackTypes.STANDARD); ItemStack woolWhite = new ItemStack(Blocks.wool, 1, 0); @@ -112,7 +115,17 @@ public BackpackRecipesList() { Chest = reviewRecipe("CWC", "WaW", "CWC", 'C', Blocks.chest, 'W', "plankWood", 'a', backpack); Chicken = reviewRecipe( - "FnF", "FaF", "nEn", 'F', Items.feather, 'n', Items.gold_nugget, 'a', backpack, 'E', Items.egg); + "FnF", + "FaF", + "nEn", + 'F', + Items.feather, + 'n', + Items.gold_nugget, + 'a', + backpack, + 'E', + Items.egg); Coal = reviewRecipe("cCc", "CaC", "ccc", 'c', Items.coal, 'C', "blockCoal", 'a', backpack); @@ -130,7 +143,17 @@ public BackpackRecipesList() { backpack); Cow = reviewRecipe( - "BLB", "BaB", "LML", 'B', Items.beef, 'a', backpack, 'L', Items.leather, 'M', Items.milk_bucket); + "BLB", + "BaB", + "LML", + 'B', + Items.beef, + 'a', + backpack, + 'L', + Items.leather, + 'M', + Items.milk_bucket); Creeper = reviewRecipe( "GHG", @@ -150,7 +173,17 @@ public BackpackRecipesList() { Cyan = reviewRecipe(covered, 'X', woolCyan, 'a', backpack); Diamond = reviewRecipe( - "GDG", "GaG", "GdG", 'G', "blockGlass", 'D', "blockDiamond", 'a', backpack, 'd', "gemDiamond"); + "GDG", + "GaG", + "GdG", + 'G', + "blockGlass", + 'D', + "blockDiamond", + 'a', + backpack, + 'd', + "gemDiamond"); Dragon = reviewRecipe( "EDE", @@ -170,7 +203,17 @@ public BackpackRecipesList() { Egg = reviewRecipe(covered, 'X', Items.egg, 'a', backpack); Emerald = reviewRecipe( - "GEG", "GaG", "eGe", 'G', Blocks.glass, 'E', Blocks.emerald_block, 'a', backpack, 'e', Items.emerald); + "GEG", + "GaG", + "eGe", + 'G', + Blocks.glass, + 'E', + Blocks.emerald_block, + 'a', + backpack, + 'e', + Items.emerald); End = reviewRecipe("eEe", "EaE", "eEe", 'E', Blocks.end_stone, 'e', Items.ender_eye, 'a', backpack); @@ -200,7 +243,17 @@ public BackpackRecipesList() { Haybale = reviewRecipe(covered, 'X', Blocks.hay_block, 'a', backpack); Iron = reviewRecipe( - "GIG", "GaG", "iGi", 'G', "blockGlass", 'I', "blockIron", 'a', backpack, 'i', Items.iron_ingot); + "GIG", + "GaG", + "iGi", + 'G', + "blockGlass", + 'I', + "blockIron", + 'a', + backpack, + 'i', + Items.iron_ingot); Lapis = reviewRecipe( "GLG", @@ -228,7 +281,17 @@ public BackpackRecipesList() { MagmaCube = reviewRecipe("MLM", "MaM", "MLM", 'M', Items.magma_cream, 'a', backpack, 'L', Items.lava_bucket); Melon = reviewRecipe( - "mMm", "mam", "msm", 'm', Items.melon, 'M', Blocks.melon_block, 'a', backpack, 's', Items.melon_seeds); + "mMm", + "mam", + "msm", + 'm', + Items.melon, + 'M', + Blocks.melon_block, + 'a', + backpack, + 's', + Items.melon_seeds); Mooshroom = reviewRecipe( "SRL", @@ -263,7 +326,15 @@ public BackpackRecipesList() { Obsidian = reviewRecipe(covered, 'X', Blocks.obsidian, 'a', backpack); Ocelot = reviewRecipe( - "FYF", "YaY", "FYF", 'F', Items.fish, 'Y', new ItemStack(Blocks.wool, 1, 4), 'a', backpack); + "FYF", + "YaY", + "FYF", + 'F', + Items.fish, + 'Y', + new ItemStack(Blocks.wool, 1, 4), + 'a', + backpack); Orange = reviewRecipe(covered, 'X', woolOrange, 'a', backpack); @@ -339,7 +410,17 @@ public BackpackRecipesList() { Snow = reviewRecipe("III", "SaS", "sSs", 'I', Blocks.ice, 'S', Blocks.snow, 's', Items.snowball, 'a', backpack); Spider = reviewRecipe( - "ESE", "LaL", "ESE", 'E', Items.spider_eye, 'S', Items.string, 'L', Blocks.ladder, 'a', backpack); + "ESE", + "LaL", + "ESE", + 'E', + Items.spider_eye, + 'S', + Items.string, + 'L', + Blocks.ladder, + 'a', + backpack); White = reviewRecipe(covered, 'X', new ItemStack(Blocks.wool, 1, 0), 'a', backpack); @@ -378,17 +459,43 @@ public BackpackRecipesList() { Yellow = reviewRecipe(covered, 'X', woolYellow, 'a', backpack); Zombie = reviewRecipe( - "FSF", "FaF", "FFF", 'F', Items.rotten_flesh, 'S', new ItemStack(Items.skull, 1, 2), 'a', backpack); + "FSF", + "FaF", + "FFF", + 'F', + Items.rotten_flesh, + 'S', + new ItemStack(Items.skull, 1, 2), + 'a', + backpack); Carrot = reviewRecipe(covered, 'a', backpack, 'X', Items.carrot); Silverfish = reviewRecipe( - "CGC", "CaC", "CGC", 'a', backpack, 'G', woolLightGray, 'C', new ItemStack(Blocks.stonebrick, 1, 2)); + "CGC", + "CaC", + "CGC", + 'a', + backpack, + 'G', + woolLightGray, + 'C', + new ItemStack(Blocks.stonebrick, 1, 2)); Sunflower = reviewRecipe(covered, 'a', backpack, 'X', new ItemStack(Blocks.double_plant, 1, 0)); Horse = reviewRecipe( - "LSL", "XaX", "LXL", 'L', Items.leather, 'S', Items.saddle, 'X', Blocks.hay_block, 'a', backpack); + "LSL", + "XaX", + "LXL", + 'L', + Items.leather, + 'S', + Items.saddle, + 'X', + Blocks.hay_block, + 'a', + backpack); Overworld = reviewRecipe( "BBB", diff --git a/src/main/java/com/darkona/adventurebackpack/init/recipes/ShapedBackpackRecipe.java b/src/main/java/com/darkona/adventurebackpack/init/recipes/ShapedBackpackRecipe.java index 425cb91f..f21acaf8 100644 --- a/src/main/java/com/darkona/adventurebackpack/init/recipes/ShapedBackpackRecipe.java +++ b/src/main/java/com/darkona/adventurebackpack/init/recipes/ShapedBackpackRecipe.java @@ -2,23 +2,25 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_INVENTORY; -import com.darkona.adventurebackpack.init.ModItems; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.reference.ModInfo; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.LogHelper; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.ShapedOreRecipe; +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.reference.ModInfo; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.LogHelper; + /** * Created on 03.03.2018 * * @author Ugachaga */ public class ShapedBackpackRecipe extends ShapedOreRecipe { + static { RecipeSorter.register( ModInfo.MOD_ID + ":shapedbackpackrecipe", @@ -35,20 +37,22 @@ public ShapedBackpackRecipe(ItemStack result, Object... recipe) { public ItemStack getCraftingResult(InventoryCrafting craftMatrix) { ItemStack craftResult = super.getCraftingResult(craftMatrix); - if (!(craftResult.getItem() == ModItems.adventureBackpack)) - return craftResult; // in case recipe is using backpack only as ingredient + if (!(craftResult.getItem() == ModItems.adventureBackpack)) return craftResult; // in case recipe is using + // backpack only as ingredient for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { ItemStack matrixStack = craftMatrix.getStackInSlot(i); - if (matrixStack != null - && matrixStack.getItem() == ModItems.adventureBackpack + if (matrixStack != null && matrixStack.getItem() == ModItems.adventureBackpack && BackpackUtils.getWearableCompound(matrixStack).hasKey(TAG_INVENTORY)) { NBTTagList itemList = BackpackUtils.getWearableInventory(matrixStack); BackpackUtils.getWearableCompound(craftResult).setTag(TAG_INVENTORY, itemList); - LogHelper.info("Successfully transferred inventory from the ingredient backpack [" - + BackpackTypes.getSkinName(matrixStack) + "] to the crafted backpack [" - + BackpackTypes.getSkinName(craftResult) + "]"); + LogHelper.info( + "Successfully transferred inventory from the ingredient backpack [" + + BackpackTypes.getSkinName(matrixStack) + + "] to the crafted backpack [" + + BackpackTypes.getSkinName(craftResult) + + "]"); break; // copy inventory content only from the 1st found backpack in the craftMatrix } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerAdventure.java b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerAdventure.java index f78f818d..f7c64133 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerAdventure.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerAdventure.java @@ -1,7 +1,7 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.common.Constants.Source; import javax.annotation.Nullable; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -9,6 +9,8 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import com.darkona.adventurebackpack.common.Constants.Source; + /** * Created on 10.04.2017 * @@ -16,6 +18,7 @@ */ @SuppressWarnings("WeakerAccess") public abstract class ContainerAdventure extends Container { + protected static final int PLAYER_INV_ROWS = 3; protected static final int PLAYER_INV_COLUMNS = 9; protected static final int PLAYER_HOT_START = 0; @@ -40,15 +43,15 @@ protected ContainerAdventure(EntityPlayer player, IInventoryTanks inventory, Sou protected void bindPlayerInventory(InventoryPlayer invPlayer, int startX, int startY) { for (int col = 0; col < PLAYER_INV_COLUMNS; col++) // hotbar - 9 slots - addSlotToContainer(new Slot(invPlayer, col, (startX + 18 * col), (58 + startY))); + addSlotToContainer(new Slot(invPlayer, col, (startX + 18 * col), (58 + startY))); for (int row = 0; row < PLAYER_INV_ROWS; row++) // inventory - 3*9, 27 slots - for (int col = 0; col < PLAYER_INV_COLUMNS; col++) - addSlotToContainer(new Slot( - invPlayer, - (PLAYER_INV_COLUMNS + row * PLAYER_INV_COLUMNS + col), - (startX + 18 * col), - (startY + row * 18))); + for (int col = 0; col < PLAYER_INV_COLUMNS; col++) addSlotToContainer( + new Slot( + invPlayer, + (PLAYER_INV_COLUMNS + row * PLAYER_INV_COLUMNS + col), + (startX + 18 * col), + (startY + row * 18))); } @Override @@ -161,8 +164,7 @@ protected boolean mergeItemStack(ItemStack initStack, int minIndex, int maxIndex activeSlot = (Slot) this.inventorySlots.get(activeIndex); activeStack = activeSlot.getStack(); - if (activeStack != null - && activeStack.getItem() == initStack.getItem() + if (activeStack != null && activeStack.getItem() == initStack.getItem() && (!initStack.getHasSubtypes() || initStack.getItemDamage() == activeStack.getItemDamage()) && ItemStack.areItemStackTagsEqual(initStack, activeStack)) { int mergedSize = activeStack.stackSize + initStack.stackSize; @@ -191,10 +193,10 @@ protected boolean mergeItemStack(ItemStack initStack, int minIndex, int maxIndex activeSlot = (Slot) this.inventorySlots.get(activeIndex); activeStack = activeSlot.getStack(); - if (activeStack == null /*&& activeSlot.isItemValid(initStack)*/) { + if (activeStack == null /* && activeSlot.isItemValid(initStack) */) { ItemStack copyStack = initStack.copy(); - int mergedSize = - copyStack.stackSize = Math.min(copyStack.stackSize, activeSlot.getSlotStackLimit()); + int mergedSize = copyStack.stackSize = Math + .min(copyStack.stackSize, activeSlot.getSlotStackLimit()); activeSlot.putStack(copyStack); if (mergedSize >= initStack.stackSize) { diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerBackpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerBackpack.java index 3f96d193..3dcaebe3 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerBackpack.java @@ -7,10 +7,6 @@ import static com.darkona.adventurebackpack.common.Constants.TOOL_LOWER; import static com.darkona.adventurebackpack.common.Constants.TOOL_UPPER; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.common.Constants.Source; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.util.TinkersUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.InventoryPlayer; @@ -21,12 +17,18 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.common.Constants.Source; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.util.TinkersUtils; + /** * Created on 12/10/2014 * * @author Darkona */ public class ContainerBackpack extends ContainerAdventure { + private static final int BACK_INV_ROWS = 6; private static final int BACK_INV_COLUMNS = 8; private static final int BACK_INV_START = PLAYER_INV_END + 1; @@ -39,8 +41,10 @@ public class ContainerBackpack extends ContainerAdventure { private static final int CRAFT_RESULT = BUCKET_RIGHT + 2 + (MATRIX_DIMENSION * MATRIX_DIMENSION); private static final int[] CRAFT_MATRIX_EMULATION = findCraftMatrixEmulationIDs(); - private InventoryCraftingBackpack craftMatrix = - new InventoryCraftingBackpack(this, MATRIX_DIMENSION, MATRIX_DIMENSION); + private InventoryCraftingBackpack craftMatrix = new InventoryCraftingBackpack( + this, + MATRIX_DIMENSION, + MATRIX_DIMENSION); private IInventory craftResult = new InventoryCraftResult(); public ContainerBackpack(EntityPlayer player, IInventoryBackpack backpack, Source source) { @@ -59,9 +63,12 @@ private void makeSlots(InventoryPlayer invPlayer) { int startX = 62; int startY = 7; for (int row = 0; row < BACK_INV_ROWS; row++) // 6*8 inventory, 48 Slots (#1-#48) [36-83] - for (int col = 0; col < BACK_INV_COLUMNS; col++) - addSlotToContainer(new SlotBackpack( - inventory, (row * BACK_INV_COLUMNS + col), (startX + 18 * col), (startY + 18 * row))); + for (int col = 0; col < BACK_INV_COLUMNS; col++) addSlotToContainer( + new SlotBackpack( + inventory, + (row * BACK_INV_COLUMNS + col), + (startX + 18 * col), + (startY + 18 * row))); addSlotToContainer(new SlotTool(inventory, TOOL_UPPER, 44, 79)); // #49 [84] addSlotToContainer(new SlotTool(inventory, TOOL_LOWER, 44, 97)); // #50 [85] @@ -74,12 +81,15 @@ private void makeSlots(InventoryPlayer invPlayer) { startX = 215; startY = -2500; // startY = LoadedMods.DEV_ENV ? 125 : -2500; for (int row = 0; row < MATRIX_DIMENSION; row++) // craftMatrix, usually 9 slots, [90-98] - for (int col = 0; col < MATRIX_DIMENSION; col++) - addSlotToContainer(new SlotCraftMatrix( - craftMatrix, (row * MATRIX_DIMENSION + col), (startX + 18 * col), (startY + 18 * row))); - - addSlotToContainer( - new SlotCraftResult(this, invPlayer.player, craftMatrix, craftResult, 0, 226, 97)); // craftResult [99] + for (int col = 0; col < MATRIX_DIMENSION; col++) addSlotToContainer( + new SlotCraftMatrix( + craftMatrix, + (row * MATRIX_DIMENSION + col), + (startX + 18 * col), + (startY + 18 * row))); + + addSlotToContainer(new SlotCraftResult(this, invPlayer.player, craftMatrix, craftResult, 0, 226, 97)); // craftResult + // [99] syncCraftMatrixWithInventory(true); } @@ -194,9 +204,9 @@ protected void dropContentOnClose() { public void onCraftMatrixChanged(IInventory inventory) { if (ConfigHandler.tinkerToolsMaintenance && TinkersUtils.isToolOrWeapon(craftMatrix.getStackInSlot(4))) craftResult.setInventorySlotContents(0, TinkersUtils.getTinkersRecipe(craftMatrix)); - else - craftResult.setInventorySlotContents( - 0, CraftingManager.getInstance().findMatchingRecipe(craftMatrix, player.worldObj)); + else craftResult.setInventorySlotContents( + 0, + CraftingManager.getInstance().findMatchingRecipe(craftMatrix, player.worldObj)); } protected void syncCraftMatrixWithInventory(boolean preCraft) { @@ -226,7 +236,7 @@ protected void syncCraftMatrixWithInventory(boolean preCraft) { } /** - * Returns the array of inventory slotIDs, emulates the craftMatrix in the lower right corner of the inventory. + * Returns the array of inventory slotIDs, emulates the craftMatrix in the lower right corner of the inventory. */ private static int[] findCraftMatrixEmulationIDs() { int[] slotsArray = new int[MATRIX_DIMENSION * MATRIX_DIMENSION]; diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerCopter.java b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerCopter.java index 9b2ecd35..3a09449c 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerCopter.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerCopter.java @@ -3,18 +3,20 @@ import static com.darkona.adventurebackpack.common.Constants.Copter.BUCKET_IN; import static com.darkona.adventurebackpack.common.Constants.Copter.BUCKET_OUT; -import com.darkona.adventurebackpack.common.Constants.Source; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants.Source; + /** * Created on 03/01/2015 * * @author Darkona */ public class ContainerCopter extends ContainerAdventure { + private static final int COPTER_INV_START = PLAYER_INV_END + 1; public ContainerCopter(EntityPlayer player, InventoryCopterPack copter, Source source) { diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerJetpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerJetpack.java index 6c7e65c6..e638c182 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/ContainerJetpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/ContainerJetpack.java @@ -4,18 +4,20 @@ import static com.darkona.adventurebackpack.common.Constants.Jetpack.BUCKET_OUT; import static com.darkona.adventurebackpack.common.Constants.Jetpack.FUEL_SLOT; -import com.darkona.adventurebackpack.common.Constants.Source; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants.Source; + /** * Created on 15/01/2015 * * @author Darkona */ public class ContainerJetpack extends ContainerAdventure { + private static final int JETPACK_INV_START = PLAYER_INV_END + 1; private static final int JETPACK_FUEL_START = PLAYER_INV_END + 3; diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/IAsynchronousInventory.java b/src/main/java/com/darkona/adventurebackpack/inventory/IAsynchronousInventory.java index 842b017d..6d575a02 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/IAsynchronousInventory.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/IAsynchronousInventory.java @@ -1,6 +1,7 @@ package com.darkona.adventurebackpack.inventory; import javax.annotation.Nullable; + import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -10,6 +11,7 @@ * @author Darkona */ public interface IAsynchronousInventory extends IInventory { + void setInventorySlotContentsNoSave(int slot, @Nullable ItemStack stack); ItemStack decrStackSizeNoSave(int slot, int amount); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryBackpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryBackpack.java index ac73e801..264a7c10 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryBackpack.java @@ -1,14 +1,16 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.reference.BackpackTypes; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.reference.BackpackTypes; + /** * Created by Darkona on 12/10/2014. */ public interface IInventoryBackpack extends IInventoryTanks { + BackpackTypes getType(); FluidTank getLeftTank(); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryTanks.java b/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryTanks.java index a8762bf3..c79b1576 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryTanks.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/IInventoryTanks.java @@ -10,6 +10,7 @@ * @author Darkona */ public interface IInventoryTanks extends IAsynchronousInventory { + ItemStack[] getInventory(); FluidTank[] getTanksArray(); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryActions.java b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryActions.java index e7e38f9e..bf376ed3 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryActions.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryActions.java @@ -1,8 +1,5 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.item.ItemHose; -import com.darkona.adventurebackpack.util.FluidUtils; import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -11,23 +8,28 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.item.ItemHose; +import com.darkona.adventurebackpack.util.FluidUtils; + /** * Created on 16/10/2014 * * @author Darkona */ public class InventoryActions { + /** - * What a complicated mess. I hated every minute of coding this. - * This code takes a fluid container item. If its filled, it empties it out into a tank. - * If its empty, it drains the tank into the item. Then it puts the resulting filled or empty item - * into a different slot, consuming the first one. If there is no empty container, such as the Forestry Cells, - * it simply fills the tank. + * What a complicated mess. I hated every minute of coding this. This code takes a fluid container item. If its + * filled, it empties it out into a tank. If its empty, it drains the tank into the item. Then it puts the resulting + * filled or empty item into a different slot, consuming the first one. If there is no empty container, such as the + * Forestry Cells, it simply fills the tank. * * @param inventory The inventory type thing that will have its tank updated. * @param tank The tank that's going to be updated. * @param slotIn The slot in which the fluid container item must be to update the tank. - * @return True if the tank was filled and the resulting filled or empty container item was placed in the other slot. + * @return True if the tank was filled and the resulting filled or empty container item was placed in the other + * slot. */ public static boolean transferContainerTank(IInventoryTanks inventory, FluidTank tank, int slotIn) { if (tank == null) return false; @@ -47,16 +49,16 @@ public static boolean transferContainerTank(IInventoryTanks inventory, FluidTank // CONTAINER ===========> TANK if (FluidContainerRegistry.isFilledContainer(stackIn)) { - int fill = tank.fill( - FluidContainerRegistry.getFluidForFilledItem(stackIn), - false); // See if the tank can accept moar fluid + int fill = tank.fill(FluidContainerRegistry.getFluidForFilledItem(stackIn), false); // See if the tank can + // accept moar fluid if (fill > 0) // If can accept the fluid { if (FluidContainerRegistry.getContainerCapacity(stackIn) + tank.getFluidAmount() <= tank.getCapacity()) { - ItemStack stackOut = FluidContainerRegistry.drainFluidContainer( - stackIn); // Get the empty container for the input, if there's any + ItemStack stackOut = FluidContainerRegistry.drainFluidContainer(stackIn); // Get the empty container + // for the input, if + // there's any if (inventory.getStackInSlot(slotOut) == null || stackOut == null) { tank.fill(FluidContainerRegistry.getFluidForFilledItem(stackIn), true); @@ -64,50 +66,49 @@ public static boolean transferContainerTank(IInventoryTanks inventory, FluidTank inventory.setInventorySlotContentsNoSave(slotOut, stackOut); return true; } else if (inventory.getStackInSlot(slotOut).getItem().equals(stackOut.getItem()) - && stackOut.getItemDamage() - == inventory.getStackInSlot(slotOut).getItemDamage()) { - int maxStack = inventory.getStackInSlot(slotOut).getMaxStackSize(); - if (maxStack > 1 && (inventory.getStackInSlot(slotOut).stackSize + 1) <= maxStack) { - tank.fill(FluidContainerRegistry.getFluidForFilledItem(stackIn), true); - inventory.decrStackSizeNoSave(slotIn, 1); - inventory.getStackInSlot(slotOut).stackSize++; - return true; - } - } + && stackOut.getItemDamage() == inventory.getStackInSlot(slotOut).getItemDamage()) { + int maxStack = inventory.getStackInSlot(slotOut).getMaxStackSize(); + if (maxStack > 1 && (inventory.getStackInSlot(slotOut).stackSize + 1) <= maxStack) { + tank.fill(FluidContainerRegistry.getFluidForFilledItem(stackIn), true); + inventory.decrStackSizeNoSave(slotIn, 1); + inventory.getStackInSlot(slotOut).stackSize++; + return true; + } + } } } } // TANK =====> CONTAINER - else if (tank.getFluid() != null - && tank.getFluidAmount() > 0 + else if (tank.getFluid() != null && tank.getFluidAmount() > 0 && FluidUtils.isEmptyContainerForFluid(stackIn, tank.getFluid().getFluid())) { - int amount = FluidContainerRegistry.getContainerCapacity( - tank.getFluid(), stackIn); // How much fluid can this container hold - FluidStack drain = tank.drain(amount, false); // Let's see how much can we drain this tank - - if (amount > 0 && drain.amount == amount) { - ItemStack stackOut = FluidContainerRegistry.fillFluidContainer(drain, stackIn); - - if (inventory.getStackInSlot(slotOut) == null || stackOut == null) { - tank.drain(amount, true); - inventory.decrStackSizeNoSave(slotIn, 1); - inventory.setInventorySlotContentsNoSave(slotOut, stackOut); - return true; - } else if (stackOut.getItem() - .equals(inventory.getStackInSlot(slotOut).getItem()) - && stackOut.getItemDamage() - == inventory.getStackInSlot(slotOut).getItemDamage()) { - int maxStack = inventory.getStackInSlot(slotOut).getMaxStackSize(); - if (maxStack > 1 && (inventory.getStackInSlot(slotOut).stackSize + 1) <= maxStack) { - tank.drain(amount, true); - inventory.decrStackSizeNoSave(slotIn, 1); - inventory.getStackInSlot(slotOut).stackSize++; - return true; + int amount = FluidContainerRegistry.getContainerCapacity(tank.getFluid(), stackIn); // How much + // fluid can + // this + // container + // hold + FluidStack drain = tank.drain(amount, false); // Let's see how much can we drain this tank + + if (amount > 0 && drain.amount == amount) { + ItemStack stackOut = FluidContainerRegistry.fillFluidContainer(drain, stackIn); + + if (inventory.getStackInSlot(slotOut) == null || stackOut == null) { + tank.drain(amount, true); + inventory.decrStackSizeNoSave(slotIn, 1); + inventory.setInventorySlotContentsNoSave(slotOut, stackOut); + return true; + } else if (stackOut.getItem().equals(inventory.getStackInSlot(slotOut).getItem()) + && stackOut.getItemDamage() == inventory.getStackInSlot(slotOut).getItemDamage()) { + int maxStack = inventory.getStackInSlot(slotOut).getMaxStackSize(); + if (maxStack > 1 && (inventory.getStackInSlot(slotOut).stackSize + 1) <= maxStack) { + tank.drain(amount, true); + inventory.decrStackSizeNoSave(slotIn, 1); + inventory.getStackInSlot(slotOut).stackSize++; + return true; + } + } } } - } - } return false; } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryAdventure.java b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryAdventure.java index 0c97aa84..3c25ccdb 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryAdventure.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryAdventure.java @@ -3,13 +3,15 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_INVENTORY; import static com.darkona.adventurebackpack.common.Constants.TAG_SLOT; -import com.darkona.adventurebackpack.util.BackpackUtils; import javax.annotation.Nullable; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import com.darkona.adventurebackpack.util.BackpackUtils; + /** * Created on 15.07.2017 * @@ -129,7 +131,7 @@ public void setInventorySlotContentsNoSave(int slot, @Nullable ItemStack stack) @Override public void dirtyInventory() { if (updateTankSlots()) // TODO this can be generalized too - dirtyTanks(); // TODO and also this + dirtyTanks(); // TODO and also this getWearableCompound().removeTag(TAG_INVENTORY); // TODO why? sync related? getWearableCompound().setTag(TAG_INVENTORY, getInventoryTagList()); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryBackpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryBackpack.java index 09b0fcf3..f1130776 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryBackpack.java @@ -13,10 +13,6 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_TYPE; import static com.darkona.adventurebackpack.common.Constants.TAG_WEARABLE_COMPOUND; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.init.ModBlocks; -import com.darkona.adventurebackpack.reference.BackpackTypes; -import com.darkona.adventurebackpack.util.CoordsUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -26,12 +22,18 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.init.ModBlocks; +import com.darkona.adventurebackpack.reference.BackpackTypes; +import com.darkona.adventurebackpack.util.CoordsUtils; + /** * Created on 12/10/2014 * * @author Darkona */ public class InventoryBackpack extends InventoryAdventure implements IInventoryBackpack { + private static final String TAG_IS_SLEEPING_BAG = "sleepingBag"; private static final String TAG_SLEEPING_BAG_X = "sleepingBagX"; private static final String TAG_SLEEPING_BAG_Y = "sleepingBagY"; @@ -79,12 +81,12 @@ public FluidTank getRightTank() { @Override public FluidTank[] getTanksArray() { - return new FluidTank[] {leftTank, rightTank}; + return new FluidTank[] { leftTank, rightTank }; } @Override public int[] getSlotsOnClosing() { - return new int[] {BUCKET_IN_LEFT, BUCKET_IN_RIGHT, BUCKET_OUT_LEFT, BUCKET_OUT_RIGHT}; + return new int[] { BUCKET_IN_LEFT, BUCKET_IN_RIGHT, BUCKET_OUT_LEFT, BUCKET_OUT_RIGHT }; } @Override @@ -94,8 +96,8 @@ public NBTTagCompound getExtendedProperties() { @Override public void loadFromNBT(NBTTagCompound compound) { - if (compound == null) - return; // this need for NEI and WAILA trying to render tile.backpack and comes here w/o nbt + if (compound == null) return; // this need for NEI and WAILA trying to render tile.backpack and comes here w/o + // nbt NBTTagCompound backpackTag = compound.getCompoundTag(TAG_WEARABLE_COMPOUND); type = BackpackTypes.getType(backpackTag.getByte(TAG_TYPE)); @@ -141,7 +143,7 @@ public void dirtyTanks() { @Override public void dirtyExtended() // TODO is it redundant? - { + { getWearableCompound().removeTag(TAG_EXTENDED_COMPOUND); // TODO again: why? getWearableCompound().setTag(TAG_EXTENDED_COMPOUND, extendedProperties); } @@ -241,7 +243,7 @@ public void removeSleepingBag(World world) { } private void detectAndConvertFromOldNBTFormat(NBTTagCompound compound) // backwards compatibility - { + { if (compound == null || !compound.hasKey("backpackData")) return; NBTTagCompound oldBackpackTag = compound.getCompoundTag("backpackData"); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCoalJetpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCoalJetpack.java index 1c9c34ab..50e3f4c9 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCoalJetpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCoalJetpack.java @@ -8,7 +8,6 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_INVENTORY; import static com.darkona.adventurebackpack.common.Constants.TAG_WEARABLE_COMPOUND; -import com.darkona.adventurebackpack.common.Constants; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -16,12 +15,15 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; + /** * Created on 15/01/2015 * * @author Darkona */ public class InventoryCoalJetpack extends InventoryAdventure { + private FluidTank waterTank = new FluidTank(Constants.Jetpack.WATER_CAPACITY); private FluidTank steamTank = new FluidTank(Constants.Jetpack.STEAM_CAPACITY); @@ -55,12 +57,12 @@ public FluidTank getSteamTank() { @Override public FluidTank[] getTanksArray() { - return new FluidTank[] {waterTank, steamTank}; + return new FluidTank[] { waterTank, steamTank }; } @Override public int[] getSlotsOnClosing() { - return new int[] {BUCKET_IN, BUCKET_OUT}; + return new int[] { BUCKET_IN, BUCKET_OUT }; } @Override @@ -218,7 +220,7 @@ public void setCurrentItemBurnTime(int currentItemBurnTime) { } private void detectAndConvertFromOldNBTFormat(NBTTagCompound compound) // backwards compatibility - { + { if (compound == null || !compound.hasKey("jetpackData")) return; NBTTagCompound oldJetpackTag = compound.getCompoundTag("jetpackData"); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCopterPack.java b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCopterPack.java index c0b6555a..9a797628 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCopterPack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCopterPack.java @@ -7,19 +7,21 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_INVENTORY; import static com.darkona.adventurebackpack.common.Constants.TAG_WEARABLE_COMPOUND; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.item.ItemCopterPack; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.item.ItemCopterPack; + /** * Created on 02/01/2015 * * @author Darkona */ public class InventoryCopterPack extends InventoryAdventure { + private FluidTank fuelTank = new FluidTank(Constants.Copter.FUEL_CAPACITY); private byte status = ItemCopterPack.OFF_MODE; @@ -42,12 +44,12 @@ public FluidTank getFuelTank() { @Override public FluidTank[] getTanksArray() { - return new FluidTank[] {fuelTank}; + return new FluidTank[] { fuelTank }; } @Override public int[] getSlotsOnClosing() { - return new int[] {BUCKET_IN, BUCKET_OUT}; + return new int[] { BUCKET_IN, BUCKET_OUT }; } @Override @@ -112,7 +114,7 @@ public void setTickCounter(int ticks) { } private void detectAndConvertFromOldNBTFormat(NBTTagCompound compound) // backwards compatibility - { + { if (compound == null || compound.hasKey(TAG_WEARABLE_COMPOUND)) return; if (compound.hasKey("status")) compound.removeTag("status"); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCraftingBackpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCraftingBackpack.java index 26c8bd27..60e42c43 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCraftingBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/InventoryCraftingBackpack.java @@ -1,6 +1,7 @@ package com.darkona.adventurebackpack.inventory; import javax.annotation.Nullable; + import net.minecraft.inventory.Container; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; @@ -11,6 +12,7 @@ * @author Ugachaga */ public class InventoryCraftingBackpack extends InventoryCrafting { + public InventoryCraftingBackpack(Container eventHandler, int columns, int rows) { super(eventHandler, columns, rows); } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotAdventure.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotAdventure.java index 3b8d4a1e..74488ce1 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotAdventure.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotAdventure.java @@ -9,6 +9,7 @@ * @author Darkona */ abstract class SlotAdventure extends Slot { + SlotAdventure(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotBackpack.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotBackpack.java index 6897b907..a80e32cf 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotBackpack.java @@ -1,33 +1,32 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.config.ConfigHandler; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import com.darkona.adventurebackpack.config.ConfigHandler; + /** * Created by Darkona on 12/10/2014. */ public class SlotBackpack extends SlotAdventure { + private static final String[] FORBIDDEN_CLASSES = { - // Adventure Backpack 2 - "com.darkona.adventurebackpack.item.ItemAdventureBackpack", - // Backpack Mod - "de.eydamos.backpack.item.ItemBackpack", - "de.eydamos.backpack.item.ItemWorkbenchBackpack", - // Blue Power Canvas Bags - "com.bluepowermod.item.ItemCanvasBag", - // Extra Utilities Golden Bag of Holding - "com.rwtema.extrautils.item.ItemGoldenBag", - // Forestry Backpacks +addons - "forestry.storage.items.ItemBackpack", - "forestry.storage.items.ItemBackpackNaturalist", - // Jabba Dolly - "mcp.mobius.betterbarrels.common.items.dolly.ItemBarrelMover", - "mcp.mobius.betterbarrels.common.items.dolly.ItemDiamondMover", - // Project Red Exploration Backpacks - "mrtjp.projectred.exploration.ItemBackpack", - }; + // Adventure Backpack 2 + "com.darkona.adventurebackpack.item.ItemAdventureBackpack", + // Backpack Mod + "de.eydamos.backpack.item.ItemBackpack", "de.eydamos.backpack.item.ItemWorkbenchBackpack", + // Blue Power Canvas Bags + "com.bluepowermod.item.ItemCanvasBag", + // Extra Utilities Golden Bag of Holding + "com.rwtema.extrautils.item.ItemGoldenBag", + // Forestry Backpacks +addons + "forestry.storage.items.ItemBackpack", "forestry.storage.items.ItemBackpackNaturalist", + // Jabba Dolly + "mcp.mobius.betterbarrels.common.items.dolly.ItemBarrelMover", + "mcp.mobius.betterbarrels.common.items.dolly.ItemDiamondMover", + // Project Red Exploration Backpacks + "mrtjp.projectred.exploration.ItemBackpack", }; SlotBackpack(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftMatrix.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftMatrix.java index f7682346..a6ead2d4 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftMatrix.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftMatrix.java @@ -10,6 +10,7 @@ * @author Ugachaga */ public class SlotCraftMatrix extends SlotAdventure { + SlotCraftMatrix(IInventory craftMatrix, int slotIndex, int posX, int posY) { super(craftMatrix, slotIndex, posX, posY); } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftResult.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftResult.java index d3003245..b7359a34 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftResult.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotCraftResult.java @@ -11,16 +11,11 @@ * @author Ugachaga */ public class SlotCraftResult extends SlotCrafting { + private ContainerBackpack eventHandler; - public SlotCraftResult( - ContainerBackpack container, - EntityPlayer player, - IInventory craftMatrix, - IInventory inventory, - int slotIndex, - int posX, - int posY) { + public SlotCraftResult(ContainerBackpack container, EntityPlayer player, IInventory craftMatrix, + IInventory inventory, int slotIndex, int posX, int posY) { super(player, craftMatrix, inventory, slotIndex, posX, posY); this.eventHandler = container; } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluid.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluid.java index 47b2bea4..d8678801 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluid.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluid.java @@ -1,20 +1,22 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.item.ItemHose; -import com.darkona.adventurebackpack.util.Utils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.item.ItemHose; +import com.darkona.adventurebackpack.util.Utils; + /** * Created on 12/10/2014 * * @author Darkona */ public class SlotFluid extends SlotAdventure { + SlotFluid(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); } diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidFuel.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidFuel.java index 7f4ec761..5ac658d7 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidFuel.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidFuel.java @@ -1,10 +1,11 @@ package com.darkona.adventurebackpack.inventory; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.common.Constants; import com.darkona.adventurebackpack.item.ItemHose; import com.darkona.adventurebackpack.reference.GeneralReference; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; /** * Created on 10.04.2017 @@ -12,14 +13,13 @@ * @author Ugachaga */ public class SlotFluidFuel extends SlotFluid { + SlotFluidFuel(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); } private static boolean isValidContainer(ItemStack stack) { - return isEmpty(stack) - || (isFilled(stack) - && GeneralReference.isValidFuel(getFluid(stack).getName())); + return isEmpty(stack) || (isFilled(stack) && GeneralReference.isValidFuel(getFluid(stack).getName())); } static boolean isValidItem(ItemStack stack) { diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidWater.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidWater.java index 6762b64b..5fb8f508 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidWater.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFluidWater.java @@ -1,19 +1,21 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.item.ItemHose; -import com.darkona.adventurebackpack.util.FluidUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.item.ItemHose; +import com.darkona.adventurebackpack.util.FluidUtils; + /** * Created on 10.04.2017 * * @author Ugachaga */ public class SlotFluidWater extends SlotFluid { + SlotFluidWater(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); } @@ -24,10 +26,7 @@ private static boolean isContainerForWater(ItemStack stack) { private static boolean isContainerWithWater(ItemStack stack) { return isFilled(stack) - && FluidContainerRegistry.getFluidForFilledItem(stack) - .getFluid() - .getName() - .contains("water"); + && FluidContainerRegistry.getFluidForFilledItem(stack).getFluid().getName().contains("water"); } private static boolean isValidContainer(ItemStack stack) { diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFuel.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFuel.java index 97a25d61..6762c54e 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotFuel.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotFuel.java @@ -10,13 +10,14 @@ * @author Darkona */ public class SlotFuel extends SlotAdventure { + SlotFuel(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); } static boolean isValidItem(ItemStack stack) { - return TileEntityFurnace.isItemFuel(stack) - && !SlotFluid.isContainer(stack); // fuel slot accepts only solid fuel + return TileEntityFurnace.isItemFuel(stack) && !SlotFluid.isContainer(stack); // fuel slot accepts only solid + // fuel } @Override diff --git a/src/main/java/com/darkona/adventurebackpack/inventory/SlotTool.java b/src/main/java/com/darkona/adventurebackpack/inventory/SlotTool.java index 55411a8f..83663f09 100644 --- a/src/main/java/com/darkona/adventurebackpack/inventory/SlotTool.java +++ b/src/main/java/com/darkona/adventurebackpack/inventory/SlotTool.java @@ -1,8 +1,5 @@ package com.darkona.adventurebackpack.inventory; -import com.darkona.adventurebackpack.util.GregtechUtils; -import com.darkona.adventurebackpack.util.ThaumcraftUtils; -import com.darkona.adventurebackpack.util.TinkersUtils; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemFishingRod; @@ -12,21 +9,22 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; +import com.darkona.adventurebackpack.util.GregtechUtils; +import com.darkona.adventurebackpack.util.ThaumcraftUtils; +import com.darkona.adventurebackpack.util.TinkersUtils; + /** * Created on 12/10/2014 * * @author Darkona */ public class SlotTool extends SlotAdventure { - private static final String[] VALID_TOOL_NAMES = { - "axe", "crowbar", "drill", "grafter", "hammer", "scoop", "shovel", "wrench", - }; - private static final String[] INVALID_TOOL_NAMES = { - "bow", "bucket", "shield", "sword", - }; - private static final String[] INVALID_TINKER_NAMES = { - "battleaxe", "bow", "cleaver", "cutlass", "dagger", "rapier", "sabre", "shield", "sign", "sword", - }; + + private static final String[] VALID_TOOL_NAMES = { "axe", "crowbar", "drill", "grafter", "hammer", "scoop", + "shovel", "wrench", }; + private static final String[] INVALID_TOOL_NAMES = { "bow", "bucket", "shield", "sword", }; + private static final String[] INVALID_TINKER_NAMES = { "battleaxe", "bow", "cleaver", "cutlass", "dagger", "rapier", + "sabre", "shield", "sign", "sword", }; SlotTool(IInventory inventory, int slotIndex, int posX, int posY) { super(inventory, slotIndex, posX, posY); @@ -46,8 +44,7 @@ public static boolean isValidTool(ItemStack stack) { String itemName = item.getUnlocalizedName().toLowerCase(); // Vanilla - if (item instanceof ItemTool - || item instanceof ItemHoe + if (item instanceof ItemTool || item instanceof ItemHoe || item instanceof ItemShears || item instanceof ItemFishingRod || item instanceof ItemFlintAndSteel) { diff --git a/src/main/java/com/darkona/adventurebackpack/item/ArmorAB.java b/src/main/java/com/darkona/adventurebackpack/item/ArmorAB.java index 1371e7e9..7fee8085 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ArmorAB.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ArmorAB.java @@ -1,15 +1,17 @@ package com.darkona.adventurebackpack.item; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.CreativeTabAB; import com.darkona.adventurebackpack.init.ModMaterials; import com.darkona.adventurebackpack.reference.ModInfo; import com.darkona.adventurebackpack.util.Resources; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; /** * Created on 11/10/2014. @@ -17,6 +19,7 @@ * @author Javier Darkona */ public class ArmorAB extends ItemArmor { + /** * @param type 2 Chain * @param renderIndex 0 Helmet, 1 Plate, 2 Pants, 3 Boots @@ -37,15 +40,15 @@ public String getUnlocalizedName(ItemStack stack) { @Override public String getUnlocalizedName() { - return String.format( - "item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + return String + .format("item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon( - this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); + itemIcon = iconRegister + .registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); } @Override diff --git a/src/main/java/com/darkona/adventurebackpack/item/IBackWearableItem.java b/src/main/java/com/darkona/adventurebackpack/item/IBackWearableItem.java index 62f884e5..be8994de 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/IBackWearableItem.java +++ b/src/main/java/com/darkona/adventurebackpack/item/IBackWearableItem.java @@ -1,19 +1,21 @@ package com.darkona.adventurebackpack.item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 08/01/2015 * * @author Darkona */ public interface IBackWearableItem { + void onEquippedUpdate(World world, EntityPlayer player, ItemStack stack); void onPlayerDeath(World world, EntityPlayer player, ItemStack stack); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemAB.java b/src/main/java/com/darkona/adventurebackpack/item/ItemAB.java index 6894d02b..08e39e62 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemAB.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemAB.java @@ -1,17 +1,20 @@ package com.darkona.adventurebackpack.item; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.CreativeTabAB; import com.darkona.adventurebackpack.reference.ModInfo; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; /** * Created by Darkona on 10/10/2014. */ public class ItemAB extends Item { + ItemAB() { super(); setCreativeTab(CreativeTabAB.TAB_AB); @@ -19,14 +22,14 @@ public class ItemAB extends Item { @Override public String getUnlocalizedName(ItemStack stack) { - return String.format( - "item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + return String + .format("item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override public String getUnlocalizedName() { - return String.format( - "item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + return String + .format("item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } public String getUnlocalizedName(String name) { @@ -36,8 +39,8 @@ public String getUnlocalizedName(String name) { @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon( - this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); + itemIcon = iconRegister + .registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); } private String getUnwrappedUnlocalizedName(String unlocalizedName) { diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventure.java b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventure.java index 59989859..b91470e2 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventure.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventure.java @@ -1,11 +1,12 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.inventory.ContainerAdventure; -import com.darkona.adventurebackpack.util.EnchUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; +import com.darkona.adventurebackpack.inventory.ContainerAdventure; +import com.darkona.adventurebackpack.util.EnchUtils; + /** * Created on 01.03.2018 * @@ -13,6 +14,7 @@ */ @SuppressWarnings("WeakerAccess") public abstract class ItemAdventure extends ItemAB implements IBackWearableItem { + public ItemAdventure() { super(); setFull3D(); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureBackpack.java b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureBackpack.java index cb0eee57..21498ade 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureBackpack.java @@ -9,6 +9,25 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_TYPE; import static com.darkona.adventurebackpack.util.TipUtils.l10n; +import java.util.List; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.Constants.NBT; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidTank; + import com.darkona.adventurebackpack.block.BlockAdventureBackpack; import com.darkona.adventurebackpack.block.TileAdventureBackpack; import com.darkona.adventurebackpack.common.BackpackAbilities; @@ -27,25 +46,9 @@ import com.darkona.adventurebackpack.util.Resources; import com.darkona.adventurebackpack.util.TipUtils; import com.darkona.adventurebackpack.util.Utils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.List; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.model.ModelBiped; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.Constants.NBT; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidTank; /** * Created on 12/10/2014 @@ -53,13 +56,14 @@ * @author Darkona */ public class ItemAdventureBackpack extends ItemAdventure { + public ItemAdventureBackpack() { super(); setUnlocalizedName("adventureBackpack"); } @Override - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({ "unchecked" }) @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List subItems) { for (BackpackTypes type : BackpackTypes.values()) { @@ -70,7 +74,7 @@ public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List subItems) } @Override - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({ "unchecked" }) @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltips, boolean advanced) { NBTTagCompound backpackTag = BackpackUtils.getWearableCompound(stack); @@ -117,17 +121,8 @@ public void onCreated(ItemStack stack, World world, EntityPlayer player) { } @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { return player.canPlayerEdit(x, y, z, side, stack) && placeBackpack(stack, player, world, x, y, z, side, true); } @@ -144,8 +139,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla @Override public void onPlayerDeath(World world, EntityPlayer player, ItemStack stack) { - if (world.isRemote - || !ConfigHandler.backpackDeathPlace + if (world.isRemote || !ConfigHandler.backpackDeathPlace || EnchUtils.isSoulBounded(stack) || player.getEntityWorld().getGameRules().getGameRuleBooleanValue("keepInventory")) { return; @@ -158,9 +152,9 @@ public void onPlayerDeath(World world, EntityPlayer player, ItemStack stack) { BackpackProperty.get(player).setWearable(null); } - private boolean tryPlace( - World world, EntityPlayer player, ItemStack backpack) // TODO extract behavior to CoordsUtils - { + private boolean tryPlace(World world, EntityPlayer player, ItemStack backpack) // TODO extract behavior to + // CoordsUtils + { int X = (int) player.posX; if (player.posX < 0) X--; int Z = (int) player.posZ; @@ -168,12 +162,22 @@ private boolean tryPlace( int Y = (int) player.posY; if (Y < 1) Y = 1; - int positions[] = {0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6}; + int positions[] = { 0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6 }; for (int shiftY : positions) { if (Y + shiftY >= 1) { ChunkCoordinates spawn = CoordsUtils.getNearestEmptyChunkCoordinatesSpiral( - world, X, Z, X, Y + shiftY, Z, 6, true, 1, (byte) 0, false); + world, + X, + Z, + X, + Y + shiftY, + Z, + 6, + true, + 1, + (byte) 0, + false); if (spawn != null) { return placeBackpack( backpack, @@ -190,8 +194,8 @@ private boolean tryPlace( return false; } - private boolean placeBackpack( - ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, boolean from) { + private boolean placeBackpack(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + boolean from) { if (stack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, stack)) return false; if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); if (!stack.stackTagCompound.hasKey(TAG_TYPE)) { @@ -234,7 +238,10 @@ private boolean placeBackpack( if (world.setBlock(x, y, z, ModBlocks.blockBackpack)) { backpack.onBlockPlacedBy(world, x, y, z, player, stack); world.playSoundAtEntity( - player, BlockAdventureBackpack.soundTypeCloth.getStepResourcePath(), 0.5f, 1.0f); + player, + BlockAdventureBackpack.soundTypeCloth.getStepResourcePath(), + 0.5f, + 1.0f); ((TileAdventureBackpack) world.getTileEntity(x, y, z)).loadFromNBT(stack.stackTagCompound); if (from) { stack.stackSize--; diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureHat.java b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureHat.java index a0c546ed..0d3db23f 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureHat.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureHat.java @@ -1,17 +1,20 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.client.models.ModelAdventureHat; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBiped; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import com.darkona.adventurebackpack.client.models.ModelAdventureHat; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created by Darkona on 11/10/2014. */ public class ItemAdventureHat extends ArmorAB { + public ItemAdventureHat() { super(2, 0); setMaxDamage(Items.leather_helmet.getMaxDamage() + 45); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventurePants.java b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventurePants.java index 2389aab4..99ebd8cb 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventurePants.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventurePants.java @@ -9,6 +9,7 @@ * @author Darkona */ public class ItemAdventurePants extends ArmorAB { + public ItemAdventurePants() { super(2, 2); setMaxDamage(Items.leather_leggings.getMaxDamage() + 75); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureSuit.java b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureSuit.java index 6b57d40b..117cc128 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureSuit.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemAdventureSuit.java @@ -9,6 +9,7 @@ * @author Darkona */ public class ItemAdventureSuit extends ArmorAB { + public ItemAdventureSuit() { super(1, 1); setMaxDamage(Items.leather_chestplate.getMaxDamage() + 70); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemCoalJetpack.java b/src/main/java/com/darkona/adventurebackpack/item/ItemCoalJetpack.java index cc4f3ea6..eeb2bb71 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemCoalJetpack.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemCoalJetpack.java @@ -2,21 +2,8 @@ import static com.darkona.adventurebackpack.util.TipUtils.l10n; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.init.ModNetwork; -import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; -import com.darkona.adventurebackpack.network.GUIPacket; -import com.darkona.adventurebackpack.network.PlayerActionPacket; -import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; -import com.darkona.adventurebackpack.network.messages.EntitySoundPacket; -import com.darkona.adventurebackpack.proxy.ClientProxy; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.Resources; -import com.darkona.adventurebackpack.util.TipUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.model.ModelBiped; @@ -36,12 +23,29 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.init.ModNetwork; +import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; +import com.darkona.adventurebackpack.network.GUIPacket; +import com.darkona.adventurebackpack.network.PlayerActionPacket; +import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; +import com.darkona.adventurebackpack.network.messages.EntitySoundPacket; +import com.darkona.adventurebackpack.proxy.ClientProxy; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.Resources; +import com.darkona.adventurebackpack.util.TipUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 15/01/2015 * * @author Darkona */ public class ItemCoalJetpack extends ItemAdventure { + public ItemCoalJetpack() { super(); setUnlocalizedName("coalJetpack"); @@ -54,7 +58,7 @@ public void getSubItems(Item item, CreativeTabs tab, List list) { } @Override - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({ "unchecked" }) @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltips, boolean advanced) { FluidTank waterTank = new FluidTank(Constants.Jetpack.WATER_CAPACITY); @@ -101,9 +105,9 @@ public void onEquipped(World world, EntityPlayer player, ItemStack stack) { } @Override - public void onEquippedUpdate( - World world, EntityPlayer player, ItemStack stack) // TODO extract behavior to separate class - { + public void onEquippedUpdate(World world, EntityPlayer player, ItemStack stack) // TODO extract behavior to separate + // class + { InventoryCoalJetpack inv = new InventoryCoalJetpack(stack); inv.openInventory(); boolean mustFizzz = !inv.isInUse(); @@ -124,9 +128,7 @@ public void onEquippedUpdate( // Elevation if (world.isRemote) { - if (inv.getStatus() - && canUse - && Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed()) { + if (inv.getStatus() && canUse && Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed()) { inv.setInUse(true); ModNetwork.net.sendToServer(new PlayerActionPacket.ActionMessage(PlayerActionPacket.JETPACK_IN_USE)); if (mustFizzz) { @@ -134,8 +136,8 @@ public void onEquippedUpdate( } } else { inv.setInUse(false); - ModNetwork.net.sendToServer( - new PlayerActionPacket.ActionMessage(PlayerActionPacket.JETPACK_NOT_IN_USE)); + ModNetwork.net + .sendToServer(new PlayerActionPacket.ActionMessage(PlayerActionPacket.JETPACK_NOT_IN_USE)); } } @@ -152,17 +154,16 @@ public void onEquippedUpdate( if (player.motionY >= 0) { player.fallDistance = 0; } - if (!world.isRemote) - ModNetwork.sendToNearby( - new EntityParticlePacket.Message(EntityParticlePacket.JETPACK_PARTICLE, player), player); + if (!world.isRemote) ModNetwork.sendToNearby( + new EntityParticlePacket.Message(EntityParticlePacket.JETPACK_PARTICLE, player), + player); } inv.closeInventory(); } private static void elevate(EntityPlayer player) { - if (player.posY < 135) - if (player.motionY <= 0.32) player.motionY += 0.1; - else player.motionY = Math.max(player.motionY, 0.32); + if (player.posY < 135) if (player.motionY <= 0.32) player.motionY += 0.1; + else player.motionY = Math.max(player.motionY, 0.32); else if (player.posY < 185) player.motionY = 0.32 - (player.posY - 135) / 160; else if (player.posY >= 185) player.motionY += 0; } @@ -278,8 +279,8 @@ public boolean showDurabilityBar(ItemStack stack) { } private int getBiomeMinTemp(EntityPlayer player, World world) { - BiomeDictionary.Type[] thisBiomeTypes = - BiomeDictionary.getTypesForBiome(world.getBiomeGenForCoords((int) player.posX, (int) player.posZ)); + BiomeDictionary.Type[] thisBiomeTypes = BiomeDictionary + .getTypesForBiome(world.getBiomeGenForCoords((int) player.posX, (int) player.posZ)); for (BiomeDictionary.Type type : thisBiomeTypes) { if (type == BiomeDictionary.Type.COLD || type == BiomeDictionary.Type.SNOWY) { return 0; diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemComponent.java b/src/main/java/com/darkona/adventurebackpack/item/ItemComponent.java index d3d85fd4..e3d70880 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemComponent.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemComponent.java @@ -1,10 +1,8 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.entity.EntityInflatableBoat; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.HashMap; import java.util.List; + import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -19,24 +17,21 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; +import com.darkona.adventurebackpack.entity.EntityInflatableBoat; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 11/10/2014 * * @author Darkona */ public class ItemComponent extends ItemAB { + private HashMap componentIcons = new HashMap<>(); - private String[] names = { - "sleepingBag", - "backpackTank", - "hoseHead", - "macheteHandle", - "copterEngine", - "copterBlades", - "inflatableBoat", - "inflatableBoatMotorized", - "hydroBlades", - }; + private String[] names = { "sleepingBag", "backpackTank", "hoseHead", "macheteHandle", "copterEngine", + "copterBlades", "inflatableBoat", "inflatableBoatMotorized", "hydroBlades", }; public ItemComponent() { setNoRepair(); @@ -49,12 +44,12 @@ public ItemComponent() { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { for (String name : names) { - IIcon temporalIcon = iconRegister.registerIcon(super.getUnlocalizedName(name) - .substring(this.getUnlocalizedName().indexOf(".") + 1)); + IIcon temporalIcon = iconRegister + .registerIcon(super.getUnlocalizedName(name).substring(this.getUnlocalizedName().indexOf(".") + 1)); componentIcons.put(name, temporalIcon); } - itemIcon = iconRegister.registerIcon(super.getUnlocalizedName("sleepingBag") - .substring(this.getUnlocalizedName().indexOf(".") + 1)); + itemIcon = iconRegister.registerIcon( + super.getUnlocalizedName("sleepingBag").substring(this.getUnlocalizedName().indexOf(".") + 1)); } @Override @@ -115,8 +110,7 @@ private ItemStack placeBoat(ItemStack stack, World world, EntityPlayer player, b float f9 = 1.0F; List list = world.getEntitiesWithinAABBExcludingEntity( player, - player.boundingBox - .addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3) + player.boundingBox.addCoord(vec32.xCoord * d3, vec32.yCoord * d3, vec32.zCoord * d3) .expand((double) f9, (double) f9, (double) f9)); int i; @@ -145,15 +139,18 @@ private ItemStack placeBoat(ItemStack stack, World world, EntityPlayer player, b --j; } - EntityInflatableBoat inflatableBoat = - new EntityInflatableBoat(world, i + 0.5, j + 1.0, k + 0.5, motorized); + EntityInflatableBoat inflatableBoat = new EntityInflatableBoat( + world, + i + 0.5, + j + 1.0, + k + 0.5, + motorized); - inflatableBoat.rotationYaw = (float) - (((MathHelper.floor_double((double) (player.rotationYaw * 4.0 / 360.0) + 0.5D) & 3) - 1) - * 90); + inflatableBoat.rotationYaw = (float) (((MathHelper + .floor_double((double) (player.rotationYaw * 4.0 / 360.0) + 0.5D) & 3) - 1) * 90); if (!world.getCollidingBoundingBoxes( - inflatableBoat, inflatableBoat.boundingBox.expand(-0.1, -0.1, -0.1)) - .isEmpty()) { + inflatableBoat, + inflatableBoat.boundingBox.expand(-0.1, -0.1, -0.1)).isEmpty()) { return stack; } diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemCopterPack.java b/src/main/java/com/darkona/adventurebackpack/item/ItemCopterPack.java index 3365d310..db6baec4 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemCopterPack.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemCopterPack.java @@ -5,19 +5,8 @@ import static com.darkona.adventurebackpack.common.Constants.Copter.TAG_STATUS; import static com.darkona.adventurebackpack.util.TipUtils.l10n; -import com.darkona.adventurebackpack.init.ModNetwork; -import com.darkona.adventurebackpack.inventory.InventoryCopterPack; -import com.darkona.adventurebackpack.network.GUIPacket; -import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; -import com.darkona.adventurebackpack.proxy.ClientProxy; -import com.darkona.adventurebackpack.reference.GeneralReference; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.Resources; -import com.darkona.adventurebackpack.util.TipUtils; -import com.darkona.adventurebackpack.util.Wearing; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.model.ModelBiped; @@ -34,12 +23,27 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.init.ModNetwork; +import com.darkona.adventurebackpack.inventory.InventoryCopterPack; +import com.darkona.adventurebackpack.network.GUIPacket; +import com.darkona.adventurebackpack.network.messages.EntityParticlePacket; +import com.darkona.adventurebackpack.proxy.ClientProxy; +import com.darkona.adventurebackpack.reference.GeneralReference; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.Resources; +import com.darkona.adventurebackpack.util.TipUtils; +import com.darkona.adventurebackpack.util.Wearing; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created on 31/12/2014 * * @author Darkona */ public class ItemCopterPack extends ItemAdventure { + public static byte OFF_MODE = 0; public static byte NORMAL_MODE = 1; public static byte HOVER_MODE = 2; @@ -58,7 +62,7 @@ public void getSubItems(Item item, CreativeTabs tab, List list) { } @Override - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({ "unchecked" }) @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltips, boolean advanced) { FluidTank fuelTank = new FluidTank(FUEL_CAPACITY); @@ -101,9 +105,9 @@ public void onEquipped(World world, EntityPlayer player, ItemStack stack) { } @Override - public void onEquippedUpdate( - World world, EntityPlayer player, ItemStack stack) // TODO extract behavior to separate class - { + public void onEquippedUpdate(World world, EntityPlayer player, ItemStack stack) // TODO extract behavior to separate + // class + { InventoryCopterPack inv = new InventoryCopterPack(Wearing.getWearingCopter(player)); inv.openInventory(); boolean canElevate = true; @@ -167,7 +171,8 @@ public void onEquippedUpdate( // Smoke if (!world.isRemote) { ModNetwork.sendToNearby( - new EntityParticlePacket.Message(EntityParticlePacket.COPTER_PARTICLE, player), player); + new EntityParticlePacket.Message(EntityParticlePacket.COPTER_PARTICLE, player), + player); } // Sound @@ -196,11 +201,8 @@ public void onEquippedUpdate( } int ticks = inv.getTickCounter() - 1; FluidTank tank = inv.getFuelTank(); - if (tank.getFluid() != null - && GeneralReference.isValidFuel(tank.getFluid().getFluid().getName())) { - fuelConsumption = fuelConsumption - * GeneralReference.getFuelRate( - tank.getFluid().getFluid().getName()); + if (tank.getFluid() != null && GeneralReference.isValidFuel(tank.getFluid().getFluid().getName())) { + fuelConsumption = fuelConsumption * GeneralReference.getFuelRate(tank.getFluid().getFluid().getName()); } if (ticks <= 0) { inv.setTickCounter(3); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbow.java b/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbow.java index 0252af34..37c1b8b7 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbow.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbow.java @@ -17,6 +17,7 @@ * @author Darkona */ public class ItemCrossbow extends ItemAB { + public ItemCrossbow() { super(); setFull3D(); @@ -34,32 +35,14 @@ public boolean canItemEditBlocks() { } @Override - public boolean onItemUseFirst( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ) { + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { return false; } @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { return false; } diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbowMagazine.java b/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbowMagazine.java index e2ab6578..0d6fb3a5 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbowMagazine.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemCrossbowMagazine.java @@ -5,4 +5,5 @@ * * @author Darkona */ -public class ItemCrossbowMagazine {} +public class ItemCrossbowMagazine { +} diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemHose.java b/src/main/java/com/darkona/adventurebackpack/item/ItemHose.java index e9e9c557..5235b319 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemHose.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemHose.java @@ -3,17 +3,8 @@ import static com.darkona.adventurebackpack.common.Constants.BUCKET; import static com.darkona.adventurebackpack.util.TipUtils.l10n; -import com.darkona.adventurebackpack.CreativeTabAB; -import com.darkona.adventurebackpack.common.ServerActions; -import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; -import com.darkona.adventurebackpack.init.ModFluids; -import com.darkona.adventurebackpack.inventory.InventoryBackpack; -import com.darkona.adventurebackpack.util.Resources; -import com.darkona.adventurebackpack.util.TipUtils; -import com.darkona.adventurebackpack.util.Wearing; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.List; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.gui.GuiScreen; @@ -38,12 +29,26 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidHandler; + import org.apache.commons.lang3.text.WordUtils; +import com.darkona.adventurebackpack.CreativeTabAB; +import com.darkona.adventurebackpack.common.ServerActions; +import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; +import com.darkona.adventurebackpack.init.ModFluids; +import com.darkona.adventurebackpack.inventory.InventoryBackpack; +import com.darkona.adventurebackpack.util.Resources; +import com.darkona.adventurebackpack.util.TipUtils; +import com.darkona.adventurebackpack.util.Wearing; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created by Darkona on 12/10/2014. */ public class ItemHose extends ItemAB { + private IIcon drinkIcon; private IIcon spillIcon; private IIcon suckIcon; @@ -61,14 +66,15 @@ public ItemHose() { } @Override - @SuppressWarnings({"unchecked"}) + @SuppressWarnings({ "unchecked" }) @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltips, boolean advanced) { if (GuiScreen.isCtrlKeyDown()) { tooltips.add(l10n("hose.key.header")); tooltips.add("- " + TipUtils.pressKeyFormat(TipUtils.actionKeyFormat()) + l10n("hose.key.tank")); - tooltips.add("- " + TipUtils.pressShiftKeyFormat(TipUtils.whiteFormat(l10n("mouse.wheel"))) - + l10n("hose.key.mode")); + tooltips.add( + "- " + TipUtils.pressShiftKeyFormat(TipUtils.whiteFormat(l10n("mouse.wheel"))) + + l10n("hose.key.mode")); tooltips.add(""); tooltips.add(l10n("hose.dump1")); tooltips.add(l10n("hose.dump2")); @@ -159,9 +165,7 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int inv_slot, if (entity == null || !(entity instanceof EntityPlayer)) return; EntityPlayer player = (EntityPlayer) entity; - if (world.isRemote - && player.getItemInUse() != null - && player.getItemInUse().getItem().equals(this)) return; + if (world.isRemote && player.getItemInUse() != null && player.getItemInUse().getItem().equals(this)) return; NBTTagCompound nbt = stack.hasTagCompound() ? stack.getTagCompound() : new NBTTagCompound(); ItemStack backpack = Wearing.getWearingBackpack(player); @@ -171,8 +175,7 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int inv_slot, InventoryBackpack inv = new InventoryBackpack(backpack); FluidTank tank = nbt.getInteger("tank") == 0 ? inv.getLeftTank() : inv.getRightTank(); if (tank != null && tank.getFluid() != null) { - nbt.setString( - "fluid", WordUtils.capitalize(tank.getFluid().getFluid().getName())); + nbt.setString("fluid", WordUtils.capitalize(tank.getFluid().getFluid().getName())); nbt.setInteger("amount", tank.getFluidAmount()); } else { nbt.setInteger("amount", 0); @@ -188,17 +191,8 @@ public void onUpdate(ItemStack stack, World world, Entity entity, int inv_slot, } @Override - public boolean onItemUse( - ItemStack stack, - EntityPlayer player, - World world, - int x, - int y, - int z, - int side, - float hitX, - float hitY, - float hitZ) { + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, + float hitX, float hitY, float hitZ) { if (!Wearing.isWearingBackpack(player)) return true; InventoryBackpack inv = new InventoryBackpack(Wearing.getWearingBackpack(player)); @@ -248,8 +242,8 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla return stack; } // TODO adjust for Adventure Mode - Fluid fluidBlock = - FluidRegistry.lookupFluidForBlock(world.getBlock(mop.blockX, mop.blockY, mop.blockZ)); + Fluid fluidBlock = FluidRegistry + .lookupFluidForBlock(world.getBlock(mop.blockX, mop.blockY, mop.blockZ)); if (fluidBlock != null) { FluidStack fluid = new FluidStack(fluidBlock, BUCKET); if (tank.getFluid() == null || tank.getFluid().containsFluid(fluid)) { @@ -301,7 +295,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla if (!world.isAirBlock(x, y, z) && !flag) { return stack; } - /* IN HELL DIMENSION No, I won't let you put water in the nether. You freak*/ + /* IN HELL DIMENSION No, I won't let you put water in the nether. You freak */ if (world.provider.isHellWorld && fluid.getFluid() == FluidRegistry.WATER) { tank.drain(BUCKET, true); world.playSoundEffect( @@ -337,8 +331,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla if (world.setBlock(x, y, z, Blocks.flowing_lava, 0, 3)) { tank.drain(BUCKET, true); } - } else if (world.setBlock( - x, y, z, fluid.getFluid().getBlock(), 0, 3)) { + } else if (world.setBlock(x, y, z, fluid.getFluid().getBlock(), 0, 3)) { tank.drain(BUCKET, true); } } diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemJuiceBottle.java b/src/main/java/com/darkona/adventurebackpack/item/ItemJuiceBottle.java index 5f02d52d..ac7bb282 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemJuiceBottle.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemJuiceBottle.java @@ -1,9 +1,5 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.CreativeTabAB; -import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; -import com.darkona.adventurebackpack.init.ModFluids; -import com.darkona.adventurebackpack.util.Resources; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -11,12 +7,18 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import com.darkona.adventurebackpack.CreativeTabAB; +import com.darkona.adventurebackpack.fluids.FluidEffectRegistry; +import com.darkona.adventurebackpack.init.ModFluids; +import com.darkona.adventurebackpack.util.Resources; + /** * Created on 19/10/2014 * * @author Darkona */ public class ItemJuiceBottle extends ItemAB { + public ItemJuiceBottle() { super(); setCreativeTab(CreativeTabAB.TAB_AB); diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemMachete.java b/src/main/java/com/darkona/adventurebackpack/item/ItemMachete.java index b81def5d..9bf99ad7 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemMachete.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemMachete.java @@ -1,9 +1,7 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.CreativeTabAB; -import com.darkona.adventurebackpack.init.ModMaterials; -import com.google.common.collect.Sets; import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -17,12 +15,17 @@ import net.minecraftforge.common.IShearable; import net.minecraftforge.oredict.OreDictionary; +import com.darkona.adventurebackpack.CreativeTabAB; +import com.darkona.adventurebackpack.init.ModMaterials; +import com.google.common.collect.Sets; + /** * Created on 10/10/2014 * * @author Darkona */ public class ItemMachete extends ToolAB { + private static final Set BREAKABLE_BLOCKS = Sets.newHashSet( Blocks.pumpkin, Blocks.web, @@ -69,14 +72,11 @@ public float func_150893_a(ItemStack stack, Block block) { for (ItemStack stacky : OreDictionary.getOres("treeLeaves")) { if (stacky.getItem() == Item.getItemFromBlock(block)) return 15F; } - return material == Material.plants - || material == Material.vine - || material == Material.coral - || material == Material.gourd - || material == Material.leaves - || material == Material.cloth - ? 12.0F - : 0.5F; + return material == Material.plants || material == Material.vine + || material == Material.coral + || material == Material.gourd + || material == Material.leaves + || material == Material.cloth ? 12.0F : 0.5F; } @Override @@ -86,10 +86,9 @@ public boolean hitEntity(ItemStack p_77644_1_, EntityLivingBase p_77644_2_, Enti } @Override - public boolean onBlockDestroyed( - ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase entityLivingBase) { - return block == Blocks.vine - || block instanceof IShearable + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, + EntityLivingBase entityLivingBase) { + return block == Blocks.vine || block instanceof IShearable || super.onBlockDestroyed(stack, world, block, x, y, z, entityLivingBase); } diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemPistonBoots.java b/src/main/java/com/darkona/adventurebackpack/item/ItemPistonBoots.java index f22eee8d..fa7ce62b 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemPistonBoots.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemPistonBoots.java @@ -1,6 +1,5 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.config.ConfigHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -8,10 +7,13 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; +import com.darkona.adventurebackpack.config.ConfigHandler; + /** * Created by Darkona on 11/10/2014. */ public class ItemPistonBoots extends ArmorAB { + public ItemPistonBoots() { super(2, 3); setMaxDamage(Items.iron_boots.getMaxDamage() + 55); @@ -21,9 +23,8 @@ public ItemPistonBoots() { @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if (ConfigHandler.pistonBootsAutoStep) player.stepHeight = 1.001F; - if (ConfigHandler.pistonBootsSprintBoost != 0 && player.isSprinting()) - player.addPotionEffect( - new PotionEffect(Potion.moveSpeed.getId(), 1, ConfigHandler.pistonBootsSprintBoost - 1)); + if (ConfigHandler.pistonBootsSprintBoost != 0 && player.isSprinting()) player.addPotionEffect( + new PotionEffect(Potion.moveSpeed.getId(), 1, ConfigHandler.pistonBootsSprintBoost - 1)); } @Override diff --git a/src/main/java/com/darkona/adventurebackpack/item/ItemProjectile.java b/src/main/java/com/darkona/adventurebackpack/item/ItemProjectile.java index 54fadb46..e7694a97 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ItemProjectile.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ItemProjectile.java @@ -7,4 +7,5 @@ * * @author Darkona */ -public class ItemProjectile extends Item {} +public class ItemProjectile extends Item { +} diff --git a/src/main/java/com/darkona/adventurebackpack/item/ToolAB.java b/src/main/java/com/darkona/adventurebackpack/item/ToolAB.java index 048c1daf..4425b7ef 100644 --- a/src/main/java/com/darkona/adventurebackpack/item/ToolAB.java +++ b/src/main/java/com/darkona/adventurebackpack/item/ToolAB.java @@ -1,19 +1,23 @@ package com.darkona.adventurebackpack.item; -import com.darkona.adventurebackpack.reference.ModInfo; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.util.Set; + 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.item.ItemTool; +import com.darkona.adventurebackpack.reference.ModInfo; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + /** * Created by Darkona on 11/10/2014. */ public class ToolAB extends ItemTool { + ToolAB(ToolMaterial material, Set breakableBlocks) { super(1f, material, breakableBlocks); // setCreativeTab(CreativeTabAB.TAB_AB); @@ -26,21 +30,21 @@ public Item setCreativeTab(CreativeTabs tab) { @Override public String getUnlocalizedName(ItemStack stack) { - return String.format( - "item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + return String + .format("item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override public String getUnlocalizedName() { - return String.format( - "item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); + return String + .format("item.%s%s", ModInfo.MOD_ID + ":", getUnwrappedUnlocalizedName(super.getUnlocalizedName())); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon( - this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); + itemIcon = iconRegister + .registerIcon(this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1)); } protected String getUnwrappedUnlocalizedName(String unlocalizedName) { diff --git a/src/main/java/com/darkona/adventurebackpack/nei/BackpackOverlayHandler.java b/src/main/java/com/darkona/adventurebackpack/nei/BackpackOverlayHandler.java index b3c741c2..e3bc5d0b 100644 --- a/src/main/java/com/darkona/adventurebackpack/nei/BackpackOverlayHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/nei/BackpackOverlayHandler.java @@ -1,11 +1,14 @@ package com.darkona.adventurebackpack.nei; -import codechicken.nei.recipe.DefaultOverlayHandler; -import com.darkona.adventurebackpack.inventory.SlotBackpack; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Slot; +import codechicken.nei.recipe.DefaultOverlayHandler; + +import com.darkona.adventurebackpack.inventory.SlotBackpack; + public class BackpackOverlayHandler extends DefaultOverlayHandler { + public BackpackOverlayHandler() { super(127, 55); } diff --git a/src/main/java/com/darkona/adventurebackpack/nei/BackpackStackPositioner.java b/src/main/java/com/darkona/adventurebackpack/nei/BackpackStackPositioner.java index a0d2240e..e0ac4eef 100644 --- a/src/main/java/com/darkona/adventurebackpack/nei/BackpackStackPositioner.java +++ b/src/main/java/com/darkona/adventurebackpack/nei/BackpackStackPositioner.java @@ -1,13 +1,17 @@ package com.darkona.adventurebackpack.nei; +import java.util.ArrayList; + +import net.minecraft.client.Minecraft; + import codechicken.nei.PositionedStack; import codechicken.nei.api.IStackPositioner; import codechicken.nei.recipe.GuiRecipe; + import com.darkona.adventurebackpack.client.gui.GuiAdvBackpack; -import java.util.ArrayList; -import net.minecraft.client.Minecraft; public class BackpackStackPositioner implements IStackPositioner { + @Override public ArrayList positionStacks(ArrayList stacks) { if (Minecraft.getMinecraft().currentScreen instanceof GuiRecipe) { diff --git a/src/main/java/com/darkona/adventurebackpack/nei/NEIConfig.java b/src/main/java/com/darkona/adventurebackpack/nei/NEIConfig.java index 79e9df1f..836334db 100644 --- a/src/main/java/com/darkona/adventurebackpack/nei/NEIConfig.java +++ b/src/main/java/com/darkona/adventurebackpack/nei/NEIConfig.java @@ -2,10 +2,12 @@ import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; + import com.darkona.adventurebackpack.client.gui.GuiAdvBackpack; import com.darkona.adventurebackpack.reference.ModInfo; public class NEIConfig implements IConfigureNEI { + @Override public void loadConfig() { API.registerGuiOverlay(GuiAdvBackpack.class, "crafting", new BackpackStackPositioner()); diff --git a/src/main/java/com/darkona/adventurebackpack/network/CowAbilityPacket.java b/src/main/java/com/darkona/adventurebackpack/network/CowAbilityPacket.java index 7484b8a9..14d780a7 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/CowAbilityPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/CowAbilityPacket.java @@ -1,16 +1,19 @@ package com.darkona.adventurebackpack.network; +import java.util.UUID; + +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; + import com.darkona.adventurebackpack.inventory.ContainerBackpack; import com.darkona.adventurebackpack.inventory.IInventoryBackpack; + import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import java.util.UUID; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; /** * Created on 16/10/2014 @@ -18,6 +21,7 @@ * @author Darkona */ public class CowAbilityPacket implements IMessageHandler { + public static final byte CONSUME_WHEAT = 0; @Override @@ -39,6 +43,7 @@ public IMessage onMessage(CowAbilityMessage message, MessageContext ctx) { } public static class CowAbilityMessage implements IMessage { + private byte action; private String playerID; diff --git a/src/main/java/com/darkona/adventurebackpack/network/CycleToolPacket.java b/src/main/java/com/darkona/adventurebackpack/network/CycleToolPacket.java index 6e2c3902..de5d3982 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/CycleToolPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/CycleToolPacket.java @@ -1,11 +1,13 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.entity.player.EntityPlayerMP; + import com.darkona.adventurebackpack.common.ServerActions; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; /** * Created by Darkona on 12/10/2014. @@ -13,6 +15,7 @@ * @ */ public class CycleToolPacket implements IMessageHandler { + public static final byte TOGGLE_HOSE_TANK = 0; public static final byte SWITCH_HOSE_ACTION = 1; public static final byte CYCLE_TOOL_ACTION = 2; @@ -40,6 +43,7 @@ public IMessage onMessage(CycleToolMessage message, MessageContext ctx) { } public static class CycleToolMessage implements IMessage { + private byte typeOfAction; private boolean isWheelUp; diff --git a/src/main/java/com/darkona/adventurebackpack/network/EquipUnequipBackWearablePacket.java b/src/main/java/com/darkona/adventurebackpack/network/EquipUnequipBackWearablePacket.java index d163dad9..ef5ca15c 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/EquipUnequipBackWearablePacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/EquipUnequipBackWearablePacket.java @@ -1,13 +1,15 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentTranslation; + import com.darkona.adventurebackpack.util.BackpackUtils; import com.darkona.adventurebackpack.util.Wearing; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentTranslation; /** * Created on 08/01/2015 @@ -16,6 +18,7 @@ */ public class EquipUnequipBackWearablePacket implements IMessageHandler { + public static final byte EQUIP_WEARABLE = 0; public static final byte UNEQUIP_WEARABLE = 1; @@ -29,15 +32,14 @@ public Message onMessage(Message message, MessageContext ctx) { if (message.action == EQUIP_WEARABLE && Wearing.isHoldingWearable(player)) { if (Wearing.isWearingWearable(player)) { Wearing.WearableType wtype = Wearing.getWearingWearableType(player); - if (wtype != Wearing.WearableType.UNKNOWN) - player.addChatComponentMessage( - new ChatComponentTranslation("adventurebackpack:messages.already.equipped." - + wtype.name().toLowerCase())); + if (wtype != Wearing.WearableType.UNKNOWN) player.addChatComponentMessage( + new ChatComponentTranslation( + "adventurebackpack:messages.already.equipped." + wtype.name().toLowerCase())); } else if (BackpackUtils.equipWearable(player.getCurrentEquippedItem(), player) == BackpackUtils.Reasons.SUCCESSFUL) { - player.inventory.setInventorySlotContents(player.inventory.currentItem, null); - player.inventoryContainer.detectAndSendChanges(); - } + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventoryContainer.detectAndSendChanges(); + } } else if (message.action == UNEQUIP_WEARABLE) { BackpackUtils.unequipWearable(player); } @@ -46,6 +48,7 @@ public Message onMessage(Message message, MessageContext ctx) { } public static class Message implements IMessage { + private byte action; public Message() {} diff --git a/src/main/java/com/darkona/adventurebackpack/network/GUIPacket.java b/src/main/java/com/darkona/adventurebackpack/network/GUIPacket.java index d5ce93c7..b6bf0df2 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/GUIPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/GUIPacket.java @@ -1,23 +1,26 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; + import com.darkona.adventurebackpack.AdventureBackpack; import com.darkona.adventurebackpack.block.TileAdventureBackpack; import com.darkona.adventurebackpack.handlers.GuiHandler; import com.darkona.adventurebackpack.inventory.ContainerBackpack; import com.darkona.adventurebackpack.reference.GeneralReference; import com.darkona.adventurebackpack.util.Wearing; + import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.world.World; /** * Created by Darkona on 12/10/2014. */ public class GUIPacket implements IMessageHandler { + public static final byte FROM_WEARING = 0; public static final byte FROM_HOLDING = 1; public static final byte FROM_TILE = 2; @@ -40,75 +43,69 @@ public IMessage onMessage(GUImessage message, MessageContext ctx) { if (message.type == COPTER_GUI) { if (message.from == FROM_WEARING) { - if (Wearing.isWearingCopter(player)) - FMLNetworkHandler.openGui( - player, - AdventureBackpack.instance, - GuiHandler.COPTER_WEARING, - world, - playerX, - playerY, - playerZ); + if (Wearing.isWearingCopter(player)) FMLNetworkHandler.openGui( + player, + AdventureBackpack.instance, + GuiHandler.COPTER_WEARING, + world, + playerX, + playerY, + playerZ); } else if (message.from == FROM_HOLDING) { - if (Wearing.isHoldingCopter(player)) - FMLNetworkHandler.openGui( - player, - AdventureBackpack.instance, - GuiHandler.COPTER_HOLDING, - world, - playerX, - playerY, - playerZ); + if (Wearing.isHoldingCopter(player)) FMLNetworkHandler.openGui( + player, + AdventureBackpack.instance, + GuiHandler.COPTER_HOLDING, + world, + playerX, + playerY, + playerZ); } } else if (message.type == JETPACK_GUI) { if (message.from == FROM_WEARING) { - if (Wearing.isWearingJetpack(player)) - FMLNetworkHandler.openGui( - player, - AdventureBackpack.instance, - GuiHandler.JETPACK_WEARING, - world, - playerX, - playerY, - playerZ); + if (Wearing.isWearingJetpack(player)) FMLNetworkHandler.openGui( + player, + AdventureBackpack.instance, + GuiHandler.JETPACK_WEARING, + world, + playerX, + playerY, + playerZ); } else if (message.from == FROM_HOLDING) { - if (Wearing.isHoldingJetpack(player)) - FMLNetworkHandler.openGui( - player, - AdventureBackpack.instance, - GuiHandler.JETPACK_HOLDING, - world, - playerX, - playerY, - playerZ); + if (Wearing.isHoldingJetpack(player)) FMLNetworkHandler.openGui( + player, + AdventureBackpack.instance, + GuiHandler.JETPACK_HOLDING, + world, + playerX, + playerY, + playerZ); } } else if (message.type == BACKPACK_GUI) { if (!GeneralReference.isDimensionAllowed(player)) return null; if (message.from == FROM_WEARING) { - if (Wearing.isWearingBackpack(player)) - FMLNetworkHandler.openGui( - player, - AdventureBackpack.instance, - GuiHandler.BACKPACK_WEARING, - world, - playerX, - playerY, - playerZ); + if (Wearing.isWearingBackpack(player)) FMLNetworkHandler.openGui( + player, + AdventureBackpack.instance, + GuiHandler.BACKPACK_WEARING, + world, + playerX, + playerY, + playerZ); } else if (message.from == FROM_HOLDING) { - if (Wearing.isHoldingBackpack(player)) - FMLNetworkHandler.openGui( - player, - AdventureBackpack.instance, - GuiHandler.BACKPACK_HOLDING, - world, - playerX, - playerY, - playerZ); + if (Wearing.isHoldingBackpack(player)) FMLNetworkHandler.openGui( + player, + AdventureBackpack.instance, + GuiHandler.BACKPACK_HOLDING, + world, + playerX, + playerY, + playerZ); } else if (message.from == FROM_TILE) { if (player.openContainer instanceof ContainerBackpack) { - TileAdventureBackpack te = (TileAdventureBackpack) - ((ContainerBackpack) player.openContainer).getInventoryBackpack(); + TileAdventureBackpack te = (TileAdventureBackpack) ((ContainerBackpack) player.openContainer) + .getInventoryBackpack(); FMLNetworkHandler.openGui( player, AdventureBackpack.instance, @@ -125,6 +122,7 @@ public IMessage onMessage(GUImessage message, MessageContext ctx) { } public static class GUImessage implements IMessage { + private byte type; private byte from; diff --git a/src/main/java/com/darkona/adventurebackpack/network/PlayerActionPacket.java b/src/main/java/com/darkona/adventurebackpack/network/PlayerActionPacket.java index e27a5a7e..27fc64eb 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/PlayerActionPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/PlayerActionPacket.java @@ -1,22 +1,25 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.common.Constants; import com.darkona.adventurebackpack.entity.EntityFriendlySpider; import com.darkona.adventurebackpack.inventory.ContainerBackpack; import com.darkona.adventurebackpack.inventory.IInventoryBackpack; import com.darkona.adventurebackpack.inventory.InventoryCoalJetpack; import com.darkona.adventurebackpack.util.Wearing; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; /** * Created by Darkona on 12/10/2014. */ public class PlayerActionPacket implements IMessageHandler { + public static final byte SPIDER_JUMP = 0; public static final byte JETPACK_IN_USE = 1; public static final byte JETPACK_NOT_IN_USE = 2; @@ -54,6 +57,7 @@ else if (message.type == GUI_NOT_HOLDING_SPACE) } public static class ActionMessage implements IMessage { + private byte type; public ActionMessage() {} diff --git a/src/main/java/com/darkona/adventurebackpack/network/SleepingBagPacket.java b/src/main/java/com/darkona/adventurebackpack/network/SleepingBagPacket.java index d37420c9..e8e6d1d5 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/SleepingBagPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/SleepingBagPacket.java @@ -1,12 +1,14 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.entity.player.EntityPlayerMP; + import com.darkona.adventurebackpack.common.ServerActions; import com.darkona.adventurebackpack.config.ConfigHandler; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; /** * Created on 19/10/2014 @@ -14,6 +16,7 @@ * @author Darkona */ public class SleepingBagPacket implements IMessageHandler { + @Override public IMessage onMessage(SleepingBagMessage message, MessageContext ctx) { if (ctx.side.isServer()) { @@ -30,6 +33,7 @@ public IMessage onMessage(SleepingBagMessage message, MessageContext ctx) { } public static class SleepingBagMessage implements IMessage { + private boolean isTile; private int cX; private int cY; diff --git a/src/main/java/com/darkona/adventurebackpack/network/SyncPropertiesPacket.java b/src/main/java/com/darkona/adventurebackpack/network/SyncPropertiesPacket.java index d3ec8120..9f752ab0 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/SyncPropertiesPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/SyncPropertiesPacket.java @@ -1,15 +1,17 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.client.Minecraft; +import net.minecraft.nbt.NBTTagCompound; + import com.darkona.adventurebackpack.AdventureBackpack; import com.darkona.adventurebackpack.init.ModNetwork; import com.darkona.adventurebackpack.playerProperties.BackpackProperty; + import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.NBTTagCompound; /** * Created on 08/01/2015 @@ -18,6 +20,7 @@ */ public class SyncPropertiesPacket implements IMessageHandler { + public static final byte DATA_ONLY = 0; public static final byte TANKS_ONLY = 1; public static final byte INVENTORY_ONLY = 2; @@ -39,6 +42,7 @@ public Message onMessage(Message message, MessageContext ctx) { } public static class Message implements IMessage { + private int ID; private NBTTagCompound properties; diff --git a/src/main/java/com/darkona/adventurebackpack/network/WearableModePacket.java b/src/main/java/com/darkona/adventurebackpack/network/WearableModePacket.java index 4c5e81c7..f4d03419 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/WearableModePacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/WearableModePacket.java @@ -1,13 +1,15 @@ package com.darkona.adventurebackpack.network; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.common.ServerActions; import com.darkona.adventurebackpack.util.Wearing; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; /** * Created on 12/10/2014 @@ -15,6 +17,7 @@ * @author Darkona */ public class WearableModePacket implements IMessageHandler { + public static final byte COPTER_ON_OFF = 0; public static final byte COPTER_TOGGLE = 1; public static final byte JETPACK_ON_OFF = 2; @@ -38,7 +41,7 @@ public Message onMessage(Message message, MessageContext ctx) { } else if (message.type == JETPACK_ON_OFF) { ItemStack jetpack = Wearing.getWearingJetpack(player); if (jetpack != null) // so now we are well-defended - ServerActions.toggleCoalJetpack(player, jetpack); + ServerActions.toggleCoalJetpack(player, jetpack); } else if (message.type == CYCLING_ON_OFF || message.type == NIGHTVISION_ON_OFF) { ItemStack backpack = Wearing.getWearingBackpack(player); if (backpack != null) // null shall not pass! @@ -52,6 +55,7 @@ public Message onMessage(Message message, MessageContext ctx) { } public static class Message implements IMessage { + private byte type; public Message() {} diff --git a/src/main/java/com/darkona/adventurebackpack/network/messages/EntityParticlePacket.java b/src/main/java/com/darkona/adventurebackpack/network/messages/EntityParticlePacket.java index 8281cd90..d5eff845 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/messages/EntityParticlePacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/messages/EntityParticlePacket.java @@ -1,13 +1,15 @@ package com.darkona.adventurebackpack.network.messages; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; + import com.darkona.adventurebackpack.client.ClientActions; import com.darkona.adventurebackpack.init.ModNetwork; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; /** * Created on 06/01/2015 @@ -16,6 +18,7 @@ */ public class EntityParticlePacket implements IMessageHandler { + public static final byte NYAN_PARTICLE = 0; public static final byte COPTER_PARTICLE = 1; public static final byte SLIME_PARTICLE = 2; @@ -33,6 +36,7 @@ public Message onMessage(Message message, MessageContext ctx) { } public static class Message implements IMessage { + private byte particleCode; private int entityID; diff --git a/src/main/java/com/darkona/adventurebackpack/network/messages/EntitySoundPacket.java b/src/main/java/com/darkona/adventurebackpack/network/messages/EntitySoundPacket.java index d11f7cd9..99cbf298 100644 --- a/src/main/java/com/darkona/adventurebackpack/network/messages/EntitySoundPacket.java +++ b/src/main/java/com/darkona/adventurebackpack/network/messages/EntitySoundPacket.java @@ -1,14 +1,16 @@ package com.darkona.adventurebackpack.network.messages; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; + import com.darkona.adventurebackpack.client.ClientActions; import com.darkona.adventurebackpack.init.ModNetwork; + import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; /** * Created on 06/01/2015 @@ -16,6 +18,7 @@ * @author Darkona */ public class EntitySoundPacket implements IMessageHandler { + public static final boolean play = true; public static final byte NYAN_SOUND = 0; @@ -28,7 +31,8 @@ public class EntitySoundPacket implements IMessageHandler extendedEntityData = new HashMap<>(); @Override @@ -30,9 +33,9 @@ public static void storePlayerProps(EntityPlayer player) { try { NBTTagCompound data = BackpackProperty.get(player).getData(); if (data.hasKey("wearable")) { - LogHelper.info("Storing wearable: " - + ItemStack.loadItemStackFromNBT(data.getCompoundTag("wearable")) - .getDisplayName()); + LogHelper.info( + "Storing wearable: " + + ItemStack.loadItemStackFromNBT(data.getCompoundTag("wearable")).getDisplayName()); } extendedEntityData.put(player.getUniqueID(), data); LogHelper.info("Stored player properties for dead player"); diff --git a/src/main/java/com/darkona/adventurebackpack/reference/BackpackTypes.java b/src/main/java/com/darkona/adventurebackpack/reference/BackpackTypes.java index 574be91a..139d0b4e 100644 --- a/src/main/java/com/darkona/adventurebackpack/reference/BackpackTypes.java +++ b/src/main/java/com/darkona/adventurebackpack/reference/BackpackTypes.java @@ -6,20 +6,23 @@ import static com.darkona.adventurebackpack.reference.BackpackTypes.Props.SPECIAL; import static com.darkona.adventurebackpack.reference.BackpackTypes.Props.TILE; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.google.common.collect.BiMap; -import com.google.common.collect.EnumHashBiMap; -import com.google.common.collect.ImmutableBiMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; import java.util.Arrays; + import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; + import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.text.WordUtils; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.google.common.collect.BiMap; +import com.google.common.collect.EnumHashBiMap; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; + /** * Created on 15.08.2017 * @@ -27,6 +30,7 @@ */ @SuppressWarnings("unused") public enum BackpackTypes { + // @formatter:off STANDARD(0), @@ -155,8 +159,7 @@ public static String getSkinName(ItemStack backpack) { } public static String getLocalizedName(BackpackTypes type) { - return StatCollector.translateToLocal( - "adventurebackpack:skin.name." + type.name().toLowerCase()); + return StatCollector.translateToLocal("adventurebackpack:skin.name." + type.name().toLowerCase()); } public static byte getMeta(BackpackTypes type) { @@ -184,7 +187,7 @@ public static BackpackTypes getType(String skinName) { public static BackpackTypes getType(ItemStack backpack) { if (backpack == null) // well... Wearing.getWearingBackpack() may return null... //TODO solve this damn null - return null; + return null; NBTTagCompound backpackTag = BackpackUtils.getWearableCompound(backpack); if (backpackTag.getByte(TAG_TYPE) == UNKNOWN.meta) // TODO remove? are we rly need to normalize it? @@ -218,13 +221,14 @@ public static boolean hasProperties(BackpackTypes type, ImmutableSet prop } public enum Props { + SPECIAL, REMOVAL, TILE, NIGHT_VISION, - // HOLIDAY, - // OTHER_ABILITY, // creeper or skeleton etc - ; + // HOLIDAY, + // OTHER_ABILITY, // creeper or skeleton etc + ; public static final ImmutableSet POTION_EFFECT = Sets.immutableEnumSet(SPECIAL, REMOVAL); } diff --git a/src/main/java/com/darkona/adventurebackpack/reference/GeneralReference.java b/src/main/java/com/darkona/adventurebackpack/reference/GeneralReference.java index bd50dfa7..74aef0b7 100644 --- a/src/main/java/com/darkona/adventurebackpack/reference/GeneralReference.java +++ b/src/main/java/com/darkona/adventurebackpack/reference/GeneralReference.java @@ -1,22 +1,26 @@ package com.darkona.adventurebackpack.reference; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.util.LogHelper; import java.util.HashMap; import java.util.HashSet; import java.util.Set; + import javax.annotation.Nonnull; import javax.annotation.Nullable; + import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fluids.FluidRegistry; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.util.LogHelper; + /** * Created on 16/01/2015 * * @author Darkona */ public class GeneralReference { + private static HashMap liquidFuels = new HashMap<>(); private static Set dimensionBlacklist = new HashSet<>(); @@ -80,10 +84,12 @@ private static void parseLiquidFuelsConfig() { } if (wrongCount > 0 || unregCount > 0) { - LogHelper.info("Skipped " - + (wrongCount > 0 ? (wrongCount + " incorrect entr" + (wrongCount > 1 ? "ies" : "y")) : "") - + (wrongCount > 0 && unregCount > 0 ? " and " : "") - + (unregCount > 0 ? (unregCount + " unregistered fluid" + (unregCount > 1 ? "s" : "")) : "")); + LogHelper.info( + "Skipped " + + (wrongCount > 0 ? (wrongCount + " incorrect entr" + (wrongCount > 1 ? "ies" : "y")) : "") + + (wrongCount > 0 && unregCount > 0 ? " and " : "") + + (unregCount > 0 ? (unregCount + " unregistered fluid" + (unregCount > 1 ? "s" : "")) + : "")); } } diff --git a/src/main/java/com/darkona/adventurebackpack/reference/LoadedMods.java b/src/main/java/com/darkona/adventurebackpack/reference/LoadedMods.java index 3a51b196..eabd792d 100644 --- a/src/main/java/com/darkona/adventurebackpack/reference/LoadedMods.java +++ b/src/main/java/com/darkona/adventurebackpack/reference/LoadedMods.java @@ -1,9 +1,11 @@ package com.darkona.adventurebackpack.reference; +import net.minecraft.launchwrapper.Launch; + import com.darkona.adventurebackpack.util.LogHelper; + import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; -import net.minecraft.launchwrapper.Launch; /** * Created on 24.02.2018 @@ -11,6 +13,7 @@ * @author Ugachaga */ public final class LoadedMods { + public static final boolean DEV_ENV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); public static final boolean BUILDCRAFT = registerMod("BuildCraft|Core"); diff --git a/src/main/java/com/darkona/adventurebackpack/reference/ModInfo.java b/src/main/java/com/darkona/adventurebackpack/reference/ModInfo.java index 62636741..efec2dbd 100644 --- a/src/main/java/com/darkona/adventurebackpack/reference/ModInfo.java +++ b/src/main/java/com/darkona/adventurebackpack/reference/ModInfo.java @@ -4,6 +4,7 @@ * Created by Darkona on 10/10/2014. */ public class ModInfo { + public static final String MOD_ID = "adventurebackpack"; // must be lowercase public static final String MOD_NAME = "Adventure Backpack"; public static final String MOD_VERSION = "GRADLETOKEN_VERSION"; diff --git a/src/main/java/com/darkona/adventurebackpack/reference/ToolHandler.java b/src/main/java/com/darkona/adventurebackpack/reference/ToolHandler.java index 1fff6973..b2e3a629 100644 --- a/src/main/java/com/darkona/adventurebackpack/reference/ToolHandler.java +++ b/src/main/java/com/darkona/adventurebackpack/reference/ToolHandler.java @@ -1,9 +1,10 @@ package com.darkona.adventurebackpack.reference; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.util.GregtechUtils; import com.darkona.adventurebackpack.util.ThaumcraftUtils; import com.darkona.adventurebackpack.util.TinkersUtils; -import net.minecraft.item.ItemStack; /** * Created on 06.02.2018 @@ -11,11 +12,11 @@ * @author Ugachaga */ public enum ToolHandler { + VANILLA, GREGTECH, TCONSTRUCT, - THAUMCRAFT, - ; + THAUMCRAFT,; public static ToolHandler getToolHandler(ItemStack stack) { if (stack == null) return VANILLA; diff --git a/src/main/java/com/darkona/adventurebackpack/reference/WailaTileAdventureBackpack.java b/src/main/java/com/darkona/adventurebackpack/reference/WailaTileAdventureBackpack.java index bd13feda..e9700719 100644 --- a/src/main/java/com/darkona/adventurebackpack/reference/WailaTileAdventureBackpack.java +++ b/src/main/java/com/darkona/adventurebackpack/reference/WailaTileAdventureBackpack.java @@ -6,18 +6,15 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_TYPE; import static com.darkona.adventurebackpack.common.Constants.TAG_WEARABLE_COMPOUND; -import com.darkona.adventurebackpack.block.TileAdventureBackpack; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.util.BackpackUtils; -import com.darkona.adventurebackpack.util.TipUtils; -import com.darkona.adventurebackpack.util.Utils; -import cpw.mods.fml.common.event.FMLInterModComms; import java.util.List; + import javax.annotation.Nullable; + import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; import mcp.mobius.waila.api.IWailaRegistrar; + import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -28,12 +25,20 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.block.TileAdventureBackpack; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.util.BackpackUtils; +import com.darkona.adventurebackpack.util.TipUtils; +import com.darkona.adventurebackpack.util.Utils; +import cpw.mods.fml.common.event.FMLInterModComms; + /** * Created on 03.02.2018 * * @author Ugachaga */ public class WailaTileAdventureBackpack implements IWailaDataProvider { + public static void init() { FMLInterModComms.sendMessage( "Waila", @@ -63,8 +68,8 @@ private ItemStack addTypeToStack(IWailaDataAccessor accessor) { } @Override - public List getWailaHead( - ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { addHeadToBackpack(currenttip, accessor); return currenttip; } @@ -86,8 +91,8 @@ private static void addHeadToBackpack(List currenttip, NBTTagCompound ba } @Override - public List getWailaBody( - ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { addTipToBackpack(currenttip, accessor); return currenttip; } @@ -116,15 +121,15 @@ private static void addTipToBackpack(List currenttip, NBTTagCompound bac @Nullable @Override - public List getWailaTail( - ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { return null; } @Nullable @Override - public NBTTagCompound getNBTData( - EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) { + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, + int y, int z) { return null; } } diff --git a/src/main/java/com/darkona/adventurebackpack/util/BackpackUtils.java b/src/main/java/com/darkona/adventurebackpack/util/BackpackUtils.java index 9ac74cd0..50e7ac28 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/BackpackUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/BackpackUtils.java @@ -4,12 +4,9 @@ import static com.darkona.adventurebackpack.common.Constants.TAG_TYPE; import static com.darkona.adventurebackpack.common.Constants.TAG_WEARABLE_COMPOUND; -import com.darkona.adventurebackpack.events.WearableEvent; -import com.darkona.adventurebackpack.init.ModItems; -import com.darkona.adventurebackpack.playerProperties.BackpackProperty; -import com.darkona.adventurebackpack.reference.BackpackTypes; import java.util.Timer; import java.util.TimerTask; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -18,12 +15,18 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Constants; +import com.darkona.adventurebackpack.events.WearableEvent; +import com.darkona.adventurebackpack.init.ModItems; +import com.darkona.adventurebackpack.playerProperties.BackpackProperty; +import com.darkona.adventurebackpack.reference.BackpackTypes; + /** * Created on 08/01/2015 * * @author Darkona */ public class BackpackUtils { + private static Timer timer = new Timer(); // TODO remove timer, find the dupe, fix the dupe public enum Reasons { @@ -53,6 +56,7 @@ public static void unequipWearable(EntityPlayer player) { } private static class DelayUnequipTask extends TimerTask { + private EntityPlayer player; DelayUnequipTask(EntityPlayer player) { diff --git a/src/main/java/com/darkona/adventurebackpack/util/ColorReplacer.java b/src/main/java/com/darkona/adventurebackpack/util/ColorReplacer.java index 7d9bf66f..ad3a650c 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/ColorReplacer.java +++ b/src/main/java/com/darkona/adventurebackpack/util/ColorReplacer.java @@ -9,6 +9,7 @@ import java.awt.image.WritableRaster; public class ColorReplacer { + public static BufferedImage colorImage(int colour, BufferedImage image) { int width = image.getWidth(); int height = image.getHeight(); diff --git a/src/main/java/com/darkona/adventurebackpack/util/CoordsUtils.java b/src/main/java/com/darkona/adventurebackpack/util/CoordsUtils.java index b1aeff22..7f45260d 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/CoordsUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/CoordsUtils.java @@ -1,8 +1,7 @@ package com.darkona.adventurebackpack.util; -import com.darkona.adventurebackpack.block.TileAdventureBackpack; -import com.darkona.adventurebackpack.init.ModBlocks; import javax.annotation.Nullable; + import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; @@ -11,12 +10,16 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import com.darkona.adventurebackpack.block.TileAdventureBackpack; +import com.darkona.adventurebackpack.init.ModBlocks; + /** * Created on 31.01.2018 * * @author Ugachaga */ public class CoordsUtils { + private CoordsUtils() {} public static ChunkCoordinates findBlock2D(World world, int cX, int cY, int cZ, Block block, int range) { @@ -30,8 +33,8 @@ public static ChunkCoordinates findBlock2D(World world, int cX, int cY, int cZ, return null; } - public static ChunkCoordinates findBlock3D( - World world, int cX, int cY, int cZ, Block block, int hRange, int vRange) { + public static ChunkCoordinates findBlock3D(World world, int cX, int cY, int cZ, Block block, int hRange, + int vRange) { for (int i = (cY - vRange); i <= (cY + vRange); i++) { for (int j = (cX - hRange); j <= (cX + hRange); j++) { for (int k = (cZ - hRange); k <= (cZ + hRange); k++) { @@ -53,19 +56,17 @@ private static boolean isAirOrReplaceable(IBlockAccess world, int cX, int cY, in return world.isAirBlock(cX, cY, cZ) || world.getBlock(cX, cY, cZ).isReplaceable(world, cX, cY, cZ); } - private static ChunkCoordinates checkCoordsForPlayer( - IBlockAccess world, int origX, int origZ, int cX, int cY, int cZ, boolean except) { + private static ChunkCoordinates checkCoordsForPlayer(IBlockAccess world, int origX, int origZ, int cX, int cY, + int cZ, boolean except) { LogHelper.info("Checking coordinates in X=" + cX + ", Y=" + cY + ", Z=" + cZ); - if (except - && world.isSideSolid(cX, cY - 1, cZ, ForgeDirection.UP, true) + if (except && world.isSideSolid(cX, cY - 1, cZ, ForgeDirection.UP, true) && world.isAirBlock(cX, cY, cZ) && world.isAirBlock(cX, cY + 1, cZ) && !areCoordinatesTheSame2D(origX, origZ, cX, cZ)) { LogHelper.info("Found spot with the exception of the origin point"); return new ChunkCoordinates(cX, cY, cZ); } - if (!except - && world.isSideSolid(cX, cY - 1, cZ, ForgeDirection.UP, true) + if (!except && world.isSideSolid(cX, cY - 1, cZ, ForgeDirection.UP, true) && world.isAirBlock(cX, cY, cZ) && world.isAirBlock(cX, cY + 1, cZ)) { LogHelper.info("Found spot without exceptions"); @@ -75,9 +76,9 @@ private static ChunkCoordinates checkCoordsForPlayer( } /** - * Gets you the nearest Empty Chunk Coordinates, free of charge! Looks in two dimensions and finds a block - * that a: can have stuff placed on it and b: has space above it. - * This is a spiral search, will begin at close range and move out. + * Gets you the nearest Empty Chunk Coordinates, free of charge! Looks in two dimensions and finds a block that a: + * can have stuff placed on it and b: has space above it. This is a spiral search, will begin at close range and + * move out. * * @param world The world object. * @param origX Original cX coordinate @@ -87,23 +88,15 @@ private static ChunkCoordinates checkCoordsForPlayer( * @param cZ Moving cZ coordinate, should be the same as origZ when called. * @param radius The radius of the search. If set to high numbers, will create a ton of lag * @param except Wether to include the origin of the search as a valid block. - * @param steps Number of steps of the recursive recursiveness that recurses through the recursion. It is the first size of the spiral, should be one (1) always at the first call. + * @param steps Number of steps of the recursive recursiveness that recurses through the recursion. It is the first + * size of the spiral, should be one (1) always at the first call. * @param pass Pass switch for the witchcraft I can't quite explain. Set to 0 always at the beggining. * @param type True = for player, False = for backpack - * @return The coordinates of the block in the chunk of the world of the game of the server of the owner of the computer, where you can place something above it. + * @return The coordinates of the block in the chunk of the world of the game of the server of the owner of the + * computer, where you can place something above it. */ - public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral( - IBlockAccess world, - int origX, - int origZ, - int cX, - int cY, - int cZ, - int radius, - boolean except, - int steps, - byte pass, - boolean type) { + public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral(IBlockAccess world, int origX, int origZ, + int cX, int cY, int cZ, int radius, boolean except, int steps, byte pass, boolean type) { // Spiral search, because I'm awesome :) // This is so the backpack tries to get placed near the death point first // And then goes looking farther away at each step @@ -115,8 +108,7 @@ public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral( if (steps % 2 == 0) { if (pass == 0) { for (; i <= cX + steps; i++) { - ChunkCoordinates coords = type - ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) + ChunkCoordinates coords = type ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) : checkCoordsForBackpack(world, cX, cY, cZ); if (coords != null) { return coords; @@ -124,12 +116,21 @@ public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral( } pass++; return getNearestEmptyChunkCoordinatesSpiral( - world, origX, origZ, i, cY, j, radius, except, steps, pass, type); + world, + origX, + origZ, + i, + cY, + j, + radius, + except, + steps, + pass, + type); } if (pass == 1) { for (; j >= cZ - steps; j--) { - ChunkCoordinates coords = type - ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) + ChunkCoordinates coords = type ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) : checkCoordsForBackpack(world, cX, cY, cZ); if (coords != null) { return coords; @@ -138,15 +139,24 @@ public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral( pass--; steps++; return getNearestEmptyChunkCoordinatesSpiral( - world, origX, origZ, i, cY, j, radius, except, steps, pass, type); + world, + origX, + origZ, + i, + cY, + j, + radius, + except, + steps, + pass, + type); } } if (steps % 2 == 1) { if (pass == 0) { for (; i >= cX - steps; i--) { - ChunkCoordinates coords = type - ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) + ChunkCoordinates coords = type ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) : checkCoordsForBackpack(world, cX, cY, cZ); if (coords != null) { return coords; @@ -154,12 +164,21 @@ public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral( } pass++; return getNearestEmptyChunkCoordinatesSpiral( - world, origX, origZ, i, cY, j, radius, except, steps, pass, type); + world, + origX, + origZ, + i, + cY, + j, + radius, + except, + steps, + pass, + type); } if (pass == 1) { for (; j <= cZ + steps; j++) { - ChunkCoordinates coords = type - ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) + ChunkCoordinates coords = type ? checkCoordsForPlayer(world, origX, origZ, cX, cY, cZ, except) : checkCoordsForBackpack(world, cX, cY, cZ); if (coords != null) { return coords; @@ -168,7 +187,17 @@ public static ChunkCoordinates getNearestEmptyChunkCoordinatesSpiral( pass--; steps++; return getNearestEmptyChunkCoordinatesSpiral( - world, origX, origZ, i, cY, j, radius, except, steps, pass, type); + world, + origX, + origZ, + i, + cY, + j, + radius, + except, + steps, + pass, + type); } } @@ -182,7 +211,7 @@ public static int[] canDeploySleepingBag(World world, EntityPlayer player, int c if (!te.isSleepingBagDeployed()) switchBy = world.getBlockMetadata(cX, cY, cZ) & 3; } else { int playerDirection = MathHelper.floor_double((double) ((player.rotationYaw * 4F) / 360F) + 0.5D) & 3; - int[] tileSequence = {2, 3, 0, 1}; + int[] tileSequence = { 2, 3, 0, 1 }; for (int i = 0; i < tileSequence.length; i++) // converts to use isTile format { if (playerDirection == i) { @@ -216,12 +245,11 @@ private static int[] getDirectionAndCoordsForSleepingBag(int switchBy, World wor default: break; } - return new int[] {direction, cX, cY, cZ}; + return new int[] { direction, cX, cY, cZ }; } private static boolean isAirAboveSolid(World world, int cX, int cY, int cZ) { - return world.isAirBlock(cX, cY, cZ) - && world.getBlock(cX, cY - 1, cZ).getMaterial().isSolid(); + return world.isAirBlock(cX, cY, cZ) && world.getBlock(cX, cY - 1, cZ).getMaterial().isSolid(); } public static boolean spawnSleepingBag(EntityPlayer player, World world, int meta, int cX, int cY, int cZ) { diff --git a/src/main/java/com/darkona/adventurebackpack/util/EnchUtils.java b/src/main/java/com/darkona/adventurebackpack/util/EnchUtils.java index 07506468..748f943d 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/EnchUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/EnchUtils.java @@ -1,19 +1,21 @@ package com.darkona.adventurebackpack.util; -import com.darkona.adventurebackpack.config.ConfigHandler; -import com.darkona.adventurebackpack.reference.LoadedMods; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants.NBT; +import com.darkona.adventurebackpack.config.ConfigHandler; +import com.darkona.adventurebackpack.reference.LoadedMods; + /** * Created on 24.03.2017 * * @author Ugachaga */ public final class EnchUtils { + // -3 - disabled by config // -2 - EnderIO not found // -1 - enchantment not found diff --git a/src/main/java/com/darkona/adventurebackpack/util/FluidUtils.java b/src/main/java/com/darkona/adventurebackpack/util/FluidUtils.java index f6e938a9..f7dbc145 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/FluidUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/FluidUtils.java @@ -10,12 +10,12 @@ * @author Darkona */ public class FluidUtils { + public static boolean isContainerForFluid(ItemStack container, Fluid fluid) { if (container != null && fluid != null) { - for (FluidContainerRegistry.FluidContainerData data : - FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (data.fluid != null - && data.fluid.getFluid() != null + for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry + .getRegisteredFluidContainerData()) { + if (data.fluid != null && data.fluid.getFluid() != null && data.fluid.getFluid().getID() == fluid.getID() && (data.emptyContainer.getItem().equals(container.getItem()) || data.filledContainer.getItem().equals(container.getItem()))) { @@ -28,10 +28,9 @@ public static boolean isContainerForFluid(ItemStack container, Fluid fluid) { public static boolean isEmptyContainerForFluid(ItemStack container, Fluid fluid) { if (container != null && fluid != null) { - for (FluidContainerRegistry.FluidContainerData data : - FluidContainerRegistry.getRegisteredFluidContainerData()) { - if (data.fluid != null - && data.fluid.getFluid() != null + for (FluidContainerRegistry.FluidContainerData data : FluidContainerRegistry + .getRegisteredFluidContainerData()) { + if (data.fluid != null && data.fluid.getFluid() != null && data.fluid.getFluid().getID() == fluid.getID() && data.emptyContainer.getItem().equals(container.getItem())) { return true; diff --git a/src/main/java/com/darkona/adventurebackpack/util/GregtechUtils.java b/src/main/java/com/darkona/adventurebackpack/util/GregtechUtils.java index adcfbf1e..678631fd 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/GregtechUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/GregtechUtils.java @@ -1,21 +1,24 @@ package com.darkona.adventurebackpack.util; -import com.darkona.adventurebackpack.reference.LoadedMods; import javax.annotation.Nonnull; + import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; +import com.darkona.adventurebackpack.reference.LoadedMods; + /** * Created on 30.01.2018 * * @author Ugachaga */ public final class GregtechUtils { + private static final String CLASS_RENDERER = "gregtech.common.render.GT_MetaGenerated_Tool_Renderer"; private static final String TOOLS_NAME = "gt.metatool.01"; - private static final int[] ROTATED_45_TOOLS = {16, 26, 30, 130}; - private static final int[] ROTATED_90_TOOLS = {10, 14, 18, 22, 34, 150, 160}; + private static final int[] ROTATED_45_TOOLS = { 16, 26, 30, 130 }; + private static final int[] ROTATED_90_TOOLS = { 10, 14, 18, 22, 34, 150, 160 }; private static Class toolRenderer; private static Object toolRendererInstance; diff --git a/src/main/java/com/darkona/adventurebackpack/util/LogHelper.java b/src/main/java/com/darkona/adventurebackpack/util/LogHelper.java index 5c0bfbaf..2bfa6127 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/LogHelper.java +++ b/src/main/java/com/darkona/adventurebackpack/util/LogHelper.java @@ -1,13 +1,15 @@ package com.darkona.adventurebackpack.util; +import org.apache.logging.log4j.Level; + import com.darkona.adventurebackpack.reference.ModInfo; import cpw.mods.fml.common.FMLLog; -import org.apache.logging.log4j.Level; /** * Created by Darkona on 12/10/2014. */ public class LogHelper { + public static void log(Level logLevel, Object object) { FMLLog.log(ModInfo.MOD_NAME, logLevel, String.valueOf(object)); } diff --git a/src/main/java/com/darkona/adventurebackpack/util/Resources.java b/src/main/java/com/darkona/adventurebackpack/util/Resources.java index bd865d80..0b1053f1 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/Resources.java +++ b/src/main/java/com/darkona/adventurebackpack/util/Resources.java @@ -1,9 +1,10 @@ package com.darkona.adventurebackpack.util; +import net.minecraft.util.ResourceLocation; + import com.darkona.adventurebackpack.init.ModDates; import com.darkona.adventurebackpack.reference.BackpackTypes; import com.darkona.adventurebackpack.reference.ModInfo; -import net.minecraft.util.ResourceLocation; /** * Created on 10/10/2014 @@ -11,11 +12,11 @@ * @author Darkona */ public class Resources { + private static final String TEXTURE_LOCATION = ModInfo.MOD_ID; public static ResourceLocation getBackpackTexture(BackpackTypes type) { - return type == BackpackTypes.STANDARD - ? backpackTextureFromString(ModDates.getHoliday()) + return type == BackpackTypes.STANDARD ? backpackTextureFromString(ModDates.getHoliday()) : backpackTextureFromType(type); } diff --git a/src/main/java/com/darkona/adventurebackpack/util/ThaumcraftUtils.java b/src/main/java/com/darkona/adventurebackpack/util/ThaumcraftUtils.java index 9dd1254d..c5656bcc 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/ThaumcraftUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/ThaumcraftUtils.java @@ -1,15 +1,17 @@ package com.darkona.adventurebackpack.util; -import com.darkona.adventurebackpack.reference.LoadedMods; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; +import com.darkona.adventurebackpack.reference.LoadedMods; + /** * Created on 06.02.2018 * * @author Ugachaga */ public final class ThaumcraftUtils { + public static final boolean DIAL_BOTTOM = setDialBottom(); private static final String CLASS_RENDERER = "thaumcraft.client.renderers.item.ItemWandRenderer"; diff --git a/src/main/java/com/darkona/adventurebackpack/util/TinkersUtils.java b/src/main/java/com/darkona/adventurebackpack/util/TinkersUtils.java index 5e6f6ff9..b71152f4 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/TinkersUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/TinkersUtils.java @@ -1,11 +1,10 @@ package com.darkona.adventurebackpack.util; -import com.darkona.adventurebackpack.reference.LoadedMods; -import com.mojang.authlib.GameProfile; -import cpw.mods.fml.common.FMLCommonHandler; import java.util.UUID; + import javax.annotation.Nonnull; import javax.annotation.Nullable; + import net.minecraft.client.Minecraft; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; @@ -16,12 +15,17 @@ import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.common.util.FakePlayer; +import com.darkona.adventurebackpack.reference.LoadedMods; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.FMLCommonHandler; + /** * Created on 03.02.2018 * * @author Ugachaga */ public final class TinkersUtils { + public static final ResourceLocation GUI_ICONS = new ResourceLocation("tinker", "textures/gui/icons.png"); private static final String CLASS_CRAFTING_LOGIC = "tconstruct.tools.logic.CraftingStationLogic"; @@ -114,8 +118,7 @@ public static synchronized ItemStack getTinkersRecipe(InventoryCrafting craftMat try { craftingStation.getField(FIELD_CRAFT_MATRIX).set(craftingStationInstance, craftMatrix); - craftingStation - .getMethod(METHOD_ON_CRAFT_CHANGED, IInventory.class) + craftingStation.getMethod(METHOD_ON_CRAFT_CHANGED, IInventory.class) .invoke(craftingStationInstance, craftMatrix); return ((IInventory) craftingStation.getField(FIELD_CRAFT_RESULT).get(craftingStationInstance)) diff --git a/src/main/java/com/darkona/adventurebackpack/util/TipUtils.java b/src/main/java/com/darkona/adventurebackpack/util/TipUtils.java index 47ca2ff2..80470ce7 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/TipUtils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/TipUtils.java @@ -1,10 +1,7 @@ package com.darkona.adventurebackpack.util; -import com.darkona.adventurebackpack.common.Constants; -import com.darkona.adventurebackpack.config.Keybindings; -import com.darkona.adventurebackpack.reference.GeneralReference; -import cpw.mods.fml.common.registry.GameData; import java.util.List; + import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagList; @@ -13,12 +10,18 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; +import com.darkona.adventurebackpack.common.Constants; +import com.darkona.adventurebackpack.config.Keybindings; +import com.darkona.adventurebackpack.reference.GeneralReference; +import cpw.mods.fml.common.registry.GameData; + /** * Created on 24.03.2017 * * @author Ugachaga */ public final class TipUtils { + private TipUtils() {} public static String l10n(String tip) { @@ -122,8 +125,8 @@ public static String switchTooltip(boolean status, boolean doFormat) { } private static String switchFormat(boolean status) { - String switchFormatted = - status ? EnumChatFormatting.WHITE + l10n("on") : EnumChatFormatting.DARK_GRAY + l10n("off"); + String switchFormatted = status ? EnumChatFormatting.WHITE + l10n("on") + : EnumChatFormatting.DARK_GRAY + l10n("off"); return "[" + switchFormatted + EnumChatFormatting.GRAY + "]"; } @@ -160,9 +163,7 @@ private static String stackSizeFormat(ItemStack stack, int count) { public static String fuelConsumptionTooltip(FluidTank tank) { return (tank.getFluid() != null) - ? String.format( - "x%.2f", - GeneralReference.getFuelRate(tank.getFluid().getFluid().getName())) + ? String.format("x%.2f", GeneralReference.getFuelRate(tank.getFluid().getFluid().getName())) : EnumChatFormatting.DARK_GRAY + "-"; } diff --git a/src/main/java/com/darkona/adventurebackpack/util/ToolRenderHelper.java b/src/main/java/com/darkona/adventurebackpack/util/ToolRenderHelper.java index beea22cd..73403bab 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/ToolRenderHelper.java +++ b/src/main/java/com/darkona/adventurebackpack/util/ToolRenderHelper.java @@ -9,6 +9,7 @@ * @author Ugachaga */ public final class ToolRenderHelper { + private static final String METHOD_RENDERER = "renderItem"; private static final Object[] EMPTY_OBJECT = {}; diff --git a/src/main/java/com/darkona/adventurebackpack/util/Utils.java b/src/main/java/com/darkona/adventurebackpack/util/Utils.java index fc4b7ed9..2b44a299 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/Utils.java +++ b/src/main/java/com/darkona/adventurebackpack/util/Utils.java @@ -1,10 +1,12 @@ package com.darkona.adventurebackpack.util; +import net.minecraft.client.Minecraft; +import net.minecraft.util.EnumChatFormatting; + import com.darkona.adventurebackpack.reference.BackpackTypes; + import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; -import net.minecraft.client.Minecraft; -import net.minecraft.util.EnumChatFormatting; /** * Created on 12/10/2014 @@ -12,6 +14,7 @@ * @author Darkona */ public class Utils { + public static boolean inServer() { return FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER; } @@ -40,15 +43,9 @@ public static int[] createSlotArray(int first, int count) { return slots; } - private static final EnumChatFormatting[] RAINBOW_SEQUENCE = { - EnumChatFormatting.RED, - EnumChatFormatting.GOLD, - EnumChatFormatting.YELLOW, - EnumChatFormatting.GREEN, - EnumChatFormatting.AQUA, - EnumChatFormatting.BLUE, - EnumChatFormatting.DARK_PURPLE - }; + private static final EnumChatFormatting[] RAINBOW_SEQUENCE = { EnumChatFormatting.RED, EnumChatFormatting.GOLD, + EnumChatFormatting.YELLOW, EnumChatFormatting.GREEN, EnumChatFormatting.AQUA, EnumChatFormatting.BLUE, + EnumChatFormatting.DARK_PURPLE }; public static String makeItRainbow(String stringIn) { StringBuilder rainbowed = new StringBuilder(stringIn.length() * 3); // special characters = length * 2 @@ -123,8 +120,8 @@ private static String animateString(String stringIn, EnumChatFormatting regular, return stringIn; } - private static String decorateCharInString( - String stringIn, int charID, EnumChatFormatting regular, EnumChatFormatting bold, boolean dir) { + private static String decorateCharInString(String stringIn, int charID, EnumChatFormatting regular, + EnumChatFormatting bold, boolean dir) { int len = stringIn.length(); StringBuilder decorated = new StringBuilder(); for (int i = dir ? 0 : len - 1; dir ? i < len : i >= 0; i = dir ? ++i : --i) { diff --git a/src/main/java/com/darkona/adventurebackpack/util/Wearing.java b/src/main/java/com/darkona/adventurebackpack/util/Wearing.java index d206dfbc..ced3ea00 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/Wearing.java +++ b/src/main/java/com/darkona/adventurebackpack/util/Wearing.java @@ -1,5 +1,11 @@ package com.darkona.adventurebackpack.util; +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import com.darkona.adventurebackpack.init.ModItems; import com.darkona.adventurebackpack.inventory.IInventoryTanks; import com.darkona.adventurebackpack.inventory.InventoryBackpack; @@ -8,10 +14,6 @@ import com.darkona.adventurebackpack.item.*; import com.darkona.adventurebackpack.playerProperties.BackpackProperty; import com.darkona.adventurebackpack.reference.BackpackTypes; -import javax.annotation.Nonnull; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; /** * Created on 11/10/2014 @@ -19,7 +21,9 @@ * @author Darkona */ public class Wearing { + public enum WearableType { + BACKPACK, COPTERPACK, JETPACK, diff --git a/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarDate.java b/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarDate.java index b885f0d4..bad39f34 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarDate.java +++ b/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarDate.java @@ -1,12 +1,12 @@ package com.darkona.adventurebackpack.util.calendar; /** - * Created on 22/12/2014 - * Copyright © by Ulrich and David Greve (2005) + * Created on 22/12/2014 Copyright © by Ulrich and David Greve (2005) * * @author Darkona */ public class CalendarDate { + CalendarDate(int day, int month, int year) { this.day = day; this.month = month; diff --git a/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarImpl.java b/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarImpl.java index 14debfe0..b8b1ecca 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarImpl.java +++ b/src/main/java/com/darkona/adventurebackpack/util/calendar/CalendarImpl.java @@ -1,34 +1,27 @@ package com.darkona.adventurebackpack.util.calendar; /** - * Created on 22/12/2014 - * Copyright © by Ulrich and David Greve (2005) + * Created on 22/12/2014 Copyright © by Ulrich and David Greve (2005) * * @author Darkona */ public class CalendarImpl { /* - public static int getWeekday(int absDate) - public int getLastDayOfGregorianMonth(int month, int year) - public int absoluteFromGregorianDate(CalendarDate date) - public CalendarDate gregorianDateFromAbsolute(int absDate) - - public int getLastMonthOfJewishYear(int year) - public int getLastDayOfJewishMonth(int month, int year) - public int absoluteFromJewishDate(CalendarDate date) - public CalendarDate jewishDateFromAbsolute(int absDate) - */ + * public static int getWeekday(int absDate) public int getLastDayOfGregorianMonth(int month, int year) public int + * absoluteFromGregorianDate(CalendarDate date) public CalendarDate gregorianDateFromAbsolute(int absDate) public + * int getLastMonthOfJewishYear(int year) public int getLastDayOfJewishMonth(int month, int year) public int + * absoluteFromJewishDate(CalendarDate date) public CalendarDate jewishDateFromAbsolute(int absDate) + */ // ------------------------------------------------ public static int getWeekday(int absDate) { return (absDate % 7); } - private int month_list[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + private int month_list[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; public int getLastDayOfGregorianMonth(int month, int year) { - if ((month == 2) - && ((year % 4) == 0) + if ((month == 2) && ((year % 4) == 0) && ((year % 400) != 100) && ((year % 400) != 200) && ((year % 400) != 300)) { @@ -70,7 +63,7 @@ public CalendarDate gregorianDateFromAbsolute(int absDate) { /* Search forward from the approximation */ y = approx; - for (; ; ) { + for (;;) { temp = absoluteFromGregorianDate(new CalendarDate(1, 1, y + 1)); if (absDate < temp) break; y++; @@ -79,7 +72,7 @@ public CalendarDate gregorianDateFromAbsolute(int absDate) { /* Search forward from January */ m = 1; - for (; ; ) { + for (;;) { temp = absoluteFromGregorianDate(new CalendarDate(getLastDayOfGregorianMonth(m, year), m, year)); if (absDate <= temp) break; m++; @@ -151,25 +144,20 @@ private int hebrewCalendarElapsedDays(int year) { parts = ((hoursElapsed % 24) * 1080) + (partsElapsed % 1080); /* If new moon is at or after midday, */ - if ((parts >= 19440) - || + if ((parts >= 19440) || - /* ...or is on a Tuesday... */ - (((day % 7) == 2) - && - /* at 9 hours, 204 parts or later */ - (parts >= 9924) - && + /* ...or is on a Tuesday... */ + (((day % 7) == 2) && + /* at 9 hours, 204 parts or later */ + (parts >= 9924) && /* of a common year */ (!hebrewLeapYear(year))) || /* ...or is on a Monday at... */ - (((day % 7) == 1) - && - /* 15 hours, 589 parts or later... */ - (parts >= 16789) - && + (((day % 7) == 1) && + /* 15 hours, 589 parts or later... */ + (parts >= 16789) && /* at the end of a leap year */ (hebrewLeapYear(year - 1)))) /* Then postpone Rosh HaShanah one day */ @@ -255,7 +243,7 @@ public CalendarDate jewishDateFromAbsolute(int absDate) { /* Search forward from the approximation */ y = approx; - for (; ; ) { + for (;;) { temp = absoluteFromJewishDate(new CalendarDate(1, 7, y + 1)); if (absDate < temp) break; y++; @@ -272,7 +260,7 @@ public CalendarDate jewishDateFromAbsolute(int absDate) { /* Search forward from either Tishri or Nisan */ m = start; - for (; ; ) { + for (;;) { temp = absoluteFromJewishDate(new CalendarDate(getLastDayOfJewishMonth(m, year), m, year)); if (absDate <= temp) { break; diff --git a/src/main/java/com/darkona/adventurebackpack/util/calendar/ChineseCalendar.java b/src/main/java/com/darkona/adventurebackpack/util/calendar/ChineseCalendar.java index 6b81dbcd..e11aadc7 100644 --- a/src/main/java/com/darkona/adventurebackpack/util/calendar/ChineseCalendar.java +++ b/src/main/java/com/darkona/adventurebackpack/util/calendar/ChineseCalendar.java @@ -6,6 +6,7 @@ * @author Darkona */ public class ChineseCalendar { + private int gregorianYear; private int gregorianMonth; private int gregorianDate; @@ -17,16 +18,13 @@ public class ChineseCalendar { private int chineseDate; private int sectionalTerm; private int principleTerm; - private static char[] daysInGregorianMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - private static String[] monthNames = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - private static String[] stemNames = { - "Wood", "Wood", "Fire", "Fire", "Earth", "Earth", "Metal", "Metal", "Water", "Water" - }; - private static String[] branchNames = { - "Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Sheep", "Monkey", "Rooster", "Dog", "Boar" - }; + private static char[] daysInGregorianMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + private static String[] monthNames = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", + "Dec" }; + private static String[] stemNames = { "Wood", "Wood", "Fire", "Fire", "Earth", "Earth", "Metal", "Metal", "Water", + "Water" }; + private static String[] branchNames = { "Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Sheep", + "Monkey", "Rooster", "Dog", "Boar" }; public static void generateChineseCalendar(String[] arg) { ChineseCalendar c = new ChineseCalendar(); @@ -117,40 +115,33 @@ public static int dayOfWeek(int y, int m, int d) { } private static char[] chineseMonths = { - // Chinese month map, 2 bytes per year, from 1900 to 2100, 402 bytes. - // The first 4 bits represents the leap month of the year. - // The rest 12 bits are flags indicate if the corresponding month - // is a 29-day month. 2 bytes are stored in low-high order. - 0x00, 0x04, 0xad, 0x08, 0x5a, 0x01, 0xd5, 0x54, 0xb4, 0x09, 0x64, 0x05, 0x59, 0x45, - 0x95, 0x0a, 0xa6, 0x04, 0x55, 0x24, 0xad, 0x08, 0x5a, 0x62, 0xda, 0x04, 0xb4, 0x05, - 0xb4, 0x55, 0x52, 0x0d, 0x94, 0x0a, 0x4a, 0x2a, 0x56, 0x02, 0x6d, 0x71, 0x6d, 0x01, - 0xda, 0x02, 0xd2, 0x52, 0xa9, 0x05, 0x49, 0x0d, 0x2a, 0x45, 0x2b, 0x09, 0x56, 0x01, - 0xb5, 0x20, 0x6d, 0x01, 0x59, 0x69, 0xd4, 0x0a, 0xa8, 0x05, 0xa9, 0x56, 0xa5, 0x04, - 0x2b, 0x09, 0x9e, 0x38, 0xb6, 0x08, 0xec, 0x74, 0x6c, 0x05, 0xd4, 0x0a, 0xe4, 0x6a, - 0x52, 0x05, 0x95, 0x0a, 0x5a, 0x42, 0x5b, 0x04, 0xb6, 0x04, 0xb4, 0x22, 0x6a, 0x05, - 0x52, 0x75, 0xc9, 0x0a, 0x52, 0x05, 0x35, 0x55, 0x4d, 0x0a, 0x5a, 0x02, 0x5d, 0x31, - 0xb5, 0x02, 0x6a, 0x8a, 0x68, 0x05, 0xa9, 0x0a, 0x8a, 0x6a, 0x2a, 0x05, 0x2d, 0x09, - 0xaa, 0x48, 0x5a, 0x01, 0xb5, 0x09, 0xb0, 0x39, 0x64, 0x05, 0x25, 0x75, 0x95, 0x0a, - 0x96, 0x04, 0x4d, 0x54, 0xad, 0x04, 0xda, 0x04, 0xd4, 0x44, 0xb4, 0x05, 0x54, 0x85, - 0x52, 0x0d, 0x92, 0x0a, 0x56, 0x6a, 0x56, 0x02, 0x6d, 0x02, 0x6a, 0x41, 0xda, 0x02, - 0xb2, 0xa1, 0xa9, 0x05, 0x49, 0x0d, 0x0a, 0x6d, 0x2a, 0x09, 0x56, 0x01, 0xad, 0x50, - 0x6d, 0x01, 0xd9, 0x02, 0xd1, 0x3a, 0xa8, 0x05, 0x29, 0x85, 0xa5, 0x0c, 0x2a, 0x09, - 0x96, 0x54, 0xb6, 0x08, 0x6c, 0x09, 0x64, 0x45, 0xd4, 0x0a, 0xa4, 0x05, 0x51, 0x25, - 0x95, 0x0a, 0x2a, 0x72, 0x5b, 0x04, 0xb6, 0x04, 0xac, 0x52, 0x6a, 0x05, 0xd2, 0x0a, - 0xa2, 0x4a, 0x4a, 0x05, 0x55, 0x94, 0x2d, 0x0a, 0x5a, 0x02, 0x75, 0x61, 0xb5, 0x02, - 0x6a, 0x03, 0x61, 0x45, 0xa9, 0x0a, 0x4a, 0x05, 0x25, 0x25, 0x2d, 0x09, 0x9a, 0x68, - 0xda, 0x08, 0xb4, 0x09, 0xa8, 0x59, 0x54, 0x03, 0xa5, 0x0a, 0x91, 0x3a, 0x96, 0x04, - 0xad, 0xb0, 0xad, 0x04, 0xda, 0x04, 0xf4, 0x62, 0xb4, 0x05, 0x54, 0x0b, 0x44, 0x5d, - 0x52, 0x0a, 0x95, 0x04, 0x55, 0x22, 0x6d, 0x02, 0x5a, 0x71, 0xda, 0x02, 0xaa, 0x05, - 0xb2, 0x55, 0x49, 0x0b, 0x4a, 0x0a, 0x2d, 0x39, 0x36, 0x01, 0x6d, 0x80, 0x6d, 0x01, - 0xd9, 0x02, 0xe9, 0x6a, 0xa8, 0x05, 0x29, 0x0b, 0x9a, 0x4c, 0xaa, 0x08, 0xb6, 0x08, - 0xb4, 0x38, 0x6c, 0x09, 0x54, 0x75, 0xd4, 0x0a, 0xa4, 0x05, 0x45, 0x55, 0x95, 0x0a, - 0x9a, 0x04, 0x55, 0x44, 0xb5, 0x04, 0x6a, 0x82, 0x6a, 0x05, 0xd2, 0x0a, 0x92, 0x6a, - 0x4a, 0x05, 0x55, 0x0a, 0x2a, 0x4a, 0x5a, 0x02, 0xb5, 0x02, 0xb2, 0x31, 0x69, 0x03, - 0x31, 0x73, 0xa9, 0x0a, 0x4a, 0x05, 0x2d, 0x55, 0x2d, 0x09, 0x5a, 0x01, 0xd5, 0x48, - 0xb4, 0x09, 0x68, 0x89, 0x54, 0x0b, 0xa4, 0x0a, 0xa5, 0x6a, 0x95, 0x04, 0xad, 0x08, - 0x6a, 0x44, 0xda, 0x04, 0x74, 0x05, 0xb0, 0x25, 0x54, 0x03 - }; + // Chinese month map, 2 bytes per year, from 1900 to 2100, 402 bytes. + // The first 4 bits represents the leap month of the year. + // The rest 12 bits are flags indicate if the corresponding month + // is a 29-day month. 2 bytes are stored in low-high order. + 0x00, 0x04, 0xad, 0x08, 0x5a, 0x01, 0xd5, 0x54, 0xb4, 0x09, 0x64, 0x05, 0x59, 0x45, 0x95, 0x0a, 0xa6, 0x04, + 0x55, 0x24, 0xad, 0x08, 0x5a, 0x62, 0xda, 0x04, 0xb4, 0x05, 0xb4, 0x55, 0x52, 0x0d, 0x94, 0x0a, 0x4a, 0x2a, + 0x56, 0x02, 0x6d, 0x71, 0x6d, 0x01, 0xda, 0x02, 0xd2, 0x52, 0xa9, 0x05, 0x49, 0x0d, 0x2a, 0x45, 0x2b, 0x09, + 0x56, 0x01, 0xb5, 0x20, 0x6d, 0x01, 0x59, 0x69, 0xd4, 0x0a, 0xa8, 0x05, 0xa9, 0x56, 0xa5, 0x04, 0x2b, 0x09, + 0x9e, 0x38, 0xb6, 0x08, 0xec, 0x74, 0x6c, 0x05, 0xd4, 0x0a, 0xe4, 0x6a, 0x52, 0x05, 0x95, 0x0a, 0x5a, 0x42, + 0x5b, 0x04, 0xb6, 0x04, 0xb4, 0x22, 0x6a, 0x05, 0x52, 0x75, 0xc9, 0x0a, 0x52, 0x05, 0x35, 0x55, 0x4d, 0x0a, + 0x5a, 0x02, 0x5d, 0x31, 0xb5, 0x02, 0x6a, 0x8a, 0x68, 0x05, 0xa9, 0x0a, 0x8a, 0x6a, 0x2a, 0x05, 0x2d, 0x09, + 0xaa, 0x48, 0x5a, 0x01, 0xb5, 0x09, 0xb0, 0x39, 0x64, 0x05, 0x25, 0x75, 0x95, 0x0a, 0x96, 0x04, 0x4d, 0x54, + 0xad, 0x04, 0xda, 0x04, 0xd4, 0x44, 0xb4, 0x05, 0x54, 0x85, 0x52, 0x0d, 0x92, 0x0a, 0x56, 0x6a, 0x56, 0x02, + 0x6d, 0x02, 0x6a, 0x41, 0xda, 0x02, 0xb2, 0xa1, 0xa9, 0x05, 0x49, 0x0d, 0x0a, 0x6d, 0x2a, 0x09, 0x56, 0x01, + 0xad, 0x50, 0x6d, 0x01, 0xd9, 0x02, 0xd1, 0x3a, 0xa8, 0x05, 0x29, 0x85, 0xa5, 0x0c, 0x2a, 0x09, 0x96, 0x54, + 0xb6, 0x08, 0x6c, 0x09, 0x64, 0x45, 0xd4, 0x0a, 0xa4, 0x05, 0x51, 0x25, 0x95, 0x0a, 0x2a, 0x72, 0x5b, 0x04, + 0xb6, 0x04, 0xac, 0x52, 0x6a, 0x05, 0xd2, 0x0a, 0xa2, 0x4a, 0x4a, 0x05, 0x55, 0x94, 0x2d, 0x0a, 0x5a, 0x02, + 0x75, 0x61, 0xb5, 0x02, 0x6a, 0x03, 0x61, 0x45, 0xa9, 0x0a, 0x4a, 0x05, 0x25, 0x25, 0x2d, 0x09, 0x9a, 0x68, + 0xda, 0x08, 0xb4, 0x09, 0xa8, 0x59, 0x54, 0x03, 0xa5, 0x0a, 0x91, 0x3a, 0x96, 0x04, 0xad, 0xb0, 0xad, 0x04, + 0xda, 0x04, 0xf4, 0x62, 0xb4, 0x05, 0x54, 0x0b, 0x44, 0x5d, 0x52, 0x0a, 0x95, 0x04, 0x55, 0x22, 0x6d, 0x02, + 0x5a, 0x71, 0xda, 0x02, 0xaa, 0x05, 0xb2, 0x55, 0x49, 0x0b, 0x4a, 0x0a, 0x2d, 0x39, 0x36, 0x01, 0x6d, 0x80, + 0x6d, 0x01, 0xd9, 0x02, 0xe9, 0x6a, 0xa8, 0x05, 0x29, 0x0b, 0x9a, 0x4c, 0xaa, 0x08, 0xb6, 0x08, 0xb4, 0x38, + 0x6c, 0x09, 0x54, 0x75, 0xd4, 0x0a, 0xa4, 0x05, 0x45, 0x55, 0x95, 0x0a, 0x9a, 0x04, 0x55, 0x44, 0xb5, 0x04, + 0x6a, 0x82, 0x6a, 0x05, 0xd2, 0x0a, 0x92, 0x6a, 0x4a, 0x05, 0x55, 0x0a, 0x2a, 0x4a, 0x5a, 0x02, 0xb5, 0x02, + 0xb2, 0x31, 0x69, 0x03, 0x31, 0x73, 0xa9, 0x0a, 0x4a, 0x05, 0x2d, 0x55, 0x2d, 0x09, 0x5a, 0x01, 0xd5, 0x48, + 0xb4, 0x09, 0x68, 0x89, 0x54, 0x0b, 0xa4, 0x0a, 0xa5, 0x6a, 0x95, 0x04, 0xad, 0x08, 0x6a, 0x44, 0xda, 0x04, + 0x74, 0x05, 0xb0, 0x25, 0x54, 0x03 }; // Base date: 01-Jan-1901, 4598/11/11 in Chinese calendar private static int baseYear = 1901; private static int baseIndex = 0; @@ -180,9 +171,9 @@ public int computeChineseFields() { chineseDate = 25; } // Calculating the number of days - // between the start date and the current date + // between the start date and the current date // The following algorithm only works - // for startMonth = 1 and startDate = 1 + // for startMonth = 1 and startDate = 1 int daysDiff = 0; for (int i = startYear; i < gregorianYear; i++) { daysDiff += 365; @@ -195,7 +186,7 @@ public int computeChineseFields() { // Adding that number of days to the Chinese date // Then bring Chinese date into the correct range. - // one Chinese month at a timeInSeconds + // one Chinese month at a timeInSeconds chineseDate += daysDiff; int lastDate = daysInChineseMonth(chineseYear, chineseMonth); int nextMonth = nextChineseMonth(chineseYear, chineseMonth); @@ -210,10 +201,8 @@ public int computeChineseFields() { } private static int[] bigLeapMonthYears = { - // The leap months in the following years have 30 days - 6, 14, 19, 25, 33, 36, 38, 41, 44, 52, - 55, 79, 117, 136, 147, 150, 155, 158, 185, 193 - }; + // The leap months in the following years have 30 days + 6, 14, 19, 25, 33, 36, 38, 41, 44, 52, 55, 79, 117, 136, 147, 150, 155, 158, 185, 193 }; public static int daysInChineseMonth(int y, int m) { // Regular month: m > 0 @@ -262,92 +251,69 @@ public static int nextChineseMonth(int y, int m) { } private static char[][] sectionalTermMap = { - {7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5}, // Jan - {5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 3, 3, 4, 4, 3, 3, 3}, // Feb - {6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5}, // Mar - {5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4, 5, 4, 4, 4, 4, 5}, // Apr - {6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5}, // May - {6, 6, 7, 7, 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5}, - {7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 6, 6, 6, 7, 7}, // Jul - {8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 7}, - {8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 7}, // Sep - {9, 9, 9, 9, 8, 9, 9, 9, 8, 8, 9, 9, 8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 8}, // Oct - {8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 7}, // Nov - {7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 6, 6, 6, 7, 7} // Dec + { 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5 }, // Jan + { 5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 3, 3, 4, 4, 3, 3, 3 }, // Feb + { 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5 }, // Mar + { 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4, 5, 4, 4, 4, 4, 5 }, // Apr + { 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5 }, // May + { 6, 6, 7, 7, 6, 6, 6, 7, 6, 6, 6, 6, 5, 6, 6, 6, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 4, 5, 5, 5, 5 }, + { 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 6, 6, 6, 7, 7 }, // Jul + { 8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 7 }, + { 8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 7 }, // Sep + { 9, 9, 9, 9, 8, 9, 9, 9, 8, 8, 9, 9, 8, 8, 8, 9, 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 8 }, // Oct + { 8, 8, 8, 8, 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 7 }, // Nov + { 7, 8, 8, 8, 7, 7, 8, 8, 7, 7, 7, 8, 7, 7, 7, 7, 6, 7, 7, 7, 6, 6, 7, 7, 6, 6, 6, 7, 7 } // Dec }; - private static char[][] sectionalTermYear = { - {13, 49, 85, 117, 149, 185, 201, 250, 250}, // Jan - {13, 45, 81, 117, 149, 185, 201, 250, 250}, // Feb - {13, 48, 84, 112, 148, 184, 200, 201, 250}, // Mar - {13, 45, 76, 108, 140, 172, 200, 201, 250}, // Apr - {13, 44, 72, 104, 132, 168, 200, 201, 250}, // May - {5, 33, 68, 96, 124, 152, 188, 200, 201}, // Jun - {29, 57, 85, 120, 148, 176, 200, 201, 250}, // Jul - {13, 48, 76, 104, 132, 168, 196, 200, 201}, // Aug - {25, 60, 88, 120, 148, 184, 200, 201, 250}, // Sep - {16, 44, 76, 108, 144, 172, 200, 201, 250}, // Oct - {28, 60, 92, 124, 160, 192, 200, 201, 250}, // Nov - {17, 53, 85, 124, 156, 188, 200, 201, 250} // Dec + private static char[][] sectionalTermYear = { { 13, 49, 85, 117, 149, 185, 201, 250, 250 }, // Jan + { 13, 45, 81, 117, 149, 185, 201, 250, 250 }, // Feb + { 13, 48, 84, 112, 148, 184, 200, 201, 250 }, // Mar + { 13, 45, 76, 108, 140, 172, 200, 201, 250 }, // Apr + { 13, 44, 72, 104, 132, 168, 200, 201, 250 }, // May + { 5, 33, 68, 96, 124, 152, 188, 200, 201 }, // Jun + { 29, 57, 85, 120, 148, 176, 200, 201, 250 }, // Jul + { 13, 48, 76, 104, 132, 168, 196, 200, 201 }, // Aug + { 25, 60, 88, 120, 148, 184, 200, 201, 250 }, // Sep + { 16, 44, 76, 108, 144, 172, 200, 201, 250 }, // Oct + { 28, 60, 92, 124, 160, 192, 200, 201, 250 }, // Nov + { 17, 53, 85, 124, 156, 188, 200, 201, 250 } // Dec }; private static char[][] principleTermMap = { - {21, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 19, 20, 20, 20, 19, 19, 20 - }, - {20, 19, 19, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, 19, 19, 19, 18, 18, 19, 19, 18, 18, 18, 18, 18, 18, 18 - }, - { - 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 20, 20, 20, 20, 19, 20, 20, - 20, 20 - }, - { - 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 20, 20, 20, 20, 19, 20, 20, 20, 19, 19, 20, 20, 19, 19, 19, - 20, 20 - }, - { - 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, - 21, 21 - }, - { - 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, - 21, 21 - }, - { - 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, - 22, 23 - }, - { - 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, - 23, 23 - }, - { - 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, - 23, 23 - }, - { - 24, 24, 24, 24, 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, - 23, 23 - }, - { - 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, - 22, 22 - }, - { - 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, - 21, 22 - } - }; - private static char[][] principleTermYear = { - {13, 45, 81, 113, 149, 185, 201}, // Jan - {21, 57, 93, 125, 161, 193, 201}, // Feb - {21, 56, 88, 120, 152, 188, 200, 201}, // Mar - {21, 49, 81, 116, 144, 176, 200, 201}, // Apr - {17, 49, 77, 112, 140, 168, 200, 201}, // May - {28, 60, 88, 116, 148, 180, 200, 201}, // Jun - {25, 53, 84, 112, 144, 172, 200, 201}, // Jul - {29, 57, 89, 120, 148, 180, 200, 201}, // Aug - {17, 45, 73, 108, 140, 168, 200, 201}, // Sep - {28, 60, 92, 124, 160, 192, 200, 201}, // Oct - {16, 44, 80, 112, 148, 180, 200, 201}, // Nov - {17, 53, 88, 120, 156, 188, 200, 201} // Dec + { 21, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 19, 20, 20, 20, 19, + 19, 20 }, + { 20, 19, 19, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19, 18, 19, 19, 19, 18, 18, 19, 19, 18, 18, 18, 18, 18, + 18, 18 }, + { 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 20, 20, 20, 20, 19, 20, + 20, 20, 20 }, + { 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, 20, 21, 20, 20, 20, 20, 19, 20, 20, 20, 19, 19, 20, 20, 19, 19, + 19, 20, 20 }, + { 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, 21, 21, 20, 20, + 20, 21, 21 }, + { 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, 21, 21, 20, 21, 21, 21, 20, 20, + 21, 21, 21 }, + { 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, + 22, 22, 23 }, + { 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, + 22, 23, 23 }, + { 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, + 22, 23, 23 }, + { 24, 24, 24, 24, 23, 24, 24, 24, 23, 23, 24, 24, 23, 23, 23, 24, 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, + 23, 23, 23 }, + { 23, 23, 23, 23, 22, 23, 23, 23, 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, + 22, 22, 22 }, + { 22, 22, 23, 23, 22, 22, 22, 23, 22, 22, 22, 22, 21, 22, 22, 22, 21, 21, 22, 22, 21, 21, 21, 22, 21, 21, + 21, 21, 22 } }; + private static char[][] principleTermYear = { { 13, 45, 81, 113, 149, 185, 201 }, // Jan + { 21, 57, 93, 125, 161, 193, 201 }, // Feb + { 21, 56, 88, 120, 152, 188, 200, 201 }, // Mar + { 21, 49, 81, 116, 144, 176, 200, 201 }, // Apr + { 17, 49, 77, 112, 140, 168, 200, 201 }, // May + { 28, 60, 88, 116, 148, 180, 200, 201 }, // Jun + { 25, 53, 84, 112, 144, 172, 200, 201 }, // Jul + { 29, 57, 89, 120, 148, 180, 200, 201 }, // Aug + { 17, 45, 73, 108, 140, 168, 200, 201 }, // Sep + { 28, 60, 92, 124, 160, 192, 200, 201 }, // Oct + { 16, 44, 80, 112, 148, 180, 200, 201 }, // Nov + { 17, 53, 88, 120, 156, 188, 200, 201 } // Dec }; public int computeSolarTerms() { @@ -382,12 +348,43 @@ public static int principleTerm(int y, int m) { } public String toString() { - return "Gregorian Year: " + gregorianYear + "\n" + "Gregorian Month: " + gregorianMonth + "\n" - + "Gregorian Date: " + gregorianDate + "\n" + "Is Leap Year: " + isGregorianLeap + "\n" - + "Day of Year: " + dayOfYear + "\n" + "Day of Week: " + dayOfWeek + "\n" + "Chinese Year: " - + chineseYear + "\n" + "Heavenly Stem: " + (chineseYear - 1) % 10 + "\n" + "Earthly Branch: " - + (chineseYear - 1) % 12 + "\n" + "Chinese Month: " + chineseMonth + "\n" + "Chinese Date: " - + chineseDate + "\n" + "Sectional Term: " + sectionalTerm + "\n" + "Principle Term: " + principleTerm + return "Gregorian Year: " + gregorianYear + + "\n" + + "Gregorian Month: " + + gregorianMonth + + "\n" + + "Gregorian Date: " + + gregorianDate + + "\n" + + "Is Leap Year: " + + isGregorianLeap + + "\n" + + "Day of Year: " + + dayOfYear + + "\n" + + "Day of Week: " + + dayOfWeek + + "\n" + + "Chinese Year: " + + chineseYear + + "\n" + + "Heavenly Stem: " + + (chineseYear - 1) % 10 + + "\n" + + "Earthly Branch: " + + (chineseYear - 1) % 12 + + "\n" + + "Chinese Month: " + + chineseMonth + + "\n" + + "Chinese Date: " + + chineseDate + + "\n" + + "Sectional Term: " + + sectionalTerm + + "\n" + + "Principle Term: " + + principleTerm + "\n"; } @@ -400,8 +397,11 @@ public String[] getYearTable() { table[1] = getTextLine( 27, "Chinese Calendar Year: " + (chineseYear + 1) - + " (" + stemNames[(chineseYear + 1 - 1) % 10] - + "-" + branchNames[(chineseYear + 1 - 1) % 12] + ")"); + + " (" + + stemNames[(chineseYear + 1 - 1) % 10] + + "-" + + branchNames[(chineseYear + 1 - 1) % 12] + + ")"); int ln = 2; String[] mLeft = null; String[] mRight = null; @@ -418,8 +418,9 @@ public String[] getYearTable() { } table[ln] = getTextLine(0, null); ln++; - table[ln] = - getTextLine(0, "##/## - Gregorian date/Chinese date," + " (*)CM## - (Leap) Chinese month first day"); + table[ln] = getTextLine( + 0, + "##/## - Gregorian date/Chinese date," + " (*)CM## - (Leap) Chinese month first day"); ln++; table[ln] = getTextLine(0, "ST## - Sectional term, PT## - Principle term"); ln++;