diff --git a/InterModCommsInfo.md b/InterModCommsInfo.md new file mode 100644 index 000000000..35b55309d --- /dev/null +++ b/InterModCommsInfo.md @@ -0,0 +1,31 @@ +Adding Custom Recipes (For Modders only!): +===== + +Actually Additions adds an InterModCommunications Feature that allows you to add custom Crafting Recipes using Items from your Mods. + +To use these Features, just send an InterModComms Message in your preInit or init like this: +FMLInterModComms.sendMessage("ActuallyAdditions", [X], [Y]); +The two Brackets will have to get replaced with one of the parts of Information below. + +##### Crusher Recipes +- Create an NBTTagCompound +- To the Compound, add an NBTTagCompound with the name "input" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an NBTTagCompound with the name "outputOne" that contains the first Output saved to NBT +- To the Compound, add an NBTTagCompound with the name "outputTwo" that contains the second Output saved to NBT +- To the Compound, add an int with the name "secondChance" that contains the Chance for the second Output to appear +- Send the Message with "registerCrusherRecipe" as the [X] Argument, the Compound as the [Y] Argument. + +##### Coffee Machine Recipes +- Create an NBTTagCompound +- To the Compound, add an NBTTagCompound with the name "input" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an int with the name "id" that contains the ID of the Effect the Coffee should have (Look up the Effects in Minecraft's Potion Class!) +- To the Compound, add an int with the name "duration" that contains the Duration the Effect should have +- To the Compound, add an int with the name "amplifier" that contains the Amplifier the Effect should have (Remember: 0 = Level 1!) +- To the Compound, add an int with the name "maxAmp" that contains the maximal Amplifier the Effect can have +- Send the Message with "registerCoffeeMachineRecipe" as the [X] Argument, the Compound as the [Y] Argument. + +##### Ball of Hair Recipes +- Create an NBTTagCompound +- To the Compound, add an NBTTagCompound with the name "output" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an int with the name "chance" that contains the Chance of the Item appearing +- Send the Message with "registerBallOfHairRecipe" as the [X] Argument, the Compound as the [Y] Argument. diff --git a/README.md b/README.md index 43d0c7d31..6cbe6e357 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,36 @@ -It's a Minecraft Mod! +##It's a Minecraft Mod! For more information, visit the main Minecraft Forum Thread at http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2374910-actually-additions-a-bunch-of-awesome-gadgets +If you want to see Information on how you can use my Mod and its InterModComms Feature in your own Mod, see the InterModCommsInfo.md File! -### LICENSE: -All Rights Reserved +LICENSE: +======== -What that means? I can decide what I want to do with the License myself. +##### All Rights Reserved +What that means? The License can be customized by me: ### YOU MAY - Fork and modify the Code - Submit Pull Requests -- Copy Parts of the Code for other Projects +- Copy (SMALL!) Parts of the Code for other Projects - Make a Review/Spotlight of the Mod or use it in a Modpack +- Make Let's Play (and similar) Videos containing my Mod ### YOU CAN NOT - Copy the entire Code or claim it is yours. - Reupload the Code or Mod to another website or claim you made it. - +- Copy entire Classes, Methods or other big Parts of Code. ### YOU HAVE TO - Always credit me. Don't be a jerk and copy entire portions of the code and claim they're yours. - When it comes to the code, always link back to this Repository. - When it comes to the Mod, always link back to the the Forum Thread linked above. + +### NOTES +- The above License only applies for Code I wrote myself, any APIs used (such as the CoFH API and the InventoryTweaks API) have their own License that is being respected. +- Almost all of the Assets used in this Mod are made by Glenthor and are owned by me. You are not allowed to copy them for any other Project without my Permission. + diff --git a/build.gradle b/build.gradle index 4fc4b5d1f..df88062ee 100644 --- a/build.gradle +++ b/build.gradle @@ -18,12 +18,12 @@ buildscript { apply plugin: 'forge' apply plugin: 'maven' -version = "1.7.10-0.0.4.3" +version = "1.7.10-0.0.6.2" group = "ellpeck.actuallyadditions" archivesBaseName = "ActuallyAdditions" minecraft { - version = "1.7.10-10.13.3.1395-1710ls" + version = "1.7.10-10.13.4.1448-1.7.10" runDir = "idea" } @@ -39,21 +39,10 @@ repositories { } dependencies { - compile "mcp.mobius.waila:Waila:1.5.6_1.7.10" - - /*When Compiling from Github, you will need to have this file present - because InventoryTweaks doesn't have a Maven Repo. - But no one is going to download and compile this anyway, so it doesn't really matter. */ - compile files("lib/InventoryTweaks-api-1.58-147.jar") -} - -task copyChickenBones(type: Copy, dependsOn: "extractUserDev") { - from { configurations.compile } - include "**/*Chicken*.jar", "**/*NotEnoughItems*.jar" - exclude "**/CodeChickenLib*" - into file("./run/mods") - mustRunAfter "deobfBinJar" - mustRunAfter "repackMinecraft" + compile "mcp.mobius.waila:Waila:1.5.10_1.7.10" + compile "codechicken:CodeChickenLib:1.7.10-1.1.1.99:dev" + compile "codechicken:CodeChickenCore:1.7.10-1.0.4.29:dev" + compile "codechicken:NotEnoughItems:1.7.10-1.0.3.74:dev" } processResources{ @@ -64,7 +53,7 @@ processResources{ from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' - expand 'update':project.version, 'mcversion':project.minecraft.version + expand 'version':project.version, 'mcversion':project.minecraft.version } from(sourceSets.main.resources.srcDirs) { diff --git a/newestVersion.txt b/newestVersion.txt deleted file mode 100644 index d4ec1fbbc..000000000 --- a/newestVersion.txt +++ /dev/null @@ -1 +0,0 @@ -1.7.10-0.0.4.3 \ No newline at end of file diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java new file mode 100644 index 000000000..9b528304a --- /dev/null +++ b/src/main/java/cofh/api/CoFHAPIProps.java @@ -0,0 +1,11 @@ +package cofh.api; + +public class CoFHAPIProps { + + private CoFHAPIProps() { + + } + + public static final String VERSION = "1.7.10R1.0.2"; + +} diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java new file mode 100644 index 000000000..1674c1894 --- /dev/null +++ b/src/main/java/cofh/api/energy/EnergyStorage.java @@ -0,0 +1,158 @@ +package cofh.api.energy; + +import net.minecraft.nbt.NBTTagCompound; + +/** + * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. + * + * @author King Lemming + * + */ +public class EnergyStorage implements IEnergyStorage { + + protected int energy; + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public EnergyStorage(int capacity) { + + this(capacity, capacity, capacity); + } + + public EnergyStorage(int capacity, int maxTransfer) { + + this(capacity, maxTransfer, maxTransfer); + } + + public EnergyStorage(int capacity, int maxReceive, int maxExtract) { + + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } + + public EnergyStorage readFromNBT(NBTTagCompound nbt) { + + this.energy = nbt.getInteger("Energy"); + + if (energy > capacity) { + energy = capacity; + } + return this; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + + if (energy < 0) { + energy = 0; + } + nbt.setInteger("Energy", energy); + return nbt; + } + + public void setCapacity(int capacity) { + + this.capacity = capacity; + + if (energy > capacity) { + energy = capacity; + } + } + + public void setMaxTransfer(int maxTransfer) { + + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } + + public void setMaxReceive(int maxReceive) { + + this.maxReceive = maxReceive; + } + + public void setMaxExtract(int maxExtract) { + + this.maxExtract = maxExtract; + } + + public int getMaxReceive() { + + return maxReceive; + } + + public int getMaxExtract() { + + return maxExtract; + } + + /** + * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers + * are guaranteed to have it. + * + * @param energy + */ + public void setEnergyStored(int energy) { + + this.energy = energy; + + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } + + /** + * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this + * externally, as not all IEnergyHandlers are guaranteed to have it. + * + * @param energy + */ + public void modifyEnergyStored(int energy) { + + this.energy += energy; + + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } + + /* IEnergyStorage */ + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + } + return energyReceived; + } + + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + } + return energyExtracted; + } + + @Override + public int getEnergyStored() { + + return energy; + } + + @Override + public int getMaxEnergyStored() { + + return capacity; + } + +} diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java new file mode 100644 index 000000000..79bdf77af --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyConnection.java @@ -0,0 +1,21 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not + * accept it; otherwise just use IEnergyHandler. + *

+ * Note that {@link IEnergyHandler} is an extension of this. + * + * @author King Lemming + * + */ +public interface IEnergyConnection { + + /** + * Returns TRUE if the TileEntity can connect on a given side. + */ + boolean canConnectEnergy(ForgeDirection from); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java new file mode 100644 index 000000000..c28455b1a --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyContainerItem.java @@ -0,0 +1,52 @@ +package cofh.api.energy; + +import net.minecraft.item.ItemStack; + +/** + * Implement this interface on Item classes that support external manipulation of their internal energy storages. + *

+ * A reference implementation is provided {@link ItemEnergyContainer}. + * + * @author King Lemming + * + */ +public interface IEnergyContainerItem { + + /** + * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. + * + * @param container + * ItemStack to be charged. + * @param maxReceive + * Maximum amount of energy to be sent into the item. + * @param simulate + * If TRUE, the charge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) received by the item. + */ + int receiveEnergy(ItemStack container, int maxReceive, boolean simulate); + + /** + * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally + * discharged. + * + * @param container + * ItemStack to be discharged. + * @param maxExtract + * Maximum amount of energy to be extracted from the item. + * @param simulate + * If TRUE, the discharge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted from the item. + */ + int extractEnergy(ItemStack container, int maxExtract, boolean simulate); + + /** + * Get the amount of energy currently stored in the container item. + */ + int getEnergyStored(ItemStack container); + + /** + * Get the max amount of energy that can be stored in the container item. + */ + int getMaxEnergyStored(ItemStack container); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java new file mode 100644 index 000000000..22f2dbc62 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyHandler.java @@ -0,0 +1,58 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver { + + // merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things) + + /** + * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. + * + * @param from + * Orientation the energy is received from. + * @param maxReceive + * Maximum amount of energy to receive. + * @param simulate + * If TRUE, the charge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) received. + */ + @Override + int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate); + + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. + * + * @param from + * Orientation the energy is extracted from. + * @param maxExtract + * Maximum amount of energy to extract. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted. + */ + @Override + int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); + + + /** + * Returns the amount of energy currently stored. + */ + @Override + int getEnergyStored(ForgeDirection from); + + /** + * Returns the maximum amount of energy that can be stored. + */ + @Override + int getMaxEnergyStored(ForgeDirection from); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyProvider.java b/src/main/java/cofh/api/energy/IEnergyProvider.java new file mode 100644 index 000000000..05287b35e --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyProvider.java @@ -0,0 +1,38 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyProvider extends IEnergyConnection { + + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. + * + * @param from + * Orientation the energy is extracted from. + * @param maxExtract + * Maximum amount of energy to extract. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted. + */ + int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); + + /** + * Returns the amount of energy currently stored. + */ + int getEnergyStored(ForgeDirection from); + + /** + * Returns the maximum amount of energy that can be stored. + */ + int getMaxEnergyStored(ForgeDirection from); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyReceiver.java b/src/main/java/cofh/api/energy/IEnergyReceiver.java new file mode 100644 index 000000000..c726e09e0 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyReceiver.java @@ -0,0 +1,38 @@ +package cofh.api.energy; + +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects. + *

+ * A reference implementation is provided {@link TileEnergyHandler}. + * + * @author King Lemming + * + */ +public interface IEnergyReceiver extends IEnergyConnection { + + /** + * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. + * + * @param from + * Orientation the energy is received from. + * @param maxReceive + * Maximum amount of energy to receive. + * @param simulate + * If TRUE, the charge will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) received. + */ + int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate); + + /** + * Returns the amount of energy currently stored. + */ + int getEnergyStored(ForgeDirection from); + + /** + * Returns the maximum amount of energy that can be stored. + */ + int getMaxEnergyStored(ForgeDirection from); + +} diff --git a/src/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java new file mode 100644 index 000000000..bc2065607 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyStorage.java @@ -0,0 +1,46 @@ +package cofh.api.energy; + +/** + * An energy storage is the unit of interaction with Energy inventories.
+ * This is not to be implemented on TileEntities. This is for internal use only. + *

+ * A reference implementation can be found at {@link EnergyStorage}. + * + * @author King Lemming + * + */ +public interface IEnergyStorage { + + /** + * Adds energy to the storage. Returns quantity of energy that was accepted. + * + * @param maxReceive + * Maximum amount of energy to be inserted. + * @param simulate + * If TRUE, the insertion will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) accepted by the storage. + */ + int receiveEnergy(int maxReceive, boolean simulate); + + /** + * Removes energy from the storage. Returns quantity of energy that was removed. + * + * @param maxExtract + * Maximum amount of energy to be extracted. + * @param simulate + * If TRUE, the extraction will only be simulated. + * @return Amount of energy that was (or would have been, if simulated) extracted from the storage. + */ + int extractEnergy(int maxExtract, boolean simulate); + + /** + * Returns the amount of energy currently stored. + */ + int getEnergyStored(); + + /** + * Returns the maximum amount of energy that can be stored. + */ + int getMaxEnergyStored(); + +} diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java new file mode 100644 index 000000000..055ae45bc --- /dev/null +++ b/src/main/java/cofh/api/energy/ItemEnergyContainer.java @@ -0,0 +1,110 @@ +package cofh.api.energy; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +/** + * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. + * + * @author King Lemming + * + */ +public class ItemEnergyContainer extends Item implements IEnergyContainerItem { + + protected int capacity; + protected int maxReceive; + protected int maxExtract; + + public ItemEnergyContainer() { + + } + + public ItemEnergyContainer(int capacity) { + + this(capacity, capacity, capacity); + } + + public ItemEnergyContainer(int capacity, int maxTransfer) { + + this(capacity, maxTransfer, maxTransfer); + } + + public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { + + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } + + public ItemEnergyContainer setCapacity(int capacity) { + + this.capacity = capacity; + return this; + } + + public void setMaxTransfer(int maxTransfer) { + + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } + + public void setMaxReceive(int maxReceive) { + + this.maxReceive = maxReceive; + } + + public void setMaxExtract(int maxExtract) { + + this.maxExtract = maxExtract; + } + + /* IEnergyContainerItem */ + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("Energy"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { + return 0; + } + return container.stackTagCompound.getInteger("Energy"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + + return capacity; + } + +} diff --git a/src/main/java/cofh/api/energy/TileEnergyHandler.java b/src/main/java/cofh/api/energy/TileEnergyHandler.java new file mode 100644 index 000000000..7cc655e92 --- /dev/null +++ b/src/main/java/cofh/api/energy/TileEnergyHandler.java @@ -0,0 +1,65 @@ +package cofh.api.energy; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own. + * + * @author King Lemming + * + */ +public class TileEnergyHandler extends TileEntity implements IEnergyHandler { + + protected EnergyStorage storage = new EnergyStorage(32000); + + @Override + public void readFromNBT(NBTTagCompound nbt) { + + super.readFromNBT(nbt); + storage.readFromNBT(nbt); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + + super.writeToNBT(nbt); + storage.writeToNBT(nbt); + } + + /* IEnergyConnection */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + + return true; + } + + /* IEnergyReceiver */ + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + + return storage.receiveEnergy(maxReceive, simulate); + } + + /* IEnergyProvider */ + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + + return storage.extractEnergy(maxExtract, simulate); + } + + /* IEnergyReceiver and IEnergyProvider */ + @Override + public int getEnergyStored(ForgeDirection from) { + + return storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + + return storage.getMaxEnergyStored(); + } + +} diff --git a/src/main/java/cofh/api/energy/package-info.java b/src/main/java/cofh/api/energy/package-info.java new file mode 100644 index 000000000..7379702b8 --- /dev/null +++ b/src/main/java/cofh/api/energy/package-info.java @@ -0,0 +1,10 @@ +/** + * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub + * http://www.teamcofh.com + */ +@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy") +package cofh.api.energy; + +import cofh.api.CoFHAPIProps; +import cpw.mods.fml.common.API; + diff --git a/src/main/java/cofh/api/package-info.java b/src/main/java/cofh/api/package-info.java new file mode 100644 index 000000000..08ff5fcb6 --- /dev/null +++ b/src/main/java/cofh/api/package-info.java @@ -0,0 +1,9 @@ +/** + * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub + * http://www.teamcofh.com + */ +@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI") +package cofh.api; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java index d6d0604a6..5e5da37a6 100644 --- a/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java +++ b/src/main/java/ellpeck/actuallyadditions/ActuallyAdditions.java @@ -10,17 +10,22 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import ellpeck.actuallyadditions.achievement.InitAchievements; import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.communication.InterModCommunications; import ellpeck.actuallyadditions.config.ConfigurationHandler; import ellpeck.actuallyadditions.crafting.GrinderCrafting; import ellpeck.actuallyadditions.crafting.InitCrafting; +import ellpeck.actuallyadditions.crafting.ItemCrafting; import ellpeck.actuallyadditions.event.InitEvents; import ellpeck.actuallyadditions.gen.InitVillager; import ellpeck.actuallyadditions.gen.OreGen; import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.ItemCoffee; import ellpeck.actuallyadditions.material.InitItemMaterials; import ellpeck.actuallyadditions.network.PacketHandler; import ellpeck.actuallyadditions.proxy.IProxy; +import ellpeck.actuallyadditions.recipe.FuelHandler; +import ellpeck.actuallyadditions.recipe.HairyBallHandler; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; @@ -34,23 +39,23 @@ public class ActuallyAdditions{ @SidedProxy(clientSide = "ellpeck.actuallyadditions.proxy.ClientProxy", serverSide = "ellpeck.actuallyadditions.proxy.ServerProxy") public static IProxy proxy; - @EventHandler() + @EventHandler public void preInit(FMLPreInitializationEvent event){ Util.logInfo("Starting PreInitialization Phase..."); - PacketHandler.init(); ConfigurationHandler.init(event.getSuggestedConfigurationFile()); + PacketHandler.init(); InitItemMaterials.init(); InitBlocks.init(); InitItems.init(); InitVillager.init(); + FuelHandler.init(); proxy.preInit(); Util.logInfo("PreInitialization Finished."); } - @SuppressWarnings("unused") - @EventHandler() + @EventHandler public void init(FMLInitializationEvent event){ Util.logInfo("Starting Initialization Phase..."); @@ -66,14 +71,21 @@ public class ActuallyAdditions{ Util.logInfo("Initialization Finished."); } - @SuppressWarnings("unused") - @EventHandler() + @EventHandler public void postInit(FMLPostInitializationEvent event){ Util.logInfo("Starting PostInitialization Phase..."); + ItemCoffee.initIngredients(); GrinderCrafting.init(); + ItemCrafting.initMashedFoodRecipes(); + HairyBallHandler.init(); proxy.postInit(); Util.logInfo("PostInitialization Finished."); } + + @EventHandler + public void onIMCReceived(FMLInterModComms.IMCEvent event){ + InterModCommunications.processIMC(event.getMessages()); + } } diff --git a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt index 44545e5e1..84c7e0f5f 100644 --- a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt +++ b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt @@ -3,13 +3,17 @@ -Doesn't use Levels -Needs Quartz and Diamond Blocks instead of Bookcases around +-Chestie + -Follows you around + -Has an Inventory, a Crafting Table and a Furnace + -Instant Teleport Device -Teleports Players to where they look (Much like the Bukkit Compass) --Magnet - -Pulls Mobs and Items towards it - -Has a certain Redstone Output depending on Mob Amount - -Can be toggled On and Off +-Ender Attractor / Repulsor + -Attracts/Repulses Mobs + -Has an aggressive and a friendly version + -Maybe for Items -Void Bag -Sucks up picked up Items @@ -17,10 +21,6 @@ -Destroys excess Items (also determined by a Filter) -Gets emptied into Chest on Right-Click --Rice - -Gets planted in the Water - -Used to make Rice Flour and Rice Bread - -Auto-Crafting Item -Has a Recipe saved -Crafts Recipe on Shift-Right-Click if all Items are in Inventory @@ -57,7 +57,65 @@ -File Jukebox -Plays Sound Files put into your Minecraft Folder --RF Implementation - -Power Acceptor Block that powers Machines - -Machines still don't accept RF themselves! - -Solar Panel & Heat Collector produce RF \ No newline at end of file +-Pharmacy Plants + -Give you different effects + +-Multi-Block Ore Factory + -Fluids and things higher Multiplying Chance (x2, x3..) + -Speed Upgrades etc. + +-Advanced Redstone Transmitter + -You can mark an area + -On Activation, all blocks in the area get a Signal + +-Thermopile + -Needs a hot and a cold fluid + -Depending on the fluids, it generates more power + +-More Effect Rings + -Ring of Growth: Lets Plants grow, more Reach with Tier 2 + -Ring of Thorns: Hurts Attackers when they hit you with a Projectile + -Ring of Water Walking + -Ring of Flight + -Ring of Aquadive: Fast underwater movement + -Ring of Suction: Sucks up Items in the area + -Ring of Water Absorption: Removes Water around + -Ring of Striptease (Or something like that): Attacker lose parts of their Armor + +-Food Cannon + -Shoots Food Items + -Damage varies with Food + +-Furniture + -Can be put into a Crafting Table with a Banner to give it a pattern (1.8!) + -Parts of the furniture can have different types (eg. Wood, Stone etc.) -> Via Crafting or Tool? + +-Tinker's Concrete + -Customizable with Items in Concrete Mixer + -(eg. Redstone->Speed Glowstone->Light etc.) + +-XP Solidifier + -Block that creates Solidified Experience from Player's Levels + -Has a GUI with Buttons + +-Alarm + -Gets triggered when Mobs are in the Area + -Configurable Range + -Configurable Mobs + +-Industrial Fertilizer + -Grows the whole Plant with one Click + +-Dog Bones + -Breed Dogs faster + -Makes them have Babies too + +-Testificate Bucks + -Village House that has a Coffee Machine + -Villager who sells Coffee and Cookies + +-Inventory Emitter + -Emits a Redstone Signal dependant on the Amount of a specified Item in it + -Items are configurable in the GUI + +-Enderman Teleport Stopper diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockCanolaPress.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCanolaPress.java new file mode 100644 index 000000000..16ca12ff4 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCanolaPress.java @@ -0,0 +1,112 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityCanolaPress; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockCanolaPress extends BlockContainerBase implements INameableItem{ + + private IIcon topIcon; + + public BlockCanolaPress(){ + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return new TileEntityCanolaPress(); + } + + @Override + public IIcon getIcon(int side, int meta){ + return side == 1 || side == 0 ? this.topIcon : this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityCanolaPress press = (TileEntityCanolaPress)world.getTileEntity(x, y, z); + if (press != null) player.openGui(ActuallyAdditions.instance, GuiHandler.CANOLA_PRESS_ID, world, x, y, z); + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getName(){ + return "blockCanolaPress"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addPowerUsageInfo(list, TileEntityCanolaPress.energyUsedPerTick); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoalGenerator.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoalGenerator.java new file mode 100644 index 000000000..637beffdb --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoalGenerator.java @@ -0,0 +1,126 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityCoalGenerator; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +public class BlockCoalGenerator extends BlockContainerBase implements INameableItem{ + + private IIcon topIcon; + + public BlockCoalGenerator(){ + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + this.setTickRandomly(true); + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand){ + int meta = world.getBlockMetadata(x, y, z); + + if (meta == 1){ + for(int i = 0; i < 5; i++){ + world.spawnParticle("smoke", (double)x+0.5F, (double)y + 1.0F, (double)z+0.5F, 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return new TileEntityCoalGenerator(); + } + + @Override + public IIcon getIcon(int side, int meta){ + return side <= 1 ? this.topIcon : this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityCoalGenerator press = (TileEntityCoalGenerator)world.getTileEntity(x, y, z); + if (press != null) player.openGui(ActuallyAdditions.instance, GuiHandler.COAL_GENERATOR_ID, world, x, y, z); + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getName(){ + return "blockCoalGenerator"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addPowerProductionInfo(list, TileEntityCoalGenerator.energyProducedPerTick); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoffeeMachine.java index af10c8998..c0dcaf928 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoffeeMachine.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCoffeeMachine.java @@ -3,11 +3,15 @@ package ellpeck.actuallyadditions.blocks; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine; import ellpeck.actuallyadditions.util.BlockUtil; import ellpeck.actuallyadditions.util.INameableItem; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; @@ -15,6 +19,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; import java.util.List; @@ -22,16 +27,31 @@ import java.util.List; public class BlockCoffeeMachine extends BlockContainerBase implements INameableItem{ public BlockCoffeeMachine(){ - super(Material.wood); - this.setHarvestLevel("axe", 0); + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); this.setHardness(1.0F); - this.setStepSound(soundTypeWood); + this.setStepSound(soundTypeStone); + + float f = 1/16F; + this.setBlockBounds(f, 0F, f, 1F-f, 1F-2*f, 1F-f); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ + int rotation = MathHelper.floor_double((double)(player.rotationYaw*4.0F/360.0F)+0.5D) & 3; + + if(rotation == 0) world.setBlockMetadataWithNotify(x, y, z, 2, 0); + if(rotation == 1) world.setBlockMetadataWithNotify(x, y, z, 1, 3); + if(rotation == 2) world.setBlockMetadataWithNotify(x, y, z, 0, 2); + if(rotation == 3) world.setBlockMetadataWithNotify(x, y, z, 3, 3); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){ if(!world.isRemote){ - + TileEntityCoffeeMachine machine = (TileEntityCoffeeMachine)world.getTileEntity(x, y, z); + if (machine != null) player.openGui(ActuallyAdditions.instance, GuiHandler.COFFEE_MACHINE_ID, world, x, y, z); + return true; } return true; } @@ -44,7 +64,7 @@ public class BlockCoffeeMachine extends BlockContainerBase implements INameableI @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconReg){ - this.blockIcon = Blocks.hopper.getIcon(0, 0); + this.blockIcon = Blocks.coal_block.getIcon(0, 0); } @Override @@ -64,7 +84,7 @@ public class BlockCoffeeMachine extends BlockContainerBase implements INameableI @Override public TileEntity createNewTileEntity(World world, int meta){ - return null; + return new TileEntityCoffeeMachine(); } @Override @@ -96,7 +116,7 @@ public class BlockCoffeeMachine extends BlockContainerBase implements INameableI @Override public EnumRarity getRarity(ItemStack stack){ - return EnumRarity.uncommon; + return EnumRarity.rare; } @Override @@ -108,7 +128,8 @@ public class BlockCoffeeMachine extends BlockContainerBase implements INameableI @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { - BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addInformation(theBlock, list, 5, ""); + BlockUtil.addPowerUsageInfo(list, TileEntityCoffeeMachine.energyUsePerTick); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockCompost.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCompost.java index ec518b1c4..8953a197e 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockCompost.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockCompost.java @@ -33,6 +33,8 @@ public class BlockCompost extends BlockContainerBase implements INameableItem{ this.setHarvestLevel("axe", 0); this.setHardness(1.0F); this.setStepSound(soundTypeWood); + + this.setBlockBoundsForItemRender(); } @Override @@ -46,12 +48,11 @@ public class BlockCompost extends BlockContainerBase implements INameableItem{ else tile.slots[0].stackSize++; if(!player.capabilities.isCreativeMode) player.inventory.getCurrentItem().stackSize--; } + //Add Fertilizer to player's inventory else if(tile.slots[0] != null && (stackPlayer == null || (stackPlayer.getItem() instanceof ItemFertilizer && stackPlayer.stackSize <= stackPlayer.getMaxStackSize() - tile.slots[0].stackSize)) && tile.slots[0].getItem() instanceof ItemFertilizer){ if(stackPlayer == null) player.inventory.setInventorySlotContents(player.inventory.currentItem, tile.slots[0].copy()); else player.getCurrentEquippedItem().stackSize+=tile.slots[0].stackSize; - //TODO Add again when readding Achievements - //player.addStat(InitAchievements.achievementCraftFertilizer, 1); tile.slots[0] = null; } } diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java index f7000482d..1160e5652 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java @@ -4,8 +4,11 @@ import ellpeck.actuallyadditions.tile.TileEntityInventoryBase; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import java.util.Random; @@ -16,26 +19,43 @@ public abstract class BlockContainerBase extends BlockContainer{ super(mat); } - public TileEntityInventoryBase dropInventory(World world, int x, int y, int z){ - TileEntityInventoryBase tileEntity = (TileEntityInventoryBase)world.getTileEntity(x, y, z); - for (int i = 0; i < tileEntity.getSizeInventory(); i++){ - ItemStack itemStack = tileEntity.getStackInSlot(i); - if (itemStack != null && itemStack.stackSize > 0) { - Random rand = new Random(); - float dX = rand.nextFloat() * 0.8F + 0.1F; - float dY = rand.nextFloat() * 0.8F + 0.1F; - float dZ = rand.nextFloat() * 0.8F + 0.1F; - EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy()); - if (itemStack.hasTagCompound()) - entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy()); - float factor = 0.05F; - entityItem.motionX = rand.nextGaussian() * factor; - entityItem.motionY = rand.nextGaussian() * factor + 0.2F; - entityItem.motionZ = rand.nextGaussian() * factor; - world.spawnEntityInWorld(entityItem); - itemStack.stackSize = 0; + public void dropInventory(World world, int x, int y, int z){ + if(!world.isRemote){ + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileEntityInventoryBase){ + TileEntityInventoryBase tileEntity = (TileEntityInventoryBase)tile; + if(tileEntity.getSizeInventory() > 0){ + for(int i = 0; i < tileEntity.getSizeInventory(); i++){ + ItemStack itemStack = tileEntity.getStackInSlot(i); + if(itemStack != null && itemStack.stackSize > 0){ + Random rand = new Random(); + float dX = rand.nextFloat()*0.8F+0.1F; + float dY = rand.nextFloat()*0.8F+0.1F; + float dZ = rand.nextFloat()*0.8F+0.1F; + EntityItem entityItem = new EntityItem(world, x+dX, y+dY, z+dZ, itemStack.copy()); + if(itemStack.hasTagCompound()) entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy()); + float factor = 0.05F; + entityItem.motionX = rand.nextGaussian()*factor; + entityItem.motionY = rand.nextGaussian()*factor+0.2F; + entityItem.motionZ = rand.nextGaussian()*factor; + world.spawnEntityInWorld(entityItem); + itemStack.stackSize = 0; + } + } + } } } - return tileEntity; + } + + @Override + public boolean hasComparatorInputOverride(){ + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int meta){ + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof IInventory) return Container.calcRedstoneFromInventory((IInventory)tile); + return 0; } } diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockEnergizer.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockEnergizer.java new file mode 100644 index 000000000..872c55f45 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockEnergizer.java @@ -0,0 +1,122 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityEnergizer; +import ellpeck.actuallyadditions.tile.TileEntityEnervator; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockEnergizer extends BlockContainerBase implements INameableItem{ + + private IIcon topIcon; + private IIcon sideIcon; + private boolean isEnergizer; + + public BlockEnergizer(boolean isEnergizer){ + super(Material.rock); + this.isEnergizer = isEnergizer; + this.setHarvestLevel("pickaxe", 0); + this.setHardness(2.0F); + this.setStepSound(soundTypeStone); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return this.isEnergizer ? new TileEntityEnergizer() : new TileEntityEnervator(); + } + + @Override + public IIcon getIcon(int side, int meta){ + return side == 1 ? this.topIcon : (side == 0 ? this.blockIcon : this.sideIcon); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + this.sideIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Side"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + if(this.isEnergizer){ + TileEntityEnergizer energizer = (TileEntityEnergizer)world.getTileEntity(x, y, z); + if(energizer != null) player.openGui(ActuallyAdditions.instance, GuiHandler.ENERGIZER_ID, world, x, y, z); + } + else{ + TileEntityEnervator energizer = (TileEntityEnervator)world.getTileEntity(x, y, z); + if(energizer != null) player.openGui(ActuallyAdditions.instance, GuiHandler.ENERVATOR_ID, world, x, y, z); + } + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getName(){ + return this.isEnergizer ? "blockEnergizer" : "blockEnervator"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 2, ""); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFermentingBarrel.java new file mode 100644 index 000000000..68ab2eb43 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFermentingBarrel.java @@ -0,0 +1,111 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityFermentingBarrel; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockFermentingBarrel extends BlockContainerBase implements INameableItem{ + + private IIcon iconTop; + + public BlockFermentingBarrel(){ + super(Material.wood); + this.setHarvestLevel("axe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeWood); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return new TileEntityFermentingBarrel(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityFermentingBarrel press = (TileEntityFermentingBarrel)world.getTileEntity(x, y, z); + if (press != null) player.openGui(ActuallyAdditions.instance, GuiHandler.FERMENTING_BARREL_ID, world, x, y, z); + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public IIcon getIcon(int side, int metadata){ + return side <= 1 ? this.iconTop : this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.iconTop = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + } + + @Override + public String getName(){ + return "blockFermentingBarrel"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int meta){ + return meta; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidCollector.java new file mode 100644 index 000000000..5c7ec84af --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidCollector.java @@ -0,0 +1,135 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityFluidCollector; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.BlockPistonBase; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockFluidCollector extends BlockContainerBase implements INameableItem{ + + private IIcon frontIcon; + private IIcon topIcon; + + private boolean isPlacer; + + public BlockFluidCollector(boolean isPlacer){ + super(Material.rock); + this.isPlacer = isPlacer; + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){ + int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player); + world.setBlockMetadataWithNotify(x, y, z, rotation, 2); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return this.isPlacer ? new TileEntityFluidCollector.TileEntityFluidPlacer() : new TileEntityFluidCollector(); + } + + @Override + public IIcon getIcon(int side, int meta){ + if(side == 0 || side == 1) return this.topIcon; + if(side == 3) return this.frontIcon; + return this.blockIcon; + } + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){ + int meta = world.getBlockMetadata(x, y, z); + if(side != meta && (side == 0 || side == 1)) return this.topIcon; + if(side == meta) return this.frontIcon; + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Front"); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityFluidCollector collector = (TileEntityFluidCollector)world.getTileEntity(x, y, z); + if (collector != null) player.openGui(ActuallyAdditions.instance, GuiHandler.FLUID_COLLECTOR_ID, world, x, y, z); + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getName(){ + return this.isPlacer ? "blockFluidPlacer" : "blockFluidCollector"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidFlowing.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidFlowing.java new file mode 100644 index 000000000..c60c1f7a4 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFluidFlowing.java @@ -0,0 +1,103 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidClassic; +import net.minecraftforge.fluids.Fluid; + +import java.util.List; + +public class BlockFluidFlowing extends BlockFluidClassic implements INameableItem{ + + private String name; + + public IIcon stillIcon; + public IIcon flowingIcon; + + public BlockFluidFlowing(Fluid fluid, Material material, String unlocalizedName){ + super(fluid, material); + this.name = unlocalizedName; + this.setRenderPass(1); + displacements.put(this, false); + } + + @Override + public boolean canDisplace(IBlockAccess world, int x, int y, int z){ + return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.canDisplace(world, x, y, z); + } + + @Override + public boolean displaceIfPossible(World world, int x, int y, int z){ + return !world.getBlock(x, y, z).getMaterial().isLiquid() && super.displaceIfPossible(world, x, y, z); + } + + @Override + public IIcon getIcon(int side, int meta){ + return side <= 1 ? this.stillIcon : this.flowingIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.stillIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Still"); + this.flowingIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Flowing"); + this.definedFluid.setIcons(this.stillIcon, this.flowingIcon); + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceDouble.java index bee306682..f6f4901c3 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceDouble.java @@ -3,6 +3,7 @@ package ellpeck.actuallyadditions.blocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.tile.TileEntityFurnaceDouble; import ellpeck.actuallyadditions.util.BlockUtil; @@ -171,6 +172,7 @@ public class BlockFurnaceDouble extends BlockContainerBase implements INameableI @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addPowerUsageInfo(list, ConfigIntValues.FURNACE_ENERGY_USED.getValue()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceSolar.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceSolar.java index 3f3e8cf14..36949cd77 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceSolar.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockFurnaceSolar.java @@ -23,10 +23,10 @@ import java.util.List; public class BlockFurnaceSolar extends BlockContainerBase implements INameableItem{ public BlockFurnaceSolar(){ - super(Material.wood); - this.setHarvestLevel("axe", 0); + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); this.setHardness(1.0F); - this.setStepSound(soundTypeWood); + this.setStepSound(soundTypeStone); this.setBlockBounds(0F, 0F, 0F, 1F, 3F/16F, 1F); } @@ -97,6 +97,7 @@ public class BlockFurnaceSolar extends BlockContainerBase implements INameableIt @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addPowerProductionInfo(list, TileEntityFurnaceSolar.energyProducedPerTick); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockGeneric.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockGeneric.java new file mode 100644 index 000000000..f908f34aa --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockGeneric.java @@ -0,0 +1,85 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.util.List; + +public class BlockGeneric extends Block implements INameableItem{ + + public String name; + + public BlockGeneric(String name){ + super(Material.rock); + this.name = name; + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public IIcon getIcon(int side, int meta){ + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int meta){ + return meta; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java index 63b653816..1c63f53f6 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java @@ -3,6 +3,7 @@ package ellpeck.actuallyadditions.blocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.inventory.GuiHandler; import ellpeck.actuallyadditions.tile.TileEntityGrinder; import ellpeck.actuallyadditions.util.BlockUtil; @@ -29,7 +30,7 @@ public class BlockGrinder extends BlockContainerBase implements INameableItem{ private IIcon onIcon; private IIcon bottomIcon; - private boolean isDouble; + private final boolean isDouble; public BlockGrinder(boolean isDouble){ super(Material.rock); @@ -134,6 +135,7 @@ public class BlockGrinder extends BlockContainerBase implements INameableItem{ @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { BlockUtil.addInformation(theBlock, list, ((BlockGrinder)theBlock).isDouble ? 3 : 4, ""); + BlockUtil.addPowerUsageInfo(list, ((BlockGrinder)theBlock).isDouble ? ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue() : ConfigIntValues.GRINDER_ENERGY_USED.getValue()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockHeatCollector.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockHeatCollector.java index 6d12ce546..c026c01dd 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockHeatCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockHeatCollector.java @@ -85,6 +85,7 @@ public class BlockHeatCollector extends BlockContainerBase implements INameableI @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { BlockUtil.addInformation(theBlock, list, 3, ""); + BlockUtil.addPowerProductionInfo(list, TileEntityHeatCollector.energyProducedPerTick); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java index 5f9495cde..9f5fa7856 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java @@ -121,7 +121,7 @@ public class BlockInputter extends BlockContainerBase implements INameableItem{ public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { if(KeyUtil.isShiftPressed()){ list.add(StatCollector.translateToLocalFormatted("tooltip." + ModUtil.MOD_ID_LOWER + ".blockInputter.desc." + 1, StringUtil.OBFUSCATED, StringUtil.LIGHT_GRAY)); - for(int i = 1; i < 6; i++){ + for(int i = 1; i < 7; i++){ list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".blockInputter.desc." + (i + 1))); } if((((BlockInputter)theBlock).isAdvanced)) list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + "." + ((INameableItem)theBlock).getName() + ".desc")); diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockItemRepairer.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockItemRepairer.java index 0b41e06d8..905b3d0ce 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockItemRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockItemRepairer.java @@ -21,12 +21,10 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import java.util.List; -import java.util.Random; public class BlockItemRepairer extends BlockContainerBase implements INameableItem{ private IIcon topIcon; - private IIcon onIcon; private IIcon bottomIcon; public BlockItemRepairer(){ @@ -54,24 +52,16 @@ public class BlockItemRepairer extends BlockContainerBase implements INameableIt @Override public IIcon getIcon(int side, int meta){ - if(side == 1 && meta != 1) return this.topIcon; - if(side == 1) return this.onIcon; + if(side == 1) return this.topIcon; if(side == 0) return this.bottomIcon; return this.blockIcon; } - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random rand){ - - } - @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconReg){ this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); - this.onIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "On"); this.bottomIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Bottom"); } @@ -122,6 +112,7 @@ public class BlockItemRepairer extends BlockContainerBase implements INameableIt @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addPowerUsageInfo(list, TileEntityItemRepairer.energyUsePerTick); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockLavaFactoryController.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockLavaFactoryController.java new file mode 100644 index 000000000..782eb30f2 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockLavaFactoryController.java @@ -0,0 +1,118 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.tile.TileEntityLavaFactoryController; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockLavaFactoryController extends BlockContainerBase implements INameableItem{ + + private IIcon topIcon; + + public BlockLavaFactoryController(){ + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return new TileEntityLavaFactoryController(); + } + + @Override + public IIcon getIcon(int side, int meta){ + return side == 1 ? this.topIcon : this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityLavaFactoryController factory = (TileEntityLavaFactoryController)world.getTileEntity(x, y, z); + if(factory != null){ + int state = factory.isMultiblock(); + if(state == TileEntityLavaFactoryController.NOT_MULTI){ + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".factory.notPart.desc"))); + } + if(state == TileEntityLavaFactoryController.HAS_AIR || state == TileEntityLavaFactoryController.HAS_LAVA){ + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".factory.works.desc"))); + } + player.addChatComponentMessage(new ChatComponentText(factory.storage.getEnergyStored() + "/" + factory.storage.getMaxEnergyStored() + " RF")); + } + return true; + } + return true; + } + + @Override + public String getName(){ + return "blockLavaFactoryController"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 3, ""); + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".uses.desc") + " " + TileEntityLavaFactoryController.energyNeededToProduceLava + " RF/B"); + } + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockMisc.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockMisc.java index 1bb1a2594..8ceeed77b 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockMisc.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockMisc.java @@ -45,7 +45,7 @@ public class BlockMisc extends Block implements INameableItem{ @Override public IIcon getIcon(int side, int metadata){ - return textures[metadata]; + return metadata >= textures.length ? null : textures[metadata]; } @Override @@ -79,19 +79,19 @@ public class BlockMisc extends Block implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allMiscBlocks[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allMiscBlocks.length ? EnumRarity.common : allMiscBlocks[stack.getItemDamage()].rarity; } @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allMiscBlocks[stack.getItemDamage()].getName(); + return this.getUnlocalizedName() + (stack.getItemDamage() >= allMiscBlocks.length ? " ERROR!" : allMiscBlocks[stack.getItemDamage()].getName()); } @Override @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { - BlockUtil.addInformation(theBlock, list, 1, allMiscBlocks[stack.getItemDamage()].getName()); + if(stack.getItemDamage() < allMiscBlocks.length) BlockUtil.addInformation(theBlock, list, 1, allMiscBlocks[stack.getItemDamage()].getName()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockOilGenerator.java new file mode 100644 index 000000000..6fc338596 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockOilGenerator.java @@ -0,0 +1,126 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityOilGenerator; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +public class BlockOilGenerator extends BlockContainerBase implements INameableItem{ + + private IIcon topIcon; + + public BlockOilGenerator(){ + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + this.setTickRandomly(true); + } + + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random rand){ + int meta = world.getBlockMetadata(x, y, z); + + if (meta == 1){ + for(int i = 0; i < 5; i++){ + world.spawnParticle("smoke", (double)x+0.5F, (double)y + 1.0F, (double)z+0.5F, 0.0D, 0.0D, 0.0D); + } + } + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + return new TileEntityOilGenerator(); + } + + @Override + public IIcon getIcon(int side, int meta){ + return side <= 1 ? this.topIcon : this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Top"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ + if(!world.isRemote){ + TileEntityOilGenerator generator = (TileEntityOilGenerator)world.getTileEntity(x, y, z); + if (generator != null) player.openGui(ActuallyAdditions.instance, GuiHandler.OIL_GENERATOR_ID, world, x, y, z); + return true; + } + return true; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getName(){ + return "blockOilGenerator"; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + BlockUtil.addPowerProductionInfo(list, TileEntityOilGenerator.energyProducedPerTick); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockPhantomBooster.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPhantomBooster.java new file mode 100644 index 000000000..268276d99 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPhantomBooster.java @@ -0,0 +1,109 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.tile.TileEntityPhantomBooster; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockPhantomBooster extends BlockContainerBase implements INameableItem{ + + public BlockPhantomBooster(){ + super(Material.rock); + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + + float f = 1F/16F; + this.setBlockBounds(3*f, 0F, 3*f, 1-3*f, 1F, 1-3*f); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + public boolean renderAsNormalBlock(){ + return false; + } + + @Override + public int getRenderType(){ + return RenderingRegistry.getNextAvailableRenderId(); + } + + @Override + public IIcon getIcon(int side, int metadata){ + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = Blocks.lapis_block.getIcon(0, 0); + } + + @Override + public String getName(){ + return "blockPhantomBooster"; + } + + @Override + public TileEntity createNewTileEntity(World world, int i){ + return new TileEntityPhantomBooster(); + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.epic; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 2, ""); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockPhantomface.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPhantomface.java new file mode 100644 index 000000000..06b5c994f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPhantomface.java @@ -0,0 +1,174 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer; +import ellpeck.actuallyadditions.tile.TileEntityPhantomface; +import ellpeck.actuallyadditions.util.*; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockPhantomface extends BlockContainerBase implements INameableItem{ + + public static final int FACE = 0; + public static final int PLACER = 1; + public static final int BREAKER = 2; + public static final int LIQUIFACE = 3; + public static final int ENERGYFACE = 4; + + public int type; + public int range; + + public BlockPhantomface(int type){ + super(Material.rock); + this.type = type; + this.setHarvestLevel("pickaxe", 0); + this.setHardness(1.0F); + this.setStepSound(soundTypeStone); + + if(type == FACE || type == LIQUIFACE || type == ENERGYFACE) this.range = ConfigIntValues.PHANTOMFACE_RANGE.getValue(); + else if(type == BREAKER || type == PLACER) this.range = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue(); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int par6){ + if(this.type == PLACER || this.type == BREAKER) this.dropInventory(world, x, y, z); + super.breakBlock(world, x, y, z, block, par6); + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ){ + if(!world.isRemote){ + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null){ + if(tile instanceof TileEntityPhantomface){ + TileEntityPhantomface phantom = (TileEntityPhantomface)tile; + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range)); + if(phantom.hasBoundTile()){ + if(phantom.isBoundTileInRage()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedBlock.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ))); + else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ))); + } + else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"))); + } + + else if(tile instanceof TileEntityPhantomPlacer){ + if(player.isSneaking()){ + TileEntityPhantomPlacer phantom = (TileEntityPhantomPlacer)tile; + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.range)); + if(phantom.hasBoundPosition()){ + if(phantom.isBoundPositionInRange()) player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedBlock.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ))); + else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connectedNoRange.desc", phantom.boundPosition.posX, phantom.boundPosition.posY, phantom.boundPosition.posZ))); + } + else player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.notConnected.desc"))); + } + else player.openGui(ActuallyAdditions.instance, GuiHandler.PHANTOM_PLACER_ID, world, x, y, z); + } + } + } + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int par2){ + switch(this.type){ + case PLACER: + return new TileEntityPhantomPlacer(); + case BREAKER: + return new TileEntityPhantomPlacer.TileEntityPhantomBreaker(); + case LIQUIFACE: + return new TileEntityPhantomface.TileEntityPhantomLiquiface(); + case ENERGYFACE: + return new TileEntityPhantomface.TileEntityPhantomEnergyface(); + default: + return new TileEntityPhantomface.TileEntityPhantomItemface(); + } + } + + @Override + public IIcon getIcon(int side, int metadata){ + return this.blockIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + switch(this.type){ + case PLACER: + return "blockPhantomPlacer"; + case BREAKER: + return "blockPhantomBreaker"; + case LIQUIFACE: + return "blockPhantomLiquiface"; + case ENERGYFACE: + return "blockPhantomEnergyface"; + default: + return "blockPhantomface"; + } + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.epic; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 2, ""); + if(KeyUtil.isShiftPressed()){ + if(((BlockPhantomface)this.theBlock).type == LIQUIFACE){ + list.add(StringUtil.ORANGE+StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.3")); + list.add(StringUtil.ORANGE+StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.4")); + } + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + ((BlockPhantomface)theBlock).range); + } + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java new file mode 100644 index 000000000..f48af25a9 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockPlant.java @@ -0,0 +1,130 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.BlockCrops; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +public class BlockPlant extends BlockCrops implements INameableItem{ + + private IIcon[] textures; + private String name; + public Item seedItem; + public Item returnItem; + public int returnMeta; + private int minDropAmount; + private int addDropAmount; + + public BlockPlant(String name, int stages, int minDropAmount, int addDropAmount){ + this.name = name; + this.textures = new IIcon[stages]; + this.minDropAmount = minDropAmount; + this.addDropAmount = addDropAmount; + } + + @Override + public int quantityDropped(int meta, int fortune, Random random){ + return meta >= 7 ? random.nextInt(addDropAmount)+minDropAmount : super.quantityDropped(meta, fortune, random); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta){ + if(meta < 7){ + if (meta == 6) meta = 5; + return this.textures[meta >> 1]; + } + else return this.textures[this.textures.length-1]; + } + + @Override + public Item func_149866_i(){ + return this.seedItem; + } + + @Override + public Item getItemDropped(int meta, Random rand, int par3){ + return meta >= 7 ? this.func_149865_P() : this.func_149866_i(); + } + + @Override + public Item func_149865_P(){ + return this.returnItem; + } + + @Override + public int damageDropped(int meta){ + return this.returnMeta; + } + + @Override + public int getDamageValue(World world, int x, int y, int z){ + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconReg){ + for (int i = 0; i < this.textures.length; i++){ + textures[i] = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName() + "Stage" + (i+1)); + } + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockSlabs.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockSlabs.java new file mode 100644 index 000000000..ab02e09b0 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockSlabs.java @@ -0,0 +1,129 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import java.util.List; + +public class BlockSlabs extends Block implements INameableItem{ + + private String name; + private Block fullBlock; + + public BlockSlabs(String name, Block fullBlock){ + super(Material.rock); + this.fullBlock = fullBlock; + this.name = name; + } + + @Override + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axis, List list, Entity entity){ + this.setBlockBoundsBasedOnState(world, x, y, z); + super.addCollisionBoxesToList(world, x, y, z, axis, list, entity); + } + + @Override + public void setBlockBoundsForItemRender(){ + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){ + int meta = world.getBlockMetadata(x, y, z); + float minY = meta == 1 ? 0.5F : 0.0F; + float maxY = meta == 1 ? 1.0F : 0.5F; + this.setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F); + } + + @Override + public int onBlockPlaced(World par1World, int blockX, int blockY, int blockZ, int side, float hitX, float hitY, float hitZ, int meta){ + if (side == 1) return meta; + if (side == 0 || hitY >= 0.5F) return meta+1; + return meta; + } + + @Override + public boolean isOpaqueCube(){ + return false; + } + + @Override + public boolean renderAsNormalBlock(){ + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta){ + return this.fullBlock.getIcon(0, 0); + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int meta){ + return meta; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){ + if(world.getBlock(x, y, z) == this.theBlock && ((side == 1 && world.getBlockMetadata(x, y, z) == 0) || (side == 0 && world.getBlockMetadata(x, y, z) == 1))){ + if(world.setBlock(x, y, z, ((BlockSlabs)this.theBlock).fullBlock, 0, 3)){ + world.playSoundEffect(x+0.5F, y+0.5F, z+0.5F, this.theBlock.stepSound.getBreakSound(), (this.theBlock.stepSound.getVolume()+1.0F)/2.0F, this.theBlock.stepSound.getPitch()*0.8F); + stack.stackSize--; + return true; + } + } + return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockStair.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockStair.java new file mode 100644 index 000000000..97da40c66 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockStair.java @@ -0,0 +1,69 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import net.minecraft.block.Block; +import net.minecraft.block.BlockStairs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public class BlockStair extends BlockStairs implements INameableItem{ + + private String name; + + public BlockStair(Block block, String name){ + super(block, 0); + this.name = name; + this.setLightOpacity(0); + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(false); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + BlockUtil.addInformation(theBlock, list, 1, ""); + } + + @Override + public int getMetadata(int meta){ + return meta; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockWildPlant.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockWildPlant.java new file mode 100644 index 000000000..93e88aa18 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockWildPlant.java @@ -0,0 +1,118 @@ +package ellpeck.actuallyadditions.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.metalists.TheWildPlants; +import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.INameableItem; +import net.minecraft.block.Block; +import net.minecraft.block.BlockBush; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; +import java.util.List; + +public class BlockWildPlant extends BlockBush implements INameableItem{ + + public static final TheWildPlants[] allWildPlants = TheWildPlants.values(); + public IIcon[] textures = new IIcon[allWildPlants.length]; + + public BlockWildPlant(){ + this.setStepSound(soundTypeGrass); + } + + @Override + public boolean canBlockStay(World world, int x, int y, int z){ + return world.getBlockMetadata(x, y, z) == TheWildPlants.RICE.ordinal() ? world.getBlock(x, y-1, z).getMaterial() == Material.water : world.getBlock(x, y - 1, z).canSustainPlant(world, x, y - 1, z, ForgeDirection.UP, this); + } + + @Override + public boolean canSilkHarvest(){ + return false; + } + + @SuppressWarnings("all") + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs tab, List list){ + for (int j = 0; j < allWildPlants.length; j++){ + list.add(new ItemStack(item, 1, j)); + } + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune){ + return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getDrops(world, x, y, z, 7, fortune); + } + + @Override + public IIcon getIcon(int side, int metadata){ + return metadata >= allWildPlants.length ? null : allWildPlants[metadata].wildVersionOf.getIcon(0, 7); + } + + @Override + public String getName(){ + return "blockWild"; + } + + @Override + @SideOnly(Side.CLIENT) + public Item getItem(World world, int x, int y, int z){ + int meta = world.getBlockMetadata(x, y, z); + return meta >= allWildPlants.length ? null : ((BlockPlant)allWildPlants[meta].wildVersionOf).seedItem; + } + + @Override + public String getOredictName(){ + return ""; + } + + public static class TheItemBlock extends ItemBlock{ + + private Block theBlock; + + public TheItemBlock(Block block){ + super(block); + this.theBlock = block; + this.setHasSubtypes(true); + this.setMaxDamage(0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return stack.getItemDamage() >= allWildPlants.length ? EnumRarity.common : allWildPlants[stack.getItemDamage()].rarity; + } + + @Override + public String getUnlocalizedName(ItemStack stack){ + return this.getUnlocalizedName() + (stack.getItemDamage() >= allWildPlants.length ? " ERROR!" : allWildPlants[stack.getItemDamage()].getName()); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + if(stack.getItemDamage() < allWildPlants.length) BlockUtil.addInformation(theBlock, list, 1, allWildPlants[stack.getItemDamage()].getName()); + } + + @Override + public int getMetadata(int damage){ + return damage; + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIconFromDamage(int meta){ + return this.theBlock.getIcon(0, meta); + } + + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/FluidAA.java b/src/main/java/ellpeck/actuallyadditions/blocks/FluidAA.java new file mode 100644 index 000000000..5e09fef8a --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/FluidAA.java @@ -0,0 +1,10 @@ +package ellpeck.actuallyadditions.blocks; + +import net.minecraftforge.fluids.Fluid; + +public class FluidAA extends Fluid{ + + public FluidAA(String fluidName){ + super(fluidName); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java index 40b45453e..53f03e35b 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java @@ -1,13 +1,22 @@ package ellpeck.actuallyadditions.blocks; +import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.util.BlockUtil; +import ellpeck.actuallyadditions.util.CompatUtil; +import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.EnumRarity; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import org.apache.logging.log4j.Level; public class InitBlocks{ public static Block blockCompost; public static Block blockMisc; + public static Block blockWildPlant; public static Block blockFeeder; public static Block blockGiantChest; @@ -26,9 +35,114 @@ public class InitBlocks{ public static Block blockPlacer; public static Block blockDropper; + public static Block blockRice; + public static Block blockCanola; + public static Block blockFlax; + public static Block blockCoffee; + + public static Fluid fluidCanolaOil; + public static Block blockCanolaOil; + public static Fluid fluidOil; + public static Block blockOil; + + public static Block blockCanolaPress; + public static Block blockFermentingBarrel; + + public static Block blockCoalGenerator; + public static Block blockOilGenerator; + + public static Block blockPhantomface; + public static Block blockPhantomPlacer; + public static Block blockPhantomBreaker; + public static Block blockPhantomLiquiface; + public static Block blockPhantomEnergyface; + + public static Block blockFluidPlacer; + public static Block blockFluidCollector; + + public static Block blockLavaFactoryController; + public static Block blockCoffeeMachine; + + public static Block blockPhantomBooster; + + public static Block blockEnergizer; + public static Block blockEnervator; + + public static Block blockTestifiBucksGreenWall; + public static Block blockTestifiBucksWhiteWall; + public static Block blockTestifiBucksGreenStairs; + public static Block blockTestifiBucksWhiteStairs; + public static Block blockTestifiBucksGreenSlab; + public static Block blockTestifibucksWhiteSlab; + public static void init(){ Util.logInfo("Initializing Blocks..."); + blockTestifiBucksGreenWall = new BlockGeneric("blockTestifiBucksGreenWall"); + BlockUtil.register(blockTestifiBucksGreenWall, BlockGeneric.TheItemBlock.class); + blockTestifiBucksWhiteWall = new BlockGeneric("blockTestifiBucksWhiteWall"); + BlockUtil.register(blockTestifiBucksWhiteWall, BlockGeneric.TheItemBlock.class); + blockTestifiBucksGreenStairs = new BlockStair(blockTestifiBucksGreenWall, "blockTestifiBucksGreenStairs"); + BlockUtil.register(blockTestifiBucksGreenStairs, BlockStair.TheItemBlock.class); + blockTestifiBucksWhiteStairs = new BlockStair(blockTestifiBucksWhiteWall, "blockTestifiBucksWhiteStairs"); + BlockUtil.register(blockTestifiBucksWhiteStairs, BlockStair.TheItemBlock.class); + blockTestifiBucksGreenSlab = new BlockSlabs("blockTestifiBucksGreenSlab", blockTestifiBucksGreenWall); + BlockUtil.register(blockTestifiBucksGreenSlab, BlockSlabs.TheItemBlock.class); + blockTestifibucksWhiteSlab = new BlockSlabs("blockTestifibucksWhiteSlab", blockTestifiBucksWhiteWall); + BlockUtil.register(blockTestifibucksWhiteSlab, BlockSlabs.TheItemBlock.class); + + blockEnergizer = new BlockEnergizer(true); + BlockUtil.register(blockEnergizer, BlockEnergizer.TheItemBlock.class); + + blockEnervator = new BlockEnergizer(false); + BlockUtil.register(blockEnervator, BlockEnergizer.TheItemBlock.class); + + blockLavaFactoryController = new BlockLavaFactoryController(); + BlockUtil.register(blockLavaFactoryController, BlockLavaFactoryController.TheItemBlock.class); + + blockCanolaPress = new BlockCanolaPress(); + BlockUtil.register(blockCanolaPress, BlockCanolaPress.TheItemBlock.class); + + blockPhantomface = new BlockPhantomface(BlockPhantomface.FACE); + BlockUtil.register(blockPhantomface, BlockPhantomface.TheItemBlock.class); + + blockPhantomPlacer = new BlockPhantomface(BlockPhantomface.PLACER); + BlockUtil.register(blockPhantomPlacer, BlockPhantomface.TheItemBlock.class); + + blockPhantomLiquiface = new BlockPhantomface(BlockPhantomface.LIQUIFACE); + BlockUtil.register(blockPhantomLiquiface, BlockPhantomface.TheItemBlock.class); + + blockPhantomEnergyface = new BlockPhantomface(BlockPhantomface.ENERGYFACE); + BlockUtil.register(blockPhantomEnergyface, BlockPhantomface.TheItemBlock.class); + + blockPhantomBreaker = new BlockPhantomface(BlockPhantomface.BREAKER); + BlockUtil.register(blockPhantomBreaker, BlockPhantomface.TheItemBlock.class); + + blockCoalGenerator = new BlockCoalGenerator(); + BlockUtil.register(blockCoalGenerator, BlockCoalGenerator.TheItemBlock.class); + + blockOilGenerator = new BlockOilGenerator(); + BlockUtil.register(blockOilGenerator, BlockOilGenerator.TheItemBlock.class); + + blockFermentingBarrel = new BlockFermentingBarrel(); + BlockUtil.register(blockFermentingBarrel, BlockFermentingBarrel.TheItemBlock.class); + + blockRice = new BlockPlant("blockRice", 6, 1, 2); + BlockUtil.register(blockRice, BlockPlant.TheItemBlock.class, false); + CompatUtil.registerMFRPlant(blockRice); + + blockCanola = new BlockPlant("blockCanola", 4, 3, 3); + BlockUtil.register(blockCanola, BlockPlant.TheItemBlock.class, false); + CompatUtil.registerMFRPlant(blockCanola); + + blockFlax = new BlockPlant("blockFlax", 6, 2, 4); + BlockUtil.register(blockFlax, BlockPlant.TheItemBlock.class, false); + CompatUtil.registerMFRPlant(blockFlax); + + blockCoffee = new BlockPlant("blockCoffee", 6, 2, 2); + BlockUtil.register(blockCoffee, BlockPlant.TheItemBlock.class, false); + CompatUtil.registerMFRPlant(blockCoffee); + blockCompost = new BlockCompost(); BlockUtil.register(blockCompost, BlockCompost.TheItemBlock.class); @@ -79,5 +193,70 @@ public class InitBlocks{ blockDropper = new BlockDropper(); BlockUtil.register(blockDropper, BlockDropper.TheItemBlock.class); + + blockFluidPlacer = new BlockFluidCollector(true); + BlockUtil.register(blockFluidPlacer, BlockFluidCollector.TheItemBlock.class); + + blockFluidCollector = new BlockFluidCollector(false); + BlockUtil.register(blockFluidCollector, BlockFluidCollector.TheItemBlock.class); + + blockCoffeeMachine = new BlockCoffeeMachine(); + BlockUtil.register(blockCoffeeMachine, BlockCoffeeMachine.TheItemBlock.class); + + blockPhantomBooster = new BlockPhantomBooster(); + BlockUtil.register(blockPhantomBooster, BlockPhantomBooster.TheItemBlock.class); + + blockWildPlant = new BlockWildPlant(); + BlockUtil.register(blockWildPlant, BlockWildPlant.TheItemBlock.class, false, BlockWildPlant.allWildPlants); + + registerFluids(); + } + + public static void registerFluids(){ + //Canola Fluid + String canolaOil = "canolaoil"; + if(!FluidRegistry.isFluidRegistered(canolaOil) || ConfigBoolValues.PREVENT_CANOLA_OVERRIDE.isEnabled()){ + fluidCanolaOil = new FluidAA(canolaOil).setDensity(1200).setViscosity(1500).setTemperature(300).setRarity(EnumRarity.uncommon); + FluidRegistry.registerFluid(fluidCanolaOil); + } + else{ + errorAlreadyRegistered("Canola Oil Fluid"); + } + fluidCanolaOil = FluidRegistry.getFluid(canolaOil); + + //Canola Block + if(fluidCanolaOil.getBlock() == null || ConfigBoolValues.PREVENT_CANOLA_BLOCK_OVERRIDE.isEnabled()){ + blockCanolaOil = new BlockFluidFlowing(fluidCanolaOil, Material.water, "blockCanolaOil"); + BlockUtil.register(blockCanolaOil, BlockFluidFlowing.TheItemBlock.class, false); + } + else{ + errorAlreadyRegistered("Canola Oil Block"); + } + blockCanolaOil = fluidCanolaOil.getBlock(); + + //Oil Fluid + String oil = "oil"; + if(!FluidRegistry.isFluidRegistered(oil) || ConfigBoolValues.PREVENT_OIL_OVERRIDE.isEnabled()){ + fluidOil = new FluidAA(oil).setDensity(1200).setViscosity(1500).setTemperature(300).setRarity(EnumRarity.uncommon); + FluidRegistry.registerFluid(fluidOil); + } + else{ + errorAlreadyRegistered("Oil Fluid"); + } + fluidOil = FluidRegistry.getFluid(oil); + + //Oil Block + if(fluidOil.getBlock() == null || ConfigBoolValues.PREVENT_OIL_BLOCK_OVERRIDE.isEnabled()){ + blockOil = new BlockFluidFlowing(fluidOil, Material.water, "blockOil"); + BlockUtil.register(blockOil, BlockFluidFlowing.TheItemBlock.class, false); + } + else{ + errorAlreadyRegistered("Oil Block"); + } + blockOil = fluidOil.getBlock(); + } + + public static void errorAlreadyRegistered(String str){ + ModUtil.LOGGER.log(Level.WARN, str + " from Actually Additions is not getting used as it has already been registered by another Mod! If this causes Issues (which it shouldn't!), you can turn this off in the Config File!"); } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheMiscBlocks.java b/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheMiscBlocks.java index d2c2dcdb3..fe6ac9a7a 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheMiscBlocks.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheMiscBlocks.java @@ -10,7 +10,11 @@ public enum TheMiscBlocks implements INameableItem{ QUARTZ("BlackQuartz", EnumRarity.rare, "blockQuartzBlack"), ORE_QUARTZ("OreBlackQuartz", EnumRarity.epic, "oreQuartzBlack"), WOOD_CASING("WoodCasing", EnumRarity.common, "blockCasingWood"), - STONE_CASING("StoneCasing", EnumRarity.uncommon, "blockCasingStone"); + STONE_CASING("StoneCasing", EnumRarity.uncommon, "blockCasingStone"), + CHARCOAL_BLOCK("Charcoal", EnumRarity.common, "blockCharcoal"), + ENDERPEARL_BLOCK("Enderpearl", EnumRarity.rare, "blockEnderpearl"), + LAVA_FACTORY_CASE("LavaFactoryCase", EnumRarity.uncommon, "blockLavaFactoryCase"), + ENDER_CASING("EnderCasing", EnumRarity.epic, "blockEnderCasing"); public final String name; public final String oredictName; diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheWildPlants.java b/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheWildPlants.java new file mode 100644 index 000000000..8d1a03e5c --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/metalists/TheWildPlants.java @@ -0,0 +1,36 @@ +package ellpeck.actuallyadditions.blocks.metalists; + +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.util.INameableItem; +import net.minecraft.block.Block; +import net.minecraft.item.EnumRarity; + +public enum TheWildPlants implements INameableItem{ + + CANOLA("Canola", EnumRarity.rare, "blockCanolaWild", InitBlocks.blockCanola), + FLAX("Flax", EnumRarity.rare, "blockFlaxWild", InitBlocks.blockFlax), + RICE("Rice", EnumRarity.rare, "blockRiceWild", InitBlocks.blockRice), + COFFEE("Coffee", EnumRarity.rare, "blockCoffeeWild", InitBlocks.blockCoffee); + + public final String name; + public final String oredictName; + public final EnumRarity rarity; + public final Block wildVersionOf; + + TheWildPlants(String name, EnumRarity rarity, String oredictName, Block wildVersionOf){ + this.name = name; + this.rarity = rarity; + this.oredictName = oredictName; + this.wildVersionOf = wildVersionOf; + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.oredictName; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelBaseAA.java b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelBaseAA.java index a8b698739..ead226a1b 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelBaseAA.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelBaseAA.java @@ -1,6 +1,7 @@ package ellpeck.actuallyadditions.blocks.render; import net.minecraft.client.model.ModelBase; +import net.minecraft.tileentity.TileEntity; public class ModelBaseAA extends ModelBase{ @@ -11,4 +12,12 @@ public class ModelBaseAA extends ModelBase{ public String getName(){ return null; } + + public void renderExtra(float f, TileEntity tile){ + + } + + public boolean doesRotate(){ + return false; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCoffeeMachine.java new file mode 100644 index 000000000..38eb0d2bc --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCoffeeMachine.java @@ -0,0 +1,137 @@ +package ellpeck.actuallyadditions.blocks.render; + +import net.minecraft.client.model.ModelRenderer; + +public class ModelCoffeeMachine extends ModelBaseAA{ + + ModelRenderer p1; + ModelRenderer p2; + ModelRenderer p3; + ModelRenderer p4; + ModelRenderer p5; + ModelRenderer p6; + ModelRenderer p7; + ModelRenderer p8; + ModelRenderer p9; + ModelRenderer p10; + ModelRenderer p11; + ModelRenderer p12; + ModelRenderer p13; + + public ModelCoffeeMachine(){ + textureWidth = 128; + textureHeight = 128; + + p1 = new ModelRenderer(this, 0, 0); + p1.addBox(0F, 0F, 0F, 10, 1, 14); + p1.setRotationPoint(-5F, 23F, -7F); + p1.setTextureSize(128, 128); + p1.mirror = true; + setRotation(p1, 0F, 0F, 0F); + p2 = new ModelRenderer(this, 49, 0); + p2.addBox(0F, 0F, 0F, 10, 8, 6); + p2.setRotationPoint(-5F, 15F, 1F); + p2.setTextureSize(128, 128); + p2.mirror = true; + setRotation(p2, 0F, 0F, 0F); + p3 = new ModelRenderer(this, 0, 16); + p3.addBox(0F, 0F, 0F, 10, 2, 11); + p3.setRotationPoint(-5F, 13F, -4F); + p3.setTextureSize(128, 128); + p3.mirror = true; + setRotation(p3, 0F, 0F, 0F); + p4 = new ModelRenderer(this, 43, 16); + p4.addBox(0F, 0F, 0F, 8, 3, 8); + p4.setRotationPoint(-4F, 10F, -1F); + p4.setTextureSize(128, 128); + p4.mirror = true; + setRotation(p4, 0F, 0F, 0F); + p5 = new ModelRenderer(this, 0, 30); + p5.addBox(0F, 0F, 0F, 2, 1, 2); + p5.setRotationPoint(-1F, 15F, -3.5F); + p5.setTextureSize(128, 128); + p5.mirror = true; + setRotation(p5, 0F, 0F, 0F); + p6 = new ModelRenderer(this, 82, 0); + p6.addBox(0F, 0F, 0F, 4, 5, 1); + p6.setRotationPoint(-2F, 17F, -1F); + p6.setTextureSize(128, 128); + p6.mirror = true; + setRotation(p6, 0F, 0F, 0F); + p7 = new ModelRenderer(this, 82, 0); + p7.addBox(0F, 0F, 0F, 4, 5, 1); + p7.setRotationPoint(-2F, 17F, -6F); + p7.setTextureSize(128, 128); + p7.mirror = true; + setRotation(p7, 0F, 0F, 0F); + p8 = new ModelRenderer(this, 82, 0); + p8.addBox(0F, 0F, 0F, 4, 5, 1); + p8.setRotationPoint(2F, 17F, -1F); + p8.setTextureSize(128, 128); + p8.mirror = true; + setRotation(p8, 0F, 1.570796F, 0F); + p9 = new ModelRenderer(this, 82, 0); + p9.addBox(0F, 0F, 0F, 4, 5, 1); + p9.setRotationPoint(-3F, 17F, -1F); + p9.setTextureSize(128, 128); + p9.mirror = true; + setRotation(p9, 0F, 1.570796F, 0F); + p10 = new ModelRenderer(this, 93, 0); + p10.addBox(0F, 0F, 0F, 4, 1, 4); + p10.setRotationPoint(-2F, 22F, -5F); + p10.setTextureSize(128, 128); + p10.mirror = true; + setRotation(p10, 0F, 0F, 0F); + p11 = new ModelRenderer(this, 82, 7); + p11.addBox(0F, 0F, 0F, 1, 1, 2); + p11.setRotationPoint(-4F, 18F, -4F); + p11.setTextureSize(128, 128); + p11.mirror = true; + setRotation(p11, 0F, 0F, 0F); + p12 = new ModelRenderer(this, 82, 7); + p12.addBox(0F, 0F, 0F, 1, 1, 2); + p12.setRotationPoint(-4F, 21F, -4F); + p12.setTextureSize(128, 128); + p12.mirror = true; + setRotation(p12, 0F, 0F, 0F); + p13 = new ModelRenderer(this, 89, 7); + p13.addBox(0F, 0F, 0F, 1, 2, 2); + p13.setRotationPoint(-5F, 19F, -4F); + p13.setTextureSize(128, 128); + p13.mirror = true; + setRotation(p13, 0F, 0F, 0F); + } + + @Override + public void render(float f){ + p1.render(f); + p2.render(f); + p3.render(f); + p4.render(f); + p5.render(f); + p6.render(f); + p7.render(f); + p8.render(f); + p9.render(f); + p10.render(f); + p11.render(f); + p12.render(f); + p13.render(f); + } + + private void setRotation(ModelRenderer model, float x, float y, float z){ + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + @Override + public String getName(){ + return "modelCoffeeMachine"; + } + + @Override + public boolean doesRotate(){ + return true; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCompost.java b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCompost.java index 6dfc64af0..1277e985e 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCompost.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelCompost.java @@ -2,6 +2,7 @@ package ellpeck.actuallyadditions.blocks.render; import ellpeck.actuallyadditions.tile.TileEntityCompost; import net.minecraft.client.model.ModelRenderer; +import net.minecraft.tileentity.TileEntity; public class ModelCompost extends ModelBaseAA{ @@ -43,15 +44,17 @@ public class ModelCompost extends ModelBaseAA{ this.innerDone.addBox(0.0F, 0.0F, 0.0F, 12, 13, 12, 0.0F); } - public void renderExtra(float f, TileEntityCompost tile){ + @Override + public void renderExtra(float f, TileEntity tile){ + TileEntityCompost tileCompost = (TileEntityCompost)tile; int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); - if(meta > 0 && meta <= tile.amountNeededToConvert){ - int heightToDisplay = meta*13/tile.amountNeededToConvert; + if(meta > 0 && meta <= tileCompost.amountNeededToConvert){ + int heightToDisplay = meta*13/tileCompost.amountNeededToConvert; if(heightToDisplay > 13) heightToDisplay = 13; this.innerRawList[heightToDisplay-1].render(f); } - if(meta == tile.amountNeededToConvert+1){ + if(meta == tileCompost.amountNeededToConvert+1){ this.innerDone.render(f); } } diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelPhantomBooster.java b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelPhantomBooster.java new file mode 100644 index 000000000..5f11ef016 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/blocks/render/ModelPhantomBooster.java @@ -0,0 +1,148 @@ +package ellpeck.actuallyadditions.blocks.render; + +import net.minecraft.client.model.ModelRenderer; + +public class ModelPhantomBooster extends ModelBaseAA{ + + ModelRenderer s1; + ModelRenderer s2; + ModelRenderer s3; + ModelRenderer s4; + ModelRenderer s5; + ModelRenderer s6; + ModelRenderer s7; + ModelRenderer s8; + ModelRenderer s9; + ModelRenderer s10; + ModelRenderer s11; + ModelRenderer s12; + ModelRenderer s13; + ModelRenderer s14; + ModelRenderer s15; + + public ModelPhantomBooster(){ + textureWidth = 128; + textureHeight = 128; + + s1 = new ModelRenderer(this, 0, 0); + s1.addBox(0F, 0F, 0F, 4, 16, 4); + s1.setRotationPoint(-2F, 8F, -2F); + s1.setTextureSize(128, 128); + s1.mirror = true; + setRotation(s1, 0F, 0F, 0F); + s2 = new ModelRenderer(this, 17, 0); + s2.addBox(0F, 0F, 0F, 6, 1, 6); + s2.setRotationPoint(-3F, 9F, -3F); + s2.setTextureSize(128, 128); + s2.mirror = true; + setRotation(s2, 0F, 0F, 0F); + s3 = new ModelRenderer(this, 17, 0); + s3.addBox(0F, 0F, 0F, 6, 1, 6); + s3.setRotationPoint(-3F, 22F, -3F); + s3.setTextureSize(128, 128); + s3.mirror = true; + setRotation(s3, 0F, 0F, 0F); + s4 = new ModelRenderer(this, 17, 8); + s4.addBox(0F, 0F, 0F, 6, 2, 1); + s4.setRotationPoint(-3F, 10F, -4F); + s4.setTextureSize(128, 128); + s4.mirror = true; + setRotation(s4, 0F, 0F, 0F); + s5 = new ModelRenderer(this, 17, 8); + s5.addBox(0F, 0F, 0F, 6, 2, 1); + s5.setRotationPoint(-3F, 10F, 3F); + s5.setTextureSize(128, 128); + s5.mirror = true; + setRotation(s5, 0F, 0F, 0F); + s6 = new ModelRenderer(this, 17, 8); + s6.addBox(0F, 0F, 0F, 6, 2, 1); + s6.setRotationPoint(-4F, 10F, 3F); + s6.setTextureSize(128, 128); + s6.mirror = true; + setRotation(s6, 0F, 1.579523F, 0F); + s7 = new ModelRenderer(this, 17, 8); + s7.addBox(0F, 0F, 0F, 6, 2, 1); + s7.setRotationPoint(3F, 10F, 3F); + s7.setTextureSize(128, 128); + s7.mirror = true; + setRotation(s7, 0F, 1.579523F, 0F); + s8 = new ModelRenderer(this, 17, 12); + s8.addBox(0F, 0F, 0F, 6, 8, 1); + s8.setRotationPoint(-3F, 12F, -5F); + s8.setTextureSize(128, 128); + s8.mirror = true; + setRotation(s8, 0F, 0F, 0F); + s9 = new ModelRenderer(this, 17, 12); + s9.addBox(0F, 0F, 0F, 6, 8, 1); + s9.setRotationPoint(-3F, 12F, 4F); + s9.setTextureSize(128, 128); + s9.mirror = true; + setRotation(s9, 0F, 0F, 0F); + s10 = new ModelRenderer(this, 17, 12); + s10.addBox(0F, 0F, 0F, 6, 8, 1); + s10.setRotationPoint(-5F, 12F, 3F); + s10.setTextureSize(128, 128); + s10.mirror = true; + setRotation(s10, 0F, 1.579523F, 0F); + s11 = new ModelRenderer(this, 17, 12); + s11.addBox(0F, 0F, 0F, 6, 8, 1); + s11.setRotationPoint(4F, 12F, 3F); + s11.setTextureSize(128, 128); + s11.mirror = true; + setRotation(s11, 0F, 1.579523F, 0F); + s12 = new ModelRenderer(this, 17, 8); + s12.addBox(0F, 0F, 0F, 6, 2, 1); + s12.setRotationPoint(-4F, 20F, 3F); + s12.setTextureSize(128, 128); + s12.mirror = true; + setRotation(s12, 0F, 1.579523F, 0F); + s13 = new ModelRenderer(this, 17, 8); + s13.addBox(0F, 0F, 0F, 6, 2, 1); + s13.setRotationPoint(-3F, 20F, 3F); + s13.setTextureSize(128, 128); + s13.mirror = true; + setRotation(s13, 0F, 0F, 0F); + s14 = new ModelRenderer(this, 17, 8); + s14.addBox(0F, 0F, 0F, 6, 2, 1); + s14.setRotationPoint(3F, 20F, 3F); + s14.setTextureSize(128, 128); + s14.mirror = true; + setRotation(s14, 0F, 1.579523F, 0F); + s15 = new ModelRenderer(this, 17, 8); + s15.addBox(0F, 0F, 0F, 6, 2, 1); + s15.setRotationPoint(-3F, 20F, -4F); + s15.setTextureSize(128, 128); + s15.mirror = true; + setRotation(s15, 0F, 0F, 0F); + } + + @Override + public void render(float f){ + s1.render(f); + s2.render(f); + s3.render(f); + s4.render(f); + s5.render(f); + s6.render(f); + s7.render(f); + s8.render(f); + s9.render(f); + s10.render(f); + s11.render(f); + s12.render(f); + s13.render(f); + s14.render(f); + s15.render(f); + } + + @Override + public String getName(){ + return "modelPhantomBooster"; + } + + private void setRotation(ModelRenderer model, float x, float y, float z){ + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderTileEntity.java b/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderTileEntity.java index b500f1088..0a86843e9 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderTileEntity.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderTileEntity.java @@ -1,6 +1,5 @@ package ellpeck.actuallyadditions.blocks.render; -import ellpeck.actuallyadditions.tile.TileEntityCompost; import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; @@ -9,7 +8,7 @@ import org.lwjgl.opengl.GL11; public class RenderTileEntity extends TileEntitySpecialRenderer{ - ModelBaseAA theModel; + public ModelBaseAA theModel; public RenderTileEntity(ModelBaseAA model){ this.theModel = model; @@ -22,9 +21,16 @@ public class RenderTileEntity extends TileEntitySpecialRenderer{ GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -2.0F, 0.0F); this.bindTexture(new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/blocks/models/" + this.theModel.getName() + ".png")); - theModel.render(0.0625F); - if(tile instanceof TileEntityCompost && theModel instanceof ModelCompost) ((ModelCompost)theModel).renderExtra(0.0625F, (TileEntityCompost)tile); + if(theModel.doesRotate()){ + int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); + if(meta == 0) GL11.glRotatef(180F, 0F, 1F, 0F); + if(meta == 1) GL11.glRotatef(90F, 0F, 1F, 0F); + if(meta == 3) GL11.glRotatef(270F, 0F, 1F, 0F); + } + + theModel.render(0.0625F); + theModel.renderExtra(0.0625F, tile); GL11.glPopMatrix(); } diff --git a/src/main/java/ellpeck/actuallyadditions/communication/InterModCommunications.java b/src/main/java/ellpeck/actuallyadditions/communication/InterModCommunications.java new file mode 100644 index 000000000..3fa551e59 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/communication/InterModCommunications.java @@ -0,0 +1,70 @@ +package ellpeck.actuallyadditions.communication; + +import cpw.mods.fml.common.event.FMLInterModComms; +import ellpeck.actuallyadditions.items.ItemCoffee; +import ellpeck.actuallyadditions.recipe.GrinderRecipeManualRegistry; +import ellpeck.actuallyadditions.recipe.HairyBallHandler; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.Util; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; +import org.apache.logging.log4j.Level; + +import java.util.List; + +public class InterModCommunications{ + + public static void processIMC(List messages){ + for(FMLInterModComms.IMCMessage message : messages){ + if(message.key.equalsIgnoreCase("registerCrusherRecipe")){ + NBTTagCompound compound = message.getNBTValue(); + if(compound != null){ + ItemStack input = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("input")); + ItemStack outputOne = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("outputOne")); + ItemStack outputTwo = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("outputTwo")); + int secondChance = compound.getInteger("secondChance"); + + if(input != null && outputOne != null){ + GrinderRecipeManualRegistry.registerRecipe(input, outputOne, outputTwo, secondChance); + Util.logInfo("Crusher Recipe that was sent from Mod " + message.getSender() + " has been registered successfully: " + input.toString() + " -> " + outputOne.toString() + (outputTwo != null ? " + " + outputTwo.toString() + ", Second Chance: " + secondChance : "")); + } + else ModUtil.LOGGER.log(Level.ERROR, "Crusher Recipe that was sent from Mod " + message.getSender() + " could not be registered: It's missing an Input or an Output!"); + } + } + + if(message.key.equalsIgnoreCase("registerCoffeeMachineRecipe")){ + NBTTagCompound compound = message.getNBTValue(); + if(compound != null){ + ItemStack input = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("input")); + int potionID = compound.getInteger("id"); + int duration = compound.getInteger("duration"); + int amplifier = compound.getInteger("amplifier"); + int maxAmp = compound.getInteger("maxAmp"); + + if(input != null && potionID > 0 && duration > 0 && maxAmp > 0){ + PotionEffect effect = new PotionEffect(potionID, duration, amplifier); + ItemCoffee.registerIngredient(new ItemCoffee.Ingredient(input, new PotionEffect[]{effect}, maxAmp)); + Util.logInfo("Coffee Machine Recipe that was sent from Mod " + message.getSender() + " has been registered successfully: " + input.toString() + " -> " + effect.toString()); + } + else ModUtil.LOGGER.log(Level.ERROR, "Coffee Machine Recipe that was sent from Mod " + message.getSender() + " could not be registered: It's missing an Input, a Potion ID, a Duration or a max Amplifier!"); + } + } + + if(message.key.equalsIgnoreCase("registerBallOfHairRecipe")){ + NBTTagCompound compound = message.getNBTValue(); + if(compound != null){ + ItemStack output = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("output")); + int chance = compound.getInteger("chance"); + + if(output != null && chance > 0){ + HairyBallHandler.addReturn(output, chance); + Util.logInfo("Ball Of Hair Recipe that was sent from Mod " + message.getSender() + " has been registered successfully: " + output.toString() + ", Chance: " + chance); + } + else ModUtil.LOGGER.log(Level.ERROR, "Ball Of Hair Recipe that was sent from Mod " + message.getSender() + " could not be registered: It's missing an Output or a Chance!"); + } + } + } + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java index eab30ea58..dc14d923a 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigCategories.java @@ -11,7 +11,9 @@ public enum ConfigCategories{ MOB_DROPS("mob drops"), WORLD_GEN("world gen"), POTION_RING_CRAFTING("ring crafting"), - OTHER("other"); + OTHER("other"), + FLUIDS("fluids"), + DRILL_VALUES("drill values"); public final String name; diff --git a/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java b/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java index 735f1ce90..dd9ff7cf2 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/config/ConfigurationHandler.java @@ -7,6 +7,8 @@ import java.io.File; public class ConfigurationHandler{ + public static final String ISSUES_WARNING = " [THIS COULD CAUSE ISSUES, CHANGE AT YOUR OWN RISK!]"; + public static void init(File configFile){ Util.logInfo("Grabbing Configurations..."); Configuration config = new Configuration(configFile); diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java index 9c246564c..b33a7f454 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java @@ -2,6 +2,7 @@ package ellpeck.actuallyadditions.config.values; import ellpeck.actuallyadditions.config.ConfigCategories; import ellpeck.actuallyadditions.config.ConfigValues; +import ellpeck.actuallyadditions.config.ConfigurationHandler; public enum ConfigBoolValues{ @@ -20,9 +21,21 @@ public enum ConfigBoolValues{ PEARL_SHARD_DROP("Ender Pearl Shard", ConfigCategories.MOB_DROPS, true, "If the Ender Pearl Shard drops from Mobs"), EMERALD_SHARD_CROP("Emerald Shard", ConfigCategories.MOB_DROPS, true, "If the Emerald Shard drops from Mobs"), - DO_UPDATE_CHECK("Do Update Check", ConfigCategories.OTHER, true, "If Actually Additions should check for an Update on joining a World"), + DO_WAILA_INFO("Waila Display Info", ConfigCategories.OTHER, true, "If the Shift Description should display in Waila too"), - DO_CRUSHER_SPAM("Crusher Debug", ConfigCategories.OTHER, false, "Print out Crusher Recipe Initializing Debug"); + DO_UPDATE_CHECK("Do Update Check", ConfigCategories.OTHER, true, "If Actually Additions should check for an Update on joining a World"), + DO_CRUSHER_SPAM("Crusher Debug", ConfigCategories.OTHER, false, "Print out Crusher Recipe Initializing Debug"), + DO_CAT_DROPS("Do Cat Drops", ConfigCategories.OTHER, true, "If Cats drop Hairy Balls on Occasion"), + + DO_RICE_GEN("Rice Gen", ConfigCategories.WORLD_GEN, true, "If Rice should generate in the World"), + DO_CANOLA_GEN("Canola Gen", ConfigCategories.WORLD_GEN, true, "If Canola should generate in the World"), + DO_FLAX_GEN("Flax Gen", ConfigCategories.WORLD_GEN, true, "If Flax should generate in the World"), + DO_COFFEE_GEN("Coffee Gen", ConfigCategories.WORLD_GEN, true, "If Coffee should generate in the World"), + + PREVENT_OIL_OVERRIDE("Oil Fluid Override", ConfigCategories.FLUIDS, false, "If not registering Oil Fluids from Actually Additions if other Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING), + PREVENT_CANOLA_OVERRIDE("Canola Oil Fluid Override", ConfigCategories.FLUIDS, false, "If not registering Canola Oil Fluids from Actually Additions if other Canola Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING), + PREVENT_OIL_BLOCK_OVERRIDE("Oil Block Override", ConfigCategories.FLUIDS, false, "If not registering Oil Blocks from Actually Additions if other Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING), + PREVENT_CANOLA_BLOCK_OVERRIDE("Canola Oil Block Override", ConfigCategories.FLUIDS, false, "If not registering Canola Oil Blocks from Actually Additions if other Canola Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING); public final String name; public final String category; diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java index 7faebfc9d..530c36472 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigCrafting.java @@ -60,7 +60,6 @@ public enum ConfigCrafting{ RING_WATER_BREATHING("Water Breathing Ring", ConfigCategories.POTION_RING_CRAFTING), RING_INVISIBILITY("Invisibility Ring", ConfigCategories.POTION_RING_CRAFTING), RING_NIGHT_VISION("Night Vision Ring", ConfigCategories.POTION_RING_CRAFTING), - RING_SATURATION("Saturation Ring", ConfigCategories.POTION_RING_CRAFTING, false), DOUGH("Dough", ConfigCategories.ITEMS_CRAFTING), PAPER_CONE("Paper Cone", ConfigCategories.ITEMS_CRAFTING), @@ -68,7 +67,45 @@ public enum ConfigCrafting{ KNIFE_BLADE("Knife Blade", ConfigCategories.ITEMS_CRAFTING), TOOL_EMERALD("Emerald Tools", ConfigCategories.ITEMS_CRAFTING), - TOOL_OBSIDIAN("Obsidian Tools", ConfigCategories.ITEMS_CRAFTING); + TOOL_OBSIDIAN("Obsidian Tools", ConfigCategories.ITEMS_CRAFTING), + RICE_BREAD("Rice Bread", ConfigCategories.FOOD_CRAFTING), + RICE_DOUGH("Rice Dough", ConfigCategories.FOOD_CRAFTING), + + RICE_GADGETS("Rice Gadgets", ConfigCategories.ITEMS_CRAFTING), + RESONANT_RICE("Resonant Rice", ConfigCategories.ITEMS_CRAFTING), + + CANOLA_PRESS("Canola Press", ConfigCategories.BLOCKS_CRAFTING), + FERMENTING_BARREL("Fermenting Barrel", ConfigCategories.BLOCKS_CRAFTING), + COAL_GENERATOR("Coal Generator", ConfigCategories.BLOCKS_CRAFTING), + OIL_GENERATOR("Oil Generator", ConfigCategories.BLOCKS_CRAFTING), + PHANTOMFACE("Phantomface", ConfigCategories.BLOCKS_CRAFTING), + PHANTOM_CONNECTOR("Phantom Connector", ConfigCategories.ITEMS_CRAFTING), + + PHANTOM_ENERGYFACE("Phantom Energyface", ConfigCategories.BLOCKS_CRAFTING), + PHANTOM_LIQUIFACE("Phantom Liquiface", ConfigCategories.BLOCKS_CRAFTING), + PHANTOM_PLACER("Phantom Placer", ConfigCategories.BLOCKS_CRAFTING), + PHANTOM_BREAKER("Phantom Breaker", ConfigCategories.BLOCKS_CRAFTING), + LIQUID_PLACER("Liquid Placer", ConfigCategories.BLOCKS_CRAFTING), + LIQUID_BREAKER("Liquid Collector", ConfigCategories.BLOCKS_CRAFTING), + + CUP("Cup", ConfigCategories.ITEMS_CRAFTING), + PAXELS("Paxels", ConfigCategories.ITEMS_CRAFTING), + + ENDER_CASING("Ender Casing", ConfigCategories.BLOCKS_CRAFTING), + PHANTOM_BOOSTER("Phantom Booster", ConfigCategories.BLOCKS_CRAFTING), + COFFEE_MACHINE("Coffee Machine", ConfigCategories.BLOCKS_CRAFTING), + LAVA_FACTORY("Lava Factory", ConfigCategories.BLOCKS_CRAFTING), + + DRILL("Drill", ConfigCategories.ITEMS_CRAFTING), + DRILL_SPEED("Drill Speed Upgrades", ConfigCategories.ITEMS_CRAFTING), + DRILL_FORTUNE("Drill Fortune Upgrades", ConfigCategories.ITEMS_CRAFTING), + DRILL_SIZE("Drill Size Upgrades", ConfigCategories.ITEMS_CRAFTING), + DRILL_PLACING("Drill Placing Upgrade", ConfigCategories.ITEMS_CRAFTING), + DRILL_SILK_TOUCH("Drill Silk Touch Upgrade", ConfigCategories.ITEMS_CRAFTING), + BATTERY("Battery", ConfigCategories.ITEMS_CRAFTING), + + ENERGIZER("Energizer", ConfigCategories.BLOCKS_CRAFTING), + ENERVATOR("Enervator", ConfigCategories.BLOCKS_CRAFTING); public final String name; public final String category; @@ -87,5 +124,4 @@ public enum ConfigCrafting{ public boolean isEnabled(){ return ConfigValues.craftingValues[this.ordinal()]; } - } diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigFloatValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigFloatValues.java index 1af7ea863..e8d94df86 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigFloatValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigFloatValues.java @@ -9,7 +9,9 @@ public enum ConfigFloatValues{ EMERALD_MAX_DAMAGE("Emerald: Damage", ConfigCategories.TOOL_VALUES, 5.0F, 0.1F, 50.0F, "How much damage an Emerald Tool deals"), OBSIDIAN_SPEED("Obsidian: Efficiency", ConfigCategories.TOOL_VALUES, 4.0F, 1.0F, 20.0F, "How fast Obsidian Tools are"), - OBSIDIAN_MAX_DAMAGE("Obsidian: Damage", ConfigCategories.TOOL_VALUES, 2.0F, 0.1F, 50.0F, "How much damage an Obsidian Tool deals"); + OBSIDIAN_MAX_DAMAGE("Obsidian: Damage", ConfigCategories.TOOL_VALUES, 2.0F, 0.1F, 50.0F, "How much damage an Obsidian Tool deals"), + + DRILL_DAMAGE("Drill: Default Damage", ConfigCategories.DRILL_VALUES, 8.0F, 1.0F, 30.0F, "How much Damage the Drill does to an Entity"); public final String name; public final String category; diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java index 65944bf6c..2ed8f077e 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java @@ -2,6 +2,7 @@ package ellpeck.actuallyadditions.config.values; import ellpeck.actuallyadditions.config.ConfigCategories; import ellpeck.actuallyadditions.config.ConfigValues; +import net.minecraftforge.fluids.FluidContainerRegistry; public enum ConfigIntValues{ @@ -12,14 +13,14 @@ public enum ConfigIntValues{ BLACK_QUARTZ_BASE_AMOUNT("Black Quartz Amount", ConfigCategories.WORLD_GEN, 3, 1, 50, "How big a Black Quartz Vein is at least"), BLACK_QUARTZ_ADD_CHANCE("Black Quartz Additional Chance", ConfigCategories.WORLD_GEN, 3, 0, 50, "How much bigger than the Base Amount a Black Quartz Vein can get"), - BLACK_QUARTZ_CHANCE("Black Quartz Chance", ConfigCategories.WORLD_GEN, 25, 1, 150, "How often the Black Quartz tries to generate"), + BLACK_QUARTZ_CHANCE("Black Quartz Chance", ConfigCategories.WORLD_GEN, 5, 1, 150, "How often the Black Quartz tries to generate"), BLACK_QUARTZ_MIN_HEIGHT("Black Quartz Min Height", ConfigCategories.WORLD_GEN, 0, 0, 256, "How high the Black Quartz starts to generate"), BLACK_QUARTZ_MAX_HEIGHT("Black Quartz Max Height", ConfigCategories.WORLD_GEN, 25, 0, 256, "How high the Black Quartz stops to generate at"), COMPOST_AMOUNT("Compost: Amount Needed To Convert", ConfigCategories.MACHINE_VALUES, 10, 1, 64, "How many items are needed in the Compost to convert to Fertilizer"), COMPOST_TIME("Compost: Conversion Time Needed", ConfigCategories.MACHINE_VALUES, 1000, 30, 10000, "How long the Compost needs to convert to Fertilizer"), - FISHER_TIME("Fishing Net: Time Needed", ConfigCategories.MACHINE_VALUES, 2000, 50, 50000, "How long it takes on Average until the Fishing Net catches a Fish"), + FISHER_TIME("Fishing Net: Time Needed", ConfigCategories.MACHINE_VALUES, 15000, 50, 500000, "How long it takes on Average until the Fishing Net catches a Fish"), FEEDER_REACH("Feeder: Reach", ConfigCategories.MACHINE_VALUES, 5, 1, 20, "The Radius of Action of the Feeder"), FEEDER_TIME("Feeder: Time Needed", ConfigCategories.MACHINE_VALUES, 100, 50, 5000, "The time spent between feeding animals with the Feeder"), @@ -35,18 +36,70 @@ public enum ConfigIntValues{ OBSIDIAN_USES("Obsidian: Max Uses", ConfigCategories.TOOL_VALUES, 8000, 50, 20000, "How often Obsidian Tools can be used"), OBSIDIAN_ENCHANTABILITY("Obsidian: Enchantability", ConfigCategories.TOOL_VALUES, 15, 1, 30, "How enchantable an Obsidian Tool is"), - GRINDER_CRUSH_TIME("Crusher: Crush Time", ConfigCategories.MACHINE_VALUES, 200, 10, 1000, "How long the Crusher takes to crush an item"), - GRINDER_DOUBLE_CRUSH_TIME("Double Crusher: Crush Time", ConfigCategories.MACHINE_VALUES, 300, 10, 1000, "How long the Double Crusher takes to crush an item"), - FURNACE_DOUBLE_SMELT_TIME("Double Furnace: Smelt Time", ConfigCategories.MACHINE_VALUES, 300, 10, 1000, "How long the Double Furnace takes to crush an item"), + GRINDER_CRUSH_TIME("Crusher: Time", ConfigCategories.MACHINE_VALUES, 100, 10, 1000, "How long the Crusher takes to crush an item"), + GRINDER_DOUBLE_CRUSH_TIME("Double Crusher: Time", ConfigCategories.MACHINE_VALUES, 150, 10, 1000, "How long the Double Crusher takes to crush an item"), + FURNACE_DOUBLE_SMELT_TIME("Double Furnace: Time", ConfigCategories.MACHINE_VALUES, 80, 10, 1000, "How long the Double Furnace takes to crush an item"), - REPAIRER_SPEED_SLOWDOWN("Item Repairer: Speed Slowdown", ConfigCategories.MACHINE_VALUES, 2, 1, 100, "How much slower the Item Repairer repairs"), + REPAIRER_SPEED_SLOWDOWN("Repairer: Speed Slowdown", ConfigCategories.MACHINE_VALUES, 2, 1, 100, "How much slower the Item Repairer repairs"), HEAT_COLLECTOR_BLOCKS("Heat Collector: Blocks Needed", ConfigCategories.MACHINE_VALUES, 4, 1, 5, "How many Blocks are needed for the Heat Collector to power Machines above it"), - HEAT_COLLECTOR_LAVA_CHANCE("Heat Collector: Random Chance", ConfigCategories.MACHINE_VALUES, 10000, 10, 100000, "The Chance of the Heat Collector destroying a Lava Block around (Default Value 2000 meaning a 1/2000 Chance!)"), + HEAT_COLLECTOR_LAVA_CHANCE("Heat Collector: Random Chance", ConfigCategories.MACHINE_VALUES, 15000, 10, 100000, "The Chance of the Heat Collector destroying a Lava Block around (Default Value 2000 meaning a 1/2000 Chance!)"), - GLASS_TIME_NEEDED("Greenhouse Glass: Time Needed", ConfigCategories.MACHINE_VALUES, 1000, 10, 1000000, "The Time Needed for the Greenhouse Glass to grow a Plant below it"), + GLASS_TIME_NEEDED("Greenhouse Glass: Time", ConfigCategories.MACHINE_VALUES, 300, 1, 10000, "Time Needed for the Greenhouse Glass to grow a Plant below it"), BREAKER_TIME_NEEDED("Breaker and Placer: Time Needed", ConfigCategories.MACHINE_VALUES, 15, 1, 10000, "The Time Needed for the Breaker and the Placer to place or break a Block"), - DROPPER_TIME_NEEDED("Dropper: Time Needed", ConfigCategories.MACHINE_VALUES, 10, 1, 10000, "The Time Needed for the Dropper to drop an Item"); + DROPPER_TIME_NEEDED("Dropper: Time Needed", ConfigCategories.MACHINE_VALUES, 10, 1, 10000, "The Time Needed for the Dropper to drop an Item"), + + CAT_DROP_CHANCE("Cat Drops: Chance", ConfigCategories.OTHER, 5000, 5, 10000000, "The 1 in X chance for a Hairy Ball to Drop from a Cat with X being this value"), + + RICE_AMOUNT("Rice Amount", ConfigCategories.WORLD_GEN, 15, 1, 100, "The Chance of Rice generating"), + CANOLA_AMOUNT("Canola Amount", ConfigCategories.WORLD_GEN, 10, 1, 50, "The Chance of Canola generating"), + FLAX_AMOUNT("Flax Amount", ConfigCategories.WORLD_GEN, 8, 1, 50, "The Chance of Flax generating"), + COFFEE_AMOUNT("Coffee Amount", ConfigCategories.WORLD_GEN, 6, 1, 50, "The Chance of Coffee generating"), + + GRINDER_ENERGY_USED("Energy Use: Crusher", ConfigCategories.MACHINE_VALUES, 40, 1, 500, "The Amount of Energy used by the Crusher per Tick"), + GRINDER_DOUBLE_ENERGY_USED("Energy Use: Double Crusher", ConfigCategories.MACHINE_VALUES, 60, 1, 500, "The Amount of Energy used by the Double Crusher per Tick"), + FURNACE_SOLAR_ENERGY_PRODUCED("Energy Production: Furnace Solar", ConfigCategories.MACHINE_VALUES, 15, 1, 500, "The Amount of Energy produced by the Solar per Tick"), + HEAT_COLLECTOR_ENERGY_PRODUCED("Energy Production: Heat Collectors", ConfigCategories.MACHINE_VALUES, 60, 1, 500, "The Amount of Energy produced by the Heat Collector per Tick"), + REPAIRER_ENERGY_USED("Energy Use: Repairer", ConfigCategories.MACHINE_VALUES, 1250, 1, 5000, "The Amount of Energy used by the Repairer per Tick"), + FURNACE_ENERGY_USED("Energy Use: Double Furnace", ConfigCategories.MACHINE_VALUES, 25, 1, 500, "The Amount of Energy used by the Double Furnace per Tick"), + + PRESS_PROCESSING_TIME("Canola Press: Processing Time", ConfigCategories.MACHINE_VALUES, 30, 1, 1000, "The Amount of time it takes to process one Canola"), + PRESS_MB_PRODUCED("Canola Press: mB Produced", ConfigCategories.MACHINE_VALUES, 100, 1, 5000, "The Amount of Canola Oil produced from one Canola"), + PRESS_ENERGY_USED("Energy Use: Canola Press", ConfigCategories.MACHINE_VALUES, 35, 10, 500, "The Amount of Energy used by the Canola Press per Tick"), + + BARREL_MB_PRODUCED("Fermenting Barrel: mB Produced", ConfigCategories.MACHINE_VALUES, 50, 1, 3000, "The Amount of mB produced by the Barrel per cycle"), + BARREL_PROCESSING_TIME("Fermenting Barrel: Processing Time", ConfigCategories.MACHINE_VALUES, 100, 1, 5000, "The Amount of time it takes to process one Canola Oil to Oil"), + COAL_GEN_ENERGY_PRODUCED("Coal Generator: Energy Produced", ConfigCategories.MACHINE_VALUES, 30, 1, 500, "The Amount of Energy generated by the Coal Generator"), + + PHANTOMFACE_RANGE("Phantomface: Default Range", ConfigCategories.MACHINE_VALUES, 16, 3, 100, "The Default Range of the Phantomface"), + + OIL_GEN_ENERGY_PRODUCED("Oil Generator: Energy Produced", ConfigCategories.MACHINE_VALUES, 76, 1, 500, "The Amount of Energy generated by the Oil Generator"), + OIL_GEN_FUEL_USED("Oil Generator: Fuel Usage", ConfigCategories.MACHINE_VALUES, 50, 1, 300, "The Amount of Fuel used per Burnup in the Oil Generator"), + OIL_GEN_BURN_TIME("Oil Generator: Burn Time", ConfigCategories.MACHINE_VALUES, 100, 1, 1000, "The Amount of Time Fuel keeps burning for"), + + PHANTOM_PLACER_TIME("Phantom Placer and Breaker: Time Needed", ConfigCategories.MACHINE_VALUES, 30, 1, 500, "The Amount of Time a Phantom Placer/Breaker needs"), + PHANTOM_PLACER_RANGE("Phantom Placer and Breaker: Range", ConfigCategories.MACHINE_VALUES, 3, 1, 100, "The Default Range of the Phantom Placer/Breaker"), + + LAVA_FACTORY_ENERGY_USED("Lava Factory: Energy Used", ConfigCategories.MACHINE_VALUES, 150000, 10, 3000000, "The amount of Energy used by the Lava Factory per Bucket of Lava produced"), + LAVA_FACTORY_TIME("Lava Factory: Production Time", ConfigCategories.MACHINE_VALUES, 200, 5, 10000, "The amount of time it takes for the Lava Factory to produce one Bucket"), + + COFFEE_MACHINE_ENERGY_USED("Coffee Machine: Energy Use", ConfigCategories.MACHINE_VALUES, 150, 10, 3000, "The amount of Energy used by the Coffee Machine per Tick"), + COFFEE_CACHE_ADDED_PER_ITEM("Coffee Machine: Coffee added per Cup", ConfigCategories.MACHINE_VALUES, 1, 1, 300, "The amount of Coffee added by one Coffee Item in the Coffee Machine"), + COFFEE_CACHE_USED_PER_ITEM("Coffee Machine: Coffee used per Cup", ConfigCategories.MACHINE_VALUES, 10, 1, 300, "The amount of Coffee used to brew one Coffee in the Coffee Machine"), + COFFEE_MACHINE_TIME_USED("Coffee Machine: Time to Brew", ConfigCategories.MACHINE_VALUES, 500, 10, 10000, "The amount of time the Coffee Machine takes to brew a Coffee"), + COFFEE_MACHINE_WATER_USED("Coffee Machine: Water Used per Cup", ConfigCategories.MACHINE_VALUES, 500, 1, 4*FluidContainerRegistry.BUCKET_VOLUME, "The amount of Water the Coffee Machine uses per Cup"), + + COFFEE_DRINK_AMOUNT("Coffee: Drink Amount", ConfigCategories.OTHER, 4, 1, 100, "How often a Coffee can be drunk from"), + DRILL_ENERGY_USE("Drill: Energy Use Per Block or Hit", ConfigCategories.DRILL_VALUES, 100, 5, 10000, "How much Energy the Drill uses per Block"), + + DRILL_SPEED_EXTRA_USE("Speed Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 50, 0, 10000, "How much extra Energy the Speed Upgrade uses"), + DRILL_SPEED_II_EXTRA_USE("Speed II Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 75, 0, 10000, "How much extra Energy the Speed II Upgrade uses"), + DRILL_SPEED_III_EXTRA_USE("Speed III Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 175, 0, 10000, "How much extra Energy the Speed III Upgrade uses"), + DRILL_SILK_EXTRA_USE("Silk Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 30, 0, 10000, "How much extra Energy the Silk Upgrade uses"), + DRILL_FORTUNE_EXTRA_USE("Fortune Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 40, 0, 10000, "How much extra Energy the Fortune Upgrade uses"), + DRILL_FORTUNE_II_EXTRA_USE("Fortune II Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 60, 0, 10000, "How much extra Energy the Fortune II Upgrade uses"), + DRILL_THREE_BY_THREE_EXTRA_USE("3x3 Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 10, 0, 10000, "How much extra Energy the 3x3 Upgrade uses"), + DRILL_FIVE_BY_FIVE_EXTRA_USE("5x5 Upgrade: Extra Energy Use", ConfigCategories.DRILL_VALUES, 30, 0, 10000, "How much extra Energy the 5x5 Upgrade uses"); public final String name; public final String category; @@ -67,5 +120,4 @@ public enum ConfigIntValues{ public int getValue(){ return ConfigValues.intValues[this.ordinal()]; } - } diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java index acadece1b..5814ccdfb 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/BlockCrafting.java @@ -4,8 +4,10 @@ import cpw.mods.fml.common.registry.GameRegistry; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; import ellpeck.actuallyadditions.config.values.ConfigCrafting; +import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.Util; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -23,6 +25,13 @@ public class BlockCrafting{ 'W', "plankWood", 'C', TheMiscBlocks.WOOD_CASING.getOredictName())); + //Charcoal Block + GameRegistry.addRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.CHARCOAL_BLOCK.ordinal()), + "CCC", "CCC", "CCC", + 'C', new ItemStack(Items.coal, 1, 1)); + GameRegistry.addShapelessRecipe(new ItemStack(Items.coal, 9, 1), + new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.CHARCOAL_BLOCK.ordinal())); + //Wood Casing if(ConfigCrafting.WOOD_CASING.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.WOOD_CASING.ordinal()), @@ -31,6 +40,151 @@ public class BlockCrafting{ 'R', "dustRedstone", 'S', "stickWood")); + //Ender Casing + if(ConfigCrafting.ENDER_CASING.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDER_CASING.ordinal()), + "WSW", "SRS", "WSW", + 'W', TheMiscBlocks.ENDERPEARL_BLOCK.getOredictName(), + 'R', TheMiscBlocks.QUARTZ.getOredictName(), + 'S', Blocks.obsidian)); + + //Phantom Booster + if(ConfigCrafting.PHANTOM_BOOSTER.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockPhantomBooster), + "RDR", "DCD", "RDR", + 'R', "dustRedstone", + 'D', "gemDiamond", + 'C', TheMiscBlocks.ENDER_CASING.getOredictName())); + + //Coffee Machine + if(ConfigCrafting.COFFEE_MACHINE.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockCoffeeMachine), + " C ", " S ", "A A", + 'C', ((INameableItem)InitItems.itemCoffeeBean).getOredictName(), + 'S', TheMiscBlocks.STONE_CASING.getOredictName(), + 'A', TheMiscItems.COIL.getOredictName())); + + //Energizer + if(ConfigCrafting.ENERGIZER.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockEnergizer), + "I I", "CAC", "I I", + 'I', "ingotIron", + 'C', TheMiscItems.COIL_ADVANCED.getOredictName(), + 'A', TheMiscBlocks.STONE_CASING.getOredictName())); + + //Energizer + if(ConfigCrafting.ENERVATOR.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockEnervator), + " I ", "CAC", " I ", + 'I', "ingotIron", + 'C', TheMiscItems.COIL_ADVANCED.getOredictName(), + 'A', TheMiscBlocks.STONE_CASING.getOredictName())); + + //Lava Factory + if(ConfigCrafting.LAVA_FACTORY.isEnabled()){ + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockLavaFactoryController), + " C ", "ISI", " L ", + 'C', TheMiscBlocks.STONE_CASING.getOredictName(), + 'S', TheMiscItems.COIL_ADVANCED.getOredictName(), + 'I', "blockIron", + 'L', Items.lava_bucket)); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 4, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal()), + "ICI", + 'C', TheMiscBlocks.STONE_CASING.getOredictName(), + 'I', "blockIron")); + } + + //Canola Press + if(ConfigCrafting.CANOLA_PRESS.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockCanolaPress), + "CHC", "CDC", "CRC", + 'C', "cobblestone", + 'H', Blocks.hopper, + 'R', TheMiscItems.COIL_ADVANCED.getOredictName(), + 'D', TheMiscItems.CANOLA.getOredictName())); + + //Fermenting Barrel + if(ConfigCrafting.FERMENTING_BARREL.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockFermentingBarrel), + "CHC", "CDC", "CRC", + 'C', "logWood", + 'H', Blocks.hopper, + 'R', TheMiscBlocks.WOOD_CASING.getOredictName(), + 'D', TheMiscItems.CANOLA.getOredictName())); + + //Phantomface + if(ConfigCrafting.PHANTOMFACE.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockPhantomface), + " C ", "EBE", " S ", + 'E', Items.ender_eye, + 'C', Blocks.chest, + 'S', TheMiscItems.COIL_ADVANCED.getOredictName(), + 'B', TheMiscBlocks.ENDERPEARL_BLOCK.getOredictName())); + + //Phantom Placer + if(ConfigCrafting.PHANTOM_PLACER.isEnabled()) + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitBlocks.blockPhantomPlacer), + ((INameableItem)InitBlocks.blockPlacer).getOredictName(), + ((INameableItem)InitBlocks.blockPhantomface).getOredictName())); + + //Phantom Breaker + if(ConfigCrafting.PHANTOM_BREAKER.isEnabled()) + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitBlocks.blockPhantomBreaker), + ((INameableItem)InitBlocks.blockBreaker).getOredictName(), + ((INameableItem)InitBlocks.blockPhantomface).getOredictName())); + + //Phantom Energyface + if(ConfigCrafting.PHANTOM_ENERGYFACE.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockPhantomEnergyface), + " R ", "RFR", " R ", + 'R', "dustRedstone", + 'F', ((INameableItem)InitBlocks.blockPhantomface).getOredictName())); + + //Phantom Liquiface + if(ConfigCrafting.PHANTOM_LIQUIFACE.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockPhantomLiquiface), + "RFR", + 'R', Items.bucket, + 'F', ((INameableItem)InitBlocks.blockPhantomface).getOredictName())); + + //Liquid Placer + if(ConfigCrafting.LIQUID_PLACER.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockFluidPlacer), + "RFR", + 'R', Items.bucket, + 'F', ((INameableItem)InitBlocks.blockPlacer).getOredictName())); + + //Liquid Breaker + if(ConfigCrafting.LIQUID_BREAKER.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockFluidCollector), + "RFR", + 'R', Items.bucket, + 'F', ((INameableItem)InitBlocks.blockBreaker).getOredictName())); + + //Oil Generator + if(ConfigCrafting.OIL_GENERATOR.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockOilGenerator), + "CRC", "CBC", "CRC", + 'C', "cobblestone", + 'R', TheMiscBlocks.STONE_CASING.getOredictName(), + 'B', InitItems.itemBucketOil)); + + //Coal Generator + if(ConfigCrafting.COAL_GENERATOR.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockCoalGenerator), + "CRC", "CBC", "CRC", + 'C', "cobblestone", + 'R', TheMiscBlocks.STONE_CASING.getOredictName(), + 'B', new ItemStack(Items.coal, 1, Util.WILDCARD))); + + //Enderpearl Block + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ENDERPEARL_BLOCK.ordinal()), + "EE", "EE", + 'E', Items.ender_pearl)); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.ender_pearl, 4), + TheMiscBlocks.ENDERPEARL_BLOCK.getOredictName())); + //Stone Casing if(ConfigCrafting.STONE_CASING.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.STONE_CASING.ordinal()), @@ -61,25 +215,25 @@ public class BlockCrafting{ 'C', TheMiscBlocks.STONE_CASING.getOredictName())); //Solar Panel - /*if(ConfigCrafting.SOLAR_PANEL.isEnabled()) + if(ConfigCrafting.SOLAR_PANEL.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockFurnaceSolar), "IQI", "CDC", "IBI", 'D', "blockDiamond", 'I', "ingotIron", 'Q', TheMiscBlocks.STONE_CASING.getOredictName(), 'C', TheMiscItems.COIL_ADVANCED.getOredictName(), - 'B', new ItemStack(Blocks.iron_bars)));*/ + 'B', new ItemStack(Blocks.iron_bars))); //Heat Collector - /*if(ConfigCrafting.HEAT_COLLECTOR.isEnabled()) + if(ConfigCrafting.HEAT_COLLECTOR.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockHeatCollector), "BRB", "CDC", "BQB", - 'D', "blockDiamond", + 'D', "gemDiamond", 'R', new ItemStack(Items.repeater), 'Q', TheMiscBlocks.STONE_CASING.getOredictName(), 'L', new ItemStack(Items.lava_bucket), 'C', TheMiscItems.COIL_ADVANCED.getOredictName(), - 'B', new ItemStack(Blocks.iron_bars)));*/ + 'B', new ItemStack(Blocks.iron_bars))); //Quartz Pillar GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.QUARTZ_PILLAR.ordinal()), @@ -158,7 +312,7 @@ public class BlockCrafting{ GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockGreenhouseGlass), "GSG", "SDS", "GSG", 'G', "blockGlass", - 'D', "gemDiamond", + 'D', Blocks.obsidian, 'S', "treeSapling")); //Placer @@ -175,7 +329,7 @@ public class BlockCrafting{ "CCC", "CRP", "CCC", 'C', "cobblestone", 'R', TheMiscItems.COIL.getOredictName(), - 'P', Items.diamond_pickaxe)); + 'P', Items.iron_pickaxe)); //Dropper if(ConfigCrafting.DROPPER.isEnabled()) diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/FoodCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/FoodCrafting.java index ab4d04a5a..438715039 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/FoodCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/FoodCrafting.java @@ -19,6 +19,11 @@ public class FoodCrafting{ String knifeStack = ((INameableItem)InitItems.itemKnife).getOredictName(); + //Rice Bread + if(ConfigCrafting.RICE_BREAD.isEnabled()) + GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RICE_DOUGH.ordinal()), + new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal()), 1F); + //Baguette if(ConfigCrafting.BAGUETTE.isEnabled()) GameRegistry.addSmelting(new ItemStack(InitItems.itemMisc, 1, @@ -113,7 +118,7 @@ public class FoodCrafting{ //Chocolate if(ConfigCrafting.CHOCOLATE.isEnabled()) - GameRegistry.addRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.CHOCOLATE.ordinal()), + GameRegistry.addRecipe(new ItemStack(InitItems.itemFoods, 3, TheFoods.CHOCOLATE.ordinal()), "C C", "CMC", "C C", 'C', new ItemStack(Items.dye, 1, 3), 'M', new ItemStack(Items.milk_bucket)); diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java index b5cb88347..092df6a4f 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/GrinderCrafting.java @@ -2,10 +2,10 @@ package ellpeck.actuallyadditions.crafting; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.metalists.TheDusts; -import ellpeck.actuallyadditions.recipe.GrinderRecipeHandler; -import ellpeck.actuallyadditions.recipe.GrinderRecipeHandler.SearchCase; -import ellpeck.actuallyadditions.recipe.GrinderRecipeHandler.SpecialOreCase; -import ellpeck.actuallyadditions.recipe.GrinderRecipes; +import ellpeck.actuallyadditions.items.metalists.TheFoods; +import ellpeck.actuallyadditions.recipe.GrinderRecipeAutoRegistry; +import ellpeck.actuallyadditions.recipe.GrinderRecipeAutoRegistry.SearchCase; +import ellpeck.actuallyadditions.recipe.GrinderRecipeManualRegistry; import ellpeck.actuallyadditions.util.Util; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -13,25 +13,31 @@ import net.minecraft.item.ItemStack; public class GrinderCrafting{ - private static GrinderRecipeHandler grindRecHan = GrinderRecipeHandler.instance(); - private static GrinderRecipes grindRec = GrinderRecipes.instance(); - public static void init(){ Util.logInfo("Initializing Crusher Recipes..."); - grindRec.registerRecipe(new ItemStack(Blocks.iron_ore), new ItemStack(InitItems.itemDust, 2, TheDusts.IRON.ordinal()), new ItemStack(InitItems.itemDust, 1, TheDusts.GOLD.ordinal()), 10); - grindRec.registerRecipe(new ItemStack(Blocks.redstone_ore), new ItemStack(Items.redstone, 10), null, 0); - grindRec.registerRecipe(new ItemStack(Blocks.lapis_ore), new ItemStack(InitItems.itemDust, 12, TheDusts.LAPIS.ordinal()), null, 0); - grindRecHan.specialOreCases.add(new SpecialOreCase("oreNickel", "dustPlatinum", 30)); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.redstone_ore), new ItemStack(Items.redstone, 10)); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.lapis_ore), new ItemStack(InitItems.itemDust, 12, TheDusts.LAPIS.ordinal())); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Items.coal), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal())); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.coal_block), new ItemStack(InitItems.itemDust, 9, TheDusts.COAL.ordinal())); - grindRecHan.searchCases.add(new SearchCase("ore", 2)); - grindRecHan.searchCases.add(new SearchCase("oreNether", 6)); - grindRecHan.searchCases.add(new SearchCase("denseore", 8)); - grindRecHan.searchCases.add(new SearchCase("gem", 1)); - grindRecHan.searchCases.add(new SearchCase("ingot", 1)); - grindRecHan.exceptions.add("ingotBrick"); - grindRecHan.exceptions.add("ingotBrickNether"); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.sand)); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.gravel), new ItemStack(Items.flint)); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone)); + GrinderRecipeManualRegistry.registerRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.sugar, 2)); - grindRecHan.registerFinally(); + GrinderRecipeManualRegistry.registerRecipe("oreNickel", "dustNickel", "dustPlatinum", 30, 2); + GrinderRecipeManualRegistry.registerRecipe("oreIron", "dustIron", "dustGold", 20, 2); + + GrinderRecipeAutoRegistry.searchCases.add(new SearchCase("oreNether", 6)); + GrinderRecipeAutoRegistry.searchCases.add(new SearchCase("denseore", 8)); + GrinderRecipeAutoRegistry.searchCases.add(new SearchCase("gem", 1)); + GrinderRecipeAutoRegistry.searchCases.add(new SearchCase("ingot", 1)); + GrinderRecipeAutoRegistry.searchCases.add(new SearchCase("ore", 2)); + + GrinderRecipeAutoRegistry.exceptions.add("ingotBrick"); + GrinderRecipeAutoRegistry.exceptions.add("ingotBrickNether"); + + GrinderRecipeAutoRegistry.registerFinally(); } } diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/InitCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/InitCrafting.java index e52c97ae2..9697c3a98 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/InitCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/InitCrafting.java @@ -12,7 +12,6 @@ public class InitCrafting { MiscCrafting.init(); FoodCrafting.init(); ToolCrafting.init(); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java index fee9b529e..076feb3d5 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/ItemCrafting.java @@ -5,16 +5,16 @@ import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; import ellpeck.actuallyadditions.config.values.ConfigCrafting; import ellpeck.actuallyadditions.items.InitItems; -import ellpeck.actuallyadditions.items.metalists.TheDusts; -import ellpeck.actuallyadditions.items.metalists.TheMiscItems; -import ellpeck.actuallyadditions.items.metalists.ThePotionRings; -import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops; +import ellpeck.actuallyadditions.items.metalists.*; +import ellpeck.actuallyadditions.util.INameableItem; import ellpeck.actuallyadditions.util.Util; +import net.minecraft.block.IGrowable; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.IPlantable; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; @@ -22,7 +22,22 @@ public class ItemCrafting{ public static void init(){ - //Leaf Blower + //Rice Stuff + if(ConfigCrafting.RICE_GADGETS.isEnabled()){ + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(Items.paper, 3), + "RRR", + 'R', TheFoods.RICE.getOredictName())); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemMisc, 4, TheMiscItems.RICE_SLIME.ordinal()), + " R ", "RBR", " R ", + 'R', TheMiscItems.RICE_DOUGH.getOredictName(), + 'B', Items.water_bucket)); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemMisc, 4, TheMiscItems.RICE_SLIME.ordinal()), + " R ", "RBR", " R ", + 'R', TheMiscItems.RICE_DOUGH.getOredictName(), + 'B', new ItemStack(Items.potionitem))); + } + + //Leaf Blower if(ConfigCrafting.LEAF_BLOWER.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemLeafBlower), " F", "IP", "IC", @@ -31,6 +46,91 @@ public class ItemCrafting{ 'P', new ItemStack(Blocks.piston), 'C', TheMiscItems.COIL_ADVANCED.getOredictName())); + //Drill + if(ConfigCrafting.DRILL.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrill), + "DDD", "CRC", "III", + 'D', "gemDiamond", + 'C', TheMiscItems.COIL_ADVANCED.getOredictName(), + 'R', "dustRedstone", + 'I', "blockIron")); + + //Drill Speed + if(ConfigCrafting.DRILL_SPEED.isEnabled()){ + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeed), + "ISI", "SRS", "ISI", + 'I', "ingotIron", + 'S', Items.sugar, + 'R', "dustRedstone")); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeedII), + "ISI", "SCS", "ISI", + 'I', "ingotIron", + 'S', Items.sugar, + 'C', Items.cake)); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeSpeedIII), + "ISI", "SFS", "ISI", + 'I', "ingotIron", + 'S', Items.sugar, + 'F', "gemDiamond")); + } + + //Drill Fortune + if(ConfigCrafting.DRILL_FORTUNE.isEnabled()){ + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeFortune), + "ISI", "SRS", "ISI", + 'I', Blocks.glowstone, + 'S', Items.redstone, + 'R', Blocks.diamond_block)); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeFortuneII), + "ISI", "SRS", "ISI", + 'I', Blocks.glowstone, + 'S', Items.redstone, + 'R', TheMiscBlocks.ENDER_CASING.getOredictName())); + } + + //Drill Size + if(ConfigCrafting.DRILL_SIZE.isEnabled()){ + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeThreeByThree), + "DID", "ICI", "DID", + 'I', "ingotIron", + 'D', "gemDiamond", + 'C', TheMiscItems.COIL.getOredictName())); + + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeFiveByFive), + "DID", "ICI", "DID", + 'I', "ingotIron", + 'D', "gemDiamond", + 'C', TheMiscItems.COIL_ADVANCED.getOredictName())); + } + + //Drill Silk Touch + if(ConfigCrafting.DRILL_SILK_TOUCH.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeSilkTouch), + "DSD", "SCS", "DSD", + 'D', "gemEmerald", + 'S', "gemDiamond", + 'C', TheMiscItems.COIL_ADVANCED.getOredictName())); + + //Drill Placing + if(ConfigCrafting.DRILL_PLACING.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemDrillUpgradeBlockPlacing), + "CEC", "RAR", "CEC", + 'C', "cobblestone", + 'E', Items.ender_pearl, + 'A', TheMiscItems.COIL.getOredictName(), + 'R', "ingotIron")); + + //Battery + if(ConfigCrafting.BATTERY.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemBattery), + " R ", "ICI", "III", + 'R', "dustRedstone", + 'I', "ingotIron", + 'C', TheMiscItems.COIL_ADVANCED.getOredictName())); + //Coil if(ConfigCrafting.COIL.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL.ordinal()), @@ -38,6 +138,64 @@ public class ItemCrafting{ 'I', "ingotIron", 'R', "dustRedstone")); + //Cup + if(ConfigCrafting.CUP.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), + "S S", "SCS", "SSS", + 'S', "stone", + 'C', ((INameableItem)InitItems.itemCoffeeBean).getOredictName())); + + //Paxels + if(ConfigCrafting.PAXELS.isEnabled()){ + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.woodenPaxel), + new ItemStack(Items.wooden_axe), + new ItemStack(Items.wooden_pickaxe), + new ItemStack(Items.wooden_shovel), + new ItemStack(Items.wooden_sword), + new ItemStack(Items.wooden_hoe))); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.stonePaxel), + new ItemStack(Items.stone_axe), + new ItemStack(Items.stone_pickaxe), + new ItemStack(Items.stone_shovel), + new ItemStack(Items.stone_sword), + new ItemStack(Items.stone_hoe))); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.ironPaxel), + new ItemStack(Items.iron_axe), + new ItemStack(Items.iron_pickaxe), + new ItemStack(Items.iron_shovel), + new ItemStack(Items.iron_sword), + new ItemStack(Items.iron_hoe))); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.goldPaxel), + new ItemStack(Items.golden_axe), + new ItemStack(Items.golden_pickaxe), + new ItemStack(Items.golden_shovel), + new ItemStack(Items.golden_sword), + new ItemStack(Items.golden_hoe))); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.diamondPaxel), + new ItemStack(Items.diamond_axe), + new ItemStack(Items.diamond_pickaxe), + new ItemStack(Items.diamond_shovel), + new ItemStack(Items.diamond_sword), + new ItemStack(Items.diamond_hoe))); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.emeraldPaxel), + new ItemStack(InitItems.itemAxeEmerald), + new ItemStack(InitItems.itemPickaxeEmerald), + new ItemStack(InitItems.itemSwordEmerald), + new ItemStack(InitItems.itemShovelEmerald), + new ItemStack(InitItems.itemHoeEmerald))); + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.obsidianPaxel), + new ItemStack(InitItems.itemAxeObsidian), + new ItemStack(InitItems.itemPickaxeObsidian), + new ItemStack(InitItems.itemSwordObsidian), + new ItemStack(InitItems.itemShovelObsidian), + new ItemStack(InitItems.itemHoeObsidian))); + } + + //Resonant Rice + if(ConfigCrafting.RESONANT_RICE.isEnabled()) + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemResonantRice), + TheFoods.RICE.getOredictName(), "nuggetEnderium", Items.gunpowder)); + //Advanced Coil if(ConfigCrafting.ADV_COIL.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()), @@ -64,6 +222,14 @@ public class ItemCrafting{ 'P', new ItemStack(Blocks.piston), 'C', TheMiscItems.COIL_ADVANCED.getOredictName())); + //Phantom Connector + if(ConfigCrafting.PHANTOM_CONNECTOR.isEnabled()) + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemPhantomConnector), + "YE", "EY", "S ", + 'Y', Items.ender_eye, + 'E', Items.ender_pearl, + 'S', "stickWood")); + //Quartz GameRegistry.addSmelting(new ItemStack(InitBlocks.blockMisc, 1, TheMiscBlocks.ORE_QUARTZ.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.QUARTZ.ordinal()), 1F); @@ -76,22 +242,24 @@ public class ItemCrafting{ //Crafter on a Stick if(ConfigCrafting.STICK_CRAFTER.isEnabled()) - GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemCrafterOnAStick), + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemCrafterOnAStick), new ItemStack(Blocks.crafting_table), new ItemStack(Items.sign), - new ItemStack(Items.slime_ball)); + "slimeball")); - //SpeedUpgrade - if(ConfigCrafting.SPEED_UPGRADE.isEnabled()) - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemSpeedUpgrade, 2), - "RGR", "GUG", "RGR", - 'U', TheMiscItems.COIL.getOredictName(), - 'R', "dustRedstone", - 'G', "ingotGold")); + //Tiny Coal + GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.TINY_COAL.ordinal()), + new ItemStack(Items.coal)); + GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.TINY_CHAR.ordinal()), + new ItemStack(Items.coal, 1, 1)); - //Mashed Food - if(ConfigCrafting.MASHED_FOOD.isEnabled()) - initMashedFoodRecipes(); + //Rice Seeds + GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemRiceSeed), + new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal())); + + //Canola Seeds + GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemCanolaSeed), + new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal())); //Rings initPotionRingRecipes(); @@ -133,20 +301,20 @@ public class ItemCrafting{ if(ConfigCrafting.RING_WATER_BREATHING.isEnabled()) addRingRecipeWithStack(ThePotionRings.WATER_BREATHING.craftingItem, ThePotionRings.WATER_BREATHING.ordinal()); if(ConfigCrafting.RING_INVISIBILITY.isEnabled()) addRingRecipeWithStack(ThePotionRings.INVISIBILITY.craftingItem, ThePotionRings.INVISIBILITY.ordinal()); if(ConfigCrafting.RING_NIGHT_VISION.isEnabled()) addRingRecipeWithStack(ThePotionRings.NIGHT_VISION.craftingItem, ThePotionRings.NIGHT_VISION.ordinal()); - if(ConfigCrafting.RING_SATURATION.isEnabled()) addRingRecipeWithStack(ThePotionRings.SATURATION.craftingItem, ThePotionRings.SATURATION.ordinal()); - } public static void addRingRecipeWithStack(ItemStack mainStack, int meta){ GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPotionRing, 1, meta), mainStack, mainStack, mainStack, mainStack, new ItemStack(Blocks.diamond_block), new ItemStack(Items.nether_wart), new ItemStack(Items.potionitem), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.RING.ordinal())); - GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPotionRingAdvanced, 1, meta), new ItemStack(InitItems.itemPotionRing, 1, meta), new ItemStack(Items.nether_star)); + GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemPotionRingAdvanced, 1, meta), new ItemStack(InitItems.itemPotionRing, 1, meta), new ItemStack(Items.nether_star), new ItemStack(Items.nether_star)); } public static void initMashedFoodRecipes(){ - for(Object nextIterator : Item.itemRegistry){ - if(nextIterator instanceof ItemFood){ - ItemStack ingredient = new ItemStack((Item)nextIterator, 1, Util.WILDCARD); - GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.MASHED_FOOD.ordinal()), ingredient, ingredient, ingredient, ingredient, new ItemStack(InitItems.itemKnife, 1, Util.WILDCARD)); + if(ConfigCrafting.MASHED_FOOD.isEnabled()){ + for(Object nextIterator : Item.itemRegistry){ + if(nextIterator instanceof ItemFood || nextIterator instanceof IPlantable || nextIterator instanceof IGrowable){ + ItemStack ingredient = new ItemStack((Item)nextIterator, 1, Util.WILDCARD); + GameRegistry.addShapelessRecipe(new ItemStack(InitItems.itemMisc, 8, TheMiscItems.MASHED_FOOD.ordinal()), ingredient, ingredient, ingredient, ingredient, new ItemStack(InitItems.itemKnife, 1, Util.WILDCARD)); + } } } } diff --git a/src/main/java/ellpeck/actuallyadditions/crafting/MiscCrafting.java b/src/main/java/ellpeck/actuallyadditions/crafting/MiscCrafting.java index 56e1bc903..bcfcebe14 100644 --- a/src/main/java/ellpeck/actuallyadditions/crafting/MiscCrafting.java +++ b/src/main/java/ellpeck/actuallyadditions/crafting/MiscCrafting.java @@ -3,6 +3,7 @@ package ellpeck.actuallyadditions.crafting; import cpw.mods.fml.common.registry.GameRegistry; import ellpeck.actuallyadditions.config.values.ConfigCrafting; import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheFoods; import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -18,6 +19,11 @@ public class MiscCrafting{ GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.DOUGH.ordinal()), "cropWheat", "cropWheat")); + //Rice Dough + if(ConfigCrafting.RICE_DOUGH.isEnabled()) + GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(InitItems.itemMisc, 2, TheMiscItems.RICE_DOUGH.ordinal()), + TheFoods.RICE.getOredictName(), TheFoods.RICE.getOredictName())); + //Paper Cone if(ConfigCrafting.PAPER_CONE.isEnabled()) GameRegistry.addRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.PAPER_CONE.ordinal()), @@ -33,7 +39,7 @@ public class MiscCrafting{ //Knife Blade if(ConfigCrafting.KNIFE_BLADE.isEnabled()) GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.KNIFE_BLADE.ordinal()), - "KF", + "K", "F", 'K', "ingotIron", 'F', new ItemStack(Items.flint))); } diff --git a/src/main/java/ellpeck/actuallyadditions/creative/CreativeTab.java b/src/main/java/ellpeck/actuallyadditions/creative/CreativeTab.java index a6f6b816a..541f64054 100644 --- a/src/main/java/ellpeck/actuallyadditions/creative/CreativeTab.java +++ b/src/main/java/ellpeck/actuallyadditions/creative/CreativeTab.java @@ -26,59 +26,115 @@ public class CreativeTab extends CreativeTabs{ public void displayAllReleventItems(List list){ this.list = list; - this.addBlock(InitBlocks.blockInputter); - this.addBlock(InitBlocks.blockInputterAdvanced); - this.addBlock(InitBlocks.blockGreenhouseGlass); - this.addBlock(InitBlocks.blockGrinder); - this.addBlock(InitBlocks.blockGrinderDouble); - this.addBlock(InitBlocks.blockFurnaceDouble); + add(InitBlocks.blockPhantomface); + add(InitBlocks.blockPhantomEnergyface); + add(InitBlocks.blockPhantomLiquiface); + add(InitBlocks.blockPhantomPlacer); + add(InitBlocks.blockPhantomBreaker); + add(InitBlocks.blockInputter); + add(InitBlocks.blockInputterAdvanced); + add(InitBlocks.blockPhantomBooster); + add(InitBlocks.blockCoffeeMachine); - //TODO Re-add - //this.addBlock(InitBlocks.blockFurnaceSolar); - //this.addBlock(InitBlocks.blockHeatCollector); - this.addBlock(InitBlocks.blockItemRepairer); - this.addBlock(InitBlocks.blockFishingNet); - this.addBlock(InitBlocks.blockBreaker); - this.addBlock(InitBlocks.blockPlacer); - this.addBlock(InitBlocks.blockDropper); + add(InitBlocks.blockGreenhouseGlass); + add(InitBlocks.blockGrinder); + add(InitBlocks.blockGrinderDouble); + add(InitBlocks.blockFurnaceDouble); + add(InitBlocks.blockLavaFactoryController); - this.addBlock(InitBlocks.blockMisc); - this.addBlock(InitBlocks.blockFeeder); - this.addBlock(InitBlocks.blockCompost); - this.addBlock(InitBlocks.blockGiantChest); + add(InitBlocks.blockEnergizer); + add(InitBlocks.blockEnervator); - this.addItem(InitItems.itemSpeedUpgrade); - this.addItem(InitItems.itemMisc); - this.addItem(InitItems.itemFertilizer); - this.addItem(InitItems.itemFoods); - this.addItem(InitItems.itemKnife); - this.addItem(InitItems.itemCrafterOnAStick); - this.addItem(InitItems.itemDust); - this.addItem(InitItems.itemSpecialDrop); - this.addItem(InitItems.itemLeafBlower); - this.addItem(InitItems.itemLeafBlowerAdvanced); + add(InitBlocks.blockFurnaceSolar); + add(InitBlocks.blockHeatCollector); + add(InitBlocks.blockCoalGenerator); + add(InitBlocks.blockOilGenerator); + add(InitBlocks.blockItemRepairer); + add(InitBlocks.blockFishingNet); + add(InitBlocks.blockBreaker); + add(InitBlocks.blockPlacer); + add(InitBlocks.blockDropper); + add(InitBlocks.blockFluidPlacer); + add(InitBlocks.blockFluidCollector); - this.addItem(InitItems.itemPickaxeEmerald); - this.addItem(InitItems.itemSwordEmerald); - this.addItem(InitItems.itemAxeEmerald); - this.addItem(InitItems.itemShovelEmerald); - this.addItem(InitItems.itemHoeEmerald); + add(InitBlocks.blockMisc); + add(InitBlocks.blockFeeder); + add(InitBlocks.blockCompost); + add(InitBlocks.blockGiantChest); + add(InitBlocks.blockCanolaPress); + add(InitBlocks.blockFermentingBarrel); - this.addItem(InitItems.itemPickaxeObsidian); - this.addItem(InitItems.itemSwordObsidian); - this.addItem(InitItems.itemAxeObsidian); - this.addItem(InitItems.itemShovelObsidian); - this.addItem(InitItems.itemHoeObsidian); + add(InitBlocks.blockTestifiBucksGreenWall); + add(InitBlocks.blockTestifiBucksWhiteWall); + add(InitBlocks.blockTestifiBucksGreenStairs); + add(InitBlocks.blockTestifiBucksWhiteStairs); + add(InitBlocks.blockTestifiBucksGreenSlab); + add(InitBlocks.blockTestifibucksWhiteSlab); - this.addItem(InitItems.itemPotionRing); - this.addItem(InitItems.itemPotionRingAdvanced); + add(InitItems.itemDrill); + add(InitItems.itemDrillUpgradeSpeed); + add(InitItems.itemDrillUpgradeSpeedII); + add(InitItems.itemDrillUpgradeSpeedIII); + add(InitItems.itemDrillUpgradeSilkTouch); + add(InitItems.itemDrillUpgradeFortune); + add(InitItems.itemDrillUpgradeFortuneII); + add(InitItems.itemDrillUpgradeThreeByThree); + add(InitItems.itemDrillUpgradeFiveByFive); + add(InitItems.itemDrillUpgradeBlockPlacing); + add(InitItems.itemBattery); + + add(InitItems.itemPhantomConnector); + add(InitItems.itemBucketCanolaOil); + add(InitItems.itemBucketOil); - this.addItem(InitItems.itemJams); + add(InitItems.itemCoffeeSeed); + add(InitItems.itemCoffeeBean); + add(InitItems.itemRiceSeed); + add(InitItems.itemCanolaSeed); + add(InitItems.itemFlaxSeed); + add(InitItems.itemHairyBall); + add(InitItems.itemMisc); + add(InitItems.itemResonantRice); + add(InitItems.itemFertilizer); + + add(InitItems.itemCoffee); + add(InitItems.itemFoods); + add(InitItems.itemKnife); + add(InitItems.itemCrafterOnAStick); + add(InitItems.itemDust); + add(InitItems.itemSpecialDrop); + add(InitItems.itemLeafBlower); + add(InitItems.itemLeafBlowerAdvanced); + + add(InitItems.woodenPaxel); + add(InitItems.stonePaxel); + add(InitItems.ironPaxel); + add(InitItems.goldPaxel); + add(InitItems.diamondPaxel); + add(InitItems.emeraldPaxel); + add(InitItems.obsidianPaxel); + + add(InitItems.itemPickaxeEmerald); + add(InitItems.itemSwordEmerald); + add(InitItems.itemAxeEmerald); + add(InitItems.itemShovelEmerald); + add(InitItems.itemHoeEmerald); + + add(InitItems.itemPickaxeObsidian); + add(InitItems.itemSwordObsidian); + add(InitItems.itemAxeObsidian); + add(InitItems.itemShovelObsidian); + add(InitItems.itemHoeObsidian); + + add(InitItems.itemJams); + + add(InitItems.itemPotionRing); + add(InitItems.itemPotionRingAdvanced); } @Override public Item getTabIconItem(){ - return Item.getItemFromBlock(InitBlocks.blockInputter); + return Item.getItemFromBlock(InitBlocks.blockPhantomLiquiface); } @Override @@ -86,11 +142,11 @@ public class CreativeTab extends CreativeTabs{ return new ItemStack(this.getTabIconItem()); } - private void addItem(Item item){ - item.getSubItems(item, this, list); + private void add(Item item){ + item.getSubItems(item, instance, list); } - private void addBlock(Block block){ - block.getSubBlocks(new ItemStack(block).getItem(), this, list); + private void add(Block block){ + block.getSubBlocks(new ItemStack(block).getItem(), instance, list); } } diff --git a/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java b/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java new file mode 100644 index 000000000..791ff6795 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/event/BucketFillEvent.java @@ -0,0 +1,28 @@ +package ellpeck.actuallyadditions.event; + +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.items.InitItems; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.player.FillBucketEvent; + +public class BucketFillEvent{ + + @SubscribeEvent + public void onBucketFilled(FillBucketEvent event){ + Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ); + if(block == InitBlocks.blockCanolaOil){ + event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); + event.result = new ItemStack(InitItems.itemBucketCanolaOil); + event.setResult(Event.Result.ALLOW); + } + if(block == InitBlocks.blockOil){ + event.world.setBlockToAir(event.target.blockX, event.target.blockY, event.target.blockZ); + event.result = new ItemStack(InitItems.itemBucketOil); + event.setResult(Event.Result.ALLOW); + } + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java b/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java new file mode 100644 index 000000000..ea6520261 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java @@ -0,0 +1,31 @@ +package ellpeck.actuallyadditions.event; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.config.values.ConfigBoolValues; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.InitItems; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityOcelot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; + +import java.util.Random; + +public class EntityLivingEvent{ + + @SubscribeEvent + public void livingUpdateEvent(LivingUpdateEvent event){ + if(!event.entityLiving.worldObj.isRemote){ + if(event.entityLiving instanceof EntityOcelot){ + EntityOcelot theOcelot = (EntityOcelot)event.entityLiving; + if(ConfigBoolValues.DO_CAT_DROPS.isEnabled() && theOcelot.isTamed()){ + if(new Random().nextInt(ConfigIntValues.CAT_DROP_CHANCE.getValue())+1 == 1){ + EntityItem item = new EntityItem(theOcelot.worldObj, theOcelot.posX + 0.5, theOcelot.posY + 0.5, theOcelot.posZ + 0.5, new ItemStack(InitItems.itemHairyBall)); + theOcelot.worldObj.spawnEntityInWorld(item); + } + } + } + } + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java index 71c28a16d..638251ebc 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java +++ b/src/main/java/ellpeck/actuallyadditions/event/InitEvents.java @@ -12,6 +12,9 @@ public class InitEvents{ Util.registerEvent(new KilledEvent()); Util.registerEvent(new PickupEvent()); Util.registerEvent(new TooltipEvent()); + Util.registerEvent(new EntityLivingEvent()); + Util.registerEvent(new WorldDecorationEvent()); + Util.registerEvent(new BucketFillEvent()); } } diff --git a/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java b/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java index d26b563b2..644fff2fc 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java +++ b/src/main/java/ellpeck/actuallyadditions/event/RenderPlayerEventAA.java @@ -13,8 +13,9 @@ public class RenderPlayerEventAA{ private RenderSpecial ellpeckRender = new RenderSpecial(new ModelStandardBlock("Ellpeck")); private RenderSpecial hoseRender = new RenderSpecial(new ModelTorch()); - private RenderSpecial paktoRender = new RenderSpecial(new ModelStandardBlock("Pakto")); + //private RenderSpecial paktoRender = new RenderSpecial(new ModelStandardBlock("Pakto")); private RenderSpecial glenRender = new RenderSpecial(new ModelStandardBlock("Glenthor")); + private RenderSpecial lordiRender = new RenderSpecial(new ModelStandardBlock("Lordi")); @SubscribeEvent(priority = EventPriority.HIGHEST) public void RenderPlayerEvent(RenderPlayerEvent.Pre event){ @@ -26,10 +27,10 @@ public class RenderPlayerEventAA{ } //Paktosan - if(event.entityPlayer.getUniqueID().equals(UUID.fromString("0bac71ad-9156-487e-9ade-9c5b57274b23"))){ + /*if(event.entityPlayer.getUniqueID().equals(UUID.fromString("0bac71ad-9156-487e-9ade-9c5b57274b23"))){ paktoRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); return; - } + }*/ //TwoOfEight if(event.entityPlayer.getUniqueID().equals(UUID.fromString("a57d2829-9711-4552-a7de-ee800802f643"))){ @@ -40,6 +41,12 @@ public class RenderPlayerEventAA{ //dqmhose if(event.entityPlayer.getUniqueID().equals(UUID.fromString("cb7b293a-5031-484e-b5be-b4f2f4e92726"))){ hoseRender.render(event.entityPlayer, event.partialRenderTick, 0.5F, 1.3F); + return; + } + + //Lordi + if(event.entityPlayer.getUniqueID().equals(UUID.fromString("990ecf6d-15dd-442c-b91b-323a6420c78e"))){ + lordiRender.render(event.entityPlayer, event.partialRenderTick, 0.3F, 1F); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java b/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java new file mode 100644 index 000000000..0fa3acaba --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/event/WorldDecorationEvent.java @@ -0,0 +1,61 @@ +package ellpeck.actuallyadditions.event; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.blocks.metalists.TheWildPlants; +import ellpeck.actuallyadditions.config.values.ConfigBoolValues; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent; + +import java.util.ArrayList; +import java.util.Random; + +public class WorldDecorationEvent{ + + @SubscribeEvent + public void onWorldDecoration(DecorateBiomeEvent event){ + if(ConfigBoolValues.DO_RICE_GEN.isEnabled()){ + for(int i = 0; i < ConfigIntValues.RICE_AMOUNT.getValue(); i++){ + if(new Random().nextInt(10) == 0){ + int genX = event.chunkX+event.rand.nextInt(16)+8; + int genZ = event.chunkZ+event.rand.nextInt(16)+8; + int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ); + + if(event.world.getBlock(genX, genY, genZ).getMaterial() == Material.water){ + ArrayList blocksAroundBottom = WorldUtil.getMaterialsAround(event.world, genX, genY, genZ); + ArrayList blocksAroundTop = WorldUtil.getMaterialsAround(event.world, genX, genY+1, genZ); + if(blocksAroundBottom.contains(Material.grass) || blocksAroundBottom.contains(Material.ground) || blocksAroundBottom.contains(Material.rock) || blocksAroundBottom.contains(Material.sand)){ + if(!blocksAroundTop.contains(Material.water) && event.world.getBlock(genX, genY+1, genZ).getMaterial() == Material.air){ + event.world.setBlock(genX, genY+1, genZ, InitBlocks.blockWildPlant, TheWildPlants.RICE.ordinal(), 2); + } + } + } + } + } + } + + this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.grass, event); + this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.grass, event); + this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.COFFEE.ordinal(), ConfigIntValues.COFFEE_AMOUNT.getValue(), ConfigBoolValues.DO_COFFEE_GEN.isEnabled(), Material.grass, event); + } + + public void genPlantNormally(Block plant, int meta, int amount, boolean doIt, Material blockBelow, DecorateBiomeEvent event){ + if(doIt){ + for(int i = 0; i < amount; i++){ + if(new Random().nextInt(100) == 0){ + int genX = event.chunkX+event.rand.nextInt(16)+8; + int genZ = event.chunkZ+event.rand.nextInt(16)+8; + int genY = event.world.getTopSolidOrLiquidBlock(genX, genZ)-1; + + if(event.world.getBlock(genX, genY, genZ).getMaterial() == blockBelow){ + event.world.setBlock(genX, genY+1, genZ, plant, meta, 2); + } + } + } + } + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java b/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java index d2ca7e8ec..861358e1b 100644 --- a/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java +++ b/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java @@ -42,7 +42,7 @@ public class RenderSpecial{ GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); GL11.glScalef(size, size, size); - if(!(time-(bobHeight/2) < lastTimeForBobbing)){ + if(time-(bobHeight/2) >= lastTimeForBobbing){ GL11.glTranslated(0, ((double)time-this.lastTimeForBobbing)/100, 0); } else{ diff --git a/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java b/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java index 3d58b94d7..a35437f9e 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/InitVillager.java @@ -13,31 +13,34 @@ import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraftforge.common.ChestGenHooks; -import java.util.Random; - public class InitVillager{ - public static ChestGenHooks jamHouseChest; + public static final String JAM_HOUSE_CHEST_NAME = ModUtil.MOD_ID_LOWER+".jamHouseChest"; public static void init(){ Util.logInfo("Initializing Village Addons..."); if(ConfigBoolValues.JAM_VILLAGER_EXISTS.isEnabled()){ - - int jamID = ConfigIntValues.JAM_VILLAGER_ID.getValue(); - VillagerRegistry.instance().registerVillagerId(jamID); - VillagerRegistry.instance().registerVillageTradeHandler(jamID, new JamVillagerTradeHandler()); - - jamHouseChest = new ChestGenHooks("JamHouse", new WeightedRandomChestContent[0], 5, 20); - for(int i = 0; i < TheJams.values().length; i++){ - jamHouseChest.addItem(new WeightedRandomChestContent(new ItemStack(InitItems.itemJams, new Random().nextInt(5)+1, i), 1, 1, 15)); - } - jamHouseChest.addItem(new WeightedRandomChestContent(new ItemStack(Items.glass_bottle, new Random().nextInt(5)+1), 1, 1, 15)); - jamHouseChest.addItem(new WeightedRandomChestContent(new ItemStack(Items.potionitem, new Random().nextInt(5)+1), 1, 1, 15)); - - VillagerRegistry.instance().registerVillageCreationHandler(new VillageJamHouseHandler()); - MapGenStructureIO.func_143031_a(VillageComponentJamHouse.class, ModUtil.MOD_ID_LOWER + ":jamHouseStructure"); + initJamVillagePart(); } } + private static void initJamVillagePart(){ + int jamID = ConfigIntValues.JAM_VILLAGER_ID.getValue(); + VillagerRegistry.instance().registerVillagerId(jamID); + VillagerRegistry.instance().registerVillageTradeHandler(jamID, new JamVillagerTradeHandler()); + + ChestGenHooks jamHouseChest = ChestGenHooks.getInfo(JAM_HOUSE_CHEST_NAME); + jamHouseChest.setMin(5); + jamHouseChest.setMax(20); + for(int i = 0; i < TheJams.values().length; i++){ + ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(InitItems.itemJams, 1, i), 1, 1, 10)); + } + ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(Items.glass_bottle), 1, 2, 30)); + ChestGenHooks.addItem(JAM_HOUSE_CHEST_NAME, new WeightedRandomChestContent(new ItemStack(Items.potionitem), 1, 1, 20)); + + VillagerRegistry.instance().registerVillageCreationHandler(new VillageJamHouseHandler()); + MapGenStructureIO.func_143031_a(VillageComponentJamHouse.class, ModUtil.MOD_ID_LOWER+":jamHouseStructure"); + } + } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java b/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java index dccd4fdee..e3b287914 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/JamVillagerTradeHandler.java @@ -18,15 +18,15 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa private ArrayList trades = new ArrayList(); public JamVillagerTradeHandler(){ - this.addWants("ingotGold", 3, 2); - this.addWants("cropWheat", 10, 10); - this.addWants("dustRedstone", 15, 15); - this.addWants(new ItemStack(Items.bucket), 1, 4); - this.addWants(new ItemStack(Items.glass_bottle), 5, 5); + this.addWants("ingotGold", 5, 2); + this.addWants("cropWheat", 15, 10); + this.addWants("dustRedstone", 25, 15); + this.addWants(new ItemStack(Items.bucket), 5, 4); + this.addWants(new ItemStack(Items.glass_bottle), 12, 5); this.addWants(new ItemStack(Items.potionitem), 1, 0); - this.addWants("ingotIron", 5, 5); - this.addWants("gemDiamond", 1, 1); - this.addWants("dustGlowstone", 5, 10); + this.addWants("ingotIron", 10, 5); + this.addWants("gemDiamond", 1, 2); + this.addWants("dustGlowstone", 12, 10); } @Override @@ -48,14 +48,14 @@ public class JamVillagerTradeHandler implements VillagerRegistry.IVillageTradeHa if(wantsOne == wantsTwo) wantsTwo = null; for(int k = 0; k < TheJams.values().length; k++){ - recipeList.add(new MerchantRecipe(wantsOne, wantsTwo, new ItemStack(InitItems.itemJams, rand.nextInt(5)+1, k))); + recipeList.add(new MerchantRecipe(wantsOne, wantsTwo, new ItemStack(InitItems.itemJams, rand.nextInt(3)+1, k))); } } } } public void addWants(String oredictName, int minSize, int maxSize){ - ArrayList stacks = OreDictionary.getOres(oredictName); + ArrayList stacks = (ArrayList)OreDictionary.getOres(oredictName, false); trades.add(new Trade(stacks, minSize, maxSize)); } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java index 1559282b5..513548c1c 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/OreGen.java @@ -11,6 +11,7 @@ import ellpeck.actuallyadditions.util.Util; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; +import net.minecraft.world.WorldType; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.feature.WorldGenMinable; import org.apache.logging.log4j.Level; @@ -21,13 +22,17 @@ public class OreGen implements IWorldGenerator{ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider){ - switch (world.provider.dimensionId){ + if(world.provider.terrainType == WorldType.FLAT) return; + + switch(world.provider.dimensionId){ case -1: generateNether(world, random, chunkX*16, chunkZ*16); - case 0: - generateSurface(world, random, chunkX*16, chunkZ*16); + //case 0: + // generateSurface(world, random, chunkX*16, chunkZ*16); case 1: generateEnd(world, random, chunkX*16, chunkZ*16); + default: + generateSurface(world, random, chunkX*16, chunkZ*16); } } @@ -37,7 +42,9 @@ public class OreGen implements IWorldGenerator{ } private void generateSurface(World world, Random random, int x, int z){ - if(ConfigBoolValues.GENERATE_QUARTZ.isEnabled()) this.addOreSpawn(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), Blocks.stone, world, random, x, z, this.getRandom(ConfigIntValues.BLACK_QUARTZ_BASE_AMOUNT.getValue(), ConfigIntValues.BLACK_QUARTZ_ADD_CHANCE.getValue(), random), ConfigIntValues.BLACK_QUARTZ_CHANCE.getValue(), ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue(), ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()); + if(ConfigBoolValues.GENERATE_QUARTZ.isEnabled()){ + this.addOreSpawn(InitBlocks.blockMisc, TheMiscBlocks.ORE_QUARTZ.ordinal(), Blocks.stone, world, random, x, z, this.getRandom(ConfigIntValues.BLACK_QUARTZ_BASE_AMOUNT.getValue(), ConfigIntValues.BLACK_QUARTZ_ADD_CHANCE.getValue(), random), ConfigIntValues.BLACK_QUARTZ_CHANCE.getValue(), ConfigIntValues.BLACK_QUARTZ_MIN_HEIGHT.getValue(), ConfigIntValues.BLACK_QUARTZ_MAX_HEIGHT.getValue()); + } } @SuppressWarnings("unused") @@ -55,7 +62,7 @@ public class OreGen implements IWorldGenerator{ new WorldGenMinable(block, meta, maxVeinSize, blockIn).generate(world, random, posX, posY, posZ); } } - else ModUtil.AA_LOGGER.log(Level.FATAL, "Couldn't generate '" + block.getUnlocalizedName() + "' into the world because the Min Y coordinate is bigger than the Max! This is definitely a Config Error! Check the Files!"); + else ModUtil.LOGGER.log(Level.FATAL, "Couldn't generate '" + block.getUnlocalizedName() + "' into the world because the Min Y coordinate is bigger than the Max! This is definitely a Config Error! Check the Files!"); } public int getRandom(int base, int extra, Random rand){ @@ -64,6 +71,6 @@ public class OreGen implements IWorldGenerator{ public static void init(){ Util.logInfo("Registering World Generator..."); - GameRegistry.registerWorldGenerator(new OreGen(), 0); + GameRegistry.registerWorldGenerator(new OreGen(), 10); } } diff --git a/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java b/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java index e2fda48a1..dfc349da1 100644 --- a/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java +++ b/src/main/java/ellpeck/actuallyadditions/gen/VillageComponentJamHouse.java @@ -10,6 +10,7 @@ import net.minecraft.world.World; import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; +import net.minecraftforge.common.ChestGenHooks; import java.util.List; import java.util.Random; @@ -49,8 +50,8 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ for (int i = 0; i < xSize; i++){ for(int j = 0; j < zSize; j++){ - this.clearCurrentPositionBlocksUpwards(world, j, ySize, i, sbb); - this.func_151554_b(world, Blocks.cobblestone, 0, j, -1, i, sbb); + this.clearCurrentPositionBlocksUpwards(world, i, ySize, j, sbb); + this.func_151554_b(world, Blocks.cobblestone, 0, i, -1, j, sbb); } } @@ -163,12 +164,9 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ //Loot Chest this.placeBlockAtCurrentPosition(world, Blocks.chest, 0, 8, 1, 6, sbb); - int posX = this.getXWithOffset(8, 6); - int posY = this.getYWithOffset(1); - int posZ = this.getZWithOffset(8, 6); - TileEntity chest = world.getTileEntity(posX, posY, posZ); + TileEntity chest = world.getTileEntity(this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6)); if(chest != null && chest instanceof TileEntityChest){ - WeightedRandomChestContent.generateChestContents(rand, InitVillager.jamHouseChest.getItems(rand), (TileEntityChest)chest, InitVillager.jamHouseChest.getCount(rand)); + WeightedRandomChestContent.generateChestContents(rand, ChestGenHooks.getItems(InitVillager.JAM_HOUSE_CHEST_NAME, rand), (TileEntityChest)chest, ChestGenHooks.getCount(InitVillager.JAM_HOUSE_CHEST_NAME, rand)); } //Torches diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java index 224a8f0dd..161cb37ef 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerBreaker.java @@ -50,28 +50,30 @@ public class ContainerBreaker extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 9+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 9, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCanolaPress.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCanolaPress.java new file mode 100644 index 000000000..4807e9e9e --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCanolaPress.java @@ -0,0 +1,126 @@ +package ellpeck.actuallyadditions.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCanolaPress; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +@InventoryContainer +public class ContainerCanolaPress extends Container{ + + private TileEntityCanolaPress press; + + private int lastEnergyStored; + private int lastTankAmount; + private int lastProcessTime; + + public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile){ + this.press = (TileEntityCanolaPress)tile; + + this.addSlotToContainer(new Slot(this.press, 0, 81, 10)); + this.addSlotToContainer(new Slot(this.press, 1, 136, 73)); + this.addSlotToContainer(new SlotOutput(this.press, 2, 136, 42)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.press.isUseableByPlayer(player); + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.press.getEnergyStored(ForgeDirection.UNKNOWN)); + iCraft.sendProgressBarUpdate(this, 1, this.press.tank.getFluidAmount()); + iCraft.sendProgressBarUpdate(this, 2, this.press.currentProcessTime); + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastEnergyStored != this.press.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 0, this.press.getEnergyStored(ForgeDirection.UNKNOWN)); + if(this.lastTankAmount != this.press.tank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 1, this.press.tank.getFluidAmount()); + if(this.lastProcessTime != this.press.currentProcessTime) iCraft.sendProgressBarUpdate(this, 2, this.press.currentProcessTime); + } + + this.lastEnergyStored = this.press.getEnergyStored(ForgeDirection.UNKNOWN); + this.lastTankAmount = this.press.tank.getFluidAmount(); + this.lastProcessTime = this.press.currentProcessTime; + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.press.storage.setEnergyStored(par2); + if(par1 == 1) this.press.tank.setFluid(new FluidStack(InitBlocks.fluidCanolaOil, par2)); + if(par1 == 2) this.press.currentProcessTime = par2; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 3; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() == InitItems.itemMisc && currentStack.getItemDamage() == TheMiscItems.CANOLA.ordinal()){ + this.mergeItemStack(newStack, 0, 1, false); + } + if(currentStack.getItem() == Items.bucket){ + this.mergeItemStack(newStack, 1, 2, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCoalGenerator.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCoalGenerator.java new file mode 100644 index 000000000..8f92656c2 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCoalGenerator.java @@ -0,0 +1,117 @@ +package ellpeck.actuallyadditions.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCoalGenerator; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; + +@InventoryContainer +public class ContainerCoalGenerator extends Container{ + + private TileEntityCoalGenerator generator; + + private int lastEnergyStored; + private int lastBurnTime; + private int lastMaxBurnTime; + + public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){ + this.generator = (TileEntityCoalGenerator)tile; + + this.addSlotToContainer(new Slot(this.generator, 0, 87, 43)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.generator.isUseableByPlayer(player); + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.generator.getEnergyStored(ForgeDirection.UNKNOWN)); + iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime); + iCraft.sendProgressBarUpdate(this, 2, this.generator.maxBurnTime); + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastEnergyStored != this.generator.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 0, this.generator.getEnergyStored(ForgeDirection.UNKNOWN)); + if(this.lastBurnTime != this.generator.currentBurnTime) iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime); + if(this.lastMaxBurnTime != this.generator.maxBurnTime) iCraft.sendProgressBarUpdate(this, 2, this.generator.maxBurnTime); + } + + this.lastEnergyStored = this.generator.getEnergyStored(ForgeDirection.UNKNOWN); + this.lastBurnTime = this.generator.currentBurnTime; + this.lastMaxBurnTime = this.generator.maxBurnTime; + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.generator.storage.setEnergyStored(par2); + if(par1 == 1) this.generator.currentBurnTime = par2; + if(par1 == 2) this.generator.maxBurnTime = par2; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 1; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(TileEntityFurnace.getItemBurnTime(currentStack) > 0){ + this.mergeItemStack(newStack, 0, 1, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCoffeeMachine.java new file mode 100644 index 000000000..cd6c5427a --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerCoffeeMachine.java @@ -0,0 +1,150 @@ +package ellpeck.actuallyadditions.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.ItemCoffee; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +@InventoryContainer +public class ContainerCoffeeMachine extends Container{ + + private TileEntityCoffeeMachine machine; + + private int lastCoffeeAmount; + private int lastEnergyAmount; + private int lastBrewTime; + private int lastWaterAmount; + + public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){ + this.machine = (TileEntityCoffeeMachine)tile; + + this.addSlotToContainer(new Slot(machine, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6)); + this.addSlotToContainer(new Slot(machine, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42)); + this.addSlotToContainer(new SlotOutput(machine, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73)); + + for (int i = 0; i < 4; i++){ + for (int j = 0; j < 2; j++){ + this.addSlotToContainer(new Slot(machine, j+i*2+3, 125+j*18, 6+i*18)); + } + } + + this.addSlotToContainer(new Slot(machine, TileEntityCoffeeMachine.SLOT_WATER_INPUT, 26, 73)); + this.addSlotToContainer(new SlotOutput(machine, TileEntityCoffeeMachine.SLOT_WATER_OUTPUT, 45, 73)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.machine.storage.getEnergyStored()); + iCraft.sendProgressBarUpdate(this, 1, this.machine.coffeeCacheAmount); + iCraft.sendProgressBarUpdate(this, 2, this.machine.brewTime); + iCraft.sendProgressBarUpdate(this, 3, this.machine.tank.getFluidAmount()); + + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastEnergyAmount != this.machine.storage.getEnergyStored()) iCraft.sendProgressBarUpdate(this, 0, this.machine.storage.getEnergyStored()); + if(this.lastCoffeeAmount != this.machine.coffeeCacheAmount) iCraft.sendProgressBarUpdate(this, 1, this.machine.coffeeCacheAmount); + if(this.lastBrewTime != this.machine.brewTime) iCraft.sendProgressBarUpdate(this, 2, this.machine.brewTime); + if(this.lastWaterAmount != this.machine.tank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 3, this.machine.tank.getFluidAmount()); + } + + this.lastEnergyAmount = this.machine.storage.getEnergyStored(); + this.lastCoffeeAmount = this.machine.coffeeCacheAmount; + this.lastBrewTime = this.machine.brewTime; + this.lastWaterAmount = this.machine.tank.getFluidAmount(); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.machine.storage.setEnergyStored(par2); + if(par1 == 1) this.machine.coffeeCacheAmount = par2; + if(par1 == 2) this.machine.brewTime = par2; + if(par1 == 3) this.machine.tank.setFluid(new FluidStack(FluidRegistry.WATER, par2)); + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.machine.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 13; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() == InitItems.itemCoffeeBean){ + this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS+1, false); + } + if(currentStack.getItem() == InitItems.itemMisc && currentStack.getItemDamage() == TheMiscItems.CUP.ordinal()){ + this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT+1, false); + } + if(ItemCoffee.getIngredientFromStack(newStack) != null){ + this.mergeItemStack(newStack, 3, 10, false); + } + if(FluidContainerRegistry.containsFluid(newStack, new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME))){ + this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_WATER_INPUT, TileEntityCoffeeMachine.SLOT_WATER_INPUT+1, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java new file mode 100644 index 000000000..5d5281aa7 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java @@ -0,0 +1,195 @@ +package ellpeck.actuallyadditions.inventory; + +import ellpeck.actuallyadditions.inventory.slot.SlotImmovable; +import ellpeck.actuallyadditions.items.ItemDrill; +import ellpeck.actuallyadditions.items.ItemDrillUpgrade; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +@InventoryContainer +public class ContainerDrill extends Container{ + + private static final int SLOT_AMOUNT = 5; + + private InventoryDrill drillInventory = new InventoryDrill(); + private InventoryPlayer inventory; + + public ContainerDrill(InventoryPlayer inventory){ + this.inventory = inventory; + + for(int i = 0; i < SLOT_AMOUNT; i++){ + this.addSlotToContainer(new Slot(drillInventory, i, 44+i*18, 19){ + @Override + public boolean isItemValid(ItemStack stack){ + return stack.getItem() instanceof ItemDrillUpgrade; + } + }); + } + + for(int i = 0; i < 3; i++){ + for(int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 58+i*18)); + } + } + for(int i = 0; i < 9; i++){ + if(i == inventory.currentItem) this.addSlotToContainer(new SlotImmovable(inventory, i, 8+i*18, 116)); + else this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 116)); + } + + ItemStack stack = inventory.getCurrentItem(); + if(stack != null && stack.getItem() instanceof ItemDrill){ + ItemStack[] slots = ((ItemDrill)stack.getItem()).getSlotsFromNBT(inventory.getCurrentItem()); + if(slots != null && slots.length > 0) this.drillInventory.slots = slots; + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.drillInventory.isUseableByPlayer(player); + } + + @Override + public void onContainerClosed(EntityPlayer player){ + ItemStack stack = inventory.getCurrentItem(); + if(stack != null && stack.getItem() instanceof ItemDrill){ + ((ItemDrill)stack.getItem()).writeSlotsToNBT(this.drillInventory.slots, inventory.getCurrentItem()); + } + super.onContainerClosed(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 5; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() instanceof ItemDrillUpgrade){ + this.mergeItemStack(newStack, 0, SLOT_AMOUNT, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + } + return null; + } + + public static class InventoryDrill implements IInventory{ + + public ItemStack[] slots = new ItemStack[SLOT_AMOUNT]; + + @Override + public String getInventoryName(){ + return "drill"; + } + + @Override + public boolean hasCustomInventoryName(){ + return false; + } + + @Override + public int getInventoryStackLimit(){ + return 64; + } + + @Override + public void markDirty(){ + + } + + @Override + public void openInventory(){ + + } + + @Override + public void closeInventory(){ + + } + + @Override + public boolean isItemValidForSlot(int slot, ItemStack stack){ + return true; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player){ + return true; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i){ + return getStackInSlot(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack stack){ + this.slots[i] = stack; + this.markDirty(); + } + + @Override + public int getSizeInventory(){ + return slots.length; + } + + @Override + public ItemStack getStackInSlot(int i){ + if(i < this.getSizeInventory()){ + return slots[i]; + } + return null; + } + + @Override + public ItemStack decrStackSize(int i, int j){ + if (slots[i] != null){ + ItemStack stackAt; + if(slots[i].stackSize <= j){ + stackAt = slots[i]; + slots[i] = null; + this.markDirty(); + return stackAt; + } + else{ + stackAt = slots[i].splitStack(j); + if (slots[i].stackSize == 0) slots[i] = null; + this.markDirty(); + return stackAt; + } + } + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java index 47dde5e19..095a9e254 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDropper.java @@ -50,28 +50,30 @@ public class ContainerDropper extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 9+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 9, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java new file mode 100644 index 000000000..fd54376ef --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java @@ -0,0 +1,107 @@ +package ellpeck.actuallyadditions.inventory; + +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityEnergizer; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +@InventoryContainer +public class ContainerEnergizer extends Container{ + + private TileEntityEnergizer energizer; + + private int lastEnergyStored; + + public ContainerEnergizer(InventoryPlayer inventory, TileEntityBase tile){ + this.energizer = (TileEntityEnergizer)tile; + + this.addSlotToContainer(new Slot(this.energizer, 0, 76, 73)); + this.addSlotToContainer(new SlotOutput(this.energizer, 1, 76, 42)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.energizer.isUseableByPlayer(player); + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.energizer.getEnergyStored(ForgeDirection.UNKNOWN)); + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastEnergyStored != this.energizer.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 0, this.energizer.getEnergyStored(ForgeDirection.UNKNOWN)); + } + + this.lastEnergyStored = this.energizer.getEnergyStored(ForgeDirection.UNKNOWN); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.energizer.storage.setEnergyStored(par2); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 2; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() instanceof IEnergyContainerItem){ + this.mergeItemStack(newStack, 0, 1, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java new file mode 100644 index 000000000..b9497be95 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java @@ -0,0 +1,109 @@ +package ellpeck.actuallyadditions.inventory; + +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityEnervator; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +@InventoryContainer +public class ContainerEnervator extends Container{ + + private TileEntityEnervator enervator; + + private int lastEnergyStored; + + public ContainerEnervator(InventoryPlayer inventory, TileEntityBase tile){ + this.enervator = (TileEntityEnervator)tile; + + this.addSlotToContainer(new Slot(this.enervator, 0, 76, 73)); + this.addSlotToContainer(new SlotOutput(this.enervator, 1, 76, 42)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.enervator.isUseableByPlayer(player); + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.enervator.getEnergyStored(ForgeDirection.UNKNOWN)); + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastEnergyStored != this.enervator.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 0, this.enervator.getEnergyStored(ForgeDirection.UNKNOWN)); + } + + this.lastEnergyStored = this.enervator.getEnergyStored(ForgeDirection.UNKNOWN); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.enervator.storage.setEnergyStored(par2); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 2; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(currentStack.getItem() instanceof IEnergyContainerItem){ + this.mergeItemStack(newStack, 0, 1, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java index ae0d3528f..e17e0ba9a 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFeeder.java @@ -79,28 +79,30 @@ public class ContainerFeeder extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 1, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java new file mode 100644 index 000000000..24ed5f1dd --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFermentingBarrel.java @@ -0,0 +1,128 @@ +package ellpeck.actuallyadditions.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityFermentingBarrel; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +@InventoryContainer +public class ContainerFermentingBarrel extends Container{ + + private TileEntityFermentingBarrel barrel; + + private int lastProcessTime; + private int lastCanolaTank; + private int lastOilTank; + + public ContainerFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){ + this.barrel = (TileEntityFermentingBarrel)tile; + + this.addSlotToContainer(new Slot(this.barrel, 0, 42, 74)); + this.addSlotToContainer(new SlotOutput(this.barrel, 1, 42, 43)); + this.addSlotToContainer(new Slot(this.barrel, 2, 118, 74)); + this.addSlotToContainer(new SlotOutput(this.barrel, 3, 118, 43)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.barrel.isUseableByPlayer(player); + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.barrel.oilTank.getFluidAmount()); + iCraft.sendProgressBarUpdate(this, 1, this.barrel.canolaTank.getFluidAmount()); + iCraft.sendProgressBarUpdate(this, 2, this.barrel.currentProcessTime); + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastOilTank != this.barrel.oilTank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 0, this.barrel.oilTank.getFluidAmount()); + if(this.lastCanolaTank != this.barrel.canolaTank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 1, this.barrel.canolaTank.getFluidAmount()); + if(this.lastProcessTime != this.barrel.currentProcessTime) iCraft.sendProgressBarUpdate(this, 2, this.barrel.currentProcessTime); + } + + this.lastOilTank = this.barrel.oilTank.getFluidAmount(); + this.lastCanolaTank = this.barrel.canolaTank.getFluidAmount(); + this.lastProcessTime = this.barrel.currentProcessTime; + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.barrel.oilTank.setFluid(new FluidStack(InitBlocks.fluidOil, par2)); + if(par1 == 1) this.barrel.canolaTank.setFluid(new FluidStack(InitBlocks.fluidCanolaOil, par2)); + if(par1 == 2) this.barrel.currentProcessTime = par2; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 4; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(FluidContainerRegistry.containsFluid(currentStack, new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))){ + this.mergeItemStack(newStack, 0, 1, false); + } + if(currentStack.getItem() == Items.bucket){ + this.mergeItemStack(newStack, 2, 3, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFluidCollector.java new file mode 100644 index 000000000..4b1ce7ddb --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFluidCollector.java @@ -0,0 +1,88 @@ +package ellpeck.actuallyadditions.inventory; + +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityFluidCollector; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; + +@InventoryContainer +public class ContainerFluidCollector extends Container{ + + private TileEntityFluidCollector collector; + + public ContainerFluidCollector(InventoryPlayer inventory, TileEntityBase tile){ + this.collector = (TileEntityFluidCollector)tile; + + this.addSlotToContainer(new Slot(collector, 0, 90, 73)); + this.addSlotToContainer(new SlotOutput(collector, 1, 90, 42)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.collector.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 2; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(this.collector.isPlacer){ + if(FluidContainerRegistry.isBucket(currentStack) && !newStack.isItemEqual(FluidContainerRegistry.EMPTY_BUCKET)){ + this.mergeItemStack(newStack, 0, 1, false); + } + } + else{ + if(newStack.isItemEqual(FluidContainerRegistry.EMPTY_BUCKET)){ + this.mergeItemStack(newStack, 0, 1, false); + } + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java index c2e2fbc89..3ef872724 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerFurnaceDouble.java @@ -13,15 +13,14 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; @InventoryContainer public class ContainerFurnaceDouble extends Container{ private TileEntityFurnaceDouble tileFurnace; - private int lastCoalTime; - private int lastCoalTimeLeft; + private int lastEnergy; private int lastFirstCrushTime; private int lastSecondCrushTime; private int lastBurnTime; @@ -29,15 +28,11 @@ public class ContainerFurnaceDouble extends Container{ public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){ this.tileFurnace = (TileEntityFurnaceDouble)tile; - this.addSlotToContainer(new Slot(this.tileFurnace, TileEntityFurnaceDouble.SLOT_COAL, 80, 21)); - this.addSlotToContainer(new Slot(this.tileFurnace, TileEntityFurnaceDouble.SLOT_INPUT_1, 51, 21)); this.addSlotToContainer(new SlotOutput(this.tileFurnace, TileEntityFurnaceDouble.SLOT_OUTPUT_1, 51, 69)); this.addSlotToContainer(new Slot(this.tileFurnace, TileEntityFurnaceDouble.SLOT_INPUT_2, 109, 21)); this.addSlotToContainer(new SlotOutput(this.tileFurnace, TileEntityFurnaceDouble.SLOT_OUTPUT_2, 108, 69)); - this.addSlotToContainer(new Slot(this.tileFurnace, this.tileFurnace.speedUpgradeSlot, 155, 21)); - for (int i = 0; i < 3; i++){ for (int j = 0; j < 9; j++){ this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); @@ -51,11 +46,10 @@ public class ContainerFurnaceDouble extends Container{ @Override public void addCraftingToCrafters(ICrafting iCraft){ super.addCraftingToCrafters(iCraft); - iCraft.sendProgressBarUpdate(this, 0, this.tileFurnace.coalTime); - iCraft.sendProgressBarUpdate(this, 1, this.tileFurnace.coalTimeLeft); - iCraft.sendProgressBarUpdate(this, 2, this.tileFurnace.firstSmeltTime); - iCraft.sendProgressBarUpdate(this, 3, this.tileFurnace.secondSmeltTime); - iCraft.sendProgressBarUpdate(this, 4, this.tileFurnace.maxBurnTime); + iCraft.sendProgressBarUpdate(this, 0, this.tileFurnace.firstSmeltTime); + iCraft.sendProgressBarUpdate(this, 1, this.tileFurnace.secondSmeltTime); + iCraft.sendProgressBarUpdate(this, 2, this.tileFurnace.maxBurnTime); + iCraft.sendProgressBarUpdate(this, 3, this.tileFurnace.getEnergyStored(ForgeDirection.UNKNOWN)); } @Override @@ -64,28 +58,25 @@ public class ContainerFurnaceDouble extends Container{ for(Object crafter : this.crafters){ ICrafting iCraft = (ICrafting)crafter; - if(this.lastCoalTime != this.tileFurnace.coalTime) iCraft.sendProgressBarUpdate(this, 0, this.tileFurnace.coalTime); - if(this.lastCoalTimeLeft != this.tileFurnace.coalTimeLeft) iCraft.sendProgressBarUpdate(this, 1, this.tileFurnace.coalTimeLeft); - if(this.lastFirstCrushTime != this.tileFurnace.firstSmeltTime) iCraft.sendProgressBarUpdate(this, 2, this.tileFurnace.firstSmeltTime); - if(this.lastSecondCrushTime != this.tileFurnace.secondSmeltTime) iCraft.sendProgressBarUpdate(this, 3, this.tileFurnace.secondSmeltTime); - if(this.lastBurnTime != this.tileFurnace.maxBurnTime) iCraft.sendProgressBarUpdate(this, 4, this.tileFurnace.maxBurnTime); + if(this.lastFirstCrushTime != this.tileFurnace.firstSmeltTime) iCraft.sendProgressBarUpdate(this, 0, this.tileFurnace.firstSmeltTime); + if(this.lastSecondCrushTime != this.tileFurnace.secondSmeltTime) iCraft.sendProgressBarUpdate(this, 1, this.tileFurnace.secondSmeltTime); + if(this.lastBurnTime != this.tileFurnace.maxBurnTime) iCraft.sendProgressBarUpdate(this, 2, this.tileFurnace.maxBurnTime); + if(this.lastEnergy != this.tileFurnace.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 3, this.tileFurnace.getEnergyStored(ForgeDirection.UNKNOWN)); } - this.lastCoalTime = this.tileFurnace.coalTime; - this.lastCoalTimeLeft = this.tileFurnace.coalTimeLeft; this.lastFirstCrushTime = this.tileFurnace.firstSmeltTime; this.lastSecondCrushTime = this.tileFurnace.secondSmeltTime; this.lastBurnTime = this.tileFurnace.maxBurnTime; + this.lastEnergy = this.tileFurnace.getEnergyStored(ForgeDirection.UNKNOWN); } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2){ - if(par1 == 0) this.tileFurnace.coalTime = par2; - if(par1 == 1) this.tileFurnace.coalTimeLeft = par2; - if(par1 == 2) this.tileFurnace.firstSmeltTime = par2; - if(par1 == 3) this.tileFurnace.secondSmeltTime = par2; - if(par1 == 4) this.tileFurnace.maxBurnTime = par2; + if(par1 == 0) this.tileFurnace.firstSmeltTime = par2; + if(par1 == 1) this.tileFurnace.secondSmeltTime = par2; + if(par1 == 2) this.tileFurnace.maxBurnTime = par2; + if(par1 == 3) this.tileFurnace.storage.setEnergyStored(par2); } @Override @@ -95,7 +86,7 @@ public class ContainerFurnaceDouble extends Container{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - final int inventoryStart = 6; + final int inventoryStart = 4; final int inventoryEnd = inventoryStart+26; final int hotbarStart = inventoryEnd+1; final int hotbarEnd = hotbarStart+8; @@ -105,35 +96,33 @@ public class ContainerFurnaceDouble extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(FurnaceRecipes.smelting().getSmeltingResult(currentStack) != null){ - this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false); - this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+2, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(FurnaceRecipes.smelting().getSmeltingResult(currentStack) != null){ + this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false); + this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+2, false); + } } - if(TileEntityFurnace.getItemBurnTime(currentStack) > 0){ - this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_COAL, TileEntityFurnaceDouble.SLOT_COAL+1, false); + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java index 3d5d510a8..941b9ad60 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGiantChest.java @@ -50,28 +50,30 @@ public class ContainerGiantChest extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 117, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 117, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java index a3e0c6abb..1eb7a3952 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerGrinder.java @@ -3,7 +3,7 @@ package ellpeck.actuallyadditions.inventory; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.inventory.slot.SlotOutput; -import ellpeck.actuallyadditions.recipe.GrinderRecipes; +import ellpeck.actuallyadditions.recipe.GrinderRecipeManualRegistry; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityGrinder; import invtweaks.api.container.InventoryContainer; @@ -13,7 +13,7 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; @InventoryContainer public class ContainerGrinder extends Container{ @@ -21,18 +21,15 @@ public class ContainerGrinder extends Container{ private TileEntityGrinder tileGrinder; private boolean isDouble; - private int lastCoalTime; - private int lastCoalTimeLeft; private int lastFirstCrushTime; private int lastSecondCrushTime; private int lastMaxCrushTime; + private int lastEnergyStored; public ContainerGrinder(InventoryPlayer inventory, TileEntityBase tile, boolean isDouble){ this.tileGrinder = (TileEntityGrinder)tile; this.isDouble = isDouble; - this.addSlotToContainer(new Slot(this.tileGrinder, TileEntityGrinder.SLOT_COAL, this.isDouble ? 80 : 51, 21)); - this.addSlotToContainer(new Slot(this.tileGrinder, TileEntityGrinder.SLOT_INPUT_1, this.isDouble ? 51 : 80, 21)); this.addSlotToContainer(new SlotOutput(this.tileGrinder, TileEntityGrinder.SLOT_OUTPUT_1_1, this.isDouble ? 37 : 66, 69)); this.addSlotToContainer(new SlotOutput(this.tileGrinder, TileEntityGrinder.SLOT_OUTPUT_1_2, this.isDouble ? 64 : 92, 69)); @@ -42,8 +39,6 @@ public class ContainerGrinder extends Container{ this.addSlotToContainer(new SlotOutput(this.tileGrinder, TileEntityGrinder.SLOT_OUTPUT_2_2, 121, 69)); } - this.addSlotToContainer(new Slot(this.tileGrinder, this.tileGrinder.speedUpgradeSlot, this.isDouble ? 155 : 146, 21)); - for (int i = 0; i < 3; i++){ for (int j = 0; j < 9; j++){ this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); @@ -57,11 +52,10 @@ public class ContainerGrinder extends Container{ @Override public void addCraftingToCrafters(ICrafting iCraft){ super.addCraftingToCrafters(iCraft); - iCraft.sendProgressBarUpdate(this, 0, this.tileGrinder.coalTime); - iCraft.sendProgressBarUpdate(this, 1, this.tileGrinder.coalTimeLeft); - iCraft.sendProgressBarUpdate(this, 2, this.tileGrinder.firstCrushTime); - iCraft.sendProgressBarUpdate(this, 3, this.tileGrinder.maxCrushTime); - if(this.isDouble) iCraft.sendProgressBarUpdate(this, 4, this.tileGrinder.secondCrushTime); + iCraft.sendProgressBarUpdate(this, 0, this.tileGrinder.firstCrushTime); + iCraft.sendProgressBarUpdate(this, 1, this.tileGrinder.maxCrushTime); + if(this.isDouble) iCraft.sendProgressBarUpdate(this, 2, this.tileGrinder.secondCrushTime); + iCraft.sendProgressBarUpdate(this, 3, this.tileGrinder.getEnergyStored(ForgeDirection.UNKNOWN)); } @Override @@ -70,28 +64,25 @@ public class ContainerGrinder extends Container{ for(Object crafter : this.crafters){ ICrafting iCraft = (ICrafting)crafter; - if(this.lastCoalTime != this.tileGrinder.coalTime) iCraft.sendProgressBarUpdate(this, 0, this.tileGrinder.coalTime); - if(this.lastCoalTimeLeft != this.tileGrinder.coalTimeLeft) iCraft.sendProgressBarUpdate(this, 1, this.tileGrinder.coalTimeLeft); - if(this.lastFirstCrushTime != this.tileGrinder.firstCrushTime) iCraft.sendProgressBarUpdate(this, 2, this.tileGrinder.firstCrushTime); - if(this.lastMaxCrushTime != this.tileGrinder.maxCrushTime) iCraft.sendProgressBarUpdate(this, 3, this.tileGrinder.maxCrushTime); - if(this.isDouble) if(this.lastSecondCrushTime != this.tileGrinder.secondCrushTime) iCraft.sendProgressBarUpdate(this, 4, this.tileGrinder.secondCrushTime); + if(this.lastFirstCrushTime != this.tileGrinder.firstCrushTime) iCraft.sendProgressBarUpdate(this, 0, this.tileGrinder.firstCrushTime); + if(this.lastMaxCrushTime != this.tileGrinder.maxCrushTime) iCraft.sendProgressBarUpdate(this, 1, this.tileGrinder.maxCrushTime); + if(this.isDouble) if(this.lastSecondCrushTime != this.tileGrinder.secondCrushTime) iCraft.sendProgressBarUpdate(this, 2, this.tileGrinder.secondCrushTime); + if(this.lastEnergyStored != this.tileGrinder.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 3, this.tileGrinder.getEnergyStored(ForgeDirection.UNKNOWN)); } - this.lastCoalTime = this.tileGrinder.coalTime; - this.lastCoalTimeLeft = this.tileGrinder.coalTimeLeft; this.lastFirstCrushTime = this.tileGrinder.firstCrushTime; this.lastMaxCrushTime = this.tileGrinder.maxCrushTime; if(this.isDouble) this.lastSecondCrushTime = this.tileGrinder.secondCrushTime; + this.lastEnergyStored = this.tileGrinder.getEnergyStored(ForgeDirection.UNKNOWN); } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2){ - if(par1 == 0) this.tileGrinder.coalTime = par2; - if(par1 == 1) this.tileGrinder.coalTimeLeft = par2; - if(par1 == 2) this.tileGrinder.firstCrushTime = par2; - if(par1 == 3) this.tileGrinder.maxCrushTime = par2; - if(this.isDouble && par1 == 4) this.tileGrinder.secondCrushTime = par2; + if(par1 == 0) this.tileGrinder.firstCrushTime = par2; + if(par1 == 1) this.tileGrinder.maxCrushTime = par2; + if(this.isDouble && par1 == 2) this.tileGrinder.secondCrushTime = par2; + if(par1 == 3) this.tileGrinder.storage.setEnergyStored(par2); } @Override @@ -101,7 +92,7 @@ public class ContainerGrinder extends Container{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - final int inventoryStart = this.isDouble ? 8 : 5; + final int inventoryStart = this.isDouble ? 6 : 3; final int inventoryEnd = inventoryStart+26; final int hotbarStart = inventoryEnd+1; final int hotbarEnd = hotbarStart+8; @@ -111,35 +102,33 @@ public class ContainerGrinder extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(GrinderRecipes.instance().getOutput(currentStack, false) != null){ - this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_1, TileEntityGrinder.SLOT_INPUT_1+1, false); - if(this.isDouble) this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_2, TileEntityGrinder.SLOT_INPUT_2+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(GrinderRecipeManualRegistry.getOutput(currentStack, false) != null){ + this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_1, TileEntityGrinder.SLOT_INPUT_1+1, false); + if(this.isDouble) this.mergeItemStack(newStack, TileEntityGrinder.SLOT_INPUT_2, TileEntityGrinder.SLOT_INPUT_2+1, false); + } } - if(TileEntityFurnace.getItemBurnTime(currentStack) > 0){ - this.mergeItemStack(newStack, TileEntityGrinder.SLOT_COAL, TileEntityGrinder.SLOT_COAL+1, false); + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java index 648ea273a..89893d4aa 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerInputter.java @@ -2,6 +2,7 @@ package ellpeck.actuallyadditions.inventory; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.gui.GuiInputter; import ellpeck.actuallyadditions.inventory.slot.SlotFilter; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityInputter; @@ -19,11 +20,14 @@ public class ContainerInputter extends Container{ private TileEntityInputter tileInputter; private int lastSideToPut; - private int lastSlotToPut; private int lastSideToPull; - private int lastSlotToPull; - private int lastPlaceToPutSlotAmount; - private int lastPlaceToPullSlotAmount; + private int lastIsPullWhitelist; + private int lastIsPutWhitelist; + + private int lastSlotPutStart; + private int lastSlotPutEnd; + private int lastSlotPullStart; + private int lastSlotPullEnd; private boolean isAdvanced; @@ -35,22 +39,21 @@ public class ContainerInputter extends Container{ if(isAdvanced){ for(int i = 0; i < 2; i++){ - this.addSlotToContainer(new SlotFilter(this.tileInputter, 1+i*6, 20+i*84, 6)); - this.addSlotToContainer(new SlotFilter(this.tileInputter, 2+i*6, 38+i*84, 6)); - this.addSlotToContainer(new SlotFilter(this.tileInputter, 3+i*6, 56+i*84, 6)); - this.addSlotToContainer(new SlotFilter(this.tileInputter, 4+i*6, 20+i*84, 24)); - this.addSlotToContainer(new SlotFilter(this.tileInputter, 5+i*6, 38+i*84, 24)); - this.addSlotToContainer(new SlotFilter(this.tileInputter, 6+i*6, 56+i*84, 24)); + for(int x = 0; x < 3; x++){ + for(int y = 0;y < 4; y++){ + this.addSlotToContainer(new SlotFilter(this.tileInputter, 1+y+x*4+i*12, 20+i*84+x*18, 6+y*18)); + } + } } } for(int i = 0; i < 3; i++){ for (int j = 0; j < 9; j++){ - this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18 + (isAdvanced ? 12 : 0))); + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18 + (isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); } } for(int i = 0; i < 9; i++){ - this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155 + (isAdvanced ? 12 : 0))); + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155 + (isAdvanced ? GuiInputter.OFFSET_ADVANCED : 0))); } } @@ -58,11 +61,14 @@ public class ContainerInputter extends Container{ public void addCraftingToCrafters(ICrafting iCraft){ super.addCraftingToCrafters(iCraft); iCraft.sendProgressBarUpdate(this, 0, this.tileInputter.sideToPut); - iCraft.sendProgressBarUpdate(this, 1, this.tileInputter.slotToPut); - iCraft.sendProgressBarUpdate(this, 2, this.tileInputter.sideToPull); - iCraft.sendProgressBarUpdate(this, 3, this.tileInputter.slotToPull); - iCraft.sendProgressBarUpdate(this, 4, this.tileInputter.placeToPullSlotAmount); - iCraft.sendProgressBarUpdate(this, 5, this.tileInputter.placeToPutSlotAmount); + iCraft.sendProgressBarUpdate(this, 1, this.tileInputter.sideToPull); + iCraft.sendProgressBarUpdate(this, 2, this.tileInputter.isPullWhitelist ? 1 : 0); + iCraft.sendProgressBarUpdate(this, 3, this.tileInputter.isPutWhitelist ? 1 : 0); + + iCraft.sendProgressBarUpdate(this, 4, this.tileInputter.slotToPutStart); + iCraft.sendProgressBarUpdate(this, 5, this.tileInputter.slotToPutEnd); + iCraft.sendProgressBarUpdate(this, 6, this.tileInputter.slotToPullStart); + iCraft.sendProgressBarUpdate(this, 7, this.tileInputter.slotToPullEnd); } @Override @@ -71,30 +77,39 @@ public class ContainerInputter extends Container{ for(Object crafter : this.crafters){ ICrafting iCraft = (ICrafting)crafter; if(this.lastSideToPut != this.tileInputter.sideToPut) iCraft.sendProgressBarUpdate(this, 0, this.tileInputter.sideToPut); - if(this.lastSlotToPut != this.tileInputter.slotToPut) iCraft.sendProgressBarUpdate(this, 1, this.tileInputter.slotToPut); - if(this.lastSideToPull != this.tileInputter.sideToPull) iCraft.sendProgressBarUpdate(this, 2, this.tileInputter.sideToPull); - if(this.lastSlotToPull != this.tileInputter.slotToPull) iCraft.sendProgressBarUpdate(this, 3, this.tileInputter.slotToPull); - if(this.lastPlaceToPullSlotAmount != this.tileInputter.placeToPullSlotAmount) iCraft.sendProgressBarUpdate(this, 4, this.tileInputter.placeToPullSlotAmount); - if(this.lastPlaceToPutSlotAmount != this.tileInputter.placeToPutSlotAmount) iCraft.sendProgressBarUpdate(this, 5, this.tileInputter.placeToPutSlotAmount); - } - this.lastSideToPut = this.tileInputter.sideToPut; - this.lastSlotToPut = this.tileInputter.slotToPut; - this.lastSideToPull = this.tileInputter.sideToPull; - this.lastSlotToPull = this.tileInputter.slotToPull; - this.lastPlaceToPullSlotAmount = this.tileInputter.placeToPullSlotAmount; - this.lastPlaceToPutSlotAmount = this.tileInputter.placeToPutSlotAmount; + if(this.lastSideToPull != this.tileInputter.sideToPull) iCraft.sendProgressBarUpdate(this, 1, this.tileInputter.sideToPull); + if(this.lastIsPullWhitelist != (this.tileInputter.isPullWhitelist ? 1 : 0)) iCraft.sendProgressBarUpdate(this, 2, this.tileInputter.isPullWhitelist ? 1 : 0); + if(this.lastIsPutWhitelist != (this.tileInputter.isPutWhitelist ? 1 : 0)) iCraft.sendProgressBarUpdate(this, 3, this.tileInputter.isPutWhitelist ? 1 : 0); + if(this.lastSlotPutStart != this.tileInputter.slotToPutStart) iCraft.sendProgressBarUpdate(this, 4, this.tileInputter.slotToPutStart); + if(this.lastSlotPutEnd != this.tileInputter.slotToPutEnd) iCraft.sendProgressBarUpdate(this, 5, this.tileInputter.slotToPutEnd); + if(this.lastSlotPullStart != this.tileInputter.slotToPullStart) iCraft.sendProgressBarUpdate(this, 6, this.tileInputter.slotToPullStart); + if(this.lastSlotPullEnd != this.tileInputter.slotToPullEnd) iCraft.sendProgressBarUpdate(this, 7, this.tileInputter.slotToPullEnd); + } + + this.lastSideToPut = this.tileInputter.sideToPut; + this.lastSideToPull = this.tileInputter.sideToPull; + this.lastIsPutWhitelist = this.tileInputter.isPutWhitelist ? 1 : 0; + this.lastIsPullWhitelist = this.tileInputter.isPullWhitelist ? 1 : 0; + + this.lastSlotPutStart = this.tileInputter.slotToPutStart; + this.lastSlotPutEnd = this.tileInputter.slotToPutEnd; + this.lastSlotPullStart = this.tileInputter.slotToPullStart; + this.lastSlotPullEnd = this.tileInputter.slotToPullEnd; } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2){ if(par1 == 0) this.tileInputter.sideToPut = par2; - if(par1 == 1) this.tileInputter.slotToPut = par2; - if(par1 == 2) this.tileInputter.sideToPull = par2; - if(par1 == 3) this.tileInputter.slotToPull = par2; - if(par1 == 4) this.tileInputter.placeToPullSlotAmount = par2; - if(par1 == 5) this.tileInputter.placeToPutSlotAmount = par2; + if(par1 == 1) this.tileInputter.sideToPull = par2; + if(par1 == 2) this.tileInputter.isPullWhitelist = par2 == 1; + if(par1 == 3) this.tileInputter.isPutWhitelist = par2 == 1; + + if(par1 == 4) this.tileInputter.slotToPutStart = par2; + if(par1 == 5) this.tileInputter.slotToPutEnd = par2; + if(par1 == 6) this.tileInputter.slotToPullStart = par2; + if(par1 == 7) this.tileInputter.slotToPullEnd = par2; } @Override @@ -104,38 +119,40 @@ public class ContainerInputter extends Container{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - final int inventoryStart = this.isAdvanced ? 13 : 1; - final int inventoryEnd = inventoryStart+26; - final int hotbarStart = inventoryEnd+1; - final int hotbarEnd = hotbarStart+8; + final int inventory = this.isAdvanced ? 25 : 1; + final int inventoryEnd = inventory+26; + final int hotbar = inventoryEnd+1; + final int hotbarEnd = hotbar+8; Slot theSlot = (Slot)this.inventorySlots.get(slot); if(theSlot.getHasStack()){ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, 0, 1, false); - } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventory){ + this.mergeItemStack(newStack, 0, 1, false); } - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); + if(slot <= hotbarEnd && slot >= hotbar){ + this.mergeItemStack(newStack, inventory, inventoryEnd, false); + } - return currentStack; + else if(slot <= inventoryEnd && slot >= inventory){ + this.mergeItemStack(newStack, hotbar, hotbarEnd, false); + } + + else if(slot < inventory){ + this.mergeItemStack(newStack, inventory, hotbarEnd, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java new file mode 100644 index 000000000..b367c9d33 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerOilGenerator.java @@ -0,0 +1,123 @@ +package ellpeck.actuallyadditions.inventory; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.inventory.slot.SlotOutput; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityOilGenerator; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; + +@InventoryContainer +public class ContainerOilGenerator extends Container{ + + private TileEntityOilGenerator generator; + + private int lastEnergyStored; + private int lastBurnTime; + private int lastTankAmount; + + public ContainerOilGenerator(InventoryPlayer inventory, TileEntityBase tile){ + this.generator = (TileEntityOilGenerator)tile; + + this.addSlotToContainer(new Slot(this.generator, 0, 98, 74)); + this.addSlotToContainer(new SlotOutput(this.generator, 1, 98, 43)); + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.generator.isUseableByPlayer(player); + } + + @Override + public void addCraftingToCrafters(ICrafting iCraft){ + super.addCraftingToCrafters(iCraft); + iCraft.sendProgressBarUpdate(this, 0, this.generator.getEnergyStored(ForgeDirection.UNKNOWN)); + iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime); + iCraft.sendProgressBarUpdate(this, 2, this.generator.tank.getFluidAmount()); + } + + @Override + public void detectAndSendChanges(){ + super.detectAndSendChanges(); + for(Object crafter : this.crafters){ + ICrafting iCraft = (ICrafting)crafter; + + if(this.lastEnergyStored != this.generator.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 0, this.generator.getEnergyStored(ForgeDirection.UNKNOWN)); + if(this.lastBurnTime != this.generator.currentBurnTime) iCraft.sendProgressBarUpdate(this, 1, this.generator.currentBurnTime); + if(this.lastTankAmount != this.generator.tank.getFluidAmount()) iCraft.sendProgressBarUpdate(this, 2, this.generator.tank.getFluidAmount()); + } + + this.lastEnergyStored = this.generator.getEnergyStored(ForgeDirection.UNKNOWN); + this.lastBurnTime = this.generator.currentBurnTime; + this.lastTankAmount = this.generator.tank.getFluidAmount(); + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2){ + if(par1 == 0) this.generator.storage.setEnergyStored(par2); + if(par1 == 1) this.generator.currentBurnTime = par2; + if(par1 == 2) this.generator.tank.setFluid(new FluidStack(InitBlocks.fluidOil, par2)); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 2; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(FluidContainerRegistry.containsFluid(currentStack, new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME))){ + this.mergeItemStack(newStack, 0, 1, false); + } + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerPhantomPlacer.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerPhantomPlacer.java new file mode 100644 index 000000000..613eb0628 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerPhantomPlacer.java @@ -0,0 +1,80 @@ +package ellpeck.actuallyadditions.inventory; + +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer; +import invtweaks.api.container.InventoryContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +@InventoryContainer +public class ContainerPhantomPlacer extends Container{ + + private TileEntityPhantomPlacer placer; + + public ContainerPhantomPlacer(InventoryPlayer inventory, TileEntityBase tile){ + this.placer = (TileEntityPhantomPlacer)tile; + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 3; j++){ + this.addSlotToContainer(new Slot(this.placer, j+i*3, 62+j*18, 21+i*18)); + } + } + + for (int i = 0; i < 3; i++){ + for (int j = 0; j < 9; j++){ + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18)); + } + } + for (int i = 0; i < 9; i++){ + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer player){ + return this.placer.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot){ + final int inventoryStart = 9; + final int inventoryEnd = inventoryStart+26; + final int hotbarStart = inventoryEnd+1; + final int hotbarEnd = hotbarStart+8; + + Slot theSlot = (Slot)this.inventorySlots.get(slot); + if(theSlot.getHasStack()){ + ItemStack currentStack = theSlot.getStack(); + ItemStack newStack = currentStack.copy(); + + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, 0, 9, false); + } + + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); + } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; + } + } + return null; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java index 0eb861132..da2450df6 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerRepairer.java @@ -12,21 +12,18 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; @InventoryContainer public class ContainerRepairer extends Container{ private TileEntityItemRepairer tileRepairer; - private int lastCoalTime; - private int lastCoalTimeLeft; + private int lastEnergy; public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile){ this.tileRepairer = (TileEntityItemRepairer)tile; - this.addSlotToContainer(new Slot(this.tileRepairer, TileEntityItemRepairer.SLOT_COAL, 80, 21)); - this.addSlotToContainer(new Slot(this.tileRepairer, TileEntityItemRepairer.SLOT_INPUT, 47, 53)); this.addSlotToContainer(new SlotOutput(this.tileRepairer, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53)); @@ -43,8 +40,7 @@ public class ContainerRepairer extends Container{ @Override public void addCraftingToCrafters(ICrafting iCraft){ super.addCraftingToCrafters(iCraft); - iCraft.sendProgressBarUpdate(this, 0, this.tileRepairer.coalTime); - iCraft.sendProgressBarUpdate(this, 1, this.tileRepairer.coalTimeLeft); + iCraft.sendProgressBarUpdate(this, 0, this.tileRepairer.getEnergyStored(ForgeDirection.UNKNOWN)); } @Override @@ -53,19 +49,16 @@ public class ContainerRepairer extends Container{ for(Object crafter : this.crafters){ ICrafting iCraft = (ICrafting)crafter; - if(this.lastCoalTime != this.tileRepairer.coalTime) iCraft.sendProgressBarUpdate(this, 0, this.tileRepairer.coalTime); - if(this.lastCoalTimeLeft != this.tileRepairer.coalTimeLeft) iCraft.sendProgressBarUpdate(this, 1, this.tileRepairer.coalTimeLeft); + if(this.lastEnergy != this.tileRepairer.getEnergyStored(ForgeDirection.UNKNOWN)) iCraft.sendProgressBarUpdate(this, 0, this.tileRepairer.getEnergyStored(ForgeDirection.UNKNOWN)); } - this.lastCoalTime = this.tileRepairer.coalTime; - this.lastCoalTimeLeft = this.tileRepairer.coalTimeLeft; + this.lastEnergy = this.tileRepairer.getEnergyStored(ForgeDirection.UNKNOWN); } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2){ - if(par1 == 0) this.tileRepairer.coalTime = par2; - if(par1 == 1) this.tileRepairer.coalTimeLeft = par2; + if(par1 == 0) this.tileRepairer.storage.setEnergyStored(par2); } @Override @@ -75,7 +68,7 @@ public class ContainerRepairer extends Container{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - final int inventoryStart = 3; + final int inventoryStart = 2; final int inventoryEnd = inventoryStart+26; final int hotbarStart = inventoryEnd+1; final int hotbarEnd = hotbarStart+8; @@ -85,34 +78,32 @@ public class ContainerRepairer extends Container{ ItemStack currentStack = theSlot.getStack(); ItemStack newStack = currentStack.copy(); - if(slot <= hotbarEnd && slot >= inventoryStart){ - if(TileEntityItemRepairer.canBeRepaired(currentStack)){ - this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT+1, false); + if(currentStack.getItem() != null){ + if(slot <= hotbarEnd && slot >= inventoryStart){ + if(TileEntityItemRepairer.canBeRepaired(currentStack)){ + this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT+1, false); + } } - if(TileEntityFurnace.getItemBurnTime(currentStack) > 0){ - this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_COAL, TileEntityItemRepairer.SLOT_COAL+1, false); + if(slot <= hotbarEnd && slot >= hotbarStart){ + this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); } + + else if(slot <= inventoryEnd && slot >= inventoryStart){ + this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); + } + + else if(slot < inventoryStart){ + this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); + } + + if(newStack.stackSize == 0) theSlot.putStack(null); + else theSlot.onSlotChanged(); + if(newStack.stackSize == currentStack.stackSize) return null; + theSlot.onPickupFromSlot(player, newStack); + + return currentStack; } - - if(slot <= hotbarEnd && slot >= hotbarStart){ - this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false); - } - - else if(slot <= inventoryEnd && slot >= inventoryStart){ - this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false); - } - - else if(slot < inventoryStart){ - this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false); - } - - if(newStack.stackSize == 0) theSlot.putStack(null); - else theSlot.onSlotChanged(); - if(newStack.stackSize == currentStack.stackSize) return null; - theSlot.onPickupFromSlot(player, newStack); - - return currentStack; } return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java index 7a3e81c66..74204e0e7 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java @@ -3,8 +3,8 @@ package ellpeck.actuallyadditions.inventory; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.inventory.gui.*; import ellpeck.actuallyadditions.tile.TileEntityBase; -import ellpeck.actuallyadditions.tile.TileEntityGrinder; import ellpeck.actuallyadditions.util.Util; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -13,39 +13,53 @@ public class GuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){ - switch (id){ + TileEntityBase tile = null; + if(id != CRAFTER_ID && id != DRILL_ID){ + tile = (TileEntityBase)world.getTileEntity(x, y, z); + } + switch(id){ case FEEDER_ID: - TileEntityBase tileFeeder = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerFeeder(entityPlayer.inventory, tileFeeder); + return new ContainerFeeder(entityPlayer.inventory, tile); case GIANT_CHEST_ID: - TileEntityBase tileChest = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerGiantChest(entityPlayer.inventory, tileChest); + return new ContainerGiantChest(entityPlayer.inventory, tile); case CRAFTER_ID: return new ContainerCrafter(entityPlayer); case GRINDER_ID: - TileEntityBase tileGrinder = (TileEntityGrinder)world.getTileEntity(x, y, z); - return new ContainerGrinder(entityPlayer.inventory, tileGrinder, false); + return new ContainerGrinder(entityPlayer.inventory, tile, false); case GRINDER_DOUBLE_ID: - TileEntityBase tileGrinderDouble = (TileEntityGrinder)world.getTileEntity(x, y, z); - return new ContainerGrinder(entityPlayer.inventory, tileGrinderDouble, true); + return new ContainerGrinder(entityPlayer.inventory, tile, true); case FURNACE_DOUBLE_ID: - TileEntityBase tileFurnace = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerFurnaceDouble(entityPlayer.inventory, tileFurnace); + return new ContainerFurnaceDouble(entityPlayer.inventory, tile); case INPUTTER_ID: - TileEntityBase tileInputter = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerInputter(entityPlayer.inventory, tileInputter, false); + return new ContainerInputter(entityPlayer.inventory, tile, false); case INPUTTER_ADVANCED_ID: - TileEntityBase tileInputterAdvanced = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerInputter(entityPlayer.inventory, tileInputterAdvanced, true); + return new ContainerInputter(entityPlayer.inventory, tile, true); case REPAIRER_ID: - TileEntityBase tileRepairer = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerRepairer(entityPlayer.inventory, tileRepairer); + return new ContainerRepairer(entityPlayer.inventory, tile); case BREAKER_ID: - TileEntityBase tileBreaker = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerBreaker(entityPlayer.inventory, tileBreaker); + return new ContainerBreaker(entityPlayer.inventory, tile); case DROPPER_ID: - TileEntityBase tileDropper = (TileEntityBase)world.getTileEntity(x, y, z); - return new ContainerDropper(entityPlayer.inventory, tileDropper); + return new ContainerDropper(entityPlayer.inventory, tile); + case CANOLA_PRESS_ID: + return new ContainerCanolaPress(entityPlayer.inventory, tile); + case FERMENTING_BARREL_ID: + return new ContainerFermentingBarrel(entityPlayer.inventory, tile); + case COAL_GENERATOR_ID: + return new ContainerCoalGenerator(entityPlayer.inventory, tile); + case OIL_GENERATOR_ID: + return new ContainerOilGenerator(entityPlayer.inventory, tile); + case PHANTOM_PLACER_ID: + return new ContainerPhantomPlacer(entityPlayer.inventory, tile); + case FLUID_COLLECTOR_ID: + return new ContainerFluidCollector(entityPlayer.inventory, tile); + case COFFEE_MACHINE_ID: + return new ContainerCoffeeMachine(entityPlayer.inventory, tile); + case DRILL_ID: + return new ContainerDrill(entityPlayer.inventory); + case ENERGIZER_ID: + return new ContainerEnergizer(entityPlayer.inventory, tile); + case ENERVATOR_ID: + return new ContainerEnervator(entityPlayer.inventory, tile); default: return null; } @@ -53,39 +67,53 @@ public class GuiHandler implements IGuiHandler{ @Override public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z){ - switch (id){ + TileEntityBase tile = null; + if(id != CRAFTER_ID && id != DRILL_ID){ + tile = (TileEntityBase)world.getTileEntity(x, y, z); + } + switch(id){ case FEEDER_ID: - TileEntityBase tileFeeder = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiFeeder(entityPlayer.inventory, tileFeeder); + return new GuiFeeder(entityPlayer.inventory, tile); case GIANT_CHEST_ID: - TileEntityBase tileChest = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiGiantChest(entityPlayer.inventory, tileChest); + return new GuiGiantChest(entityPlayer.inventory, tile); case CRAFTER_ID: return new GuiCrafter(entityPlayer); case GRINDER_ID: - TileEntityBase tileGrinder = (TileEntityGrinder)world.getTileEntity(x, y, z); - return new GuiGrinder(entityPlayer.inventory, tileGrinder, false); + return new GuiGrinder(entityPlayer.inventory, tile, false); case GRINDER_DOUBLE_ID: - TileEntityBase tileGrinderDouble = (TileEntityGrinder)world.getTileEntity(x, y, z); - return new GuiGrinder(entityPlayer.inventory, tileGrinderDouble, true); + return new GuiGrinder(entityPlayer.inventory, tile, true); case FURNACE_DOUBLE_ID: - TileEntityBase tileFurnace = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiFurnaceDouble(entityPlayer.inventory, tileFurnace); + return new GuiFurnaceDouble(entityPlayer.inventory, tile); case INPUTTER_ID: - TileEntityBase tileInputter = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiInputter(entityPlayer.inventory, tileInputter, x, y, z, world, false); + return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, false); case INPUTTER_ADVANCED_ID: - TileEntityBase tileInputterAdvanced = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiInputter(entityPlayer.inventory, tileInputterAdvanced, x, y, z, world, true); + return new GuiInputter(entityPlayer.inventory, tile, x, y, z, world, true); case REPAIRER_ID: - TileEntityBase tileRepairer = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiRepairer(entityPlayer.inventory, tileRepairer); + return new GuiRepairer(entityPlayer.inventory, tile); case BREAKER_ID: - TileEntityBase tileBreaker = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiBreaker(entityPlayer.inventory, tileBreaker); + return new GuiBreaker(entityPlayer.inventory, tile); case DROPPER_ID: - TileEntityBase tileDropper = (TileEntityBase)world.getTileEntity(x, y, z); - return new GuiDropper(entityPlayer.inventory, tileDropper); + return new GuiDropper(entityPlayer.inventory, tile); + case CANOLA_PRESS_ID: + return new GuiCanolaPress(entityPlayer.inventory, tile); + case FERMENTING_BARREL_ID: + return new GuiFermentingBarrel(entityPlayer.inventory, tile); + case COAL_GENERATOR_ID: + return new GuiCoalGenerator(entityPlayer.inventory, tile); + case OIL_GENERATOR_ID: + return new GuiOilGenerator(entityPlayer.inventory, tile); + case PHANTOM_PLACER_ID: + return new GuiPhantomPlacer(entityPlayer.inventory, tile); + case FLUID_COLLECTOR_ID: + return new GuiFluidCollector(entityPlayer.inventory, tile); + case COFFEE_MACHINE_ID: + return new GuiCoffeeMachine(entityPlayer.inventory, tile, x, y, z, world); + case DRILL_ID: + return new GuiDrill(entityPlayer.inventory); + case ENERGIZER_ID: + return new GuiEnergizer(entityPlayer.inventory, tile); + case ENERVATOR_ID: + return new GuiEnervator(entityPlayer.inventory, tile); default: return null; } @@ -102,6 +130,16 @@ public class GuiHandler implements IGuiHandler{ public static final int INPUTTER_ADVANCED_ID = 8; public static final int BREAKER_ID = 9; public static final int DROPPER_ID = 10; + public static final int CANOLA_PRESS_ID = 11; + public static final int FERMENTING_BARREL_ID = 12; + public static final int COAL_GENERATOR_ID = 13; + public static final int OIL_GENERATOR_ID = 14; + public static final int PHANTOM_PLACER_ID = 15; + public static final int FLUID_COLLECTOR_ID = 16; + public static final int COFFEE_MACHINE_ID = 17; + public static final int DRILL_ID = 18; + public static final int ENERGIZER_ID = 19; + public static final int ENERVATOR_ID = 20; public static void init(){ Util.logInfo("Initializing GuiHandler..."); diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiInputter.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiInputter.java deleted file mode 100644 index 4b036a739..000000000 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiInputter.java +++ /dev/null @@ -1,161 +0,0 @@ -package ellpeck.actuallyadditions.inventory; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.actuallyadditions.network.PacketHandler; -import ellpeck.actuallyadditions.network.PacketInputterButton; -import ellpeck.actuallyadditions.tile.TileEntityBase; -import ellpeck.actuallyadditions.tile.TileEntityInputter; -import ellpeck.actuallyadditions.util.AssetUtil; -import ellpeck.actuallyadditions.util.ModUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import org.lwjgl.opengl.GL11; - -@SideOnly(Side.CLIENT) -public class GuiInputter extends GuiContainer{ - - private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiInputter"); - private static final ResourceLocation resLocAdvanced = AssetUtil.getGuiLocation("guiInputterAdvanced"); - - private TileEntityInputter tileInputter; - - private int x; - private int y; - private int z; - private World world; - - private SmallerButton buttonSlotPutP; - private SmallerButton buttonSlotPullP; - private SmallerButton buttonSlotPutM; - private SmallerButton buttonSlotPullM; - - private boolean isAdvanced; - - public static final String[] sideString = new String[]{ - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.disabled"), - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.up"), - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.down"), - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.north"), - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.east"), - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.south"), - StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.west")}; - - public GuiInputter(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world, boolean isAdvanced){ - super(new ContainerInputter(inventory, tile, isAdvanced)); - this.tileInputter = (TileEntityInputter)tile; - this.x = x; - this.y = y; - this.z = z; - this.world = world; - this.xSize = 176; - this.ySize = 93+86 + (isAdvanced ? 12 : 0); - this.isAdvanced = isAdvanced; - } - - @Override - public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, this.isAdvanced ? 105-5 : 93-5, -10, this.tileInputter.getInventoryName()); - } - - @SuppressWarnings("unchecked") - @Override - public void initGui(){ - super.initGui(); - - SmallerButton buttonSidePutP = new SmallerButton(0, guiLeft + 70, guiTop + 43 + (isAdvanced ? 12 : 0), ">"); - SmallerButton buttonSidePutM = new SmallerButton(1, guiLeft + 5, guiTop + 43 + (isAdvanced ? 12 : 0), "<"); - buttonSlotPutP = new SmallerButton(2, guiLeft + 70, guiTop + 64 + (isAdvanced ? 12 : 0), "+"); - buttonSlotPutM = new SmallerButton(3, guiLeft + 5, guiTop + 64 + (isAdvanced ? 12 : 0), "-"); - - SmallerButton buttonSidePullP = new SmallerButton(4, guiLeft + 155, guiTop + 43 + (isAdvanced ? 12 : 0), ">"); - SmallerButton buttonSidePullM = new SmallerButton(5, guiLeft + 90, guiTop + 43 + (isAdvanced ? 12 : 0), "<"); - buttonSlotPullP = new SmallerButton(6, guiLeft+ 155, guiTop + 64 + (isAdvanced ? 12 : 0), "+"); - buttonSlotPullM = new SmallerButton(7, guiLeft + 90, guiTop + 64 + (isAdvanced ? 12 : 0), "-"); - - this.buttonList.add(buttonSidePutP); - this.buttonList.add(buttonSlotPutP); - this.buttonList.add(buttonSidePullP); - this.buttonList.add(buttonSlotPullP); - this.buttonList.add(buttonSidePutM); - this.buttonList.add(buttonSlotPutM); - this.buttonList.add(buttonSidePullM); - this.buttonList.add(buttonSlotPullM); - } - - @Override - public void drawGuiContainerBackgroundLayer(float f, int x, int y){ - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); - this.drawTexturedModalRect(this.guiLeft, this.guiTop+93 + (isAdvanced ? 12 : 0), 0, 0, 176, 86); - - this.mc.getTextureManager().bindTexture(this.isAdvanced ? resLocAdvanced : resLoc); - this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93 + (isAdvanced ? 12 : 0)); - - this.fontRendererObj.drawString(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.put"), guiLeft + 22 + 3, guiTop + 32 + (isAdvanced ? 12 : 0), 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.pull"), guiLeft + 107 + 3, guiTop + 32 + (isAdvanced ? 12 : 0), 4210752); - - this.fontRendererObj.drawString(sideString[tileInputter.sideToPut+1], guiLeft + 24 + 1, guiTop + 45 + 3 + (isAdvanced ? 12 : 0), 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.slot") + " " + (tileInputter.slotToPut == -1 ? StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.all") : tileInputter.slotToPut).toString(), guiLeft + 24 + 3, guiTop + 66 + 3 + (isAdvanced ? 12 : 0), 4210752); - - this.fontRendererObj.drawString(sideString[tileInputter.sideToPull+1], guiLeft + 109 + 1, guiTop + 45 + 3 + (isAdvanced ? 12 : 0), 4210752); - this.fontRendererObj.drawString(StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.slot") + " " + (tileInputter.slotToPull == -1 ? StatCollector.translateToLocal("info." + ModUtil.MOD_ID_LOWER + ".gui.all") : tileInputter.slotToPull).toString(), guiLeft + 109 + 3, guiTop + 66 + 3 + (isAdvanced ? 12 : 0), 4210752); - } - - @Override - public void drawScreen(int x, int y, float f){ - super.drawScreen(x, y, f); - - this.buttonSlotPullP.enabled = this.tileInputter.placeToPullSlotAmount > 0; - this.buttonSlotPullM.enabled = this.tileInputter.placeToPullSlotAmount > 0; - - this.buttonSlotPutP.enabled = this.tileInputter.placeToPutSlotAmount > 0; - this.buttonSlotPutM.enabled = this.tileInputter.placeToPutSlotAmount > 0; - } - - @Override - public void actionPerformed(GuiButton button){ - PacketHandler.theNetwork.sendToServer(new PacketInputterButton(x, y, z, world, button.id)); - } - - public class SmallerButton extends GuiButton{ - - private final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiInputter"); - - public SmallerButton(int id, int x, int y, String display){ - super(id, x, y, 16, 16, display); - } - - @Override - public void drawButton(Minecraft mc, int x, int y){ - if (this.visible){ - FontRenderer renderer = mc.fontRenderer; - mc.getTextureManager().bindTexture(resLoc); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height; - int k = this.getHoverState(this.field_146123_n); - GL11.glEnable(GL11.GL_BLEND); - OpenGlHelper.glBlendFunc(770, 771, 1, 0); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - this.drawTexturedModalRect(this.xPosition, this.yPosition, 176, k*16, 16, 16); - this.mouseDragged(mc, x, y); - - int color = 14737632; - if (packedFGColour != 0) color = packedFGColour; - else if (!this.enabled) color = 10526880; - else if (this.field_146123_n) color = 16777120; - - this.drawCenteredString(renderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height-8) / 2, color); - } - } - } - -} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiBreaker.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiBreaker.java similarity index 87% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiBreaker.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiBreaker.java index 9975882b7..7f6fdad35 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiBreaker.java @@ -1,7 +1,8 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerBreaker; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityBreaker; import ellpeck.actuallyadditions.util.AssetUtil; @@ -26,7 +27,7 @@ public class GuiBreaker extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 93-5, -10, this.breaker.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.breaker.getInventoryName()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCanolaPress.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCanolaPress.java new file mode 100644 index 000000000..bc5a498d3 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCanolaPress.java @@ -0,0 +1,76 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerCanolaPress; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCanolaPress; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiCanolaPress extends GuiContainer{ + + private TileEntityCanolaPress press; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiCanolaPress"); + + public GuiCanolaPress(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerCanolaPress(inventory, tile)); + this.press = (TileEntityCanolaPress)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.press.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.press.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.press.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft + 43, this.guiTop+89-i, 176, 29, 16, i); + } + + if(this.press.tank.getFluidAmount() > 0){ + int i = this.press.getTankScaled(83); + drawTexturedModalRect(this.guiLeft + 117, this.guiTop+89-i, 192, 29, 16, i); + } + + if(this.press.currentProcessTime > 0){ + int i = this.press.getProcessScaled(29); + drawTexturedModalRect(this.guiLeft + 83, this.guiTop+32, 176, 0, 12, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + String text1 = this.press.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.press.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+43 && y >= guiTop+6 && x <= guiLeft+58 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + + String text2 = this.press.tank.getFluidAmount() + "/" + this.press.tank.getCapacity() + " mB " +StatCollector.translateToLocal("fluid.canolaoil"); + if(x >= guiLeft+117 && y >= guiTop+6 && x <= guiLeft+132 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text2), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCoalGenerator.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCoalGenerator.java new file mode 100644 index 000000000..17e60df8b --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCoalGenerator.java @@ -0,0 +1,65 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerCoalGenerator; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCoalGenerator; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiCoalGenerator extends GuiContainer{ + + private TileEntityCoalGenerator generator; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiCoalGenerator"); + + public GuiCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerCoalGenerator(inventory, tile)); + this.generator = (TileEntityCoalGenerator)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.generator.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.generator.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.generator.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 0, 16, i); + } + + if(this.generator.currentBurnTime > 0){ + int i = this.generator.getBurningScaled(13); + this.drawTexturedModalRect(guiLeft+87, guiTop+27+12-i, 176, 96-i, 14, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + String text1 = this.generator.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.generator.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+43 && y >= guiTop+6 && x <= guiLeft+58 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCoffeeMachine.java new file mode 100644 index 000000000..fb48794bd --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCoffeeMachine.java @@ -0,0 +1,118 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerCoffeeMachine; +import ellpeck.actuallyadditions.network.PacketHandler; +import ellpeck.actuallyadditions.network.gui.PacketGuiButton; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityCoffeeMachine; +import ellpeck.actuallyadditions.util.AssetUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidRegistry; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiCoffeeMachine extends GuiContainer{ + + private TileEntityCoffeeMachine machine; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiCoffeeMachine"); + + private int x; + private int y; + private int z; + private World world; + + public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){ + super(new ContainerCoffeeMachine(inventory, tile)); + this.machine = (TileEntityCoffeeMachine)tile; + this.xSize = 176; + this.ySize = 93+86; + this.x = x; + this.y = y; + this.z = z; + this.world = world; + } + + @SuppressWarnings("unchecked") + @Override + public void initGui(){ + super.initGui(); + + GuiButton buttonOkay = new GuiButton(0, guiLeft+60, guiTop+11, 58, 20, StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.ok")); + this.buttonList.add(buttonOkay); + } + + @Override + public void actionPerformed(GuiButton button){ + PacketHandler.theNetwork.sendToServer(new PacketGuiButton(x, y, z, world, button.id, Minecraft.getMinecraft().thePlayer)); + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.machine.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.machine.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.machine.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+17, this.guiTop+89-i, 176, 0, 6, i); + } + if(this.machine.tank.getFluidAmount() > 0){ + int i = this.machine.getWaterScaled(64); + drawTexturedModalRect(this.guiLeft+27, this.guiTop+70-i, 182, 0, 6, i); + } + + if(this.machine.coffeeCacheAmount > 0){ + int i = this.machine.getCoffeeScaled(30); + drawTexturedModalRect(this.guiLeft+41, this.guiTop+56-i, 192, 0, 8, i); + } + + if(this.machine.brewTime > 0){ + int i = this.machine.getBrewScaled(23); + drawTexturedModalRect(this.guiLeft+53, this.guiTop+42, 192, 30, i, 16); + + int j = this.machine.getBrewScaled(26); + drawTexturedModalRect(this.guiLeft+99+25-j, this.guiTop+44, 192+25-j, 46, j, 12); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + + String text1 = this.machine.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.machine.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+16 && y >= guiTop+5 && x <= guiLeft+23 && y <= guiTop+89){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + String text3 = this.machine.tank.getFluidAmount() + "/" + this.machine.tank.getCapacity() + " mB "+StatCollector.translateToLocal(FluidRegistry.WATER.getUnlocalizedName()); + if(x >= guiLeft+27 && y >= guiTop+5 && x <= guiLeft+33 && y <= guiTop+70){ + this.func_146283_a(Collections.singletonList(text3), x, y); + } + + String text2 = this.machine.coffeeCacheAmount + "/" + this.machine.coffeeCacheMaxAmount+" "+StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.coffee"); + if(x >= guiLeft+40 && y >= guiTop+25 && x <= guiLeft+49 && y <= guiTop+56){ + this.func_146283_a(Collections.singletonList(text2), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiCrafter.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCrafter.java similarity index 82% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiCrafter.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCrafter.java index 6a3357f93..7df2aaf70 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiCrafter.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiCrafter.java @@ -1,7 +1,8 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerCrafter; import ellpeck.actuallyadditions.util.AssetUtil; import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.client.gui.inventory.GuiContainer; @@ -23,7 +24,7 @@ public class GuiCrafter extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 74, -10, "container." + ModUtil.MOD_ID_LOWER + ".crafting"); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, "container."+ModUtil.MOD_ID_LOWER+".crafting"); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiDrill.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiDrill.java new file mode 100644 index 000000000..3c63f9f75 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiDrill.java @@ -0,0 +1,39 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerDrill; +import ellpeck.actuallyadditions.util.AssetUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiDrill extends GuiContainer{ + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiDrill"); + + public GuiDrill(InventoryPlayer inventory){ + super(new ContainerDrill(inventory)); + this.xSize = 176; + this.ySize = 54+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, "container."+ModUtil.MOD_ID_LOWER+".drill"); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+54, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 54); + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiDropper.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiDropper.java similarity index 87% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiDropper.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiDropper.java index eb7543178..877fb0333 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiDropper.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiDropper.java @@ -1,7 +1,8 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerDropper; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityDropper; import ellpeck.actuallyadditions.util.AssetUtil; @@ -26,7 +27,7 @@ public class GuiDropper extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 93-5, -10, this.dropper.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.dropper.getInventoryName()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java new file mode 100644 index 000000000..19cc34336 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java @@ -0,0 +1,60 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerEnergizer; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityEnergizer; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiEnergizer extends GuiContainer{ + + private TileEntityEnergizer energizer; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer"); + + public GuiEnergizer(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerEnergizer(inventory, tile)); + this.energizer = (TileEntityEnergizer)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.energizer.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.energizer.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.energizer.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+57, this.guiTop+89-i, 176, 0, 16, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + String text1 = this.energizer.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.energizer.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+57 && y >= guiTop+6 && x <= guiLeft+72 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java new file mode 100644 index 000000000..215fe9909 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java @@ -0,0 +1,60 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerEnervator; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityEnervator; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiEnervator extends GuiContainer{ + + private TileEntityEnervator enervator; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer"); + + public GuiEnervator(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerEnervator(inventory, tile)); + this.enervator = (TileEntityEnervator)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.enervator.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.enervator.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.enervator.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+57, this.guiTop+89-i, 176, 0, 16, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + String text1 = this.enervator.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.enervator.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+57 && y >= guiTop+6 && x <= guiLeft+72 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiFeeder.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFeeder.java similarity index 92% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiFeeder.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFeeder.java index 288a1a8b2..e98a4d800 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFeeder.java @@ -1,7 +1,8 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerFeeder; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityFeeder; import ellpeck.actuallyadditions.util.AssetUtil; @@ -18,7 +19,7 @@ import java.util.Arrays; public class GuiFeeder extends GuiContainer{ private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiFeeder"); - private TileEntityFeeder tileFeeder; + public TileEntityFeeder tileFeeder; public int loveCounter; @@ -31,7 +32,7 @@ public class GuiFeeder extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 70-5, -10, this.tileFeeder.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.tileFeeder.getInventoryName()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFermentingBarrel.java new file mode 100644 index 000000000..90a0649e0 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFermentingBarrel.java @@ -0,0 +1,76 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerFermentingBarrel; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityFermentingBarrel; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiFermentingBarrel extends GuiContainer{ + + private TileEntityFermentingBarrel press; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiFermentingBarrel"); + + public GuiFermentingBarrel(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerFermentingBarrel(inventory, tile)); + this.press = (TileEntityFermentingBarrel)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.press.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.press.canolaTank.getFluidAmount() > 0){ + int i = this.press.getCanolaTankScaled(83); + drawTexturedModalRect(this.guiLeft + 61, this.guiTop+89-i, 192, 29, 16, i); + } + + if(this.press.oilTank.getFluidAmount() > 0){ + int i = this.press.getOilTankScaled(83); + drawTexturedModalRect(this.guiLeft + 99, this.guiTop+89-i, 176, 29, 16, i); + } + + if(this.press.currentProcessTime > 0){ + int i = this.press.getProcessScaled(29); + drawTexturedModalRect(this.guiLeft+82, this.guiTop+34, 176, 0, 12, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + + String text1 = this.press.canolaTank.getFluidAmount() + "/" + this.press.canolaTank.getCapacity() + " mB " +StatCollector.translateToLocal("fluid.canolaoil"); + if(x >= guiLeft+61 && y >= guiTop+6 && x <= guiLeft+76 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + + String text2 = this.press.oilTank.getFluidAmount() + "/" + this.press.oilTank.getCapacity() + " mB " +StatCollector.translateToLocal("fluid.oil"); + if(x >= guiLeft+99 && y >= guiTop+6 && x <= guiLeft+114 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text2), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFluidCollector.java new file mode 100644 index 000000000..e319b43ad --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFluidCollector.java @@ -0,0 +1,60 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerFluidCollector; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityFluidCollector; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiFluidCollector extends GuiContainer{ + + private TileEntityFluidCollector collector; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiFluidCollector"); + + public GuiFluidCollector(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerFluidCollector(inventory, tile)); + this.collector = (TileEntityFluidCollector)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.collector.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.collector.tank.getFluidAmount() > 0){ + int i = this.collector.getTankScaled(83); + drawTexturedModalRect(this.guiLeft+68, this.guiTop+89-i, 176, 0, 16, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + + String text2 = this.collector.tank.getFluidAmount()+"/"+this.collector.tank.getCapacity()+" mB "+ (this.collector.tank.getFluidAmount() > 0 ? this.collector.tank.getFluid().getLocalizedName() : ""); + if(x >= guiLeft+68 && y >= guiTop+6 && x <= guiLeft+83 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text2), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFurnaceDouble.java similarity index 70% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiFurnaceDouble.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFurnaceDouble.java index 3afe84460..96637d3f7 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiFurnaceDouble.java @@ -1,15 +1,19 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerFurnaceDouble; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityFurnaceDouble; import ellpeck.actuallyadditions.util.AssetUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import java.util.Collections; + @SideOnly(Side.CLIENT) public class GuiFurnaceDouble extends GuiContainer{ @@ -25,7 +29,7 @@ public class GuiFurnaceDouble extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 93-5, -10, this.tileFurnace.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.tileFurnace.getInventoryName()); } @Override @@ -38,9 +42,9 @@ public class GuiFurnaceDouble extends GuiContainer{ this.mc.getTextureManager().bindTexture(resLoc); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.tileFurnace.coalTime > 0){ - int i = this.tileFurnace.getCoalTimeToScale(15); - this.drawTexturedModalRect(this.guiLeft+80, this.guiTop+5+14-i, 176, 44+14-i, 14, i); + if(this.tileFurnace.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.tileFurnace.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+28, this.guiTop+89-i, 176, 44, 16, i); } if(this.tileFurnace.firstSmeltTime > 0){ int i = this.tileFurnace.getFirstTimeToScale(23); @@ -55,5 +59,9 @@ public class GuiFurnaceDouble extends GuiContainer{ @Override public void drawScreen(int x, int y, float f){ super.drawScreen(x, y, f); + String text = this.tileFurnace.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.tileFurnace.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+28 && y >= guiTop+6 && x <= guiLeft+43 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text), x, y); + } } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiGiantChest.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiGiantChest.java similarity index 86% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiGiantChest.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiGiantChest.java index 9d85dc943..d163f9f19 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiGiantChest.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiGiantChest.java @@ -1,7 +1,8 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerGiantChest; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityGiantChest; import ellpeck.actuallyadditions.util.AssetUtil; @@ -27,7 +28,7 @@ public class GuiGiantChest extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 172-5, -10, this.chest.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.chest.getInventoryName()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiGrinder.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiGrinder.java similarity index 69% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiGrinder.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiGrinder.java index b9f723df7..bcbe38416 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiGrinder.java @@ -1,15 +1,19 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerGrinder; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityGrinder; import ellpeck.actuallyadditions.util.AssetUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import java.util.Collections; + @SideOnly(Side.CLIENT) public class GuiGrinder extends GuiContainer{ @@ -28,7 +32,7 @@ public class GuiGrinder extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 93-5, -10, this.tileGrinder.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.tileGrinder.getInventoryName()); } @Override @@ -41,9 +45,9 @@ public class GuiGrinder extends GuiContainer{ this.mc.getTextureManager().bindTexture(this.isDouble ? resLocDouble : resLoc); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.tileGrinder.coalTime > 0){ - int i = this.tileGrinder.getCoalTimeToScale(15); - this.drawTexturedModalRect(this.guiLeft+(isDouble ? 80 : 51), this.guiTop+5+14-i, 176, 44+14-i, 14, i); + if(this.tileGrinder.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.tileGrinder.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft + (isDouble ? 14 : 43), this.guiTop+89-i, 176, (isDouble ? 44 : 23), 16, i); } if(this.tileGrinder.firstCrushTime > 0){ int i = this.tileGrinder.getFirstTimeToScale(23); @@ -60,5 +64,9 @@ public class GuiGrinder extends GuiContainer{ @Override public void drawScreen(int x, int y, float f){ super.drawScreen(x, y, f); + String text = this.tileGrinder.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.tileGrinder.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if((this.isDouble && x >= guiLeft+14 && y >= guiTop+6 && x <= guiLeft+29 && y <= guiTop+88) || (!this.isDouble && x >= guiLeft+43 && y >= guiTop+6 && x <= guiLeft+58 && y <= guiTop+88)){ + this.func_146283_a(Collections.singletonList(text), x, y); + } } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiInputter.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiInputter.java new file mode 100644 index 000000000..846ee6806 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiInputter.java @@ -0,0 +1,293 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerInputter; +import ellpeck.actuallyadditions.network.PacketHandler; +import ellpeck.actuallyadditions.network.gui.PacketGuiButton; +import ellpeck.actuallyadditions.network.gui.PacketGuiNumber; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityInputter; +import ellpeck.actuallyadditions.util.AssetUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiInputter extends GuiContainer{ + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiInputter"); + private static final ResourceLocation resLocAdvanced = AssetUtil.getGuiLocation("guiInputterAdvanced"); + + public TileEntityInputter tileInputter; + + private int x; + private int y; + private int z; + private World world; + + private SmallerButton whitelistPut; + private SmallerButton whitelistPull; + + private GuiTextField fieldPutStart; + private GuiTextField fieldPutEnd; + + private GuiTextField fieldPullStart; + private GuiTextField fieldPullEnd; + + private boolean isAdvanced; + + public static final int OFFSET_ADVANCED = 12+36; + + public static final String[] sideString = new String[]{ + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.disabled"), + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.up"), + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.down"), + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.north"), + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.east"), + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.south"), + StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.west")}; + + public GuiInputter(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world, boolean isAdvanced){ + super(new ContainerInputter(inventory, tile, isAdvanced)); + this.tileInputter = (TileEntityInputter)tile; + this.x = x; + this.y = y; + this.z = z; + this.world = world; + this.xSize = 176; + this.ySize = 93+86+(isAdvanced ? OFFSET_ADVANCED : 0); + this.isAdvanced = isAdvanced; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.tileInputter.getInventoryName()); + } + + @Override + public void updateScreen(){ + super.updateScreen(); + + this.fieldPutStart.updateCursorCounter(); + this.fieldPutEnd.updateCursorCounter(); + this.fieldPullStart.updateCursorCounter(); + this.fieldPullEnd.updateCursorCounter(); + } + + @SuppressWarnings("unchecked") + @Override + public void initGui(){ + super.initGui(); + + this.fieldPullStart = new GuiTextField(this.fontRendererObj, guiLeft+13, guiTop+80+(isAdvanced ? OFFSET_ADVANCED : 0), 27, 8); + this.fieldPullStart.setMaxStringLength(4); + this.fieldPullStart.setEnableBackgroundDrawing(false); + this.fieldPullEnd = new GuiTextField(this.fontRendererObj, guiLeft+50, guiTop+80+(isAdvanced ? OFFSET_ADVANCED : 0), 27, 8); + this.fieldPullEnd.setMaxStringLength(4); + this.fieldPullEnd.setEnableBackgroundDrawing(false); + + this.fieldPutStart = new GuiTextField(this.fontRendererObj, guiLeft+98, guiTop+80+(isAdvanced ? OFFSET_ADVANCED : 0), 27, 8); + this.fieldPutStart.setMaxStringLength(4); + this.fieldPutStart.setEnableBackgroundDrawing(false); + this.fieldPutEnd = new GuiTextField(this.fontRendererObj, guiLeft+135, guiTop+80+(isAdvanced ? OFFSET_ADVANCED : 0), 27, 8); + this.fieldPutEnd.setMaxStringLength(4); + this.fieldPutEnd.setEnableBackgroundDrawing(false); + + SmallerButton buttonSidePutP = new SmallerButton(0, guiLeft+155, guiTop+43+(isAdvanced ? OFFSET_ADVANCED : 0), ">"); + SmallerButton buttonSidePutM = new SmallerButton(1, guiLeft+90, guiTop+43+(isAdvanced ? OFFSET_ADVANCED : 0), "<"); + + SmallerButton buttonSidePullP = new SmallerButton(2, guiLeft+70, guiTop+43+(isAdvanced ? OFFSET_ADVANCED : 0), ">"); + SmallerButton buttonSidePullM = new SmallerButton(3, guiLeft+5, guiTop+43+(isAdvanced ? OFFSET_ADVANCED : 0), "<"); + + whitelistPull = new SmallerButton(TileEntityInputter.WHITELIST_PULL_BUTTON_ID, guiLeft+3, guiTop+16, ""); + whitelistPut = new SmallerButton(TileEntityInputter.WHITELIST_PUT_BUTTON_ID, guiLeft+157, guiTop+16, ""); + + this.buttonList.add(buttonSidePutP); + this.buttonList.add(buttonSidePullP); + this.buttonList.add(buttonSidePutM); + this.buttonList.add(buttonSidePullM); + if(this.isAdvanced){ + this.buttonList.add(whitelistPut); + this.buttonList.add(whitelistPull); + } + + this.buttonList.add(new TinyButton(TileEntityInputter.OKAY_BUTTON_ID, guiLeft+84, guiTop+80+(isAdvanced ? OFFSET_ADVANCED : 0))); + } + + @Override + protected void mouseClicked(int par1, int par2, int par3){ + this.fieldPutStart.mouseClicked(par1, par2, par3); + this.fieldPutEnd.mouseClicked(par1, par2, par3); + this.fieldPullStart.mouseClicked(par1, par2, par3); + this.fieldPullEnd.mouseClicked(par1, par2, par3); + + super.mouseClicked(par1, par2, par3); + } + + @Override + public void keyTyped(char theChar, int key){ + if((!fieldPutStart.isFocused() && !fieldPutEnd.isFocused() && !fieldPullStart.isFocused() && !fieldPullEnd.isFocused())){ + super.keyTyped(theChar, key); + } + + if(key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER){ + if(this.fieldPutStart.isFocused()) this.setVariable(this.fieldPutStart, 0); + if(this.fieldPutEnd.isFocused()) this.setVariable(this.fieldPutEnd, 1); + if(this.fieldPullStart.isFocused()) this.setVariable(this.fieldPullStart, 2); + if(this.fieldPullEnd.isFocused()) this.setVariable(this.fieldPullEnd, 3); + } + + if(Character.isDigit(theChar) || key == Keyboard.KEY_BACK || key == Keyboard.KEY_DELETE || key == Keyboard.KEY_LEFT || key == Keyboard.KEY_RIGHT){ + this.fieldPutStart.textboxKeyTyped(theChar, key); + this.fieldPutEnd.textboxKeyTyped(theChar, key); + this.fieldPullStart.textboxKeyTyped(theChar, key); + this.fieldPullEnd.textboxKeyTyped(theChar, key); + } + } + + public void setVariable(GuiTextField field, int sendInt){ + if(!field.getText().isEmpty()){ + this.sendPacket(parse(field.getText()), sendInt); + field.setText(""); + } + } + + private int parse(String theInt){ + try{ + return Integer.parseInt(theInt); + } + catch(Exception e){ + return -1; + } + } + + private void sendPacket(int text, int textID){ + PacketHandler.theNetwork.sendToServer(new PacketGuiNumber(x, y, z, world, text, textID, Minecraft.getMinecraft().thePlayer)); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93+(isAdvanced ? OFFSET_ADVANCED : 0), 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(this.isAdvanced ? resLocAdvanced : resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93+(isAdvanced ? OFFSET_ADVANCED : 0)); + + this.fontRendererObj.drawString(StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.pull"), guiLeft+22+3, guiTop+32+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRendererObj.drawString(StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.put"), guiLeft+107+3, guiTop+32+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + + this.fontRendererObj.drawString(sideString[tileInputter.sideToPull+1], guiLeft+24+1, guiTop+45+3+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + this.fontRendererObj.drawString(sideString[tileInputter.sideToPut+1], guiLeft+109+1, guiTop+45+3+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); + + this.fontRendererObj.drawString(Integer.toString(this.tileInputter.slotToPutStart), guiLeft+99, guiTop+67+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRendererObj.drawString(Integer.toString(this.tileInputter.slotToPutEnd), guiLeft+136, guiTop+67+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRendererObj.drawString(Integer.toString(this.tileInputter.slotToPullStart), guiLeft+14, guiTop+67+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + this.fontRendererObj.drawString(Integer.toString(this.tileInputter.slotToPullEnd), guiLeft+51, guiTop+67+(isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_WHITE); + + this.fieldPutStart.drawTextBox(); + this.fieldPutEnd.drawTextBox(); + this.fieldPullStart.drawTextBox(); + this.fieldPullEnd.drawTextBox(); + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + + this.whitelistPull.displayString = this.tileInputter.isPullWhitelist ? "O" : "X"; + this.whitelistPut.displayString = this.tileInputter.isPutWhitelist ? "O" : "X"; + + if(this.isAdvanced){ + String text1 = this.tileInputter.isPullWhitelist ? StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.whitelist") : StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.blacklist"); + if(x >= guiLeft+3 && y >= guiTop+16 && x <= guiLeft+18 && y <= guiTop+31){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + String text2 = this.tileInputter.isPutWhitelist ? StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.whitelist") : StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.blacklist"); + if(x >= guiLeft+157 && y >= guiTop+16 && x <= guiLeft+172 && y <= guiTop+31){ + this.func_146283_a(Collections.singletonList(text2), x, y); + } + } + } + + @Override + public void actionPerformed(GuiButton button){ + if(button.id == TileEntityInputter.OKAY_BUTTON_ID){ + this.setVariable(this.fieldPutStart, 0); + this.setVariable(this.fieldPutEnd, 1); + this.setVariable(this.fieldPullStart, 2); + this.setVariable(this.fieldPullEnd, 3); + } + else + PacketHandler.theNetwork.sendToServer(new PacketGuiButton(x, y, z, world, button.id, Minecraft.getMinecraft().thePlayer)); + } + + public static class SmallerButton extends GuiButton{ + + public final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiInputter"); + + public SmallerButton(int id, int x, int y, String display){ + super(id, x, y, 16, 16, display); + } + + @Override + public void drawButton(Minecraft mc, int x, int y){ + if(this.visible){ + mc.getTextureManager().bindTexture(resLoc); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height; + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 176, k*16, 16, 16); + this.mouseDragged(mc, x, y); + + int color = 14737632; + if(packedFGColour != 0) color = packedFGColour; + else if(!this.enabled) color = 10526880; + else if(this.field_146123_n) color = 16777120; + + this.drawCenteredString(mc.fontRenderer, this.displayString, this.xPosition+this.width/2, this.yPosition+(this.height-8)/2, color); + } + } + } + + public static class TinyButton extends GuiButton{ + + public final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiInputter"); + + public TinyButton(int id, int x, int y){ + super(id, x, y, 8, 8, ""); + } + + @Override + public void drawButton(Minecraft mc, int x, int y){ + if(this.visible){ + mc.getTextureManager().bindTexture(resLoc); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition+this.width && y < this.yPosition+this.height; + int k = this.getHoverState(this.field_146123_n); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.drawTexturedModalRect(this.xPosition, this.yPosition, 192, k*8, 8, 8); + this.mouseDragged(mc, x, y); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiOilGenerator.java new file mode 100644 index 000000000..7d0fe4bf2 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiOilGenerator.java @@ -0,0 +1,75 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerOilGenerator; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityOilGenerator; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; +import org.lwjgl.opengl.GL11; + +import java.util.Collections; + +@SideOnly(Side.CLIENT) +public class GuiOilGenerator extends GuiContainer{ + + private TileEntityOilGenerator generator; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiOilGenerator"); + + public GuiOilGenerator(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerOilGenerator(inventory, tile)); + this.generator = (TileEntityOilGenerator)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.generator.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + + if(this.generator.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.generator.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+43, this.guiTop+89-i, 176, 0, 16, i); + } + + if(this.generator.tank.getFluidAmount() > 0){ + int i = this.generator.getTankScaled(83); + drawTexturedModalRect(this.guiLeft+117, this.guiTop+89-i, 192, 0, 16, i); + } + + if(this.generator.currentBurnTime > 0){ + int i = this.generator.getBurningScaled(13); + this.drawTexturedModalRect(guiLeft+72, guiTop+44+12-i, 176, 96-i, 14, i); + } + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + String text1 = this.generator.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.generator.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+43 && y >= guiTop+6 && x <= guiLeft+58 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text1), x, y); + } + String text2 = this.generator.tank.getFluidAmount() + "/" + this.generator.tank.getCapacity() + " mB " +StatCollector.translateToLocal("fluid.oil"); + if(x >= guiLeft+117 && y >= guiTop+6 && x <= guiLeft+132 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text2), x, y); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiPhantomPlacer.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiPhantomPlacer.java new file mode 100644 index 000000000..18d04955f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiPhantomPlacer.java @@ -0,0 +1,48 @@ +package ellpeck.actuallyadditions.inventory.gui; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerPhantomPlacer; +import ellpeck.actuallyadditions.tile.TileEntityBase; +import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer; +import ellpeck.actuallyadditions.util.AssetUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class GuiPhantomPlacer extends GuiContainer{ + + private TileEntityPhantomPlacer placer; + + private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiBreaker"); + + public GuiPhantomPlacer(InventoryPlayer inventory, TileEntityBase tile){ + super(new ContainerPhantomPlacer(inventory, tile)); + this.placer = (TileEntityPhantomPlacer)tile; + this.xSize = 176; + this.ySize = 93+86; + } + + @Override + public void drawGuiContainerForegroundLayer(int x, int y){ + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.placer.getInventoryName()); + } + + @Override + public void drawGuiContainerBackgroundLayer(float f, int x, int y){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.mc.getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION); + this.drawTexturedModalRect(this.guiLeft, this.guiTop+93, 0, 0, 176, 86); + + this.mc.getTextureManager().bindTexture(resLoc); + this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); + } + + @Override + public void drawScreen(int x, int y, float f){ + super.drawScreen(x, y, f); + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiRepairer.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiRepairer.java similarity index 68% rename from src/main/java/ellpeck/actuallyadditions/inventory/GuiRepairer.java rename to src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiRepairer.java index 81151158b..2cbb5e84a 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiRepairer.java @@ -1,15 +1,19 @@ -package ellpeck.actuallyadditions.inventory; +package ellpeck.actuallyadditions.inventory.gui; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.inventory.ContainerRepairer; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityItemRepairer; import ellpeck.actuallyadditions.util.AssetUtil; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import java.util.Collections; + @SideOnly(Side.CLIENT) public class GuiRepairer extends GuiContainer{ @@ -25,7 +29,7 @@ public class GuiRepairer extends GuiContainer{ @Override public void drawGuiContainerForegroundLayer(int x, int y){ - AssetUtil.displayNameAndInventoryString(this.fontRendererObj, xSize, 93-5, -10, this.tileRepairer.getInventoryName()); + AssetUtil.displayNameString(this.fontRendererObj, xSize, -10, this.tileRepairer.getInventoryName()); } @Override @@ -38,9 +42,9 @@ public class GuiRepairer extends GuiContainer{ this.mc.getTextureManager().bindTexture(resLoc); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93); - if(this.tileRepairer.coalTime > 0){ - int i = this.tileRepairer.getCoalTimeToScale(15); - this.drawTexturedModalRect(this.guiLeft+80, this.guiTop+5+14-i, 176, 44+14-i, 14, i); + if(this.tileRepairer.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + int i = this.tileRepairer.getEnergyScaled(83); + drawTexturedModalRect(this.guiLeft+28, this.guiTop+89-i, 176, 44, 16, i); } if(TileEntityItemRepairer.canBeRepaired(this.tileRepairer.slots[TileEntityItemRepairer.SLOT_INPUT])){ int i = this.tileRepairer.getItemDamageToScale(22); @@ -51,5 +55,9 @@ public class GuiRepairer extends GuiContainer{ @Override public void drawScreen(int x, int y, float f){ super.drawScreen(x, y, f); + String text = this.tileRepairer.getEnergyStored(ForgeDirection.UNKNOWN) + "/" + this.tileRepairer.getMaxEnergyStored(ForgeDirection.UNKNOWN) + " RF"; + if(x >= guiLeft+28 && y >= guiTop+6 && x <= guiLeft+43 && y <= guiTop+88){ + this.func_146283_a(Collections.singletonList(text), x, y); + } } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotFilter.java b/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotFilter.java index ab1be1320..873ab776e 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotFilter.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotFilter.java @@ -13,4 +13,5 @@ public class SlotFilter extends Slot{ public int getSlotStackLimit(){ return 1; } + } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java b/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java new file mode 100644 index 000000000..5a84544b4 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java @@ -0,0 +1,24 @@ +package ellpeck.actuallyadditions.inventory.slot; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotImmovable extends Slot{ + + public SlotImmovable(IInventory inventory, int id, int x, int y){ + super(inventory, id, x, y); + } + + @Override + public boolean canTakeStack(EntityPlayer player){ + return false; + } + + @Override + public boolean isItemValid(ItemStack stack){ + return false; + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java index c0062a2c5..388eca358 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java @@ -1,7 +1,11 @@ package ellpeck.actuallyadditions.items; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.items.metalists.TheFoods; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import ellpeck.actuallyadditions.items.tools.*; import ellpeck.actuallyadditions.material.InitItemMaterials; +import ellpeck.actuallyadditions.util.CompatUtil; import ellpeck.actuallyadditions.util.ItemUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.init.Blocks; @@ -9,6 +13,7 @@ import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidContainerRegistry; public class InitItems{ @@ -38,14 +43,83 @@ public class InitItems{ public static Item itemSwordObsidian; public static Item itemHoeObsidian; - public static Item itemSpeedUpgrade; + public static Item itemHairyBall; + + public static Item itemRiceSeed; + public static Item itemCanolaSeed; + public static Item itemFlaxSeed; + public static Item itemCoffeeSeed; + + public static Item itemResonantRice; + public static Item itemBucketOil; + public static Item itemBucketCanolaOil; + + public static Item itemPhantomConnector; + + public static Item itemCoffeeBean; + public static Item itemCoffee; + + public static Item woodenPaxel; + public static Item stonePaxel; + public static Item ironPaxel; + public static Item diamondPaxel; + public static Item goldPaxel; + public static Item emeraldPaxel; + public static Item obsidianPaxel; + + public static Item itemDrill; + public static Item itemDrillUpgradeSpeed; + public static Item itemDrillUpgradeSpeedII; + public static Item itemDrillUpgradeSpeedIII; + public static Item itemDrillUpgradeSilkTouch; + public static Item itemDrillUpgradeFortune; + public static Item itemDrillUpgradeFortuneII; + public static Item itemDrillUpgradeThreeByThree; + public static Item itemDrillUpgradeFiveByFive; + public static Item itemDrillUpgradeBlockPlacing; + + public static Item itemBattery; public static void init(){ Util.logInfo("Initializing Items..."); + itemDrill = new ItemDrill(); + ItemUtil.register(itemDrill); + + itemBattery = new ItemBattery(); + ItemUtil.register(itemBattery); + + itemDrillUpgradeSpeed = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED, "itemDrillUpgradeSpeed"); + itemDrillUpgradeSpeedII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II, "itemDrillUpgradeSpeedII"); + itemDrillUpgradeSpeedIII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_III, "itemDrillUpgradeSpeedIII"); + itemDrillUpgradeSilkTouch = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SILK_TOUCH, "itemDrillUpgradeSilkTouch"); + itemDrillUpgradeFortune = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE, "itemDrillUpgradeFortune"); + itemDrillUpgradeFortuneII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FORTUNE_II, "itemDrillUpgradeFortuneII"); + itemDrillUpgradeThreeByThree = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.THREE_BY_THREE, "itemDrillUpgradeThreeByThree"); + itemDrillUpgradeFiveByFive = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE, "itemDrillUpgradeFiveByFive"); + itemDrillUpgradeBlockPlacing = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.PLACER, "itemDrillUpgradeBlockPlacing"); + ItemUtil.registerItems(new Item[]{itemDrillUpgradeSpeed, itemDrillUpgradeSpeedII, itemDrillUpgradeSpeedIII, itemDrillUpgradeSilkTouch, itemDrillUpgradeFortune, itemDrillUpgradeFortuneII, itemDrillUpgradeThreeByThree, itemDrillUpgradeFiveByFive, itemDrillUpgradeBlockPlacing}); + + itemBucketOil = new ItemBucketAA(InitBlocks.blockOil, "itemBucketOil"); + ItemUtil.register(itemBucketOil); + FluidContainerRegistry.registerFluidContainer(InitBlocks.fluidOil, new ItemStack(itemBucketOil), FluidContainerRegistry.EMPTY_BUCKET); + + itemBucketCanolaOil = new ItemBucketAA(InitBlocks.blockCanolaOil, "itemBucketCanolaOil"); + ItemUtil.register(itemBucketCanolaOil); + FluidContainerRegistry.registerFluidContainer(InitBlocks.fluidCanolaOil, new ItemStack(itemBucketCanolaOil), FluidContainerRegistry.EMPTY_BUCKET); + itemFertilizer = new ItemFertilizer(); ItemUtil.register(itemFertilizer); + itemCoffee = new ItemCoffee(); + ItemUtil.register(itemCoffee); + + itemPhantomConnector = new ItemPhantomConnector(); + ItemUtil.register(itemPhantomConnector); + + itemResonantRice = new ItemResonantRice(); + ItemUtil.register(itemResonantRice); + itemMisc = new ItemMisc(); ItemUtil.register(itemMisc, ItemMisc.allMiscItems); @@ -79,8 +153,27 @@ public class InitItems{ itemPotionRingAdvanced = new ItemPotionRing(true); ItemUtil.register(itemPotionRingAdvanced); - itemSpeedUpgrade = new ItemUpgrade(ItemUpgrade.UpgradeType.SPEED, "itemUpgradeSpeed", 2+3); - ItemUtil.register(itemSpeedUpgrade); + itemHairyBall = new ItemHairyBall(); + ItemUtil.register(itemHairyBall); + + itemCoffeeBean = new ItemCoffeeBean(); + ItemUtil.register(itemCoffeeBean); + + itemRiceSeed = new ItemSeed("itemRiceSeed", InitBlocks.blockRice, itemFoods, TheFoods.RICE.ordinal()); + ItemUtil.register(itemRiceSeed); + CompatUtil.registerMFRSeed(itemRiceSeed); + + itemCanolaSeed = new ItemSeed("itemCanolaSeed", InitBlocks.blockCanola, itemMisc, TheMiscItems.CANOLA.ordinal()); + ItemUtil.register(itemCanolaSeed); + CompatUtil.registerMFRSeed(itemCanolaSeed); + + itemFlaxSeed = new ItemSeed("itemFlaxSeed", InitBlocks.blockFlax, Items.string, 0); + ItemUtil.register(itemFlaxSeed); + CompatUtil.registerMFRSeed(itemFlaxSeed); + + itemCoffeeSeed = new ItemSeed("itemCoffeeSeed", InitBlocks.blockCoffee, itemCoffeeBean, 0); + ItemUtil.register(itemCoffeeSeed); + CompatUtil.registerMFRSeed(itemCoffeeSeed); itemPickaxeEmerald = new ItemPickaxeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemPickaxeEmerald", EnumRarity.rare); itemAxeEmerald = new ItemAxeAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "itemAxeEmerald", EnumRarity.rare); @@ -96,5 +189,13 @@ public class InitItems{ itemHoeObsidian = new ItemHoeAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "itemHoeObsidian", EnumRarity.uncommon); ItemUtil.registerItems(new Item[]{itemPickaxeObsidian, itemAxeObsidian, itemShovelObsidian, itemSwordObsidian, itemHoeObsidian}); + woodenPaxel = new ItemAllToolAA(Item.ToolMaterial.WOOD, new ItemStack(Blocks.planks), "woodenPaxel", EnumRarity.uncommon); + stonePaxel = new ItemAllToolAA(Item.ToolMaterial.STONE, new ItemStack(Blocks.stone), "stonePaxel", EnumRarity.uncommon); + ironPaxel = new ItemAllToolAA(Item.ToolMaterial.IRON, new ItemStack(Items.iron_ingot), "ironPaxel", EnumRarity.rare); + goldPaxel = new ItemAllToolAA(Item.ToolMaterial.GOLD, new ItemStack(Items.gold_ingot), "goldPaxel", EnumRarity.rare); + diamondPaxel = new ItemAllToolAA(Item.ToolMaterial.EMERALD, new ItemStack(Items.diamond), "diamondPaxel", EnumRarity.epic); + emeraldPaxel = new ItemAllToolAA(InitItemMaterials.toolMaterialEmerald, new ItemStack(Items.emerald), "emeraldPaxel", EnumRarity.epic); + obsidianPaxel = new ItemAllToolAA(InitItemMaterials.toolMaterialObsidian, new ItemStack(Blocks.obsidian), "obsidianPaxel", EnumRarity.epic); + ItemUtil.registerItems(new Item[]{woodenPaxel, stonePaxel, ironPaxel, goldPaxel, diamondPaxel, emeraldPaxel, obsidianPaxel}); } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java b/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java new file mode 100644 index 000000000..80df95194 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java @@ -0,0 +1,107 @@ +package ellpeck.actuallyadditions.items; + +import cofh.api.energy.ItemEnergyContainer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import java.util.List; + +public class ItemBattery extends ItemEnergyContainer implements INameableItem{ + + public ItemBattery(){ + super(1000000, 10000); + this.setMaxStackSize(1); + this.setHasSubtypes(true); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack){ + double energyDif = getMaxEnergyStored(stack)-getEnergyStored(stack); + double maxAmount = getMaxEnergyStored(stack); + return energyDif/maxAmount; + } + + @Override + public boolean showDurabilityBar(ItemStack itemStack){ + return true; + } + + @Override + public void onCreated(ItemStack stack, World world, EntityPlayer player){ + this.setEnergy(stack, 0); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + public void setEnergy(ItemStack stack, int energy){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) compound = new NBTTagCompound(); + compound.setInteger("Energy", energy); + stack.setTagCompound(compound); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tabs, List list){ + ItemStack stackFull = new ItemStack(this); + this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull)); + list.add(stackFull); + + ItemStack stackEmpty = new ItemStack(this); + this.setEnergy(stackEmpty, 0); + list.add(stackEmpty); + } + + @Override + public String getName(){ + return "itemBattery"; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ + ItemUtil.addInformation(this, list, 1, ""); + if(KeyUtil.isShiftPressed()){ + list.add(this.getEnergyStored(stack) + "/" + this.getMaxEnergyStored(stack) + " RF"); + } + } + + @Override + public boolean getShareTag(){ + return true; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemBucketAA.java b/src/main/java/ellpeck/actuallyadditions/items/ItemBucketAA.java new file mode 100644 index 000000000..6c106c564 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemBucketAA.java @@ -0,0 +1,60 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemBucket; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import java.util.List; + +public class ItemBucketAA extends ItemBucket implements INameableItem{ + + private String name; + + public ItemBucketAA(Block block, String unlocName){ + super(block); + this.name = unlocName; + this.setContainerItem(Items.bucket); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.uncommon; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + ItemUtil.addInformation(this, list, 1, ""); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.getName(); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java new file mode 100644 index 000000000..17c36aaf2 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffee.java @@ -0,0 +1,268 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.EnumAction; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.ArrayList; +import java.util.List; + +public class ItemCoffee extends ItemFood implements INameableItem{ + + public static ArrayList ingredients = new ArrayList(); + + public static void initIngredients(){ + registerIngredient(new Ingredient(new ItemStack(Items.milk_bucket), null, 0){ + @Override + public boolean effect(ItemStack stack){ + PotionEffect[] effects = getEffectsFromStack(stack); + ArrayList effectsNew = new ArrayList(); + if(effects != null && effects.length > 0){ + for(PotionEffect effect : effects){ + if(effect.getAmplifier() > 0) effectsNew.add(new PotionEffect(effect.getPotionID(), effect.getDuration()+120, effect.getAmplifier()-1)); + } + stack.setTagCompound(new NBTTagCompound()); + if(effectsNew.size() > 0){ + this.effects = effectsNew.toArray(new PotionEffect[effectsNew.size()]); + ItemCoffee.addEffectToStack(stack, this); + } + } + this.effects = null; + return true; + } + @Override + public String getExtraText(){ + return StatCollector.translateToLocal("container.nei." + ModUtil.MOD_ID_LOWER + ".coffee.extra.milk"); + } + }); + registerIngredient(new Ingredient(new ItemStack(Items.sugar), new PotionEffect[]{new PotionEffect(Potion.moveSpeed.getId(), 30, 0)}, 4)); + registerIngredient(new Ingredient(new ItemStack(Items.magma_cream), new PotionEffect[]{new PotionEffect(Potion.fireResistance.getId(), 20, 0)}, 1)); + registerIngredient(new Ingredient(new ItemStack(Items.fish, 1, 3), new PotionEffect[]{new PotionEffect(Potion.waterBreathing.getId(), 10, 0)}, 1)); + registerIngredient(new Ingredient(new ItemStack(Items.golden_carrot), new PotionEffect[]{new PotionEffect(Potion.nightVision.getId(), 30, 0)}, 1)); + registerIngredient(new Ingredient(new ItemStack(Items.ghast_tear), new PotionEffect[]{new PotionEffect(Potion.regeneration.getId(), 5, 0)}, 3)); + registerIngredient(new Ingredient(new ItemStack(Items.blaze_powder), new PotionEffect[]{new PotionEffect(Potion.damageBoost.getId(), 15, 0)}, 4)); + registerIngredient(new Ingredient(new ItemStack(Items.fermented_spider_eye), new PotionEffect[]{new PotionEffect(Potion.invisibility.getId(), 25, 0)}, 1)); + } + + public ItemCoffee(){ + super(8, 5.0F, false); + this.setMaxDamage(ConfigIntValues.COFFEE_DRINK_AMOUNT.getValue()-1); + this.setAlwaysEdible(); + this.setMaxStackSize(1); + this.setNoRepair(); + } + + public static Ingredient getIngredientFromStack(ItemStack stack){ + for(Ingredient ingredient : ingredients){ + if(ingredient.ingredient.copy().isItemEqual(stack)) return ingredient; + } + return null; + } + + public static void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp){ + PotionEffect[] effects = getEffectsFromStack(stack); + stack.setTagCompound(new NBTTagCompound()); + for(int i = 0; i < effects.length; i++){ + if(effects[i].getPotionID() == effect.getPotionID()){ + effects[i] = new PotionEffect(effects[i].getPotionID(), effects[i].getDuration()+(addDur ? effect.getDuration() : 0), effects[i].getAmplifier()+(addAmp ? (effect.getAmplifier() > 0 ? effect.getAmplifier() : 1) : 0)); + } + addEffectToStack(stack, effects[i]); + } + } + + public static void addEffectToStack(ItemStack stack, PotionEffect effect){ + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) tag = new NBTTagCompound(); + + int prevCounter = tag.getInteger("Counter"); + NBTTagCompound compound = new NBTTagCompound(); + compound.setInteger("ID", effect.getPotionID()); + compound.setInteger("Duration", effect.getDuration()); + compound.setInteger("Amplifier", effect.getAmplifier()); + + int counter = prevCounter+1; + tag.setTag(counter+"", compound); + tag.setInteger("Counter", counter); + + stack.setTagCompound(tag); + } + + public static boolean addEffectToStack(ItemStack stack, Ingredient ingredient){ + boolean worked = false; + if(ingredient != null){ + PotionEffect[] effects = ingredient.getEffects(); + if(effects != null && effects.length > 0){ + for(PotionEffect effect : effects){ + PotionEffect effectHas = getSameEffectFromStack(stack, effect); + if(effectHas != null){ + if(effectHas.getAmplifier() < ingredient.maxAmplifier-1){ + addEffectProperties(stack, effect, false, true); + worked = true; + } + } + else{ + addEffectToStack(stack, effect); + worked = true; + } + } + } + } + return worked; + } + + public static PotionEffect[] getEffectsFromStack(ItemStack stack){ + ArrayList effects = new ArrayList(); + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null){ + int counter = tag.getInteger("Counter"); + while(counter > 0){ + NBTTagCompound compound = (NBTTagCompound)tag.getTag(counter + ""); + PotionEffect effect = new PotionEffect(compound.getInteger("ID"), compound.getInteger("Duration"), compound.getByte("Amplifier")); + if(effect.getPotionID() > 0){ + effects.add(effect); + } + counter--; + } + } + return effects.size() > 0 ? effects.toArray(new PotionEffect[effects.size()]) : null; + } + + public static PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect){ + PotionEffect[] effectsStack = getEffectsFromStack(stack); + if(effectsStack != null && effectsStack.length > 0){ + for(PotionEffect effectStack : effectsStack){ + if(effect.getPotionID() == effectStack.getPotionID()) return effectStack; + } + } + return null; + } + + public static void applyPotionEffectsFromStack(ItemStack stack, EntityPlayer player){ + PotionEffect[] effects = getEffectsFromStack(stack); + if(effects != null && effects.length > 0){ + for(PotionEffect effect : effects){ + player.addPotionEffect(new PotionEffect(effect.getPotionID(), effect.getDuration()*20, effect.getAmplifier())); + } + } + } + + @Override + public boolean getShareTag(){ + return true; + } + + @Override + public EnumAction getItemUseAction(ItemStack stack){ + return EnumAction.drink; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + public int getMetadata(int damage){ + return damage; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){ + ItemStack theStack = stack.copy(); + super.onEaten(stack, world, player); + applyPotionEffectsFromStack(stack, player); + theStack.setItemDamage(theStack.getItemDamage()+1); + if(theStack.getMaxDamage()-theStack.getItemDamage() < 0) return new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()); + else return theStack; + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+"."+this.getName()+".desc.1")); + list.add(StatCollector.translateToLocalFormatted("tooltip."+ModUtil.MOD_ID_LOWER+"."+this.getName()+".desc.2", this.getMaxDamage()+1)); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".hunger.desc")+": "+this.func_150905_g(stack)); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".saturation.desc")+": "+this.func_150906_h(stack)); + list.add(""); + + PotionEffect[] effects = getEffectsFromStack(stack); + if(effects != null && effects.length > 0){ + for(PotionEffect effect : effects){ + list.add(StatCollector.translateToLocal(effect.getEffectName())+" "+(effect.getAmplifier()+1)+ " (" + Potion.getDurationString(new PotionEffect(0, effect.getDuration()*20, 0)) + ")"); + } + } + else list.add("No Effects"); + } + else list.add(ItemUtil.shiftForInfo()); + } + + @Override + public IIcon getIconFromDamage(int par1){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return "itemCoffee"; + } + + public static void registerIngredient(Ingredient ingredient){ + ingredients.add(ingredient); + } + + public static class Ingredient{ + + public final ItemStack ingredient; + protected PotionEffect[] effects; + public final int maxAmplifier; + + public Ingredient(ItemStack ingredient, PotionEffect[] effects, int maxAmplifier){ + this.ingredient = ingredient.copy(); + this.effects = effects; + this.maxAmplifier = maxAmplifier; + } + + public String getExtraText(){ + return null; + } + + public PotionEffect[] getEffects(){ + return this.effects; + } + + public boolean effect(ItemStack stack){ + return ItemCoffee.addEffectToStack(stack, this); + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemUpgrade.java b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java similarity index 69% rename from src/main/java/ellpeck/actuallyadditions/items/ItemUpgrade.java rename to src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java index 96623e566..08a55cd57 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemUpgrade.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemCoffeeBean.java @@ -8,22 +8,22 @@ import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; +import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import java.util.List; -public class ItemUpgrade extends Item implements INameableItem{ +public class ItemCoffeeBean extends ItemFood implements INameableItem{ - private final String name; - public UpgradeType type; - private int textAmount; + public ItemCoffeeBean(){ + super(1, 1F, false); + this.setMaxDamage(0); + } - public ItemUpgrade(UpgradeType type, String name, int textAmount){ - this.name = name; - this.type = type; - this.textAmount = textAmount; + @Override + public String getOredictName(){ + return this.getName(); } @Override @@ -34,11 +34,12 @@ public class ItemUpgrade extends Item implements INameableItem{ @Override @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) - public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { - ItemUtil.addInformation(this, list, this.textAmount, ""); + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ + ItemUtil.addInformation(this, list, 1, ""); } @Override + @SideOnly(Side.CLIENT) public IIcon getIcon(ItemStack stack, int pass){ return this.itemIcon; } @@ -51,15 +52,6 @@ public class ItemUpgrade extends Item implements INameableItem{ @Override public String getName(){ - return this.name; + return "itemCoffeeBeans"; } - - @Override - public String getOredictName(){ - return this.getName(); - } - - public enum UpgradeType{ - SPEED - } -} +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java b/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java new file mode 100644 index 000000000..6c99a0359 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java @@ -0,0 +1,413 @@ +package ellpeck.actuallyadditions.items; + +import cofh.api.energy.ItemEnergyContainer; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; +import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.ActuallyAdditions; +import ellpeck.actuallyadditions.config.values.ConfigFloatValues; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.inventory.GuiHandler; +import ellpeck.actuallyadditions.items.tools.ItemAllToolAA; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; +import org.apache.logging.log4j.Level; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@SuppressWarnings("unchecked") +public class ItemDrill extends ItemEnergyContainer implements INameableItem{ + + private static final Set allSet = Sets.newHashSet(); + static{ + allSet.addAll(ItemAllToolAA.pickSet); + allSet.addAll(ItemAllToolAA.shovelSet); + } + + public ItemDrill(){ + super(500000, 5000); + this.setMaxStackSize(1); + this.setHasSubtypes(true); + } + + public static float defaultEfficiency = ConfigFloatValues.DRILL_DAMAGE.getValue(); + public static int energyUsePerBlockOrHit = ConfigIntValues.DRILL_ENERGY_USE.getValue(); + + @Override + public double getDurabilityForDisplay(ItemStack stack){ + double energyDif = getMaxEnergyStored(stack)-getEnergyStored(stack); + double maxAmount = getMaxEnergyStored(stack); + return energyDif/maxAmount; + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int hitSide, float hitX, float hitY, float hitZ){ + ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER); + if(upgrade != null){ + int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade); + if(slot >= 0 && slot < InventoryPlayer.getHotbarSize()){ + ItemStack anEquip =player.inventory.getStackInSlot(slot); + if(anEquip != null && anEquip != stack){ + ItemStack equip = anEquip.copy(); + if(!world.isRemote){ + try{ + if(equip.tryPlaceItemIntoWorld(player, world, x, y, z, hitSide, hitX, hitY, hitZ)){ + if(!player.capabilities.isCreativeMode) player.inventory.setInventorySlotContents(slot, equip.stackSize <= 0 ? null : equip.copy()); + player.inventoryContainer.detectAndSendChanges(); + return true; + } + } + catch(Exception e){ + player.addChatComponentMessage(new ChatComponentText("Ouch! That really hurt! You must have done something wrong, don't do that again please!")); + ModUtil.LOGGER.log(Level.ERROR, "Player "+player.getDisplayName()+" who should place a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!"); + } + } + else return true; + } + } + } + return false; + } + + @Override + public boolean showDurabilityBar(ItemStack itemStack){ + return true; + } + + @Override + public void onCreated(ItemStack stack, World world, EntityPlayer player){ + this.setEnergy(stack, 0); + } + + public float getEfficiencyFromUpgrade(ItemStack stack){ + float efficiency = defaultEfficiency; + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)){ + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)){ + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)) efficiency += 37.0F; + else efficiency += 28.0F; + } + else efficiency += 15.0F; + } + return efficiency; + } + + public int getEnergyUsePerBlock(ItemStack stack){ + int use = energyUsePerBlockOrHit; + + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)){ + use += ConfigIntValues.DRILL_SPEED_EXTRA_USE.getValue(); + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_II)){ + use += ConfigIntValues.DRILL_SPEED_II_EXTRA_USE.getValue(); + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED_III)) use += ConfigIntValues.DRILL_SPEED_III_EXTRA_USE.getValue(); + } + } + + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)) use += ConfigIntValues.DRILL_SILK_EXTRA_USE.getValue(); + + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)){ + use += ConfigIntValues.DRILL_FORTUNE_EXTRA_USE.getValue(); + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II)) use += ConfigIntValues.DRILL_FORTUNE_II_EXTRA_USE.getValue(); + } + + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ + use += ConfigIntValues.DRILL_THREE_BY_THREE_EXTRA_USE.getValue(); + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) use += ConfigIntValues.DRILL_FIVE_BY_FIVE_EXTRA_USE.getValue(); + } + + return use; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean hasEffect(ItemStack stack, int pass){ + return false; + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.epic; + } + + public boolean getHasUpgrade(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade){ + return this.getHasUpgradeAsStack(stack, upgrade) != null; + } + + public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) return null; + + ItemStack[] slots = this.getSlotsFromNBT(stack); + if(slots != null && slots.length > 0){ + for(ItemStack slotStack : slots){ + if(slotStack != null && slotStack.getItem() instanceof ItemDrillUpgrade){ + if(((ItemDrillUpgrade)slotStack.getItem()).type == upgrade) return slotStack; + } + } + } + return null; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + public void setEnergy(ItemStack stack, int energy){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) compound = new NBTTagCompound(); + compound.setInteger("Energy", energy); + stack.setTagCompound(compound); + } + + public void writeSlotsToNBT(ItemStack[] slots, ItemStack stack){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) compound = new NBTTagCompound(); + + if(slots != null && slots.length > 0){ + compound.setInteger("SlotAmount", slots.length); + NBTTagList tagList = new NBTTagList(); + for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){ + if(slots[currentIndex] != null){ + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)currentIndex); + slots[currentIndex].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + compound.setTag("Items", tagList); + } + stack.setTagCompound(compound); + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems(Item item, CreativeTabs tabs, List list){ + ItemStack stackFull = new ItemStack(this); + this.setEnergy(stackFull, this.getMaxEnergyStored(stackFull)); + list.add(stackFull); + + ItemStack stackEmpty = new ItemStack(this); + this.setEnergy(stackEmpty, 0); + list.add(stackEmpty); + } + + public ItemStack[] getSlotsFromNBT(ItemStack stack){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) return null; + + int slotAmount = compound.getInteger("SlotAmount"); + ItemStack[] slots = new ItemStack[slotAmount]; + + if(slots.length > 0){ + NBTTagList tagList = compound.getTagList("Items", 10); + for(int i = 0; i < tagList.tagCount(); i++){ + NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); + byte slotIndex = tagCompound.getByte("Slot"); + if(slotIndex >= 0 && slotIndex < slots.length){ + slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } + return slots; + } + + public void breakBlocks(ItemStack stack, int radius, World world, int x, int y, int z, EntityPlayer player){ + int xRange = radius; + int yRange = radius; + int zRange = 0; + + MovingObjectPosition pos = this.getMovingObjectPositionFromPlayer(world, player, false); + if(pos != null){ + int side = pos.sideHit; + if(side == 0 || side == 1){ + zRange = radius; + yRange = 0; + } + if(side == 4 || side == 5){ + xRange = 0; + zRange = radius; + } + + for(int xPos = x-xRange; xPos <= x+xRange; xPos++){ + for(int yPos = y-yRange; yPos <= y+yRange; yPos++){ + for(int zPos = z-zRange; zPos <= z+zRange; zPos++){ + int use = this.getEnergyUsePerBlock(stack); + if(this.getEnergyStored(stack) >= use){ + Block block = world.getBlock(xPos, yPos, zPos); + float hardness = block.getBlockHardness(world, xPos, yPos, zPos); + if(hardness > -1.0F && ((x == xPos && y == yPos && z == zPos) || this.canHarvestBlock(block, stack))){ + this.extractEnergy(stack, use, false); + + ArrayList drops = new ArrayList(); + int meta = world.getBlockMetadata(xPos, yPos, zPos); + + if(block.canSilkHarvest(world, player, xPos, yPos, zPos, meta) && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SILK_TOUCH)){ + addSilkDrops(drops, block, meta, world, player); + } + else{ + int fortune = this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE) ? (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) ? 3 : 1) : 0; + drops.addAll(block.getDrops(world, xPos, yPos, zPos, meta, fortune)); + block.dropXpOnBlockBreak(world, x, y, z, block.getExpDrop(world, meta, fortune)); + } + + if(!(x == xPos && y == yPos && z == zPos)){ + world.playAuxSFX(2001, xPos, yPos, zPos, Block.getIdFromBlock(block)+(meta << 12)); + } + world.setBlockToAir(xPos, yPos, zPos); + for(ItemStack theDrop : drops){ + EntityItem item = new EntityItem(world, xPos+0.5, yPos+0.5, zPos+0.5, theDrop); + item.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(item); + } + } + } + else return; + } + } + } + } + } + + public static void addSilkDrops(ArrayList drops, Block block, int meta, World world, EntityPlayer player){ + try{ + Method method = ReflectionHelper.findMethod(Block.class, block, new String[]{"createStackedBlock"}, int.class); + ItemStack silkDrop = (ItemStack)method.invoke(block, meta); + if(silkDrop != null) drops.add(silkDrop); + } + catch(Exception e){ + player.addChatComponentMessage(new ChatComponentText("Oh! That shouldn't have happened! Trying to get and use a private Method here might have bugged! Report this situation to the Mod Author ASAP!")); + ModUtil.LOGGER.log(Level.ERROR, "Player "+player.getDisplayName()+" who should break a Block using a Drill at "+player.posX+", "+player.posY+", "+player.posZ+" in World "+world.provider.dimensionId+" threw an Exception trying to get and use a private Method! Report this to the Mod Author ASAP!"); + } + } + + @Override + public String getName(){ + return "itemDrill"; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase living){ + if(living instanceof EntityPlayer){ + EntityPlayer player = (EntityPlayer)living; + int use = this.getEnergyUsePerBlock(stack); + if(this.getEnergyStored(stack) >= use){ + if(!world.isRemote){ + if(!living.isSneaking() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)){ + if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)){ + this.breakBlocks(stack, 2, world, x, y, z, player); + } + else this.breakBlocks(stack, 1, world, x, y, z, player); + } + else this.breakBlocks(stack, 0, world, x, y, z, player); + } + } + } + return true; + } + + @Override + public float func_150893_a(ItemStack stack, Block block){ + if(this.getEnergyStored(stack) < this.getEnergyUsePerBlock(stack)) return 0.0F; + if(block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil || block.getMaterial() == Material.rock || allSet.contains(block)) return this.getEfficiencyFromUpgrade(stack); + else return super.func_150893_a(stack, block); + } + + @Override + public boolean hitEntity(ItemStack stack, EntityLivingBase entity1, EntityLivingBase entity2){ + int use = this.getEnergyUsePerBlock(stack); + if(this.getEnergyStored(stack) >= use){ + this.extractEnergy(stack, use, false); + } + return true; + } + + @Override + public boolean canHarvestBlock(Block block, ItemStack stack){ + return this.func_150893_a(stack, block) > super.func_150893_a(stack, block); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + if(!world.isRemote && player.isSneaking() && stack == player.getCurrentEquippedItem()){ + player.openGui(ActuallyAdditions.instance, GuiHandler.DRILL_ID, world, (int)player.posX, (int)player.posY, (int)player.posZ); + } + return stack; + } + + @Override + public int getHarvestLevel(ItemStack stack, String toolClass){ + return ToolMaterial.EMERALD.getHarvestLevel(); + } + + @Override + public Set getToolClasses(ItemStack stack){ + HashSet hashSet = new HashSet(); + hashSet.add("pickaxe"); + hashSet.add("shovel"); + return hashSet; + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta){ + return this.func_150893_a(stack, block); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ + ItemUtil.addInformation(this, list, 3, ""); + if(KeyUtil.isShiftPressed()){ + list.add(this.getEnergyStored(stack) + "/" + this.getMaxEnergyStored(stack) + " RF"); + } + } + + @Override + public Multimap getAttributeModifiers(ItemStack stack){ + Multimap map = super.getAttributeModifiers(stack); + map.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Tool modifier", this.getEnergyStored(stack) >= energyUsePerBlockOrHit ? 8.0F : 0.0F, 0)); + return map; + } + + @Override + public boolean getShareTag(){ + return true; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemDrillUpgrade.java b/src/main/java/ellpeck/actuallyadditions/items/ItemDrillUpgrade.java new file mode 100644 index 000000000..c73f60e41 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemDrillUpgrade.java @@ -0,0 +1,104 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; + +import java.util.List; + +public class ItemDrillUpgrade extends Item implements INameableItem{ + + public enum UpgradeType{ + SPEED, + SPEED_II, + SPEED_III, + SILK_TOUCH, + FORTUNE, + FORTUNE_II, + THREE_BY_THREE, + FIVE_BY_FIVE, + PLACER + } + + public UpgradeType type; + public String unlocalizedName; + + public ItemDrillUpgrade(UpgradeType type, String unlocName){ + this.type = type; + this.unlocalizedName = unlocName; + this.setMaxStackSize(1); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + if(!world.isRemote && this.type == UpgradeType.PLACER){ + this.setSlotToPlaceFrom(stack, player.inventory.currentItem); + } + return stack; + } + + public void setSlotToPlaceFrom(ItemStack stack, int slot){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) compound = new NBTTagCompound(); + + compound.setInteger("SlotToPlaceFrom", slot+1); + + stack.setTagCompound(compound); + } + + public static int getSlotToPlaceFrom(ItemStack stack){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound != null){ + return compound.getInteger("SlotToPlaceFrom")-1; + } + return -1; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return this.unlocalizedName; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ + ItemUtil.addInformation(this, list, this.type == UpgradeType.PLACER ? 3 : 1, ""); + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".itemDrillUpgrade.desc")); + if(this.type == UpgradeType.PLACER){ + int slot = getSlotToPlaceFrom(stack); + if(slot >= 0){ + list.add(StatCollector.translateToLocal("info."+ModUtil.MOD_ID_LOWER+".gui.slot")+": "+(slot+1)); + } + } + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemDust.java b/src/main/java/ellpeck/actuallyadditions/items/ItemDust.java index 97e9b7dfd..d81f4d634 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemDust.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemDust.java @@ -41,7 +41,7 @@ public class ItemDust extends Item implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allDusts[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allDusts.length ? EnumRarity.common : allDusts[stack.getItemDamage()].rarity; } @SuppressWarnings("all") @@ -54,14 +54,14 @@ public class ItemDust extends Item implements INameableItem{ @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allDusts[stack.getItemDamage()].name; + return this.getUnlocalizedName() + (stack.getItemDamage() >= allDusts.length ? " ERROR!" : allDusts[stack.getItemDamage()].getName()); } @Override @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ - ItemUtil.addInformation(this, list, 1, allDusts[stack.getItemDamage()].getName()); + if(stack.getItemDamage() < allDusts.length) ItemUtil.addInformation(this, list, 1, allDusts[stack.getItemDamage()].getName()); } @Override @@ -72,7 +72,7 @@ public class ItemDust extends Item implements INameableItem{ @Override @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int pass){ - return allDusts[stack.getItemDamage()].color; + return stack.getItemDamage() >= allDusts.length ? 0 : allDusts[stack.getItemDamage()].color; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemFoods.java b/src/main/java/ellpeck/actuallyadditions/items/ItemFoods.java index 0492eb531..5f1578bb6 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemFoods.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemFoods.java @@ -37,27 +37,27 @@ public class ItemFoods extends ItemFood implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allFoods[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allFoods.length ? EnumRarity.common : allFoods[stack.getItemDamage()].rarity; } @Override public int func_150905_g(ItemStack stack){ - return allFoods[stack.getItemDamage()].healAmount; + return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].healAmount; } @Override public float func_150906_h(ItemStack stack){ - return allFoods[stack.getItemDamage()].saturation; + return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].saturation; } @Override public EnumAction getItemUseAction(ItemStack stack){ - return allFoods[stack.getItemDamage()].getsDrunken ? EnumAction.drink : EnumAction.eat; + return stack.getItemDamage() >= allFoods.length ? EnumAction.eat : (allFoods[stack.getItemDamage()].getsDrunken ? EnumAction.drink : EnumAction.eat); } @Override public int getMaxItemUseDuration(ItemStack stack){ - return allFoods[stack.getItemDamage()].useDuration; + return stack.getItemDamage() >= allFoods.length ? 0 : allFoods[stack.getItemDamage()].useDuration; } @Override @@ -75,14 +75,14 @@ public class ItemFoods extends ItemFood implements INameableItem{ @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allFoods[stack.getItemDamage()].getName(); + return this.getUnlocalizedName() + (stack.getItemDamage() >= allFoods.length ? " ERROR!" : allFoods[stack.getItemDamage()].getName()); } @Override public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){ ItemStack stackToReturn = super.onEaten(stack, world, player); - ItemStack returnItem = allFoods[stack.getItemDamage()].returnItem; - if (returnItem != null){ + ItemStack returnItem = stack.getItemDamage() >= allFoods.length ? null : allFoods[stack.getItemDamage()].returnItem; + if(returnItem != null){ if(!player.inventory.addItemStackToInventory(returnItem.copy())){ if(!world.isRemote){ EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy()); @@ -98,17 +98,19 @@ public class ItemFoods extends ItemFood implements INameableItem{ @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ - if(KeyUtil.isShiftPressed()){ - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + "." + this.getName() + allFoods[stack.getItemDamage()].getName() + ".desc")); - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".hunger.desc") + ": " + allFoods[stack.getItemDamage()].healAmount); - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".saturation.desc") + ": " + allFoods[stack.getItemDamage()].saturation); + if(stack.getItemDamage() < allFoods.length){ + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+"."+this.getName()+allFoods[stack.getItemDamage()].getName()+".desc")); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".hunger.desc")+": "+allFoods[stack.getItemDamage()].healAmount); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".saturation.desc")+": "+allFoods[stack.getItemDamage()].saturation); + } + else list.add(ItemUtil.shiftForInfo()); } - else list.add(ItemUtil.shiftForInfo()); } @Override public IIcon getIconFromDamage(int par1){ - return textures[par1]; + return par1 >= textures.length ? null : textures[par1]; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java b/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java new file mode 100644 index 000000000..8ce79fdd3 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java @@ -0,0 +1,75 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.recipe.HairyBallHandler; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.WeightedRandom; +import net.minecraft.world.World; + +import java.util.List; +import java.util.Random; + +public class ItemHairyBall extends Item implements INameableItem{ + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + if(!world.isRemote){ + ItemStack returnItem = this.getRandomReturnItem(); + if(!player.inventory.addItemStackToInventory(returnItem)){ + EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem); + entityItem.delayBeforeCanPickup = 0; + player.worldObj.spawnEntityInWorld(entityItem); + } + stack.stackSize--; + world.playSoundAtEntity(player, "random.pop", 0.2F, new Random().nextFloat() * 0.1F + 0.9F); + } + return stack; + } + + public ItemStack getRandomReturnItem(){ + return ((HairyBallHandler.Return)WeightedRandom.getRandomItem(new Random(), HairyBallHandler.returns)).returnItem.copy(); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.epic; + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + ItemUtil.addInformation(this, list, 2, ""); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return "itemHairyBall"; + } + + @Override + public String getOredictName(){ + return this.getName(); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemJams.java b/src/main/java/ellpeck/actuallyadditions/items/ItemJams.java index 5ce347cd3..5a98848a4 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemJams.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemJams.java @@ -41,17 +41,17 @@ public class ItemJams extends ItemFood implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allJams[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allJams.length ? EnumRarity.common : allJams[stack.getItemDamage()].rarity; } @Override public int func_150905_g(ItemStack stack){ - return allJams[stack.getItemDamage()].healAmount; + return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].healAmount; } @Override public float func_150906_h(ItemStack stack){ - return allJams[stack.getItemDamage()].saturation; + return stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].saturation; } @Override @@ -69,20 +69,20 @@ public class ItemJams extends ItemFood implements INameableItem{ @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allJams[stack.getItemDamage()].getName(); + return this.getUnlocalizedName() + (stack.getItemDamage() >= allJams.length ? " ERROR!" : allJams[stack.getItemDamage()].getName()); } @Override @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int pass){ - return pass > 0 ? allJams[stack.getItemDamage()].color : super.getColorFromItemStack(stack, pass); + return pass > 0 ? (stack.getItemDamage() >= allJams.length ? 0 : allJams[stack.getItemDamage()].color) : super.getColorFromItemStack(stack, pass); } @Override public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player){ ItemStack stackToReturn = super.onEaten(stack, world, player); - if(!world.isRemote){ + if(!world.isRemote && stack.getItemDamage() < allJams.length){ PotionEffect firstEffectToGet = new PotionEffect(allJams[stack.getItemDamage()].firstEffectToGet, 200); player.addPotionEffect(firstEffectToGet); @@ -103,14 +103,16 @@ public class ItemJams extends ItemFood implements INameableItem{ @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ - if(KeyUtil.isShiftPressed()){ - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + "." + this.getName() + ".desc.1")); - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + "." + this.getName() + allJams[stack.getItemDamage()].getName() + ".desc")); - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + "." + this.getName() + ".desc.2")); - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".hunger.desc") + ": " + allJams[stack.getItemDamage()].healAmount); - list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".saturation.desc") + ": " + allJams[stack.getItemDamage()].saturation); + if(stack.getItemDamage() < allJams.length){ + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+"."+this.getName()+".desc.1")); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+"."+this.getName()+allJams[stack.getItemDamage()].getName()+".desc")); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+"."+this.getName()+".desc.2")); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".hunger.desc")+": "+allJams[stack.getItemDamage()].healAmount); + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".saturation.desc")+": "+allJams[stack.getItemDamage()].saturation); + } + else list.add(ItemUtil.shiftForInfo()); } - else list.add(ItemUtil.shiftForInfo()); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemMisc.java b/src/main/java/ellpeck/actuallyadditions/items/ItemMisc.java index 2cf6110b6..fd77272e5 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemMisc.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemMisc.java @@ -37,7 +37,7 @@ public class ItemMisc extends Item implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allMiscItems[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allMiscItems.length ? EnumRarity.common : allMiscItems[stack.getItemDamage()].rarity; } @Override @@ -55,19 +55,19 @@ public class ItemMisc extends Item implements INameableItem{ @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allMiscItems[stack.getItemDamage()].name; + return this.getUnlocalizedName() + (stack.getItemDamage() >= allMiscItems.length ? " ERROR!" : allMiscItems[stack.getItemDamage()].getName()); } @Override @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ - ItemUtil.addInformation(this, list, 1, allMiscItems[stack.getItemDamage()].getName()); + if(stack.getItemDamage() < allMiscItems.length) ItemUtil.addInformation(this, list, 1, allMiscItems[stack.getItemDamage()].getName()); } @Override public IIcon getIconFromDamage(int par1){ - return textures[par1]; + return par1 >= textures.length ? null : textures[par1]; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java b/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java new file mode 100644 index 000000000..04a3e66f9 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemPhantomConnector.java @@ -0,0 +1,184 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer; +import ellpeck.actuallyadditions.tile.TileEntityPhantomface; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import java.util.List; + +public class ItemPhantomConnector extends Item implements INameableItem{ + + public ItemPhantomConnector(){ + this.setMaxStackSize(1); + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10){ + if(!world.isRemote){ + //Passing Data to Phantoms + TileEntity tile = world.getTileEntity(x, y, z); + if(tile != null){ + //Passing to Face + if(tile instanceof TileEntityPhantomface){ + if(this.checkHasConnection(stack, player, tile)){ + ((TileEntityPhantomface)tile).boundPosition = this.getStoredPosition(stack); + ((TileEntityPhantomface)tile).boundWorld = this.getStoredWorld(stack); + TileEntityPhantomface.updateAround(tile); + this.clearStorage(stack); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc"))); + return true; + } + return false; + } + //Passing to Placer + else if(tile instanceof TileEntityPhantomPlacer){ + if(this.checkHasConnection(stack, player, tile)){ + ((TileEntityPhantomPlacer)tile).boundPosition = this.getStoredPosition(stack); + ((TileEntityPhantomPlacer)tile).boundWorld = this.getStoredWorld(stack); + tile.markDirty(); + this.clearStorage(stack); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".phantom.connected.desc"))); + return true; + } + return false; + } + } + //Storing Connections + this.storeConnection(stack, x, y, z, world); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".phantom.stored.desc"))); + } + return true; + } + + public boolean checkHasConnection(ItemStack stack, EntityPlayer player, TileEntity tile){ + if(this.getStoredPosition(stack) != null && this.getStoredWorld(stack) != null){ + return true; + } + else{ + if(tile instanceof TileEntityPhantomPlacer){ + ((TileEntityPhantomPlacer)tile).boundWorld = null; + ((TileEntityPhantomPlacer)tile).boundPosition = null; + } + if(tile instanceof TileEntityPhantomface){ + ((TileEntityPhantomface)tile).boundWorld = null; + ((TileEntityPhantomface)tile).boundPosition = null; + } + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".phantom.unbound.desc"))); + return false; + } + } + + @Override + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ + if(this.getStoredPosition(stack) == null || this.getStoredWorld(stack) == null) this.clearStorage(stack); + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + if(KeyUtil.isAltPressed()) this.clearStorage(stack); + return stack; + } + + public ChunkCoordinates getStoredPosition(ItemStack stack){ + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null){ + int x = tag.getInteger("XCoordOfTileStored"); + int y = tag.getInteger("YCoordOfTileStored"); + int z = tag.getInteger("ZCoordOfTileStored"); + + if(x == 0 && y == 0 && z == 0) return null; + return new ChunkCoordinates(x, y, z); + } + return null; + } + + public World getStoredWorld(ItemStack stack){ + NBTTagCompound tag = stack.getTagCompound(); + if(tag != null){ + return DimensionManager.getWorld(tag.getInteger("WorldOfTileStored")); + } + return null; + } + + public void storeConnection(ItemStack stack, int x, int y, int z, World world){ + NBTTagCompound tag = stack.getTagCompound(); + if(tag == null) tag = new NBTTagCompound(); + + tag.setInteger("XCoordOfTileStored", x); + tag.setInteger("YCoordOfTileStored", y); + tag.setInteger("ZCoordOfTileStored", z); + tag.setInteger("WorldOfTileStored", world.provider.dimensionId); + + stack.setTagCompound(tag); + } + + public void clearStorage(ItemStack stack){ + stack.setTagCompound(new NBTTagCompound()); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.epic; + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + ItemUtil.addInformation(this, list, 2, ""); + ChunkCoordinates coords = this.getStoredPosition(stack); + World world = this.getStoredWorld(stack); + if(coords != null && world != null){ + list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".phantom.boundTo.desc") + ":"); + list.add("X: " + coords.posX); + list.add("Y: " + coords.posY); + list.add("Z: " + coords.posZ); + list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".phantom.inWorld.desc") + " " + world.provider.dimensionId); + } + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return "itemPhantomConnector"; + } + + @Override + public String getOredictName(){ + return this.getName(); + } + + @Override + public boolean getShareTag(){ + return true; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemPotionRing.java b/src/main/java/ellpeck/actuallyadditions/items/ItemPotionRing.java index 785608fd1..db3fe422c 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemPotionRing.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemPotionRing.java @@ -3,7 +3,9 @@ package ellpeck.actuallyadditions.items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.items.metalists.ThePotionRings; -import ellpeck.actuallyadditions.util.*; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -40,7 +42,7 @@ public class ItemPotionRing extends Item implements INameableItem{ public void onUpdate(ItemStack stack, World world, Entity player, int par4, boolean par5){ super.onUpdate(stack, world, player, par4, par5); - if(!world.isRemote){ + if(!world.isRemote && stack.getItemDamage() < allRings.length){ if(player instanceof EntityPlayer){ EntityPlayer thePlayer = (EntityPlayer)player; ItemStack equippedStack = ((EntityPlayer)player).getCurrentEquippedItem(); @@ -71,7 +73,7 @@ public class ItemPotionRing extends Item implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allRings[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allRings.length ? EnumRarity.common : allRings[stack.getItemDamage()].rarity; } @SuppressWarnings("all") @@ -84,20 +86,15 @@ public class ItemPotionRing extends Item implements INameableItem{ @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allRings[stack.getItemDamage()].name; + return this.getUnlocalizedName() + (stack.getItemDamage() >= allRings.length ? " ERROR!" : allRings[stack.getItemDamage()].getName()); } @Override @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ - ItemUtil.addInformation(this, list, 2, ""); - - if(KeyUtil.isShiftPressed()){ - if(stack.getItemDamage() == ThePotionRings.SATURATION.ordinal()){ - list.add(StringUtil.RED + StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".itemPotionRing.desc.off.1")); - list.add(StringUtil.RED + StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".itemPotionRing.desc.off.2")); - } + if(stack.getItemDamage() < allRings.length){ + ItemUtil.addInformation(this, list, 2, ""); } } @@ -109,7 +106,7 @@ public class ItemPotionRing extends Item implements INameableItem{ @Override @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack stack, int pass){ - return allRings[stack.getItemDamage()].color; + return stack.getItemDamage() >= allRings.length ? 0 : allRings[stack.getItemDamage()].color; } @Override @@ -121,8 +118,10 @@ public class ItemPotionRing extends Item implements INameableItem{ @Override public String getItemStackDisplayName(ItemStack stack){ String standardName = StatCollector.translateToLocal(this.getUnlocalizedName() + ".name"); - String name = allRings[stack.getItemDamage()].getName(); - String effect = StatCollector.translateToLocal("effect." + ModUtil.MOD_ID_LOWER + "." + name.substring(0, 1).toLowerCase() + name.substring(1) + ".name"); - return standardName + " " + effect; + if(stack.getItemDamage() < allRings.length){ + String effect = StatCollector.translateToLocal(allRings[stack.getItemDamage()].getName()); + return standardName+" "+effect; + } + return standardName; } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemResonantRice.java b/src/main/java/ellpeck/actuallyadditions/items/ItemResonantRice.java new file mode 100644 index 000000000..b1f1eff50 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemResonantRice.java @@ -0,0 +1,62 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.*; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.List; + +public class ItemResonantRice extends Item implements INameableItem{ + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ + if(!world.isRemote){ + stack.stackSize--; + world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true); + } + return stack; + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.epic; + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + ItemUtil.addInformation(this, list, 1, ""); + if(KeyUtil.isShiftPressed() && OreDictionary.getOres("nuggetEnderium", false).size() <= 0) list.add(StringUtil.RED + StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".itemResonantRice.uncraftable.desc")); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return "itemResonantRice"; + } + + @Override + public String getOredictName(){ + return this.getName(); + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java b/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java new file mode 100644 index 000000000..d052b3690 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemSeed.java @@ -0,0 +1,77 @@ +package ellpeck.actuallyadditions.items; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.BlockPlant; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemSeeds; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import java.util.List; + +public class ItemSeed extends ItemSeeds implements INameableItem{ + + public Block plant; + public String name; + + public ItemSeed(String name, Block plant, Item returnItem, int returnMeta){ + super(plant, Blocks.farmland); + this.name = name; + this.plant = plant; + ((BlockPlant)this.plant).seedItem = this; + ((BlockPlant)this.plant).returnItem = returnItem; + ((BlockPlant)this.plant).returnMeta = returnMeta; + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return EnumRarity.rare; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + ItemUtil.addInformation(this, list, 1, ""); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public Block getPlant(IBlockAccess world, int x, int y, int z){ + return this.plant; + } + + @Override + public int getPlantMetadata(IBlockAccess world, int x, int y, int z){ + return 0; + } + + @Override + public String getName(){ + return this.name; + } + + @Override + public String getOredictName(){ + return this.getName(); + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemSpecialDrop.java b/src/main/java/ellpeck/actuallyadditions/items/ItemSpecialDrop.java index 200273019..22a758de4 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemSpecialDrop.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemSpecialDrop.java @@ -17,10 +17,11 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import java.util.List; -import java.util.Random; public class ItemSpecialDrop extends Item implements INameableItem{ + public static final int SOLID_XP_AMOUNT = 8; + public static final TheSpecialDrops[] allDrops = TheSpecialDrops.values(); public IIcon[] textures = new IIcon[allDrops.length]; @@ -32,8 +33,14 @@ public class ItemSpecialDrop extends Item implements INameableItem{ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ if(!world.isRemote){ if(stack.getItemDamage() == TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal()){ - world.spawnEntityInWorld(new EntityXPOrb(world, player.posX+0.5, player.posY+0.5, player.posZ+0.5, 5+new Random().nextInt(6))); - if(!player.capabilities.isCreativeMode) stack.stackSize--; + if(!player.isSneaking()){ + world.spawnEntityInWorld(new EntityXPOrb(world, player.posX+0.5, player.posY+0.5, player.posZ+0.5, SOLID_XP_AMOUNT)); + if(!player.capabilities.isCreativeMode) stack.stackSize--; + } + else{ + world.spawnEntityInWorld(new EntityXPOrb(world, player.posX+0.5, player.posY+0.5, player.posZ+0.5, SOLID_XP_AMOUNT*stack.stackSize)); + if(!player.capabilities.isCreativeMode) stack.stackSize = 0; + } } } return stack; @@ -46,7 +53,7 @@ public class ItemSpecialDrop extends Item implements INameableItem{ @Override public EnumRarity getRarity(ItemStack stack){ - return allDrops[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= allDrops.length ? EnumRarity.common : allDrops[stack.getItemDamage()].rarity; } @Override @@ -69,19 +76,19 @@ public class ItemSpecialDrop extends Item implements INameableItem{ @Override public String getUnlocalizedName(ItemStack stack){ - return this.getUnlocalizedName() + allDrops[stack.getItemDamage()].name; + return this.getUnlocalizedName() + (stack.getItemDamage() >= allDrops.length ? " ERROR!" : allDrops[stack.getItemDamage()].getName()); } @Override @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld){ - ItemUtil.addInformation(this, list, 1, allDrops[stack.getItemDamage()].getName()); + if(stack.getItemDamage() < allDrops.length) ItemUtil.addInformation(this, list, stack.getItemDamage() == TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal() ? 2 : 1, allDrops[stack.getItemDamage()].getName()); } @Override public IIcon getIconFromDamage(int par1){ - return textures[par1]; + return par1 >= textures.length ? null : textures[par1]; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java index b9df1658a..4dc38122c 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java +++ b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheFoods.java @@ -23,7 +23,9 @@ public enum TheFoods implements INameableItem{ BIG_COOKIE("BigCookie", 6, 1F, false, 20, EnumRarity.uncommon, "foodBigCookie"), HAMBURGER("Hamburger", 14, 6F, false, 40, EnumRarity.common, "foodHamburger"), PIZZA("Pizza", 20, 10F, false, 45, EnumRarity.uncommon, "foodPizza"), - BAGUETTE("Baguette", 7, 2F, false, 25, EnumRarity.common, "foodBaguette"); + BAGUETTE("Baguette", 7, 2F, false, 25, EnumRarity.common, "foodBaguette"), + RICE("Rice", 2, 1F, false, 10, EnumRarity.uncommon, "foodRice"), + RICE_BREAD("RiceBread", 8, 3F, false, 25, EnumRarity.uncommon, "foodRiceBread"); public static void setReturnItems(){ SPAGHETTI.returnItem = new ItemStack(Items.bowl); diff --git a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheJams.java b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheJams.java index fc770f571..f2b404a13 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheJams.java +++ b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheJams.java @@ -5,12 +5,12 @@ import net.minecraft.item.EnumRarity; public enum TheJams implements INameableItem{ - CU_BA_RA("CuBaRa", 20, 5F, EnumRarity.rare, "jamCuBaRa", 5, 12, 12595273), - GRA_KI_BA("GraKiBa", 20, 5F, EnumRarity.rare, "jamGraKiBa", 16, 13, 5492820), - PL_AP_LE("PlApLe", 20, 5F, EnumRarity.rare, "jamPlApLe", 15, 3, 13226009), - CH_AP_CI("ChApCi", 20, 5F, EnumRarity.rare, "jamChApCi", 10, 1, 13189222), - HO_ME_KI("HoMeKi", 20, 5F, EnumRarity.rare, "jamHoMeKi", 10, 14, 2031360), - PI_CO("PiCo", 20, 5F, EnumRarity.rare, "jamPiCo", 9, 1, 16056203); + CU_BA_RA("CuBaRa", 4, 2F, EnumRarity.rare, "jamCuBaRa", 5, 12, 12595273), + GRA_KI_BA("GraKiBa", 4, 2F, EnumRarity.rare, "jamGraKiBa", 16, 13, 5492820), + PL_AP_LE("PlApLe", 4, 2F, EnumRarity.rare, "jamPlApLe", 15, 3, 13226009), + CH_AP_CI("ChApCi", 4, 2F, EnumRarity.rare, "jamChApCi", 10, 1, 13189222), + HO_ME_KI("HoMeKi", 4, 2F, EnumRarity.rare, "jamHoMeKi", 10, 14, 2031360), + PI_CO("PiCo", 4, 2F, EnumRarity.rare, "jamPiCo", 9, 1, 16056203); public final String name; public final String oredictName; diff --git a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java index c8e5fcfd1..d1a819731 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/metalists/TheMiscItems.java @@ -13,7 +13,13 @@ public enum TheMiscItems implements INameableItem{ QUARTZ("BlackQuartz", EnumRarity.epic, "gemQuartzBlack"), RING("Ring", EnumRarity.uncommon, "itemRing"), COIL("Coil", EnumRarity.common, "itemCoilBasic"), - COIL_ADVANCED("CoilAdvanced", EnumRarity.uncommon, "itemCoilAdvanced"); + COIL_ADVANCED("CoilAdvanced", EnumRarity.uncommon, "itemCoilAdvanced"), + RICE_DOUGH("RiceDough", EnumRarity.uncommon, "itemRiceDough"), + TINY_COAL("TinyCoal", EnumRarity.common, "itemTinyCoal"), + TINY_CHAR("TinyCharcoal", EnumRarity.common, "itemTinyChar"), + RICE_SLIME("RiceSlime", EnumRarity.uncommon, "slimeball"), + CANOLA("Canola", EnumRarity.uncommon, "itemCanola"), + CUP("Cup", EnumRarity.uncommon, "itemCup"); public final String name; public final String oredictName; diff --git a/src/main/java/ellpeck/actuallyadditions/items/metalists/ThePotionRings.java b/src/main/java/ellpeck/actuallyadditions/items/metalists/ThePotionRings.java index 3e08a50c9..e79f599b2 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/metalists/ThePotionRings.java +++ b/src/main/java/ellpeck/actuallyadditions/items/metalists/ThePotionRings.java @@ -5,32 +5,32 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; public enum ThePotionRings implements INameableItem{ - SPEED("Speed", 8171462, 1, 0, 3, 10, false, EnumRarity.uncommon, new ItemStack(Items.sugar)), - //TODO Slowness - HASTE("Haste", 14270531, 3, 0, 3, 10, false, EnumRarity.epic, new ItemStack(Items.repeater)), - //TODO Mining Fatigue - STRENGTH("Strength", 9643043, 5, 0, 3, 10, false, EnumRarity.rare, new ItemStack(Items.blaze_powder)), + SPEED(Potion.moveSpeed.getName(), 8171462, Potion.moveSpeed.getId(), 0, 1, 10, false, EnumRarity.uncommon, new ItemStack(Items.sugar)), + //Slowness + HASTE(Potion.digSpeed.getName(), 14270531, Potion.digSpeed.getId(), 0, 1, 10, false, EnumRarity.epic, new ItemStack(Items.repeater)), + //Mining Fatigue + STRENGTH(Potion.damageBoost.getName(), 9643043, Potion.damageBoost.getId(), 0, 1, 10, false, EnumRarity.rare, new ItemStack(Items.blaze_powder)), //Health (Not Happening) - //TODO Damage - JUMP_BOOST("JumpBoost", 7889559, 8, 0, 3, 10, false, EnumRarity.rare, new ItemStack(Blocks.piston)), - //TODO Nausea - REGEN("Regen", 13458603, 10, 0, 3, 50, true, EnumRarity.rare, new ItemStack(Items.ghast_tear)), - RESISTANCE("Resistance", 10044730, 11, 0, 3, 10, false, EnumRarity.epic, new ItemStack(Items.slime_ball)), - FIRE_RESISTANCE("FireResistance", 14981690, 12, 0, 0, 10, false, EnumRarity.uncommon, new ItemStack(Items.magma_cream)), - WATER_BREATHING("WaterBreathing", 3035801, 13, 0, 0, 10, false, EnumRarity.rare, new ItemStack(Items.fish, 1, 3)), - INVISIBILITY("Invisibility", 8356754, 14, 0, 0, 10, false, EnumRarity.epic, new ItemStack(Items.fermented_spider_eye)), - //TODO Blindness - NIGHT_VISION("NightVision", 2039713, 16, 0, 0, 300, false, EnumRarity.rare, new ItemStack(Items.golden_carrot)), - //TODO Hunger - //TODO Weakness - //TODO Poison - //TODO Withering + //Damage + JUMP_BOOST(Potion.jump.getName(), 7889559, Potion.jump.getId(), 0, 1, 10, false, EnumRarity.rare, new ItemStack(Blocks.piston)), + //Nausea + REGEN(Potion.regeneration.getName(), 13458603, Potion.regeneration.getId(), 0, 1, 50, true, EnumRarity.rare, new ItemStack(Items.ghast_tear)), + RESISTANCE(Potion.resistance.getName(), 10044730, Potion.resistance.getId(), 0, 1, 10, false, EnumRarity.epic, new ItemStack(Items.slime_ball)), + FIRE_RESISTANCE(Potion.fireResistance.getName(), 14981690, Potion.fireResistance.getId(), 0, 0, 10, false, EnumRarity.uncommon, new ItemStack(Items.magma_cream)), + WATER_BREATHING(Potion.waterBreathing.getName(), 3035801, Potion.waterBreathing.getId(), 0, 0, 10, false, EnumRarity.rare, new ItemStack(Items.fish, 1, 3)), + INVISIBILITY(Potion.invisibility.getName(), 8356754, Potion.invisibility.getId(), 0, 0, 10, false, EnumRarity.epic, new ItemStack(Items.fermented_spider_eye)), + //Blindness + NIGHT_VISION(Potion.nightVision.getName(), 2039713, Potion.nightVision.getId(), 0, 0, 300, false, EnumRarity.rare, new ItemStack(Items.golden_carrot)); + //Hunger + //Weakness + //Poison + //Withering //Health Boost (Not Happening) //Absorption (Not Happening) - SATURATION("Saturation", 16262179, 23, 0, 3, 10, false, EnumRarity.epic, new ItemStack(Items.cooked_beef)); public final String name; public final int color; diff --git a/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java b/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java new file mode 100644 index 000000000..fd8484ff7 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/items/tools/ItemAllToolAA.java @@ -0,0 +1,143 @@ +package ellpeck.actuallyadditions.items.tools; +import com.google.common.collect.Sets; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.INameableItem; +import ellpeck.actuallyadditions.util.ItemUtil; +import ellpeck.actuallyadditions.util.KeyUtil; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemTool; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.UseHoeEvent; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +@SuppressWarnings("unchecked") +public class ItemAllToolAA extends ItemTool implements INameableItem{ + + public static final Set axeSet = Sets.newHashSet(Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin); + public static final Set pickSet = Sets.newHashSet(Blocks.cobblestone, Blocks.double_stone_slab, Blocks.stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail); + public static final Set shovelSet = Sets.newHashSet(Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium); + + private static final Set allSet = Sets.newHashSet(); + static{ + allSet.addAll(axeSet); + allSet.addAll(pickSet); + allSet.addAll(shovelSet); + } + + private String name; + private EnumRarity rarity; + private ItemStack repairItem; + private String oredictName; + + public ItemAllToolAA(ToolMaterial toolMat, ItemStack repairItem, String unlocalizedName, EnumRarity rarity){ + super(5.0F, toolMat, allSet); + + this.repairItem = repairItem; + this.name = unlocalizedName; + this.oredictName = unlocalizedName; + this.rarity = rarity; + + this.setMaxDamage(this.getMaxDamage()*4); + } + + @Override + public float func_150893_a(ItemStack stack, Block block){ + return block.getMaterial() != Material.iron && block.getMaterial() != Material.anvil && block.getMaterial() != Material.rock && block.getMaterial() != Material.wood && block.getMaterial() != Material.plants && block.getMaterial() != Material.vine ? super.func_150893_a(stack, block) : this.efficiencyOnProperMaterial; + } + + @Override + public boolean func_150897_b(Block block){ + return block == Blocks.snow_layer || block == Blocks.snow || (block == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (block != Blocks.diamond_block && block != Blocks.diamond_ore ? (block != Blocks.emerald_ore && block != Blocks.emerald_block ? (block != Blocks.gold_block && block != Blocks.gold_ore ? (block != Blocks.iron_block && block != Blocks.iron_ore ? (block != Blocks.lapis_block && block != Blocks.lapis_ore ? (block != Blocks.redstone_ore && block != Blocks.lit_redstone_ore ? (block.getMaterial() == Material.rock || (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2)); + } + + @Override + @SuppressWarnings("unchecked") + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) { + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip."+ModUtil.MOD_ID_LOWER+".paxel.desc")); + list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".durability.desc") + ": " + (this.getMaxDamage()-this.getDamage(stack)) + "/" + this.getMaxDamage()); + } + else list.add(ItemUtil.shiftForInfo()); + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){ + if (!player.canPlayerEdit(x, y, z, side, stack)) return false; + else{ + UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); + if(MinecraftForge.EVENT_BUS.post(event)) return false; + if(event.getResult() == Event.Result.ALLOW){ + stack.damageItem(1, player); + return true; + } + Block block = world.getBlock(x, y, z); + if(side != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)){ + Block block1 = Blocks.farmland; + world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F); + if (world.isRemote) return true; + else{ + world.setBlock(x, y, z, block1); + stack.damageItem(1, player); + return true; + } + } + else return false; + } + } + + @Override + public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ + return stack.getItem() == repairItem.getItem(); + } + + @Override + public EnumRarity getRarity(ItemStack stack){ + return this.rarity; + } + + @Override + public IIcon getIcon(ItemStack stack, int pass){ + return this.itemIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconReg){ + this.itemIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER + ":" + this.getName()); + } + + @Override + public String getName(){ + return name; + } + + @Override + public String getOredictName(){ + return oredictName; + } + + @Override + public Set getToolClasses(ItemStack stack){ + HashSet hashSet = new HashSet(); + hashSet.add("pickaxe"); + hashSet.add("axe"); + hashSet.add("shovel"); + return hashSet; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/nei/CoffeeMachineRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/CoffeeMachineRecipeHandler.java new file mode 100644 index 000000000..1d134e88e --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/CoffeeMachineRecipeHandler.java @@ -0,0 +1,158 @@ +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.inventory.gui.GuiCoffeeMachine; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.ItemCoffee; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class CoffeeMachineRecipeHandler extends TemplateRecipeHandler{ + + public static final String NAME = "actuallyadditions.coffee"; + + public CoffeeMachineRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 32, 3); + } + + public class CachedCoffee extends CachedRecipe{ + + public PositionedStack cup; + public PositionedStack coffeeBeans; + public PositionedStack result; + public PositionedStack ingredientStack; + public String extraText; + public int maxAmp; + + public CachedCoffee(ItemCoffee.Ingredient ingredient){ + this.cup = new PositionedStack(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), 45, 39); + this.coffeeBeans = new PositionedStack(new ItemStack(InitItems.itemCoffeeBean), 2, 39); + this.ingredientStack = new PositionedStack(ingredient.ingredient.copy(), 90, 21); + this.setupResult(ingredient); + this.extraText = ingredient.getExtraText(); + this.maxAmp = ingredient.maxAmplifier; + } + + public void setupResult(ItemCoffee.Ingredient ingredient){ + ItemStack result = new ItemStack(InitItems.itemCoffee); + ItemCoffee.addEffectToStack(result, ingredient); + this.result = new PositionedStack(result.copy(), 45, 70); + } + + @Override + public List getIngredients(){ + ArrayList list = new ArrayList(); + list.add(this.ingredientStack); + list.add(this.cup); + list.add(this.coffeeBeans); + return list; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 1; + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(21, 39, 22, 16), NAME)); + transferRects.add(new RecipeTransferRect(new Rectangle(67, 42, 22, 10), NAME)); + } + + @Override + public Class getGuiClass(){ + return GuiCoffeeMachine.class; + } + + @Override + public String getRecipeName(){ + return StatCollector.translateToLocal("container.nei." + NAME + ".name"); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == CoffeeMachineRecipeHandler.class){ + ArrayList ingredients = ItemCoffee.ingredients; + for(ItemCoffee.Ingredient ingredient : ingredients){ + arecipes.add(new CachedCoffee(ingredient)); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + ArrayList ingredients = ItemCoffee.ingredients; + for(ItemCoffee.Ingredient ingredient : ingredients){ + if(result.getItem() instanceof ItemCoffee) arecipes.add(new CachedCoffee(ingredient)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + + ArrayList ingredients = ItemCoffee.ingredients; + for(ItemCoffee.Ingredient ingr : ingredients){ + if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemCoffeeBean), ingredient) || NEIServerUtils.areStacksSameTypeCrafting(ingr.ingredient.copy(), ingredient)){ + CachedCoffee theRecipe = new CachedCoffee(ingr); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredientStack), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEICoffeeMachine.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 126, 88); + } + + @Override + public void drawExtras(int recipe){ + drawProgressBar(21, 39, 126, 0, 21, 16, 48, 0); + drawProgressBar(63, 42, 125, 16, 24, 12, 48, 2); + + CachedCoffee cache = (CachedCoffee)this.arecipes.get(recipe); + if(cache.extraText != null){ + GuiDraw.drawString(StatCollector.translateToLocal("container.nei." + ModUtil.MOD_ID_LOWER + ".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + GuiDraw.drawString(cache.extraText, 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + GuiDraw.drawString(StatCollector.translateToLocal("container.nei." + ModUtil.MOD_ID_LOWER + ".coffee.shift"), 1, 75, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + + if(cache.maxAmp > 0){ + GuiDraw.drawString(StatCollector.translateToLocal("container.nei." + ModUtil.MOD_ID_LOWER + ".coffee.maxAmount") + ": " + cache.maxAmp, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/CompostRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/CompostRecipeHandler.java new file mode 100644 index 000000000..4bb42739a --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/CompostRecipeHandler.java @@ -0,0 +1,109 @@ +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.Collections; + +public class CompostRecipeHandler extends TemplateRecipeHandler{ + + public static final String NAME = "actuallyadditions.compost"; + + public CompostRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + public class CachedCompostRecipe extends CachedRecipe{ + + public PositionedStack result; + public PositionedStack input; + public int chance; + + public CachedCompostRecipe(ItemStack input, ItemStack result){ + this.result = new PositionedStack(result, 67+32, 19); + this.input = new PositionedStack(input, 5+32, 19); + } + + @Override + public PositionedStack getIngredient(){ + return input; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 2; + } + + @Override + public Class getGuiClass(){ + return null; + } + + @Override + public String getRecipeName(){ + return StatCollector.translateToLocal("container.nei." + NAME + ".name"); + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME)); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == CompostRecipeHandler.class){ + arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue()))); + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + if(NEIServerUtils.areStacksSameType(new ItemStack(InitItems.itemFertilizer), result)) arecipes.add(new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue()))); + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + if(NEIServerUtils.areStacksSameTypeCrafting(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), ingredient)){ + CachedCompostRecipe theRecipe = new CachedCompostRecipe(new ItemStack(InitItems.itemMisc, ConfigIntValues.COMPOST_AMOUNT.getValue(), TheMiscItems.MASHED_FOOD.ordinal()), new ItemStack(InitItems.itemFertilizer, ConfigIntValues.COMPOST_AMOUNT.getValue())); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient); + arecipes.add(theRecipe); + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEICompost.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60); + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java index 8eae1f040..1d3acfaf8 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/CrusherRecipeHandler.java @@ -1,33 +1,27 @@ package ellpeck.actuallyadditions.nei; import codechicken.lib.gui.GuiDraw; -import codechicken.nei.ItemList; import codechicken.nei.NEIServerUtils; import codechicken.nei.PositionedStack; import codechicken.nei.recipe.RecipeInfo; import codechicken.nei.recipe.TemplateRecipeHandler; -import ellpeck.actuallyadditions.inventory.GuiGrinder; -import ellpeck.actuallyadditions.recipe.GrinderRecipes; +import ellpeck.actuallyadditions.inventory.gui.GuiGrinder; +import ellpeck.actuallyadditions.recipe.GrinderRecipeManualRegistry; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.StringUtil; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; import java.awt.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class CrusherRecipeHandler extends TemplateRecipeHandler{ - public static final String NAME = "crushing"; - public static final String FUEL = "fuel"; - - public static ArrayList fuels; + public static final String NAME = "actuallyadditions.crushing"; public CrusherRecipeHandler(){ super(); @@ -59,15 +53,9 @@ public class CrusherRecipeHandler extends TemplateRecipeHandler{ return resultOne; } - @Override - public PositionedStack getOtherStack(){ - return fuels.get((cycleticks / 48) % fuels.size()).stack; - } - @Override public List getOtherStacks(){ ArrayList list = new ArrayList(); - list.add(this.getOtherStack()); if(this.resultTwo != null) list.add(this.resultTwo); return list; } @@ -78,20 +66,8 @@ public class CrusherRecipeHandler extends TemplateRecipeHandler{ return 1; } - public static class Fuel{ - - public Fuel(ItemStack in, int burnTime){ - this.stack = new PositionedStack(in, 51, 21, false); - this.burnTime = burnTime; - } - - public PositionedStack stack; - public int burnTime; - } - @Override public void loadTransferRects(){ - transferRects.add(new RecipeTransferRect(new Rectangle(51, 5, 14, 14), FUEL)); transferRects.add(new RecipeTransferRect(new Rectangle(80, 40, 24, 22), NAME)); } @@ -102,20 +78,14 @@ public class CrusherRecipeHandler extends TemplateRecipeHandler{ @Override public String getRecipeName(){ - return StatCollector.translateToLocal("container." + ModUtil.MOD_ID_LOWER + ".nei." + NAME + ".name"); - } - - @Override - public TemplateRecipeHandler newInstance(){ - if (fuels == null || fuels.isEmpty()) findFuels(); - return super.newInstance(); + return StatCollector.translateToLocal("container.nei." + NAME + ".name"); } @Override public void loadCraftingRecipes(String outputId, Object... results){ if(outputId.equals(NAME) && getClass() == CrusherRecipeHandler.class){ - ArrayList recipes = GrinderRecipes.instance().recipes; - for(GrinderRecipes.GrinderRecipe recipe : recipes){ + ArrayList recipes = GrinderRecipeManualRegistry.recipes; + for(GrinderRecipeManualRegistry.GrinderRecipe recipe : recipes){ arecipes.add(new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance)); } } @@ -124,22 +94,16 @@ public class CrusherRecipeHandler extends TemplateRecipeHandler{ @Override public void loadCraftingRecipes(ItemStack result){ - ArrayList recipes = GrinderRecipes.instance().recipes; - for(GrinderRecipes.GrinderRecipe recipe : recipes){ + ArrayList recipes = GrinderRecipeManualRegistry.recipes; + for(GrinderRecipeManualRegistry.GrinderRecipe recipe : recipes){ if(NEIServerUtils.areStacksSameType(recipe.firstOutput, result) || NEIServerUtils.areStacksSameType(recipe.secondOutput, result)) arecipes.add(new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance)); } } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients){ - if (inputId.equals(FUEL) && getClass() == CrusherRecipeHandler.class) loadCraftingRecipes(NAME); - else super.loadUsageRecipes(inputId, ingredients); - } - @Override public void loadUsageRecipes(ItemStack ingredient){ - ArrayList recipes = GrinderRecipes.instance().recipes; - for(GrinderRecipes.GrinderRecipe recipe : recipes){ + ArrayList recipes = GrinderRecipeManualRegistry.recipes; + for(GrinderRecipeManualRegistry.GrinderRecipe recipe : recipes){ if(NEIServerUtils.areStacksSameTypeCrafting(recipe.input, ingredient)){ CachedCrush theRecipe = new CachedCrush(recipe.input, recipe.firstOutput, recipe.secondOutput, recipe.secondChance); theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.ingredient), ingredient); @@ -157,12 +121,11 @@ public class CrusherRecipeHandler extends TemplateRecipeHandler{ public void drawBackground(int recipeIndex){ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(49, 5, 49, 5, 66, 86); + GuiDraw.drawTexturedModalRect(60, 13, 60, 13, 56, 79); } @Override public void drawExtras(int recipe){ - drawProgressBar(51, 5, 176, 44, 14, 14, 48, 7); drawProgressBar(80, 40, 176, 0, 24, 23, 48, 1); CachedCrush crush = (CachedCrush)this.arecipes.get(recipe); @@ -173,28 +136,6 @@ public class CrusherRecipeHandler extends TemplateRecipeHandler{ } } - private static Set excludedFuels(){ - Set theFuels = new HashSet(); - theFuels.add(Item.getItemFromBlock(Blocks.brown_mushroom)); - theFuels.add(Item.getItemFromBlock(Blocks.red_mushroom)); - theFuels.add(Item.getItemFromBlock(Blocks.standing_sign)); - theFuels.add(Item.getItemFromBlock(Blocks.wall_sign)); - theFuels.add(Item.getItemFromBlock(Blocks.wooden_door)); - theFuels.add(Item.getItemFromBlock(Blocks.trapped_chest)); - return theFuels; - } - - private static void findFuels(){ - fuels = new ArrayList(); - Set theFuels = excludedFuels(); - for(ItemStack item : ItemList.items){ - if(!theFuels.contains(item.getItem())){ - int burnTime = TileEntityFurnace.getItemBurnTime(item); - if(burnTime > 0) fuels.add(new Fuel(item.copy(), burnTime)); - } - } - } - @Override public String getOverlayIdentifier(){ return NAME; diff --git a/src/main/java/ellpeck/actuallyadditions/nei/HairyBallRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/nei/HairyBallRecipeHandler.java new file mode 100644 index 000000000..1456c5a67 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/nei/HairyBallRecipeHandler.java @@ -0,0 +1,129 @@ +package ellpeck.actuallyadditions.nei; + +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.RecipeInfo; +import codechicken.nei.recipe.TemplateRecipeHandler; +import ellpeck.actuallyadditions.recipe.HairyBallHandler; +import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.util.StringUtil; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; + +public class HairyBallRecipeHandler extends TemplateRecipeHandler{ + + public static final String NAME = "actuallyadditions.ballOfHair"; + + public HairyBallRecipeHandler(){ + super(); + RecipeInfo.setGuiOffset(this.getGuiClass(), 0, 0); + } + + public class CachedBallRecipe extends CachedRecipe{ + + public PositionedStack result; + public PositionedStack input; + public int chance; + + public CachedBallRecipe(ItemStack input, ItemStack result, int chance){ + this.result = new PositionedStack(result, 67+32, 19); + this.chance = chance; + this.input = new PositionedStack(input, 5+32, 19); + } + + @Override + public PositionedStack getIngredient(){ + return input; + } + + @Override + public PositionedStack getResult(){ + return result; + } + } + + @Override + public int recipiesPerPage(){ + return 2; + } + + @Override + public Class getGuiClass(){ + return null; + } + + @Override + public String getRecipeName(){ + return StatCollector.translateToLocal("container.nei." + NAME + ".name"); + } + + @Override + public void loadTransferRects(){ + transferRects.add(new RecipeTransferRect(new Rectangle(31+32, 18, 22, 16), NAME)); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results){ + if(outputId.equals(NAME) && getClass() == HairyBallRecipeHandler.class){ + ArrayList recipes = HairyBallHandler.returns; + for(HairyBallHandler.Return recipe : recipes){ + arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight)); + } + } + else super.loadCraftingRecipes(outputId, results); + } + + @Override + public void loadCraftingRecipes(ItemStack result){ + ArrayList recipes = HairyBallHandler.returns; + for(HairyBallHandler.Return recipe : recipes){ + if(NEIServerUtils.areStacksSameType(recipe.returnItem, result)) arecipes.add(new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight)); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient){ + ArrayList recipes = HairyBallHandler.returns; + for(HairyBallHandler.Return recipe : recipes){ + if(NEIServerUtils.areStacksSameTypeCrafting(recipe.inputItem, ingredient)){ + CachedBallRecipe theRecipe = new CachedBallRecipe(recipe.inputItem, recipe.returnItem, recipe.itemWeight); + theRecipe.setIngredientPermutation(Collections.singletonList(theRecipe.input), ingredient); + arecipes.add(theRecipe); + } + } + } + + @Override + public String getGuiTexture(){ + return ModUtil.MOD_ID_LOWER + ":textures/gui/guiNEIHairyBall.png"; + } + + @Override + public void drawBackground(int recipeIndex){ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(32, 0, 0, 0, 96, 60); + } + + @Override + public void drawExtras(int rec){ + CachedBallRecipe recipe = (CachedBallRecipe)this.arecipes.get(rec); + if(recipe.result != null){ + int secondChance = recipe.chance; + String secondString = secondChance + "%"; + GuiDraw.drawString(secondString, 65+32, 48, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); + } + } + + @Override + public String getOverlayIdentifier(){ + return NAME; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java b/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java index 7f90d5e67..d27279f5c 100644 --- a/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java +++ b/src/main/java/ellpeck/actuallyadditions/nei/NEIActuallyAdditionsConfig.java @@ -2,7 +2,9 @@ package ellpeck.actuallyadditions.nei; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.recipe.DefaultOverlayHandler; import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.inventory.gui.GuiCrafter; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.item.ItemStack; @@ -13,13 +15,30 @@ public class NEIActuallyAdditionsConfig implements IConfigureNEI{ public void loadConfig(){ Util.logInfo("Initializing Not Enough Items Plugin..."); + API.registerGuiOverlay(GuiCrafter.class, "crafting"); + API.registerGuiOverlayHandler(GuiCrafter.class, new DefaultOverlayHandler(), "crafting"); + CrusherRecipeHandler crusherRecipeHandler = new CrusherRecipeHandler(); API.registerRecipeHandler(crusherRecipeHandler); API.registerUsageHandler(crusherRecipeHandler); - //TODO Re-add - API.hideItem(new ItemStack(InitBlocks.blockHeatCollector)); - API.hideItem(new ItemStack(InitBlocks.blockFurnaceSolar)); + HairyBallRecipeHandler ballRecipeHandler = new HairyBallRecipeHandler(); + API.registerRecipeHandler(ballRecipeHandler); + API.registerUsageHandler(ballRecipeHandler); + + CompostRecipeHandler compostRecipeHandler = new CompostRecipeHandler(); + API.registerRecipeHandler(compostRecipeHandler); + API.registerUsageHandler(compostRecipeHandler); + + CoffeeMachineRecipeHandler coffeeMachineRecipeHandler = new CoffeeMachineRecipeHandler(); + API.registerRecipeHandler(coffeeMachineRecipeHandler); + API.registerUsageHandler(coffeeMachineRecipeHandler); + + API.hideItem(new ItemStack(InitBlocks.blockRice)); + API.hideItem(new ItemStack(InitBlocks.blockCanola)); + API.hideItem(new ItemStack(InitBlocks.blockFlax)); + API.hideItem(new ItemStack(InitBlocks.blockCoffee)); + API.hideItem(new ItemStack(InitBlocks.blockWildPlant, 1, Util.WILDCARD)); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketFluidCollectorToClient.java b/src/main/java/ellpeck/actuallyadditions/network/PacketFluidCollectorToClient.java new file mode 100644 index 000000000..6ce986166 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketFluidCollectorToClient.java @@ -0,0 +1,81 @@ +package ellpeck.actuallyadditions.network; + +import cpw.mods.fml.client.FMLClientHandler; +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 cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.tile.TileEntityFluidCollector; +import io.netty.buffer.ByteBuf; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class PacketFluidCollectorToClient implements IMessage{ + + private boolean hasFluid; + private int fluidID; + private int fluidAmount; + private int x; + private int y; + private int z; + + @SuppressWarnings("unused") + public PacketFluidCollectorToClient(){ + + } + + public PacketFluidCollectorToClient(FluidStack fluid, TileEntity tile){ + if(fluid != null){ + this.hasFluid = true; + this.fluidID = fluid.getFluidID(); + this.fluidAmount = fluid.amount; + } + else this.hasFluid = false; + + this.x = tile.xCoord; + this.y = tile.yCoord; + this.z = tile.zCoord; + } + + @Override + public void fromBytes(ByteBuf buf){ + this.hasFluid = buf.readBoolean(); + this.fluidID = buf.readInt(); + this.fluidAmount = buf.readInt(); + this.x = buf.readInt(); + this.y = buf.readInt(); + this.z = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf){ + buf.writeBoolean(this.hasFluid); + buf.writeInt(this.fluidID); + buf.writeInt(this.fluidAmount); + buf.writeInt(this.x); + buf.writeInt(this.y); + buf.writeInt(this.z); + } + + public static class Handler implements IMessageHandler{ + + @Override + @SideOnly(Side.CLIENT) + public IMessage onMessage(PacketFluidCollectorToClient message, MessageContext ctx){ + World world = FMLClientHandler.instance().getClient().theWorld; + TileEntity tile = world.getTileEntity(message.x, message.y, message.z); + + if(tile instanceof TileEntityFluidCollector){ + TileEntityFluidCollector collector = (TileEntityFluidCollector)tile; + if(message.hasFluid){ + collector.tank.setFluid(new FluidStack(FluidRegistry.getFluid(message.fluidID), message.fluidAmount)); + } + else collector.tank.setFluid(null); + } + return null; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java b/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java index f136a8a9a..e9e621138 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java @@ -3,6 +3,8 @@ package ellpeck.actuallyadditions.network; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; +import ellpeck.actuallyadditions.network.gui.PacketGuiButton; +import ellpeck.actuallyadditions.network.gui.PacketGuiNumber; import ellpeck.actuallyadditions.util.ModUtil; public class PacketHandler{ @@ -13,6 +15,8 @@ public class PacketHandler{ theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID_LOWER); theNetwork.registerMessage(PacketTileEntityFeeder.Handler.class, PacketTileEntityFeeder.class, 0, Side.CLIENT); - theNetwork.registerMessage(PacketInputterButton.Handler.class, PacketInputterButton.class, 1, Side.SERVER); + theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 1, Side.SERVER); + theNetwork.registerMessage(PacketFluidCollectorToClient.Handler.class, PacketFluidCollectorToClient.class, 2, Side.CLIENT); + theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 3, Side.SERVER); } } diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketTileEntityFeeder.java b/src/main/java/ellpeck/actuallyadditions/network/PacketTileEntityFeeder.java index 5f172baca..221667edb 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketTileEntityFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketTileEntityFeeder.java @@ -6,7 +6,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.actuallyadditions.inventory.GuiFeeder; +import ellpeck.actuallyadditions.inventory.gui.GuiFeeder; import ellpeck.actuallyadditions.tile.TileEntityFeeder; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; @@ -60,10 +60,12 @@ public class PacketTileEntityFeeder implements IMessage{ if(tile instanceof TileEntityFeeder){ TileEntityFeeder tileFeeder = (TileEntityFeeder)tile; tileFeeder.feedAnimal((EntityAnimal)world.getEntityByID(message.animalID)); - } - if(Minecraft.getMinecraft().currentScreen instanceof GuiFeeder){ - ((GuiFeeder)Minecraft.getMinecraft().currentScreen).loveCounter++; + if(Minecraft.getMinecraft().currentScreen instanceof GuiFeeder){ + if(((GuiFeeder)Minecraft.getMinecraft().currentScreen).tileFeeder == tileFeeder){ + ((GuiFeeder)Minecraft.getMinecraft().currentScreen).loveCounter++; + } + } } return null; diff --git a/src/main/java/ellpeck/actuallyadditions/network/gui/IButtonReactor.java b/src/main/java/ellpeck/actuallyadditions/network/gui/IButtonReactor.java new file mode 100644 index 000000000..6f67de9d6 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/network/gui/IButtonReactor.java @@ -0,0 +1,8 @@ +package ellpeck.actuallyadditions.network.gui; + +import net.minecraft.entity.player.EntityPlayer; + +public interface IButtonReactor{ + + void onButtonPressed(int buttonID, EntityPlayer player); +} diff --git a/src/main/java/ellpeck/actuallyadditions/network/gui/INumberReactor.java b/src/main/java/ellpeck/actuallyadditions/network/gui/INumberReactor.java new file mode 100644 index 000000000..98c70a6db --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/network/gui/INumberReactor.java @@ -0,0 +1,8 @@ +package ellpeck.actuallyadditions.network.gui; + +import net.minecraft.entity.player.EntityPlayer; + +public interface INumberReactor{ + + void onNumberReceived(int text, int textID, EntityPlayer player); +} diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketInputterButton.java b/src/main/java/ellpeck/actuallyadditions/network/gui/PacketGuiButton.java similarity index 66% rename from src/main/java/ellpeck/actuallyadditions/network/PacketInputterButton.java rename to src/main/java/ellpeck/actuallyadditions/network/gui/PacketGuiButton.java index 231201764..ace4444c7 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketInputterButton.java +++ b/src/main/java/ellpeck/actuallyadditions/network/gui/PacketGuiButton.java @@ -1,33 +1,35 @@ -package ellpeck.actuallyadditions.network; +package ellpeck.actuallyadditions.network.gui; 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 ellpeck.actuallyadditions.tile.TileEntityInputter; import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; -public class PacketInputterButton implements IMessage{ +public class PacketGuiButton implements IMessage{ private int tileX; private int tileY; private int tileZ; private int worldID; private int buttonID; + private int playerID; @SuppressWarnings("unused") - public PacketInputterButton(){ + public PacketGuiButton(){ } - public PacketInputterButton(int x, int y, int z, World world, int buttonID){ + public PacketGuiButton(int x, int y, int z, World world, int buttonID, EntityPlayer player){ this.tileX = x; this.tileY = y; this.tileZ = z; this.worldID = world.provider.dimensionId; this.buttonID = buttonID; + this.playerID = player.getEntityId(); } @Override @@ -37,6 +39,7 @@ public class PacketInputterButton implements IMessage{ this.tileZ = buf.readInt(); this.worldID = buf.readInt(); this.buttonID = buf.readInt(); + this.playerID = buf.readInt(); } @Override @@ -46,18 +49,19 @@ public class PacketInputterButton implements IMessage{ buf.writeInt(this.tileZ); buf.writeInt(this.worldID); buf.writeInt(this.buttonID); + buf.writeInt(this.playerID); } - public static class Handler implements IMessageHandler{ + public static class Handler implements IMessageHandler{ @Override - public IMessage onMessage(PacketInputterButton message, MessageContext ctx){ + public IMessage onMessage(PacketGuiButton message, MessageContext ctx){ World world = DimensionManager.getWorld(message.worldID); TileEntity tile = world.getTileEntity(message.tileX, message.tileY, message.tileZ); - if(tile instanceof TileEntityInputter){ - TileEntityInputter inputter = (TileEntityInputter)tile; - inputter.onButtonPressed(message.buttonID); + if(tile instanceof IButtonReactor){ + IButtonReactor reactor = (IButtonReactor)tile; + reactor.onButtonPressed(message.buttonID, (EntityPlayer)world.getEntityByID(message.playerID)); } return null; diff --git a/src/main/java/ellpeck/actuallyadditions/network/gui/PacketGuiNumber.java b/src/main/java/ellpeck/actuallyadditions/network/gui/PacketGuiNumber.java new file mode 100644 index 000000000..2ab2d332d --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/network/gui/PacketGuiNumber.java @@ -0,0 +1,74 @@ +package ellpeck.actuallyadditions.network.gui; + +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.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +public class PacketGuiNumber implements IMessage{ + + private int tileX; + private int tileY; + private int tileZ; + private int worldID; + private int text; + private int textID; + private int playerID; + + @SuppressWarnings("unused") + public PacketGuiNumber(){ + + } + + public PacketGuiNumber(int x, int y, int z, World world, int text, int textID, EntityPlayer player){ + this.tileX = x; + this.tileY = y; + this.tileZ = z; + this.worldID = world.provider.dimensionId; + this.text = text; + this.textID = textID; + this.playerID = player.getEntityId(); + } + + @Override + public void fromBytes(ByteBuf buf){ + this.tileX = buf.readInt(); + this.tileY = buf.readInt(); + this.tileZ = buf.readInt(); + this.worldID = buf.readInt(); + this.text = buf.readInt(); + this.textID = buf.readInt(); + this.playerID = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf){ + buf.writeInt(this.tileX); + buf.writeInt(this.tileY); + buf.writeInt(this.tileZ); + buf.writeInt(this.worldID); + buf.writeInt(this.text); + buf.writeInt(this.textID); + buf.writeInt(this.playerID); + } + + public static class Handler implements IMessageHandler{ + + @Override + public IMessage onMessage(PacketGuiNumber message, MessageContext ctx){ + World world = DimensionManager.getWorld(message.worldID); + TileEntity tile = world.getTileEntity(message.tileX, message.tileY, message.tileZ); + + if(tile instanceof INumberReactor){ + INumberReactor reactor = (INumberReactor)tile; + reactor.onNumberReceived(message.text, message.textID, (EntityPlayer)world.getEntityByID(message.playerID)); + } + + return null; + } + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java index d304b006c..aef05af84 100644 --- a/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java +++ b/src/main/java/ellpeck/actuallyadditions/proxy/ClientProxy.java @@ -8,9 +8,7 @@ import ellpeck.actuallyadditions.blocks.render.*; import ellpeck.actuallyadditions.config.values.ConfigBoolValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.event.RenderPlayerEventAA; -import ellpeck.actuallyadditions.tile.TileEntityCompost; -import ellpeck.actuallyadditions.tile.TileEntityFishingNet; -import ellpeck.actuallyadditions.tile.TileEntityFurnaceSolar; +import ellpeck.actuallyadditions.tile.*; import ellpeck.actuallyadditions.update.UpdateChecker; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; @@ -24,16 +22,16 @@ public class ClientProxy implements IProxy{ @Override public void preInit(){ Util.logInfo("PreInitializing ClientProxy..."); + + if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){ + new UpdateChecker().init(); + } } @Override public void init(){ Util.logInfo("Initializing ClientProxy..."); - if(ConfigBoolValues.DO_UPDATE_CHECK.isEnabled()){ - new UpdateChecker().init(); - } - ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCompost.class, new RenderTileEntity(new ModelCompost())); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCompost), new RenderItems(new ModelCompost())); @@ -43,6 +41,12 @@ public class ClientProxy implements IProxy{ ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFurnaceSolar.class, new RenderTileEntity(new ModelFurnaceSolar())); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockFurnaceSolar), new RenderItems(new ModelFurnaceSolar())); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoffeeMachine.class, new RenderTileEntity(new ModelCoffeeMachine())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCoffeeMachine), new RenderItems(new ModelCoffeeMachine())); + + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPhantomBooster.class, new RenderTileEntity(new ModelPhantomBooster())); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockPhantomBooster), new RenderItems(new ModelPhantomBooster())); + VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png")); Util.registerEvent(new RenderPlayerEventAA()); diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/FuelHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/FuelHandler.java new file mode 100644 index 000000000..9b10c7853 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/recipe/FuelHandler.java @@ -0,0 +1,64 @@ +package ellpeck.actuallyadditions.recipe; + +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.registry.GameRegistry; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.Util; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.HashMap; + +@SuppressWarnings("unused") +public class FuelHandler implements IFuelHandler{ + + private static HashMap, Integer> fuelList = new HashMap, Integer>(); + + public static void setFuelValues(){ + addFuel(InitItems.itemMisc, TheMiscItems.TINY_CHAR.ordinal(), 200); + addFuel(InitItems.itemMisc, TheMiscItems.TINY_COAL.ordinal(), 200); + addFuel(InitBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), 16000); + } + + public static void init(){ + Util.logInfo("Initializing Fuelstuffs..."); + + GameRegistry.registerFuelHandler(new FuelHandler()); + setFuelValues(); + } + + @Override + public int getBurnTime(ItemStack fuel){ + return getFuelValue(fuel); + } + + private static void addFuel(Item item, int metadata, int value){ + fuelList.put(Pair.of(item, metadata), value); + } + + private static void addFuel(Block block, int metadata, int value){ + addFuel(Item.getItemFromBlock(block), metadata, value); + } + + private static int getFuelValue(ItemStack stack){ + if(stack != null && stack.getItem() != null){ + Pair pair = Pair.of(stack.getItem(), stack.getItemDamage()); + + if(fuelList.containsKey(pair)){ + return fuelList.get(pair); + } + else{ + pair = Pair.of(stack.getItem(), 0); + if(fuelList.containsKey(pair)){ + return fuelList.get(pair); + } + } + } + return 0; + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeAutoRegistry.java b/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeAutoRegistry.java new file mode 100644 index 000000000..d0415530f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeAutoRegistry.java @@ -0,0 +1,75 @@ +package ellpeck.actuallyadditions.recipe; + +import ellpeck.actuallyadditions.config.values.ConfigBoolValues; +import ellpeck.actuallyadditions.util.ModUtil; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import org.apache.logging.log4j.Level; + +import java.util.ArrayList; + +public class GrinderRecipeAutoRegistry{ + + public static ArrayList searchCases = new ArrayList(); + public static ArrayList exceptions = new ArrayList(); + + public static class SearchCase{ + + public final String name; + public final int resultAmount; + + public SearchCase(String name, int resultAmount){ + this.name = name; + this.resultAmount = resultAmount; + } + } + + public static void registerFinally(){ + String[] names = OreDictionary.getOreNames(); + for(String inputName : names){ + + if(!exceptions.contains(inputName)){ + int resultAmount = 1; + String inputNameWithoutPrefix = null; + + for(SearchCase searchCase : searchCases){ + String toSearch = searchCase.name; + if(inputName.length() > toSearch.length() && inputName.substring(0, toSearch.length()).equals(toSearch)){ + inputNameWithoutPrefix = inputName.substring(toSearch.length()); + resultAmount = searchCase.resultAmount; + break; + } + } + + if(inputNameWithoutPrefix != null){ + String inputWithDustPrefix = "dust" + inputNameWithoutPrefix; + ArrayList allOresOfInitialInputName = (ArrayList)OreDictionary.getOres(inputName, false); + ArrayList allOresWithDustPrefix = (ArrayList)OreDictionary.getOres(inputWithDustPrefix, false); + if(allOresOfInitialInputName != null && allOresOfInitialInputName.size() > 0){ + if(allOresWithDustPrefix != null && allOresWithDustPrefix.size() > 0){ + for(ItemStack theInput : allOresOfInitialInputName){ + for(ItemStack theDust : allOresWithDustPrefix){ + ItemStack input = theInput.copy(); + ItemStack output = theDust.copy(); + output.stackSize = resultAmount; + if(!GrinderRecipeManualRegistry.hasRecipe(input, output)){ + GrinderRecipeManualRegistry.registerRecipe(input, output, null, 0); + } + } + } + } + else{ + if(ConfigBoolValues.DO_CRUSHER_SPAM.isEnabled()) + ModUtil.LOGGER.log(Level.INFO, "Couldn't register Crusher Recipe! An Item with OreDictionary Registry '" + inputWithDustPrefix + "' doesn't exist! It should correspond to '" + inputName + "'! This is not an Error, just a bit sad :("); + } + + } + else{ + if(ConfigBoolValues.DO_CRUSHER_SPAM.isEnabled()) + ModUtil.LOGGER.log(Level.WARN, "Couldn't register Crusher Recipe! Didn't find Items registered as '" + inputName + "'! This shouldn't happen as there is something registered as '" + inputName + "' that doesn't exist!"); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeHandler.java deleted file mode 100644 index 192270f4f..000000000 --- a/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeHandler.java +++ /dev/null @@ -1,112 +0,0 @@ -package ellpeck.actuallyadditions.recipe; - -import ellpeck.actuallyadditions.config.values.ConfigBoolValues; -import ellpeck.actuallyadditions.util.ModUtil; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import org.apache.logging.log4j.Level; - -import java.util.ArrayList; - -public class GrinderRecipeHandler{ - - private static final GrinderRecipeHandler instance = new GrinderRecipeHandler(); - - public static GrinderRecipeHandler instance(){ - return instance; - } - - public ArrayList searchCases = new ArrayList(); - public ArrayList exceptions = new ArrayList(); - public ArrayList specialOreCases = new ArrayList(); - - public static class SearchCase{ - - public final String name; - public final int resultAmount; - - public SearchCase(String name, int resultAmount){ - this.name = name; - this.resultAmount = resultAmount; - } - } - - public static class SpecialOreCase{ - - public final String inputName; - public final String secondResultName; - public final int secondResultChance; - - public SpecialOreCase(String inputName, String secondResultName, int secondResultChance){ - this.inputName = inputName; - this.secondResultChance = secondResultChance; - this.secondResultName = secondResultName; - } - - } - - public void registerFinally(){ - String[] names = OreDictionary.getOreNames(); - for(String inputName : names){ - - if(!this.exceptions.contains(inputName)){ - int resultAmount = 1; - String inputNameWithoutPrefix = null; - - for(SearchCase searchCase : searchCases){ - String toSearch = searchCase.name; - if(inputName.length() > toSearch.length() && inputName.substring(0, toSearch.length()).equals(toSearch)){ - inputNameWithoutPrefix = inputName.substring(toSearch.length()); - resultAmount = searchCase.resultAmount; - break; - } - } - - if(inputNameWithoutPrefix != null){ - String inputWithDustPrefix = "dust" + inputNameWithoutPrefix; - ArrayList allOresOfInitialInputName = OreDictionary.getOres(inputName); - ArrayList allOresWithDustPrefix = OreDictionary.getOres(inputWithDustPrefix); - if(allOresOfInitialInputName != null && allOresOfInitialInputName.size() > 0){ - if(allOresWithDustPrefix != null && allOresWithDustPrefix.size() > 0){ - for(ItemStack theInput : allOresOfInitialInputName){ - for(ItemStack theDust : allOresWithDustPrefix){ - ItemStack input = theInput.copy(); - ItemStack output = theDust.copy(); - output.stackSize = resultAmount; - if(!GrinderRecipes.instance().hasExactRecipe(input, output)){ - ArrayList specialStacks = null; - int specialAmount = 0; - - for(SpecialOreCase theCase : specialOreCases){ - if(inputName.equals(theCase.inputName)){ - specialStacks = OreDictionary.getOres(theCase.secondResultName); - specialAmount = theCase.secondResultChance; - } - } - if(specialStacks != null && specialStacks.size() > 0){ - for(ItemStack theSpecial : specialStacks){ - ItemStack special = theSpecial.copy(); - GrinderRecipes.instance().registerRecipe(input, output, special, specialAmount); - } - } - else GrinderRecipes.instance().registerRecipe(input, output, null, 0); - } - } - } - } - else{ - if(ConfigBoolValues.DO_CRUSHER_SPAM.isEnabled()) - ModUtil.AA_LOGGER.log(Level.INFO, "Couldn't register Crusher Recipe! An Item with OreDictionary Registry '" + inputWithDustPrefix + "' doesn't exist! It should correspond to '" + inputName + "'! This is not an Error, just a bit sad :("); - } - - } - else{ - if(ConfigBoolValues.DO_CRUSHER_SPAM.isEnabled()) - ModUtil.AA_LOGGER.log(Level.WARN, "Couldn't register Crusher Recipe! Didn't find Items registered as '" + inputName + "'! This shouldn't happen as there is something registered as '" + inputName + "' that doesn't exist!"); - } - } - } - } - } - -} diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeManualRegistry.java b/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeManualRegistry.java new file mode 100644 index 000000000..f4b73cc4f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipeManualRegistry.java @@ -0,0 +1,85 @@ +package ellpeck.actuallyadditions.recipe; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; + +public class GrinderRecipeManualRegistry{ + + public static ArrayList recipes = new ArrayList(); + + public static void registerRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int secondChance){ + recipes.add(new GrinderRecipe(input, outputOne, outputTwo, secondChance)); + } + + public static void registerRecipe(String input, String outputOne, String outputTwo, int secondChance, int outputAmount){ + ArrayList inputStacks = (ArrayList)OreDictionary.getOres(input, false); + ArrayList outputOneStacks = (ArrayList)OreDictionary.getOres(outputOne, false); + ArrayList outputTwoStacks = (ArrayList)OreDictionary.getOres(outputTwo, false); + + if(inputStacks != null && !inputStacks.isEmpty()){ + for(ItemStack anInput : inputStacks){ + ItemStack theInput = anInput.copy(); + if(outputOneStacks != null && !outputOneStacks.isEmpty()){ + for(ItemStack anOutputOne : outputOneStacks){ + ItemStack theOutputOne = anOutputOne.copy(); + theOutputOne.stackSize = outputAmount; + if(outputTwoStacks != null && !outputTwoStacks.isEmpty()){ + for(ItemStack anOutputTwo : outputTwoStacks){ + ItemStack theOutputTwo = anOutputTwo.copy(); + registerRecipe(theInput, theOutputOne, theOutputTwo, secondChance); + } + } + else registerRecipe(theInput, theOutputOne, null, 0); + } + } + } + } + } + + public static void registerRecipe(ItemStack input, ItemStack outputOne){ + registerRecipe(input, outputOne, null, 0); + } + + public static ItemStack getOutput(ItemStack input, boolean wantSecond){ + for(GrinderRecipe recipe : recipes){ + if(recipe.input.isItemEqual(input)){ + return wantSecond ? recipe.secondOutput : recipe.firstOutput; + } + } + return null; + } + + public static boolean hasRecipe(ItemStack input, ItemStack outputOne){ + for(GrinderRecipe recipe : recipes){ + if(recipe.input.isItemEqual(input) && recipe.firstOutput.isItemEqual(outputOne)) return true; + } + return false; + } + + public static int getSecondChance(ItemStack input){ + for(GrinderRecipe recipe : recipes){ + if(recipe.input.isItemEqual(input)){ + return recipe.secondChance; + } + } + return 0; + } + + public static class GrinderRecipe{ + + public final ItemStack input; + public final ItemStack firstOutput; + public final ItemStack secondOutput; + public final int secondChance; + + public GrinderRecipe(ItemStack input, ItemStack firstOutput, ItemStack secondOutput, int secondChance){ + this.input = input; + this.firstOutput = firstOutput; + this.secondOutput = secondOutput; + this.secondChance = secondChance; + } + + } +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipes.java b/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipes.java deleted file mode 100644 index d0a2ebab2..000000000 --- a/src/main/java/ellpeck/actuallyadditions/recipe/GrinderRecipes.java +++ /dev/null @@ -1,63 +0,0 @@ -package ellpeck.actuallyadditions.recipe; - -import net.minecraft.item.ItemStack; - -import java.util.ArrayList; - -public class GrinderRecipes{ - - private static final GrinderRecipes instance = new GrinderRecipes(); - - public ArrayList recipes = new ArrayList(); - - public static GrinderRecipes instance(){ - return instance; - } - - public void registerRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int secondChance){ - this.recipes.add(new GrinderRecipe(input, outputOne, outputTwo, secondChance)); - } - - public ItemStack getOutput(ItemStack input, boolean wantSecond){ - for(GrinderRecipe recipe : recipes){ - if(recipe.input.isItemEqual(input)){ - return wantSecond ? recipe.secondOutput : recipe.firstOutput; - } - } - return null; - } - - public boolean hasExactRecipe(ItemStack input, ItemStack outputOne){ - for(GrinderRecipe recipe : recipes){ - if(recipe.input.isItemEqual(input) && recipe.firstOutput.isItemEqual(outputOne)){ - return true; - } - } - return false; - } - - public int getSecondChance(ItemStack input){ - for(GrinderRecipe recipe : recipes){ - if(recipe.input.isItemEqual(input)){ - return recipe.secondChance; - } - } - return 0; - } - - public class GrinderRecipe{ - - public final ItemStack input; - public final ItemStack firstOutput; - public final ItemStack secondOutput; - public final int secondChance; - - public GrinderRecipe(ItemStack input, ItemStack firstOutput, ItemStack secondOutput, int secondChance){ - this.input = input; - this.firstOutput = firstOutput; - this.secondOutput = secondOutput; - this.secondChance = secondChance; - } - - } -} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/recipe/HairyBallHandler.java b/src/main/java/ellpeck/actuallyadditions/recipe/HairyBallHandler.java new file mode 100644 index 000000000..f4ddc7716 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/recipe/HairyBallHandler.java @@ -0,0 +1,62 @@ +package ellpeck.actuallyadditions.recipe; + +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandom; + +import java.util.ArrayList; + +public class HairyBallHandler{ + + public static ArrayList returns = new ArrayList(); + + public static void init(){ + addReturn(new ItemStack(Items.string), 100); + addReturn(new ItemStack(Items.diamond), 2); + addReturn(new ItemStack(Items.name_tag), 1); + addReturn(new ItemStack(Items.fish), 80); + addReturn(new ItemStack(Items.fish, 1, 1), 60); + addReturn(new ItemStack(Items.fish, 1, 2), 10); + addReturn(new ItemStack(Items.fish, 1, 3), 40); + addReturn(new ItemStack(Items.feather), 60); + addReturn(new ItemStack(Items.leather), 30); + addReturn(new ItemStack(Items.dye), 70); + addReturn(new ItemStack(Items.clay_ball), 40); + addReturn(new ItemStack(Items.stick), 40); + addReturn(new ItemStack(Items.iron_ingot), 10); + addReturn(new ItemStack(Items.gold_ingot), 6); + addReturn(new ItemStack(Items.beef), 30); + addReturn(new ItemStack(Items.ender_pearl), 2); + addReturn(new ItemStack(Blocks.planks), 20); + addReturn(new ItemStack(Blocks.waterlily), 10); + addReturn(new ItemStack(Items.experience_bottle), 3); + addReturn(new ItemStack(Blocks.gravel), 40); + addReturn(new ItemStack(Blocks.sand), 50); + addReturn(new ItemStack(Blocks.vine), 30); + addReturn(new ItemStack(Blocks.web), 4); + addReturn(new ItemStack(InitItems.itemSpecialDrop, 1, TheSpecialDrops.SOLIDIFIED_EXPERIENCE.ordinal()), 20); + addReturn(new ItemStack(InitItems.itemSpecialDrop, 1, TheSpecialDrops.EMERALD_SHARD.ordinal()), 10); + addReturn(new ItemStack(InitItems.itemSpecialDrop, 1, TheSpecialDrops.PEARL_SHARD.ordinal()), 10); + } + + public static void addReturn(ItemStack stack, int chance){ + returns.add(new Return(stack, chance)); + } + + public static class Return extends WeightedRandom.Item{ + + public ItemStack returnItem; + public ItemStack inputItem; + + public Return(ItemStack returnItem, int chance){ + super(chance); + this.returnItem = returnItem; + this.inputItem = new ItemStack(InitItems.itemHairyBall); + } + + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/IPowerAcceptor.java b/src/main/java/ellpeck/actuallyadditions/tile/IPowerAcceptor.java deleted file mode 100644 index 4c4f46d19..000000000 --- a/src/main/java/ellpeck/actuallyadditions/tile/IPowerAcceptor.java +++ /dev/null @@ -1,12 +0,0 @@ -package ellpeck.actuallyadditions.tile; - -public interface IPowerAcceptor{ - - void setBlockMetadataToOn(); - - void setPower(int power); - - void setItemPower(int power); - - int getItemPower(); -} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java index cfde380a7..b6bf4319e 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java @@ -4,7 +4,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -16,15 +15,14 @@ public class TileEntityBase extends TileEntity{ @Override public Packet getDescriptionPacket(){ - NBTTagCompound compound = new NBTTagCompound(); - this.writeToNBT(compound); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), compound); + NBTTagCompound tag = new NBTTagCompound(); + this.writeToNBT(tag); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet){ - super.onDataPacket(net, packet); - this.readFromNBT(packet.func_148857_g()); + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ + this.readFromNBT(pkt.func_148857_g()); } public static void init(){ @@ -45,10 +43,26 @@ public class TileEntityBase extends TileEntity{ GameRegistry.registerTileEntity(TileEntityInputter.TileEntityInputterAdvanced.class, ModUtil.MOD_ID_LOWER + ":tileEntityInputterAdvanced"); GameRegistry.registerTileEntity(TileEntityBreaker.TileEntityPlacer.class, ModUtil.MOD_ID_LOWER + ":tileEntityPlacer"); GameRegistry.registerTileEntity(TileEntityGrinder.TileEntityGrinderDouble.class, ModUtil.MOD_ID_LOWER + ":tileEntityGrinderDouble"); + GameRegistry.registerTileEntity(TileEntityCanolaPress.class, ModUtil.MOD_ID_LOWER + ":tileEntityCanolaPress"); + GameRegistry.registerTileEntity(TileEntityFermentingBarrel.class, ModUtil.MOD_ID_LOWER + ":tileEntityFermentingBarrel"); + GameRegistry.registerTileEntity(TileEntityOilGenerator.class, ModUtil.MOD_ID_LOWER + ":tileEntityOilGenerator"); + GameRegistry.registerTileEntity(TileEntityCoalGenerator.class, ModUtil.MOD_ID_LOWER + ":tileEntityCoalGenerator"); + GameRegistry.registerTileEntity(TileEntityPhantomface.TileEntityPhantomItemface.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomItemface"); + GameRegistry.registerTileEntity(TileEntityPhantomface.TileEntityPhantomLiquiface.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomLiquiface"); + GameRegistry.registerTileEntity(TileEntityPhantomface.TileEntityPhantomEnergyface.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomEnergyface"); + GameRegistry.registerTileEntity(TileEntityPhantomPlacer.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomPlacer"); + GameRegistry.registerTileEntity(TileEntityPhantomPlacer.TileEntityPhantomBreaker.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomBreaker"); + GameRegistry.registerTileEntity(TileEntityFluidCollector.class, ModUtil.MOD_ID_LOWER + ":tileEntityFluidCollector"); + GameRegistry.registerTileEntity(TileEntityFluidCollector.TileEntityFluidPlacer.class, ModUtil.MOD_ID_LOWER + ":tileEntityFluidPlacer"); + GameRegistry.registerTileEntity(TileEntityLavaFactoryController.class, ModUtil.MOD_ID_LOWER + ":tileEntityLavaFactoryController"); + GameRegistry.registerTileEntity(TileEntityCoffeeMachine.class, ModUtil.MOD_ID_LOWER + ":tileEntityCoffeeMachine"); + GameRegistry.registerTileEntity(TileEntityPhantomBooster.class, ModUtil.MOD_ID_LOWER + ":tileEntityPhantomBooster"); + GameRegistry.registerTileEntity(TileEntityEnergizer.class, ModUtil.MOD_ID_LOWER + ":tileEntityEnergizer"); + GameRegistry.registerTileEntity(TileEntityEnervator.class, ModUtil.MOD_ID_LOWER + ":tileEntityEnervator"); } @Override public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z){ - return newBlock == null || newBlock instanceof BlockAir; + return !(oldBlock.isAssociatedBlock(newBlock)); } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java index 27ef4bfb3..4a799dce7 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java @@ -3,7 +3,6 @@ package ellpeck.actuallyadditions.tile; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChunkCoordinates; @@ -54,18 +53,17 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ int meta = worldObj.getBlockMetadata(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ); drops.addAll(blockToBreak.getDrops(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ, meta, 0)); - if(this.addToInventory(drops, false)){ + if(addToInventory(this.slots, drops, false)){ worldObj.playAuxSFX(2001, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ, Block.getIdFromBlock(blockToBreak) + (meta << 12)); WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); - this.addToInventory(drops, true); + addToInventory(this.slots, drops, true); this.markDirty(); } } - else if(this.isPlacer && (worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ))){ - ItemStack removeFalse = this.removeFromInventory(false); - if(removeFalse != null && Block.getBlockFromItem(removeFalse.getItem()) != blockToBreak && WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, removeFalse)){ - this.removeFromInventory(true); - } + else if(this.isPlacer && worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ)){ + int theSlot = testInventory(this.slots); + this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, this.slots[theSlot])); + if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null; } } } @@ -87,15 +85,15 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ this.currentTime = compound.getInteger("CurrentTime"); } - public boolean addToInventory(ArrayList stacks, boolean actuallyDo){ + public static boolean addToInventory(ItemStack[] slots, ArrayList stacks, boolean actuallyDo){ int working = 0; for(ItemStack stack : stacks){ - for(int i = 0; i < this.slots.length; i++){ - if(this.slots[i] == null || (this.slots[i].isItemEqual(stack) && this.slots[i].stackSize <= stack.getMaxStackSize()-stack.stackSize)){ + for(int i = 0; i < slots.length; i++){ + if(slots[i] == null || (slots[i].isItemEqual(stack) && slots[i].stackSize <= stack.getMaxStackSize()-stack.stackSize)){ working++; if(actuallyDo){ - if(this.slots[i] == null) this.slots[i] = stack.copy(); - else this.slots[i].stackSize += stack.stackSize; + if(slots[i] == null) slots[i] = stack.copy(); + else slots[i].stackSize += stack.stackSize; } break; } @@ -104,18 +102,13 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ return working >= stacks.size(); } - public ItemStack removeFromInventory(boolean actuallyDo){ - for(int i = 0; i < this.slots.length; i++){ - if(this.slots[i] != null && !(Block.getBlockFromItem(this.slots[i].getItem()) instanceof BlockAir)){ - ItemStack slot = this.slots[i].copy(); - if(actuallyDo){ - this.slots[i].stackSize--; - if(this.slots[i].stackSize <= 0) this.slots[i] = null; - } - return slot; + public static int testInventory(ItemStack[] slots){ + for(int i = 0; i < slots.length; i++){ + if(slots[i] != null){ + return i; } } - return null; + return 0; } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java new file mode 100644 index 000000000..31fbf5d2c --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java @@ -0,0 +1,170 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler{ + + public EnergyStorage storage = new EnergyStorage(40000); + + public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); + + public static int energyUsedPerTick = ConfigIntValues.PRESS_ENERGY_USED.getValue(); + public int mbProducedPerCanola = ConfigIntValues.PRESS_MB_PRODUCED.getValue(); + + public int maxTimeProcessing = ConfigIntValues.PRESS_PROCESSING_TIME.getValue(); + public int currentProcessTime; + + public TileEntityCanolaPress(){ + super(3, "canolaPress"); + } + + @Override + @SuppressWarnings("unchecked") + public void updateEntity(){ + if(!worldObj.isRemote){ + if(this.isCanola(0) && this.mbProducedPerCanola <= this.tank.getCapacity()-this.tank.getFluidAmount()){ + if(this.storage.getEnergyStored() >= energyUsedPerTick){ + this.currentProcessTime++; + this.storage.extractEnergy(energyUsedPerTick, false); + if(this.currentProcessTime >= this.maxTimeProcessing){ + this.currentProcessTime = 0; + + this.slots[0].stackSize--; + if(this.slots[0].stackSize == 0) this.slots[0] = null; + + this.tank.fill(new FluidStack(InitBlocks.fluidCanolaOil, mbProducedPerCanola), true); + this.markDirty(); + } + } + } + else this.currentProcessTime = 0; + + if(this.slots[1] != null && this.slots[1].getItem() == Items.bucket && this.slots[2] == null){ + if(this.tank.getFluidAmount() > 0 && this.tank.getFluid().getFluid() == InitBlocks.fluidCanolaOil && this.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){ + this.slots[2] = new ItemStack(InitItems.itemBucketCanolaOil); + this.slots[1].stackSize--; + if(this.slots[1].stackSize == 0) this.slots[1] = null; + this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); + } + } + + if(this.tank.getFluidAmount() > 0){ + WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.tank); + } + } + } + + public boolean isCanola(int slot){ + return this.slots[slot] != null && this.slots[slot].getItem() == InitItems.itemMisc && this.slots[slot].getItemDamage() == TheMiscItems.CANOLA.ordinal(); + } + + @SideOnly(Side.CLIENT) + public int getTankScaled(int i){ + return this.tank.getFluidAmount() * i / this.tank.getCapacity(); + } + + @SideOnly(Side.CLIENT) + public int getProcessScaled(int i){ + return this.currentProcessTime * i / this.maxTimeProcessing; + } + + @SideOnly(Side.CLIENT) + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + compound.setInteger("ProcessTime", this.currentProcessTime); + this.storage.writeToNBT(compound); + this.tank.writeToNBT(compound); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.currentProcessTime = compound.getInteger("ProcessTime"); + this.storage.readFromNBT(compound); + this.tank.readFromNBT(compound); + super.readFromNBT(compound); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal()) || (i == 1 && stack.getItem() == Items.bucket); + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return slot == 2 && FluidContainerRegistry.containsFluid(this.slots[0], new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME)); + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.receiveEnergy(maxReceive, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ + if(resource.getFluid() == InitBlocks.fluidCanolaOil) return this.tank.drain(resource.amount, doDrain); + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ + return this.tank.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid){ + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid){ + return from != ForgeDirection.UP; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from){ + return new FluidTankInfo[]{this.tank.getInfo()}; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java new file mode 100644 index 000000000..cad145cc6 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java @@ -0,0 +1,128 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyProvider; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider{ + + public EnergyStorage storage = new EnergyStorage(60000); + + public static int energyProducedPerTick = ConfigIntValues.COAL_GEN_ENERGY_PRODUCED.getValue(); + + public int maxBurnTime; + public int currentBurnTime; + + public TileEntityCoalGenerator(){ + super(1, "coalGenerator"); + } + + @Override + @SuppressWarnings("unchecked") + public void updateEntity(){ + if(!worldObj.isRemote){ + boolean flag = this.currentBurnTime > 0; + + if(this.currentBurnTime > 0){ + this.currentBurnTime--; + this.storage.receiveEnergy(energyProducedPerTick, false); + } + + if(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0){ + int burnTime = TileEntityFurnace.getItemBurnTime(this.slots[0]); + if(energyProducedPerTick*burnTime <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ + this.maxBurnTime = burnTime; + this.currentBurnTime = burnTime; + this.slots[0].stackSize--; + if(this.slots[0].stackSize == 0) this.slots[0] = this.slots[0].getItem().getContainerItem(this.slots[0]); + } + } + + if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); + } + + if(flag != this.currentBurnTime > 0){ + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if(meta == 1){ + if(!(this.currentBurnTime <= 0 && this.slots[0] != null && TileEntityFurnace.getItemBurnTime(this.slots[0]) > 0 && energyProducedPerTick*TileEntityFurnace.getItemBurnTime(this.slots[0]) <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN))) + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); + } + else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); + } + } + } + + @SideOnly(Side.CLIENT) + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); + } + + @SideOnly(Side.CLIENT) + public int getBurningScaled(int i){ + return this.currentBurnTime * i / this.maxBurnTime; + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + compound.setInteger("BurnTime", this.currentBurnTime); + compound.setInteger("MaxBurnTime", this.maxBurnTime); + this.storage.writeToNBT(compound); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.currentBurnTime = compound.getInteger("BurnTime"); + this.maxBurnTime = compound.getInteger("MaxBurnTime"); + this.storage.readFromNBT(compound); + super.readFromNBT(compound); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return TileEntityFurnace.getItemBurnTime(stack) > 0; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return false; + } + + @Override + public int extractEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.extractEnergy(maxReceive, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java new file mode 100644 index 000000000..be3b7c1ab --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java @@ -0,0 +1,216 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.items.ItemCoffee; +import ellpeck.actuallyadditions.items.metalists.TheMiscItems; +import ellpeck.actuallyadditions.network.gui.IButtonReactor; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, IFluidHandler{ + + public static final int SLOT_COFFEE_BEANS = 0; + public static final int SLOT_INPUT = 1; + public static final int SLOT_OUTPUT = 2; + public static final int SLOT_WATER_INPUT = 11; + public static final int SLOT_WATER_OUTPUT = 12; + + public EnergyStorage storage = new EnergyStorage(300000); + public FluidTank tank = new FluidTank(4*FluidContainerRegistry.BUCKET_VOLUME); + + public static int energyUsePerTick = ConfigIntValues.COFFEE_MACHINE_ENERGY_USED.getValue(); + public final int waterUsedPerCoffee = 500; + + public final int coffeeCacheMaxAmount = 300; + public final int coffeeCacheAddPerItem = ConfigIntValues.COFFEE_CACHE_ADDED_PER_ITEM.getValue(); + public final int coffeeCacheUsePerItem = ConfigIntValues.COFFEE_CACHE_USED_PER_ITEM.getValue(); + public int coffeeCacheAmount; + + public final int maxBrewTime = ConfigIntValues.COFFEE_MACHINE_TIME_USED.getValue(); + public int brewTime; + + public TileEntityCoffeeMachine(){ + super(13, "coffeeMachine"); + } + + @Override + public void updateEntity(){ + if(!worldObj.isRemote){ + this.storeCoffee(); + + if(this.brewTime > 0 || this.worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ + this.brew(); + } + } + } + + public void storeCoffee(){ + if(this.slots[SLOT_COFFEE_BEANS] != null && this.slots[SLOT_COFFEE_BEANS].getItem() == InitItems.itemCoffeeBean){ + if(this.coffeeCacheAddPerItem <= this.coffeeCacheMaxAmount-this.coffeeCacheAmount){ + this.slots[SLOT_COFFEE_BEANS].stackSize--; + if(this.slots[SLOT_COFFEE_BEANS].stackSize <= 0) this.slots[SLOT_COFFEE_BEANS] = null; + this.coffeeCacheAmount += this.coffeeCacheAddPerItem; + } + } + + if(this.slots[SLOT_WATER_INPUT] != null && FluidContainerRegistry.containsFluid(this.slots[SLOT_WATER_INPUT], new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME)) && (this.slots[SLOT_WATER_OUTPUT] == null || (this.slots[SLOT_WATER_OUTPUT].stackSize < this.slots[SLOT_WATER_OUTPUT].getMaxStackSize()))){ + if(FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){ + if(this.slots[SLOT_WATER_OUTPUT] == null) this.slots[SLOT_WATER_OUTPUT] = new ItemStack(Items.bucket); + else this.slots[SLOT_WATER_OUTPUT].stackSize++; + this.slots[SLOT_WATER_INPUT] = null; + this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true); + } + } + } + + public void brew(){ + if(!worldObj.isRemote){ + if(this.slots[SLOT_INPUT] != null && this.slots[SLOT_INPUT].getItem() == InitItems.itemMisc && this.slots[SLOT_INPUT].getItemDamage() == TheMiscItems.CUP.ordinal() && this.slots[SLOT_OUTPUT] == null && this.coffeeCacheAmount >= this.coffeeCacheUsePerItem && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= this.waterUsedPerCoffee){ + if(this.storage.getEnergyStored() >= energyUsePerTick){ + this.brewTime++; + this.storage.extractEnergy(energyUsePerTick, false); + if(this.brewTime >= this.maxBrewTime){ + this.brewTime = 0; + ItemStack output = new ItemStack(InitItems.itemCoffee); + for(int i = 3; i < this.slots.length-2; i++){ + if(this.slots[i] != null){ + ItemCoffee.Ingredient ingredient = ItemCoffee.getIngredientFromStack(this.slots[i]); + if(ingredient != null){ + if(ingredient.effect(output)){ + this.slots[i].stackSize--; + if(this.slots[i].stackSize <= 0) this.slots[i] = this.slots[i].getItem().getContainerItem(this.slots[i]); + } + } + } + } + this.slots[SLOT_OUTPUT] = output.copy(); + this.slots[SLOT_INPUT].stackSize--; + if(this.slots[SLOT_INPUT].stackSize <= 0) this.slots[SLOT_INPUT] = null; + this.coffeeCacheAmount -= this.coffeeCacheUsePerItem; + this.tank.drain(this.waterUsedPerCoffee, true); + } + } + } + else this.brewTime = 0; + } + } + + @SideOnly(Side.CLIENT) + public int getCoffeeScaled(int i){ + return this.coffeeCacheAmount * i / this.coffeeCacheMaxAmount; + } + + @SideOnly(Side.CLIENT) + public int getWaterScaled(int i){ + return this.tank.getFluidAmount() * i / this.tank.getCapacity(); + } + + @SideOnly(Side.CLIENT) + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); + } + + @SideOnly(Side.CLIENT) + public int getBrewScaled(int i){ + return this.brewTime * i / this.maxBrewTime; + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + super.writeToNBT(compound); + this.storage.writeToNBT(compound); + this.tank.writeToNBT(compound); + compound.setInteger("Cache", this.coffeeCacheAmount); + compound.setInteger("Time", this.brewTime); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + super.readFromNBT(compound); + this.storage.readFromNBT(compound); + this.tank.readFromNBT(compound); + this.coffeeCacheAmount = compound.getInteger("Cache"); + this.brewTime = compound.getInteger("Time"); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal()); + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.slots.length-2 && ItemCoffee.getIngredientFromStack(stack) == null) || slot == SLOT_WATER_OUTPUT; + } + + @Override + public void onButtonPressed(int buttonID, EntityPlayer player){ + if(buttonID == 0 && this.brewTime <= 0){ + this.brew(); + } + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.receiveEnergy(maxReceive, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ + return resource.getFluid() == FluidRegistry.WATER && from != ForgeDirection.DOWN ? this.tank.fill(resource, doFill) : 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid){ + return true; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid){ + return false; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from){ + return new FluidTankInfo[]{this.tank.getInfo()}; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java index 1959426ff..6bd5ae80d 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java @@ -24,9 +24,12 @@ public class TileEntityCompost extends TileEntityInventoryBase{ if(!worldObj.isRemote){ if(this.slots[0] != null && this.slots[0].stackSize > 0){ - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, this.slots[0].stackSize + (this.slots[0].getItem() instanceof ItemFertilizer ? 1 : 0), 2); + int toSet = this.slots[0].stackSize + (this.slots[0].getItem() instanceof ItemFertilizer ? 1 : 0); + if(worldObj.getBlockMetadata(xCoord, yCoord, zCoord) != toSet) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, toSet, 2); + } + else{ + if(worldObj.getBlockMetadata(xCoord, yCoord, zCoord) != 0) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); } - else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); boolean theFlag = this.conversionTime > 0; if(this.slots[0] != null && !(this.slots[0].getItem() instanceof ItemFertilizer) && this.slots[0].stackSize >= this.amountNeededToConvert){ diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java index eeed05a36..80ba33391 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java @@ -11,7 +11,10 @@ public class TileEntityDropper extends TileEntityInventoryBase{ private final int timeNeeded = ConfigIntValues.DROPPER_TIME_NEEDED.getValue(); private int currentTime; - @SuppressWarnings("unused") + public TileEntityDropper(int slots, String name){ + super(slots, name); + } + public TileEntityDropper(){ super(9, "dropper"); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java new file mode 100644 index 000000000..62f7d0f1d --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java @@ -0,0 +1,84 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyContainerItem; +import cofh.api.energy.IEnergyReceiver; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver{ + + public EnergyStorage storage = new EnergyStorage(500000); + + public TileEntityEnergizer(){ + super(2, "energizer"); + } + + @Override + public void updateEntity(){ + if(!worldObj.isRemote){ + if(this.slots[0] != null && this.slots[0].getItem() instanceof IEnergyContainerItem && this.slots[1] == null){ + if(this.storage.getEnergyStored() > 0){ + int received = ((IEnergyContainerItem)this.slots[0].getItem()).receiveEnergy(this.slots[0], this.storage.getEnergyStored(), false); + this.storage.extractEnergy(received, false); + } + + if(((IEnergyContainerItem)this.slots[0].getItem()).getEnergyStored(this.slots[0]) >= ((IEnergyContainerItem)this.slots[0].getItem()).getMaxEnergyStored(this.slots[0])){ + this.slots[1] = this.slots[0].copy(); + this.slots[0].stackSize--; + if(this.slots[0].stackSize <= 0) this.slots[0] = null; + } + } + } + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + this.storage.writeToNBT(compound); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.storage.readFromNBT(compound); + super.readFromNBT(compound); + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return slot == 0 && stack.getItem() instanceof IEnergyContainerItem; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return slot == 1; + } + + @SideOnly(Side.CLIENT) + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.receiveEnergy(maxReceive, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java new file mode 100644 index 000000000..a26b71c78 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java @@ -0,0 +1,94 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyContainerItem; +import cofh.api.energy.IEnergyProvider; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider{ + + public EnergyStorage storage = new EnergyStorage(500000); + + public TileEntityEnervator(){ + super(2, "enervator"); + } + + @Override + public void updateEntity(){ + if(!worldObj.isRemote){ + if(this.slots[0] != null && this.slots[0].getItem() instanceof IEnergyContainerItem && this.slots[1] == null){ + if(((IEnergyContainerItem)this.slots[0].getItem()).getEnergyStored(this.slots[0]) > 0){ + int toReceive = ((IEnergyContainerItem)this.slots[0].getItem()).extractEnergy(this.slots[0], this.storage.getMaxEnergyStored()-this.storage.getEnergyStored(), false); + this.storage.receiveEnergy(toReceive, false); + } + + if(((IEnergyContainerItem)this.slots[0].getItem()).getEnergyStored(this.slots[0]) <= 0){ + this.slots[1] = this.slots[0].copy(); + this.slots[0].stackSize--; + if(this.slots[0].stackSize <= 0) this.slots[0] = null; + } + } + + if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + this.storage.writeToNBT(compound); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.storage.readFromNBT(compound); + super.readFromNBT(compound); + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ + return this.storage.extractEnergy(maxExtract, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } + + @SideOnly(Side.CLIENT) + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return slot == 0 && stack.getItem() instanceof IEnergyContainerItem; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return slot == 1; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java new file mode 100644 index 000000000..3198d74c1 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java @@ -0,0 +1,148 @@ +package ellpeck.actuallyadditions.tile; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.items.InitItems; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class TileEntityFermentingBarrel extends TileEntityInventoryBase implements IFluidHandler{ + + public FluidTank canolaTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); + public FluidTank oilTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); + + public int currentProcessTime; + public int maxTimeProcessing = ConfigIntValues.BARREL_PROCESSING_TIME.getValue(); + + public int mBProducedPerCycle = ConfigIntValues.BARREL_MB_PRODUCED.getValue(); + + public TileEntityFermentingBarrel(){ + super(4, "fermentingBarrel"); + } + + @Override + @SuppressWarnings("unchecked") + public void updateEntity(){ + if(!worldObj.isRemote){ + if(this.canolaTank.getFluidAmount() >= this.mBProducedPerCycle && this.mBProducedPerCycle <= this.oilTank.getCapacity()-this.oilTank.getFluidAmount()){ + this.currentProcessTime++; + if(this.currentProcessTime >= this.maxTimeProcessing){ + this.currentProcessTime = 0; + + this.oilTank.fill(new FluidStack(InitBlocks.fluidOil, mBProducedPerCycle), true); + this.canolaTank.drain(mBProducedPerCycle, true); + this.markDirty(); + } + } + else this.currentProcessTime = 0; + + if(this.slots[0] != null && FluidContainerRegistry.containsFluid(this.slots[0], new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME)) && (this.slots[1] == null || (this.slots[1].stackSize < this.slots[1].getMaxStackSize()))){ + if(FluidContainerRegistry.BUCKET_VOLUME <= this.canolaTank.getCapacity()-this.canolaTank.getFluidAmount()){ + if(this.slots[1] == null) this.slots[1] = new ItemStack(Items.bucket); + else this.slots[1].stackSize++; + this.slots[0] = null; + this.canolaTank.fill(new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME), true); + } + } + + if(this.slots[2] != null && this.slots[2].getItem() == Items.bucket && this.slots[3] == null){ + if(this.oilTank.getFluidAmount() > 0 && this.oilTank.getFluid().getFluid() == InitBlocks.fluidOil && this.oilTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){ + this.slots[3] = new ItemStack(InitItems.itemBucketOil); + this.slots[2].stackSize--; + if(this.slots[2].stackSize == 0) this.slots[2] = null; + this.oilTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); + } + } + + if(this.oilTank.getFluidAmount() > 0){ + WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, this.oilTank); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + compound.setInteger("ProcessTime", this.currentProcessTime); + this.canolaTank.writeToNBT(compound); + NBTTagCompound tag = new NBTTagCompound(); + this.oilTank.writeToNBT(tag); + compound.setTag("OilTank", tag); + super.writeToNBT(compound); + } + + @SideOnly(Side.CLIENT) + public int getProcessScaled(int i){ + return this.currentProcessTime * i / this.maxTimeProcessing; + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.currentProcessTime = compound.getInteger("ProcessTime"); + this.canolaTank.readFromNBT(compound); + this.oilTank.readFromNBT((NBTTagCompound)compound.getTag("OilTank")); + super.readFromNBT(compound); + } + + @SideOnly(Side.CLIENT) + public int getOilTankScaled(int i){ + return this.oilTank.getFluidAmount() * i / this.oilTank.getCapacity(); + } + + @SideOnly(Side.CLIENT) + public int getCanolaTankScaled(int i){ + return this.canolaTank.getFluidAmount() * i / this.canolaTank.getCapacity(); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return (i == 0 && FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidCanolaOil, FluidContainerRegistry.BUCKET_VOLUME))) || (i == 2 && stack.getItem() == Items.bucket); + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return (slot == 1 && stack.getItem() == Items.bucket) || (slot == 3 && FluidContainerRegistry.containsFluid(this.slots[0], new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME))); + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ + if(from != ForgeDirection.DOWN && resource.getFluid() == InitBlocks.fluidCanolaOil) return this.canolaTank.fill(resource, doFill); + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ + if(resource.getFluid() == InitBlocks.fluidOil) return this.oilTank.drain(resource.amount, doDrain); + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ + return this.oilTank.drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid){ + return from != ForgeDirection.DOWN && fluid == InitBlocks.fluidCanolaOil; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid){ + return from != ForgeDirection.UP && fluid == InitBlocks.fluidOil; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from){ + return new FluidTankInfo[]{this.canolaTank.getInfo(), this.oilTank.getInfo()}; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java index d4d84c4f2..6139fc209 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java @@ -3,8 +3,13 @@ package ellpeck.actuallyadditions.tile; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.FishingHooks; +import net.minecraftforge.common.util.ForgeDirection; import java.util.Random; @@ -17,15 +22,44 @@ public class TileEntityFishingNet extends TileEntityBase{ @Override public void updateEntity(){ if(!worldObj.isRemote){ - if(worldObj.getBlock(xCoord, yCoord-1, zCoord).getMaterial() == Material.water){ - Random rand = new Random(); - if(this.timeUntilNextDrop > 0){ - this.timeUntilNextDrop--; - if(timeUntilNextDrop <= 0){ - worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord+0.5, yCoord+1.8, zCoord+0.5, FishingHooks.getRandomFishable(rand, this.worldObj.rand.nextFloat()))); + if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ + if(worldObj.getBlock(xCoord, yCoord - 1, zCoord).getMaterial() == Material.water){ + Random rand = new Random(); + if(this.timeUntilNextDrop > 0){ + this.timeUntilNextDrop--; + if(timeUntilNextDrop <= 0){ + ItemStack fishable = FishingHooks.getRandomFishable(rand, this.worldObj.rand.nextFloat()); + TileEntity tile = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord); + if(tile != null && tile instanceof IInventory){ + this.insertIntoInventory((IInventory)tile, fishable); + } + else{ + EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, fishable); + item.lifespan = 2000; + worldObj.spawnEntityInWorld(item); + } + } + } + else this.timeUntilNextDrop = this.timeUntilNextDropToSet + rand.nextInt(this.timeUntilNextDropToSet / 2); + } + } + } + } + + public void insertIntoInventory(IInventory inventory, ItemStack stack){ + for(int i = 0; i < inventory.getSizeInventory(); i++){ + if(inventory.isItemValidForSlot(i, stack)){ + if(!(inventory instanceof ISidedInventory) || ((ISidedInventory)inventory).canInsertItem(i, stack, ForgeDirection.DOWN.flag)){ + ItemStack slot = inventory.getStackInSlot(i); + if(slot == null){ + inventory.setInventorySlotContents(i, stack); + return; + } + if(slot.isItemEqual(stack) && slot.stackSize <= slot.getMaxStackSize() - stack.stackSize && slot.stackSize <= inventory.getInventoryStackLimit() - stack.stackSize){ + slot.stackSize += stack.stackSize; + return; } } - else this.timeUntilNextDrop = this.timeUntilNextDropToSet + rand.nextInt(this.timeUntilNextDropToSet/2); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java new file mode 100644 index 000000000..9e51d1ce4 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java @@ -0,0 +1,213 @@ +package ellpeck.actuallyadditions.tile; + +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.network.PacketFluidCollectorToClient; +import ellpeck.actuallyadditions.network.PacketHandler; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class TileEntityFluidCollector extends TileEntityInventoryBase implements IFluidHandler{ + + public FluidTank tank = new FluidTank(8*FluidContainerRegistry.BUCKET_VOLUME); + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ + if(this.isPlacer){ + this.sendPacket(); + return this.tank.fill(resource, doFill); + } + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ + if(!this.isPlacer){ + this.sendPacket(); + return this.tank.drain(resource.amount, doDrain); + } + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ + if(!this.isPlacer){ + this.sendPacket(); + return this.tank.drain(maxDrain, doDrain); + } + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid){ + return this.isPlacer; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid){ + return !this.isPlacer; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from){ + return new FluidTankInfo[]{this.tank.getInfo()}; + } + + public static class TileEntityFluidPlacer extends TileEntityFluidCollector{ + + public TileEntityFluidPlacer(){ + super(2, "fluidPlacer"); + this.isPlacer = true; + } + + } + + public boolean isPlacer; + + private final int timeNeeded = ConfigIntValues.BREAKER_TIME_NEEDED.getValue(); + private int currentTime; + + public TileEntityFluidCollector(int slots, String name){ + super(slots, name); + } + + public TileEntityFluidCollector(){ + super(2, "fluidCollector"); + this.isPlacer = false; + } + + @Override + @SuppressWarnings("unchecked") + public void updateEntity(){ + if(!worldObj.isRemote){ + + int amountBefore = this.tank.getFluidAmount(); + if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ + if(this.currentTime > 0){ + this.currentTime--; + if(this.currentTime <= 0){ + ForgeDirection sideToManipulate = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); + + ChunkCoordinates coordsBlock = WorldUtil.getCoordsFromSide(sideToManipulate, xCoord, yCoord, zCoord); + if(coordsBlock != null){ + Block blockToBreak = worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ); + if(!this.isPlacer && blockToBreak != null && worldObj.getBlockMetadata(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ) == 0){ + if(blockToBreak instanceof IFluidBlock && ((IFluidBlock)blockToBreak).getFluid() != null){ + if(this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){ + this.tank.fill(new FluidStack(((IFluidBlock)blockToBreak).getFluid(), FluidContainerRegistry.BUCKET_VOLUME), true); + WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); + } + } + else if(blockToBreak == Blocks.lava || blockToBreak == Blocks.flowing_lava){ + if(this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){ + this.tank.fill(new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME), true); + WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); + } + } + else if(blockToBreak == Blocks.water || blockToBreak == Blocks.flowing_water){ + if(this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), false) >= FluidContainerRegistry.BUCKET_VOLUME){ + this.tank.fill(new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME), true); + WorldUtil.breakBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord); + } + } + } + else if(this.isPlacer && worldObj.getBlock(coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ).isReplaceable(worldObj, coordsBlock.posX, coordsBlock.posY, coordsBlock.posZ)){ + if(this.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){ + if(this.tank.getFluid().getFluid().getBlock() != null){ + Block block = worldObj.getBlock(xCoord+sideToManipulate.offsetX, yCoord+sideToManipulate.offsetY, zCoord+sideToManipulate.offsetZ); + if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){ + WorldUtil.placeBlockAtSide(sideToManipulate, worldObj, xCoord, yCoord, zCoord, new ItemStack(this.tank.getFluid().getFluid().getBlock())); + this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); + } + } + } + } + } + } + } + else this.currentTime = this.timeNeeded; + } + + if(!this.isPlacer){ + if(this.slots[0] != null && this.slots[0].getItem() == Items.bucket && this.slots[1] == null){ + if(this.tank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME){ + this.slots[1] = FluidContainerRegistry.fillFluidContainer(this.tank.getFluid(), this.slots[0].copy()); + this.slots[0].stackSize--; + if(this.slots[0].stackSize == 0) this.slots[0] = null; + this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); + } + } + } + else{ + if(this.slots[0] != null && FluidContainerRegistry.isBucket(this.slots[0]) && !this.slots[0].isItemEqual(FluidContainerRegistry.EMPTY_BUCKET) && (this.slots[1] == null || this.slots[1].stackSize < this.slots[1].getMaxStackSize())){ + if(FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){ + if(this.slots[1] == null) this.slots[1] = new ItemStack(Items.bucket); + else this.slots[1].stackSize++; + this.tank.fill(FluidContainerRegistry.getFluidForFilledItem(this.slots[0]), true); + this.slots[0] = null; + } + } + } + + if(this.tank.getFluidAmount() > 0 && !this.isPlacer){ + WorldUtil.pushFluid(worldObj, xCoord, yCoord, zCoord, ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)).getOpposite(), this.tank); + } + + if(amountBefore != this.tank.getFluidAmount()){ + this.sendPacket(); + } + } + } + + public void sendPacket(){ + PacketHandler.theNetwork.sendToAllAround(new PacketFluidCollectorToClient(this.tank.getFluid(), this), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, this.xCoord, this.yCoord, this.zCoord, 120)); + } + + @SideOnly(Side.CLIENT) + public int getTankScaled(int i){ + return this.tank.getFluidAmount() * i / this.tank.getCapacity(); + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + super.writeToNBT(compound); + compound.setInteger("CurrentTime", this.currentTime); + this.tank.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + super.readFromNBT(compound); + this.currentTime = compound.getInteger("CurrentTime"); + this.tank.readFromNBT(compound); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + if(i == 0){ + if(this.isPlacer) return FluidContainerRegistry.isFilledContainer(stack); + else return stack.isItemEqual(FluidContainerRegistry.EMPTY_BUCKET); + } + return false; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return slot == 1; + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java index efdfb5363..ccfc31aa1 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java @@ -1,86 +1,75 @@ package ellpeck.actuallyadditions.tile; +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityFurnaceDouble extends TileEntityUpgradable implements IPowerAcceptor{ +public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver{ - public static final int SLOT_COAL = 0; - public static final int SLOT_INPUT_1 = 1; - public static final int SLOT_OUTPUT_1 = 2; - public static final int SLOT_INPUT_2 = 3; - public static final int SLOT_OUTPUT_2 = 4; + public static final int SLOT_INPUT_1 = 0; + public static final int SLOT_OUTPUT_1 = 1; + public static final int SLOT_INPUT_2 = 2; + public static final int SLOT_OUTPUT_2 = 3; - public int coalTime; - public int coalTimeLeft; + public EnergyStorage storage = new EnergyStorage(30000); - public int maxBurnTime = this.getStandardSpeed(); + public int energyUsePerTick = ConfigIntValues.FURNACE_ENERGY_USED.getValue(); + + public int maxBurnTime = ConfigIntValues.FURNACE_DOUBLE_SMELT_TIME.getValue(); public int firstSmeltTime; public int secondSmeltTime; public TileEntityFurnaceDouble(){ - super(6, "furnaceDouble"); - this.speedUpgradeSlot = 5; + super(4, "furnaceDouble"); } @Override @SuppressWarnings("unchecked") public void updateEntity(){ if(!worldObj.isRemote){ - this.speedUp(); - - boolean theFlag = this.coalTimeLeft > 0; - - if(this.coalTimeLeft > 0) this.coalTimeLeft -= 1+this.burnTimeAmplifier; + boolean flag = this.firstSmeltTime > 0 || this.secondSmeltTime > 0; boolean canSmeltOnFirst = this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1); boolean canSmeltOnSecond = this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2); - if((canSmeltOnFirst || canSmeltOnSecond) && this.coalTimeLeft <= 0 && this.slots[SLOT_COAL] != null){ - this.coalTime = TileEntityFurnace.getItemBurnTime(this.slots[SLOT_COAL]); - this.coalTimeLeft = this.coalTime; - if(this.coalTime > 0){ - this.slots[SLOT_COAL].stackSize--; - if(this.slots[SLOT_COAL].stackSize <= 0) this.slots[SLOT_COAL] = this.slots[SLOT_COAL].getItem().getContainerItem(this.slots[SLOT_COAL]); - } - } - if(this.coalTimeLeft > 0){ - if(canSmeltOnFirst){ + if(canSmeltOnFirst){ + if(this.storage.getEnergyStored() >= energyUsePerTick){ this.firstSmeltTime++; if(this.firstSmeltTime >= maxBurnTime){ this.finishBurning(SLOT_INPUT_1, SLOT_OUTPUT_1); this.firstSmeltTime = 0; } } - else this.firstSmeltTime = 0; + } + else this.firstSmeltTime = 0; - if(canSmeltOnSecond){ + if(canSmeltOnSecond){ + if(this.storage.getEnergyStored() >= energyUsePerTick){ this.secondSmeltTime++; if(this.secondSmeltTime >= maxBurnTime){ this.finishBurning(SLOT_INPUT_2, SLOT_OUTPUT_2); this.secondSmeltTime = 0; } } - else this.secondSmeltTime = 0; - } - else{ - this.firstSmeltTime = 0; - this.secondSmeltTime = 0; - this.coalTime = 0; } + else this.secondSmeltTime = 0; - if(theFlag != this.coalTimeLeft > 0){ - int metaBefore = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, (this.coalTimeLeft > 0 ? metaBefore+4 : metaBefore-4), 2); - this.markDirty(); + if(this.storage.getEnergyStored() >= energyUsePerTick && this.firstSmeltTime > 0 || this.secondSmeltTime > 0) this.storage.extractEnergy(energyUsePerTick, false); + + if(flag != (this.firstSmeltTime > 0 || this.secondSmeltTime > 0)){ + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if(meta > 3){ + if(!this.canSmeltOn(SLOT_INPUT_1, SLOT_OUTPUT_1) && !this.canSmeltOn(SLOT_INPUT_2, SLOT_OUTPUT_2)) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta-4, 2); + } + else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, meta+4, 2); } } @@ -112,24 +101,22 @@ public class TileEntityFurnaceDouble extends TileEntityUpgradable implements IPo @Override public void writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); - compound.setInteger("CoalTime", this.coalTime); - compound.setInteger("CoalTimeLeft", this.coalTimeLeft); compound.setInteger("FirstSmeltTime", this.firstSmeltTime); compound.setInteger("SecondSmeltTime", this.secondSmeltTime); + this.storage.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); - this.coalTime = compound.getInteger("CoalTime"); - this.coalTimeLeft = compound.getInteger("CoalTimeLeft"); this.firstSmeltTime = compound.getInteger("FirstSmeltTime"); this.secondSmeltTime = compound.getInteger("SecondSmeltTime"); + this.storage.readFromNBT(compound); } @SideOnly(Side.CLIENT) - public int getCoalTimeToScale(int i){ - return this.coalTimeLeft * i / this.coalTime; + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); } @SideOnly(Side.CLIENT) @@ -144,7 +131,7 @@ public class TileEntityFurnaceDouble extends TileEntityUpgradable implements IPo @Override public boolean isItemValidForSlot(int i, ItemStack stack){ - return i == SLOT_COAL && TileEntityFurnace.getItemBurnTime(stack) > 0 || (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && FurnaceRecipes.smelting().getSmeltingResult(stack) != null; + return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && FurnaceRecipes.smelting().getSmeltingResult(stack) != null; } @Override @@ -154,37 +141,26 @@ public class TileEntityFurnaceDouble extends TileEntityUpgradable implements IPo @Override public boolean canExtractItem(int slot, ItemStack stack, int side){ - return slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2 || (slot == SLOT_COAL && stack.getItem() == Items.bucket); + return slot == SLOT_OUTPUT_1 || slot == SLOT_OUTPUT_2; } @Override - public void setBlockMetadataToOn(){ - int metaBefore = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, metaBefore+4, 2); + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.receiveEnergy(maxReceive, simulate); } @Override - public void setPower(int power){ - this.coalTimeLeft = power; + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); } @Override - public void setItemPower(int power){ - this.coalTime = power; + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); } @Override - public int getItemPower(){ - return this.coalTime; - } - - @Override - public int getStandardSpeed(){ - return ConfigIntValues.FURNACE_DOUBLE_SMELT_TIME.getValue(); - } - - @Override - public void setSpeed(int newSpeed){ - this.maxBurnTime = newSpeed; + public boolean canConnectEnergy(ForgeDirection from){ + return true; } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java index 3b8fa4d91..14292535c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java @@ -1,44 +1,67 @@ package ellpeck.actuallyadditions.tile; -public class TileEntityFurnaceSolar extends TileEntityBase{ +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyProvider; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider{ @Override - public boolean canUpdate(){ - return false; + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ + return this.storage.extractEnergy(maxExtract, simulate); } - //TODO Reimplement + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } - /*@Override + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return from != ForgeDirection.UP; + } + + public EnergyStorage storage = new EnergyStorage(30000); + + public static int energyProducedPerTick = ConfigIntValues.FURNACE_SOLAR_ENERGY_PRODUCED.getValue(); + + @Override public void updateEntity(){ if(!worldObj.isRemote){ if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){ - TileEntity tileBelow = WorldUtil.getTileEntityFromSide(1, worldObj, xCoord, yCoord, zCoord); + if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ + this.storage.receiveEnergy(energyProducedPerTick, false); + this.markDirty(); + } + } - givePowerTo(tileBelow); + if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); } } } - public static void givePowerTo(TileEntity tile){ - if(tile instanceof IPowerAcceptor){ - IPowerAcceptor acceptor = (IPowerAcceptor)tile; - int coalTimeBefore = acceptor.getItemPower(); - acceptor.setItemPower(42); - acceptor.setPower(42); - if(coalTimeBefore == 0){ - acceptor.setBlockMetadataToOn(); - } - return; - } - if(tile instanceof TileEntityFurnace){ - TileEntityFurnace furnaceBelow = (TileEntityFurnace)tile; - int burnTimeBefore = furnaceBelow.furnaceBurnTime; - furnaceBelow.furnaceBurnTime = 42; - furnaceBelow.currentItemBurnTime = 42; - if(burnTimeBefore == 0){ - BlockFurnace.updateFurnaceBlockState(true, tile.getWorldObj(), furnaceBelow.xCoord, furnaceBelow.yCoord, furnaceBelow.zCoord); - } - } - }*/ + @Override + public void writeToNBT(NBTTagCompound compound){ + this.storage.writeToNBT(compound); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.storage.readFromNBT(compound); + super.readFromNBT(compound); + } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGiantChest.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGiantChest.java index 7d9c0dd33..e0951f09c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGiantChest.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGiantChest.java @@ -2,8 +2,6 @@ package ellpeck.actuallyadditions.tile; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; public class TileEntityGiantChest extends TileEntityInventoryBase{ @@ -11,36 +9,6 @@ public class TileEntityGiantChest extends TileEntityInventoryBase{ super(9*13, "giantChest"); } - @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - NBTTagList tagList = new NBTTagList(); - for(int currentIndex = 0; currentIndex < slots.length; ++currentIndex){ - if (slots[currentIndex] != null){ - NBTTagCompound tagCompound = new NBTTagCompound(); - //Too many slots to get saved as Byte - tagCompound.setShort("Slot", (short)currentIndex); - slots[currentIndex].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - compound.setTag("Items", tagList); - } - - @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); - NBTTagList tagList = compound.getTagList("Items", 10); - for (int i = 0; i < tagList.tagCount(); ++i){ - NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - //Too many slots to get saved as Byte - short slotIndex = tagCompound.getShort("Slot"); - if (slotIndex >= 0 && slotIndex < slots.length){ - slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } - @Override public boolean canUpdate(){ return false; diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java index c59eea2dc..9dbe59b54 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java @@ -2,15 +2,9 @@ package ellpeck.actuallyadditions.tile; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; import net.minecraft.block.BlockGrass; import net.minecraft.block.IGrowable; -import net.minecraft.init.Items; -import net.minecraft.item.ItemDye; -import net.minecraft.item.ItemStack; import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.WorldServer; -import net.minecraftforge.common.util.FakePlayerFactory; import java.util.Random; @@ -26,14 +20,14 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{ if(worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord) && worldObj.isDaytime()){ ChunkCoordinates blockToFert = this.blockToFertilize(); if(blockToFert != null){ - Random rand = new Random(); if(this.timeUntilNextFert > 0){ this.timeUntilNextFert--; if(timeUntilNextFert <= 0){ - this.applyBonemealEffect(blockToFert); + worldObj.getBlock(blockToFert.posX, blockToFert.posY, blockToFert.posZ).updateTick(worldObj, blockToFert.posX, blockToFert.posY, blockToFert.posZ, worldObj.rand); + worldObj.playAuxSFX(2005, blockToFert.posX, blockToFert.posY, blockToFert.posZ, 0); } } - else this.timeUntilNextFert = this.timeUntilNextFertToSet + rand.nextInt(this.timeUntilNextFertToSet/2); + else this.timeUntilNextFert = this.timeUntilNextFertToSet+new Random().nextInt(this.timeUntilNextFertToSet); } } } @@ -42,7 +36,7 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{ public ChunkCoordinates blockToFertilize(){ for(int i = yCoord-1; i > 0; i--){ Block block = worldObj.getBlock(xCoord, i, zCoord); - if(block != null && !(block instanceof BlockAir)){ + if(block != null && !(worldObj.isAirBlock(xCoord, i, zCoord))){ if(block instanceof IGrowable && !(block instanceof BlockGrass)){ return new ChunkCoordinates(xCoord, i, zCoord); } @@ -52,7 +46,4 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{ return null; } - public boolean applyBonemealEffect(ChunkCoordinates coords){ - return ItemDye.applyBonemeal(new ItemStack(Items.dye, 1, 15), worldObj, coords.posX, coords.posY, coords.posZ, FakePlayerFactory.getMinecraft((WorldServer)worldObj)); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java index 6c80adcdd..21dbf34cf 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java @@ -1,39 +1,60 @@ package ellpeck.actuallyadditions.tile; +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.recipe.GrinderRecipes; -import net.minecraft.init.Items; +import ellpeck.actuallyadditions.recipe.GrinderRecipeManualRegistry; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; import java.util.Random; -public class TileEntityGrinder extends TileEntityUpgradable implements IPowerAcceptor{ +public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver{ + + public EnergyStorage storage = new EnergyStorage(60000); + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.receiveEnergy(maxReceive, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } public static class TileEntityGrinderDouble extends TileEntityGrinder{ public TileEntityGrinderDouble(){ - super(8, "grinderDouble"); + super(6, "grinderDouble"); this.isDouble = true; - this.maxCrushTime = this.getStandardSpeed(); - this.speedUpgradeSlot = 7; + this.maxCrushTime = ConfigIntValues.GRINDER_DOUBLE_CRUSH_TIME.getValue(); + energyUsePerTick = ConfigIntValues.GRINDER_DOUBLE_ENERGY_USED.getValue(); } } - public static final int SLOT_COAL = 0; - public static final int SLOT_INPUT_1 = 1; - public static final int SLOT_OUTPUT_1_1 = 2; - public static final int SLOT_OUTPUT_1_2 = 3; - public static final int SLOT_INPUT_2 = 4; - public static final int SLOT_OUTPUT_2_1 = 5; - public static final int SLOT_OUTPUT_2_2 = 6; + public static final int SLOT_INPUT_1 = 0; + public static final int SLOT_OUTPUT_1_1 = 1; + public static final int SLOT_OUTPUT_1_2 = 2; + public static final int SLOT_INPUT_2 = 3; + public static final int SLOT_OUTPUT_2_1 = 4; + public static final int SLOT_OUTPUT_2_2 = 5; - public int coalTime; - public int coalTimeLeft; + public int energyUsePerTick; public int maxCrushTime; @@ -47,73 +68,62 @@ public class TileEntityGrinder extends TileEntityUpgradable implements IPowerAcc } public TileEntityGrinder(){ - super(5, "grinder"); + super(3, "grinder"); this.isDouble = false; - this.maxCrushTime = this.getStandardSpeed(); - this.speedUpgradeSlot = 4; + this.maxCrushTime = ConfigIntValues.GRINDER_CRUSH_TIME.getValue(); + energyUsePerTick = ConfigIntValues.GRINDER_ENERGY_USED.getValue(); } @Override @SuppressWarnings("unchecked") public void updateEntity(){ if(!worldObj.isRemote){ - this.speedUp(); - - boolean theFlag = this.coalTimeLeft > 0; - - if(this.coalTimeLeft > 0) this.coalTimeLeft -= 1+this.burnTimeAmplifier; + boolean flag = this.firstCrushTime > 0 || this.secondCrushTime > 0; boolean canCrushOnFirst = this.canCrushOn(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2); boolean canCrushOnSecond = false; if(this.isDouble) canCrushOnSecond = this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); - if((canCrushOnFirst || canCrushOnSecond) && this.coalTimeLeft <= 0 && this.slots[SLOT_COAL] != null){ - this.coalTime = TileEntityFurnace.getItemBurnTime(this.slots[SLOT_COAL]); - this.coalTimeLeft = this.coalTime; - if(this.coalTime > 0){ - this.slots[SLOT_COAL].stackSize--; - if(this.slots[SLOT_COAL].stackSize <= 0) this.slots[SLOT_COAL] = this.slots[SLOT_COAL].getItem().getContainerItem(this.slots[SLOT_COAL]); - } - } - - if(this.coalTimeLeft > 0){ - if(canCrushOnFirst){ + if(canCrushOnFirst){ + if(this.storage.getEnergyStored() >= energyUsePerTick){ this.firstCrushTime++; if(this.firstCrushTime >= maxCrushTime){ this.finishCrushing(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2); this.firstCrushTime = 0; } } - else this.firstCrushTime = 0; + } + else this.firstCrushTime = 0; - if(this.isDouble){ - if(canCrushOnSecond){ + if(this.isDouble){ + if(canCrushOnSecond){ + if(this.storage.getEnergyStored() >= energyUsePerTick){ this.secondCrushTime++; if(this.secondCrushTime >= maxCrushTime){ this.finishCrushing(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2); this.secondCrushTime = 0; } } - else this.secondCrushTime = 0; } - } - else{ - this.firstCrushTime = 0; - this.secondCrushTime = 0; - this.coalTime = 0; + else this.secondCrushTime = 0; } - if(theFlag != this.coalTimeLeft > 0){ - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, (this.coalTimeLeft > 0 ? 1 : 0), 2); - this.markDirty(); + if(this.storage.getEnergyStored() >= energyUsePerTick && this.firstCrushTime > 0 || this.secondCrushTime > 0) this.storage.extractEnergy(energyUsePerTick, false); + + if(flag != (this.firstCrushTime > 0 || this.secondCrushTime > 0)){ + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if(meta == 1){ + if(!this.canCrushOn(SLOT_INPUT_1, SLOT_OUTPUT_1_1, SLOT_OUTPUT_1_2) && (!this.isDouble || !this.canCrushOn(SLOT_INPUT_2, SLOT_OUTPUT_2_1, SLOT_OUTPUT_2_2))) worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); + } + else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); } } } public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput){ if(this.slots[theInput] != null){ - ItemStack outputOne = GrinderRecipes.instance().getOutput(this.slots[theInput], false); - ItemStack outputTwo = GrinderRecipes.instance().getOutput(this.slots[theInput], true); + ItemStack outputOne = GrinderRecipeManualRegistry.getOutput(this.slots[theInput], false); + ItemStack outputTwo = GrinderRecipeManualRegistry.getOutput(this.slots[theInput], true); if(this.slots[theInput] != null){ if(outputOne != null){ if((this.slots[theFirstOutput] == null || (this.slots[theFirstOutput].isItemEqual(outputOne) && this.slots[theFirstOutput].stackSize <= this.slots[theFirstOutput].getMaxStackSize()-outputOne.stackSize)) && (outputTwo == null || (this.slots[theSecondOutput] == null || (this.slots[theSecondOutput].isItemEqual(outputTwo) && this.slots[theSecondOutput].stackSize <= this.slots[theSecondOutput].getMaxStackSize()-outputTwo.stackSize)))){ @@ -126,12 +136,14 @@ public class TileEntityGrinder extends TileEntityUpgradable implements IPowerAcc } public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput){ - ItemStack outputOnFirst = GrinderRecipes.instance().getOutput(this.slots[theInput], false); - if (this.slots[theFirstOutput] == null) this.slots[theFirstOutput] = outputOnFirst.copy(); - else if(this.slots[theFirstOutput].getItem() == outputOnFirst.getItem()) this.slots[theFirstOutput].stackSize += outputOnFirst.stackSize; + ItemStack outputOnFirst = GrinderRecipeManualRegistry.getOutput(this.slots[theInput], false); + if(outputOnFirst != null){ + if(this.slots[theFirstOutput] == null) this.slots[theFirstOutput] = outputOnFirst.copy(); + else if(this.slots[theFirstOutput].getItem() == outputOnFirst.getItem()) this.slots[theFirstOutput].stackSize += outputOnFirst.stackSize; + } - int chance = GrinderRecipes.instance().getSecondChance(this.slots[theInput]); - ItemStack outputOnSecond = GrinderRecipes.instance().getOutput(this.slots[theInput], true); + int chance = GrinderRecipeManualRegistry.getSecondChance(this.slots[theInput]); + ItemStack outputOnSecond = GrinderRecipeManualRegistry.getOutput(this.slots[theInput], true); if(outputOnSecond != null){ int rand = new Random().nextInt(100) + 1; if(rand <= chance){ @@ -146,25 +158,23 @@ public class TileEntityGrinder extends TileEntityUpgradable implements IPowerAcc @Override public void writeToNBT(NBTTagCompound compound){ - compound.setInteger("CoalTime", this.coalTime); - compound.setInteger("CoalTimeLeft", this.coalTimeLeft); compound.setInteger("FirstCrushTime", this.firstCrushTime); compound.setInteger("SecondCrushTime", this.secondCrushTime); + this.storage.writeToNBT(compound); super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound){ - this.coalTime = compound.getInteger("CoalTime"); - this.coalTimeLeft = compound.getInteger("CoalTimeLeft"); this.firstCrushTime = compound.getInteger("FirstCrushTime"); this.secondCrushTime = compound.getInteger("SecondCrushTime"); + this.storage.readFromNBT(compound); super.readFromNBT(compound); } @SideOnly(Side.CLIENT) - public int getCoalTimeToScale(int i){ - return this.coalTimeLeft * i / this.coalTime; + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); } @SideOnly(Side.CLIENT) @@ -179,7 +189,7 @@ public class TileEntityGrinder extends TileEntityUpgradable implements IPowerAcc @Override public boolean isItemValidForSlot(int i, ItemStack stack){ - return i == SLOT_COAL && TileEntityFurnace.getItemBurnTime(stack) > 0 || (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && GrinderRecipes.instance().getOutput(stack, false) != null; + return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && GrinderRecipeManualRegistry.getOutput(stack, false) != null; } @Override @@ -189,36 +199,6 @@ public class TileEntityGrinder extends TileEntityUpgradable implements IPowerAcc @Override public boolean canExtractItem(int slot, ItemStack stack, int side){ - return slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2 || (slot == SLOT_COAL && stack.getItem() == Items.bucket); - } - - @Override - public void setBlockMetadataToOn(){ - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); - } - - @Override - public void setPower(int power){ - this.coalTimeLeft = power; - } - - @Override - public void setItemPower(int power){ - this.coalTime = power; - } - - @Override - public int getItemPower(){ - return this.coalTime; - } - - @Override - public int getStandardSpeed(){ - return this.isDouble ? ConfigIntValues.GRINDER_DOUBLE_CRUSH_TIME.getValue() : ConfigIntValues.GRINDER_CRUSH_TIME.getValue(); - } - - @Override - public void setSpeed(int newSpeed){ - this.maxCrushTime = newSpeed; + return slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2; } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java index eca959c5b..c383a7837 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java @@ -1,45 +1,75 @@ package ellpeck.actuallyadditions.tile; +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyProvider; import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityHeatCollector extends TileEntityBase{ +import java.util.ArrayList; +import java.util.Random; + +public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider{ private int randomChance = ConfigIntValues.HEAT_COLLECTOR_LAVA_CHANCE.getValue(); private int blocksNeeded = ConfigIntValues.HEAT_COLLECTOR_BLOCKS.getValue(); + public EnergyStorage storage = new EnergyStorage(30000); + + public static int energyProducedPerTick = ConfigIntValues.HEAT_COLLECTOR_ENERGY_PRODUCED.getValue(); + @Override - public boolean canUpdate(){ - return false; - } - - //TODO Reimplement - - /*@Override public void updateEntity(){ if(!worldObj.isRemote){ ArrayList blocksAround = new ArrayList(); - - for(int i = 1; i <= 5; i++){ - ChunkCoordinates coords = WorldUtil.getCoordsFromSide(i, xCoord, yCoord, zCoord); - if(coords != null){ - Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ); - if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0){ - blocksAround.add(i); + if(energyProducedPerTick <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ + for(int i = 1; i <= 5; i++){ + ChunkCoordinates coords = WorldUtil.getCoordsFromSide(WorldUtil.getDirectionByRotatingSide(i), xCoord, yCoord, zCoord); + if(coords != null){ + Block block = worldObj.getBlock(coords.posX, coords.posY, coords.posZ); + if(block != null && block.getMaterial() == Material.lava && worldObj.getBlockMetadata(coords.posX, coords.posY, coords.posZ) == 0){ + blocksAround.add(i); + } } } - } - if(blocksAround.size() >= blocksNeeded){ - TileEntity tileAbove = WorldUtil.getTileEntityFromSide(0, worldObj, xCoord, yCoord, zCoord); + if(blocksAround.size() >= blocksNeeded){ + this.storage.receiveEnergy(energyProducedPerTick, false); + this.markDirty(); - TileEntityFurnaceSolar.givePowerTo(tileAbove); - - Random rand = new Random(); - if(rand.nextInt(randomChance) == 0){ - int randomSide = blocksAround.get(rand.nextInt(blocksAround.size())); - WorldUtil.breakBlockAtSide(randomSide, worldObj, xCoord, yCoord, zCoord); + Random rand = new Random(); + if(rand.nextInt(randomChance) == 0){ + int randomSide = blocksAround.get(rand.nextInt(blocksAround.size())); + WorldUtil.breakBlockAtSide(WorldUtil.getDirectionByRotatingSide(randomSide), worldObj, xCoord, yCoord, zCoord); + } + } + if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, this.storage); } } } - }*/ + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ + return this.storage.extractEnergy(maxExtract, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return from == ForgeDirection.UP; + } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java index c96d5953f..7f307175f 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java @@ -1,38 +1,63 @@ package ellpeck.actuallyadditions.tile; +import ellpeck.actuallyadditions.network.gui.IButtonReactor; +import ellpeck.actuallyadditions.network.gui.INumberReactor; import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -public class TileEntityInputter extends TileEntityInventoryBase{ +public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor{ + + @Override + public void onNumberReceived(int text, int textID, EntityPlayer player){ + if(text != -1){ + if(textID == 0) this.slotToPutStart = text; + if(textID == 1) this.slotToPutEnd = text; + if(textID == 2) this.slotToPullStart = text; + if(textID == 3) this.slotToPullEnd = text; + } + this.markDirty(); + } public static class TileEntityInputterAdvanced extends TileEntityInputter{ public TileEntityInputterAdvanced(){ - super(13, "inputterAdvanced"); + super(25, "inputterAdvanced"); this.isAdvanced = true; } } - public static final int PUT_FILTER_START = 1; - public static final int PULL_FILTER_START = 7; + public static final int PUT_FILTER_START = 13; + public static final int PULL_FILTER_START = 1; + + public static final int WHITELIST_PULL_BUTTON_ID = 87; + public static final int WHITELIST_PUT_BUTTON_ID = 88; + public static final int OKAY_BUTTON_ID = 133; public int sideToPut = -1; - public int slotToPut = -1; - public int placeToPutSlotAmount; + + public int slotToPutStart; + public int slotToPutEnd; + public TileEntity placeToPut; public int sideToPull = -1; - public int slotToPull = -1; - public int placeToPullSlotAmount; + + public int slotToPullStart; + public int slotToPullEnd; + public TileEntity placeToPull; public boolean isAdvanced; + public boolean isPullWhitelist = true; + public boolean isPutWhitelist = true; + public TileEntityInputter(int slots, String name){ super(slots, name); } @@ -48,35 +73,39 @@ public class TileEntityInputter extends TileEntityInventoryBase{ this.initVars(); if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ - if(!(this.sideToPull == this.sideToPut && this.slotToPull == this.slotToPut)){ - if(sideToPull != -1) this.pull(); - if(sideToPut != -1) this.put(); + if(!(this.sideToPull == this.sideToPut && this.slotToPullStart == this.slotToPutStart && this.slotToPullEnd == this.slotToPutEnd)){ + if(sideToPull != -1 && this.placeToPull instanceof IInventory) this.pull(); + if(sideToPut != -1 && this.placeToPut instanceof IInventory) this.put(); } } } } public void pull(){ - if(this.placeToPullSlotAmount > 0){ - IInventory theInventory = (IInventory)placeToPull; - int theSlotToPull = this.slotToPull; + IInventory theInventory = (IInventory)placeToPull; + if(theInventory.getSizeInventory() > 0){ + int theSlotToPull = this.slotToPullStart; int maxSize = theInventory.getInventoryStackLimit(); ISidedInventory theSided = null; if(theInventory instanceof ISidedInventory) theSided = (ISidedInventory)theInventory; + boolean can = false; ItemStack theStack = null; - for(int i = (theSlotToPull != -1 ? theSlotToPull : 0); i < (theSlotToPull != -1 ? theSlotToPull+1 : placeToPullSlotAmount); i++){ + for(int i = theSlotToPull; i < this.slotToPullEnd; i++){ + if(i >= theInventory.getSizeInventory()) return; + ItemStack tempStack = theInventory.getStackInSlot(i); if(tempStack != null){ if(tempStack.getMaxStackSize() < this.getInventoryStackLimit()) maxSize = tempStack.getMaxStackSize(); else maxSize = this.getInventoryStackLimit(); } - if(tempStack != null && (this.slots[0] == null || (tempStack.isItemEqual(this.slots[0]) && this.slots[0].stackSize < maxSize)) && this.checkFilters(tempStack, true)){ + if(tempStack != null && (this.slots[0] == null || (tempStack.isItemEqual(this.slots[0]) && this.slots[0].stackSize < maxSize)) && this.checkFilters(tempStack, true, isPullWhitelist)){ if(theSided != null){ for(int j = 0; j < 5; j++){ if(theSided.canExtractItem(i, tempStack, j)){ theStack = tempStack; theSlotToPull = i; + can = true; break; } } @@ -84,11 +113,12 @@ public class TileEntityInputter extends TileEntityInventoryBase{ else{ theStack = tempStack; theSlotToPull = i; - break; + can = true; } } + if(can) break; } - if(theStack != null){ + if(can){ if(this.slots[0] != null){ if(theStack.isItemEqual(this.slots[0])){ if(theStack.stackSize <= maxSize - this.slots[0].stackSize){ @@ -113,9 +143,9 @@ public class TileEntityInputter extends TileEntityInventoryBase{ } public void put(){ - if(this.placeToPutSlotAmount > 0){ - IInventory theInventory = (IInventory)placeToPut; - int theSlotToPut = this.slotToPut; + IInventory theInventory = (IInventory)placeToPut; + if(theInventory.getSizeInventory() > 0){ + int theSlotToPut = this.slotToPutStart; int maxSize = theInventory.getInventoryStackLimit(); ISidedInventory theSided = null; if(theInventory instanceof ISidedInventory) theSided = (ISidedInventory)theInventory; @@ -123,13 +153,15 @@ public class TileEntityInputter extends TileEntityInventoryBase{ if(this.slots[0] != null){ ItemStack theStack = null; - for(int i = (theSlotToPut != -1 ? theSlotToPut : 0); i < (theSlotToPut != -1 ? theSlotToPut+1 : placeToPutSlotAmount); i++){ + for(int i = theSlotToPut; i < this.slotToPutEnd; i++){ + if(i >= theInventory.getSizeInventory()) return; + ItemStack tempStack = theInventory.getStackInSlot(i); if(tempStack != null){ if(tempStack.getMaxStackSize() < theInventory.getInventoryStackLimit()) maxSize = tempStack.getMaxStackSize(); else maxSize = theInventory.getInventoryStackLimit(); } - if((tempStack == null || (theInventory.isItemValidForSlot(i, this.slots[0]) && tempStack.isItemEqual(this.slots[0]) && tempStack.stackSize < maxSize)) && this.checkFilters(this.slots[0], false)){ + if((tempStack == null || (theInventory.isItemValidForSlot(i, this.slots[0]) && tempStack.isItemEqual(this.slots[0]) && tempStack.stackSize < maxSize)) && this.checkFilters(this.slots[0], false, isPutWhitelist)){ if(theSided != null){ for(int j = 0; j < 5; j++){ if(theSided.canInsertItem(i, this.slots[0], j)){ @@ -144,9 +176,9 @@ public class TileEntityInputter extends TileEntityInventoryBase{ theStack = tempStack; theSlotToPut = i; can = true; - break; } } + if(can) break; } if(can){ if(theStack != null){ @@ -173,16 +205,16 @@ public class TileEntityInputter extends TileEntityInventoryBase{ } } - public boolean checkFilters(ItemStack stack, boolean isPull){ + public boolean checkFilters(ItemStack stack, boolean isPull, boolean isWhitelist){ if(!this.isAdvanced) return true; int slotStart = isPull ? PULL_FILTER_START : PUT_FILTER_START; - int slotStop = slotStart+6; + int slotStop = slotStart+12; for(int i = slotStart; i < slotStop; i++){ - if(this.slots[i] != null && this.slots[i].isItemEqual(stack)) return true; + if(this.slots[i] != null && this.slots[i].isItemEqual(stack)) return isWhitelist; } - return false; + return !isWhitelist; } public void initVars(){ @@ -190,62 +222,74 @@ public class TileEntityInputter extends TileEntityInventoryBase{ this.placeToPull = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionByRotatingSide(this.sideToPull), this.worldObj, this.xCoord, this.yCoord, this.zCoord); this.placeToPut = WorldUtil.getTileEntityFromSide(WorldUtil.getDirectionByRotatingSide(this.sideToPut), this.worldObj, this.xCoord, this.yCoord, this.zCoord); - if(this.placeToPull != null && this.placeToPull instanceof IInventory){ - this.placeToPullSlotAmount = ((IInventory)this.placeToPull).getSizeInventory(); + if(this.placeToPull instanceof IInventory){ + if(this.slotToPullEnd <= 0) this.slotToPullEnd = ((IInventory)this.placeToPull).getSizeInventory(); } - else{ - this.placeToPullSlotAmount = 0; - this.slotToPull = -1; - } - - if(this.placeToPut != null && this.placeToPut instanceof IInventory){ - this.placeToPutSlotAmount = ((IInventory)this.placeToPut).getSizeInventory(); - } - else{ - this.placeToPutSlotAmount = 0; - this.slotToPut = -1; + if(this.placeToPut instanceof IInventory){ + if(this.slotToPutEnd <= 0) this.slotToPutEnd = ((IInventory)this.placeToPut).getSizeInventory(); } } - public void onButtonPressed(int buttonID){ + @Override + public void onButtonPressed(int buttonID, EntityPlayer player){ + if(buttonID == WHITELIST_PULL_BUTTON_ID){ + this.isPullWhitelist = !this.isPullWhitelist; + return; + } + if(buttonID == WHITELIST_PUT_BUTTON_ID){ + this.isPutWhitelist = !this.isPutWhitelist; + return; + } + + if(buttonID == 0 || buttonID == 1){ + this.slotToPutStart = 0; + this.slotToPutEnd = 0; + } + if(buttonID == 2 || buttonID == 3){ + this.slotToPullStart = 0; + this.slotToPullEnd = 0; + } + if(buttonID == 0) this.sideToPut++; if(buttonID == 1) this.sideToPut--; - if(buttonID == 2) this.slotToPut++; - if(buttonID == 3) this.slotToPut--; - if(buttonID == 4) this.sideToPull++; - if(buttonID == 5) this.sideToPull--; - if(buttonID == 6) this.slotToPull++; - if(buttonID == 7) this.slotToPull--; + if(buttonID == 2) this.sideToPull++; + if(buttonID == 3) this.sideToPull--; if(this.sideToPut >= 6) this.sideToPut = -1; else if(this.sideToPut < -1) this.sideToPut = 5; else if(this.sideToPull >= 6) this.sideToPull = -1; else if(this.sideToPull < -1) this.sideToPull = 5; - else if(this.slotToPut >= this.placeToPutSlotAmount) this.slotToPut = -1; - else if(this.slotToPut < -1) this.slotToPut = this.placeToPutSlotAmount-1; - else if(this.slotToPull >= this.placeToPullSlotAmount) this.slotToPull = -1; - else if(this.slotToPull < -1) this.slotToPull = this.placeToPullSlotAmount-1; + + this.markDirty(); } @Override public void writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); compound.setInteger("SideToPut", this.sideToPut); - compound.setInteger("SlotToPut", this.slotToPut); + compound.setInteger("SlotToPut", this.slotToPutStart); + compound.setInteger("SlotToPutEnd", this.slotToPutEnd); compound.setInteger("SideToPull", this.sideToPull); - compound.setInteger("SlotToPull", this.slotToPull); + compound.setInteger("SlotToPull", this.slotToPullStart); + compound.setInteger("SlotToPullEnd", this.slotToPullEnd); + compound.setBoolean("PullWhitelist", this.isPullWhitelist); + compound.setBoolean("PutWhitelist", this.isPutWhitelist); } @Override public void readFromNBT(NBTTagCompound compound){ this.sideToPut = compound.getInteger("SideToPut"); - this.slotToPut = compound.getInteger("SlotToPut"); + this.slotToPutStart = compound.getInteger("SlotToPut"); + this.slotToPutEnd = compound.getInteger("SlotToPutEnd"); this.sideToPull = compound.getInteger("SideToPull"); - this.slotToPull = compound.getInteger("SlotToPull"); + this.slotToPullStart = compound.getInteger("SlotToPull"); + this.slotToPullEnd = compound.getInteger("SlotToPullEnd"); + this.isPullWhitelist = compound.getBoolean("PullWhitelist"); + this.isPutWhitelist = compound.getBoolean("PutWhitelist"); super.readFromNBT(compound); } - + @Override public boolean isItemValidForSlot(int i, ItemStack stack){ return i == 0; @@ -260,4 +304,4 @@ public class TileEntityInputter extends TileEntityInventoryBase{ public boolean canExtractItem(int slot, ItemStack stack, int side){ return slot == 0; } -} +} \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java index 2ecc4bc2d..23657083e 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java @@ -20,27 +20,31 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements @Override public void writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); - NBTTagList tagList = new NBTTagList(); - for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){ - if (slots[currentIndex] != null){ - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)currentIndex); - slots[currentIndex].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); + if(this.slots.length > 0){ + NBTTagList tagList = new NBTTagList(); + for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){ + if(slots[currentIndex] != null){ + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)currentIndex); + slots[currentIndex].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } } + compound.setTag("Items", tagList); } - compound.setTag("Items", tagList); } @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); - NBTTagList tagList = compound.getTagList("Items", 10); - for (int i = 0; i < tagList.tagCount(); i++){ - NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - byte slotIndex = tagCompound.getByte("Slot"); - if (slotIndex >= 0 && slotIndex < slots.length){ - slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + if(this.slots.length > 0){ + NBTTagList tagList = compound.getTagList("Items", 10); + for(int i = 0; i < tagList.tagCount(); i++){ + NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); + byte slotIndex = tagCompound.getByte("Slot"); + if(slotIndex >= 0 && slotIndex < slots.length){ + slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + } } } } @@ -78,7 +82,10 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements @Override public ItemStack getStackInSlot(int i){ - return slots[i]; + if(i < this.getSizeInventory()){ + return slots[i]; + } + return null; } @Override @@ -127,10 +134,13 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements @Override public int[] getAccessibleSlotsFromSide(int side){ - int[] theInt = new int[slots.length]; - for(int i = 0; i < theInt.length; i++){ - theInt[i] = i; + if(this.slots.length > 0){ + int[] theInt = new int[slots.length]; + for(int i = 0; i < theInt.length; i++){ + theInt[i] = i; + } + return theInt; } - return theInt; + else return new int[0]; } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java index d7873dd15..05dddf589 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java @@ -1,68 +1,53 @@ package ellpeck.actuallyadditions.tile; +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityItemRepairer extends TileEntityInventoryBase implements IPowerAcceptor{ +public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver{ - public static final int SLOT_COAL = 0; - public static final int SLOT_INPUT = 1; - public static final int SLOT_OUTPUT = 2; + public static final int SLOT_INPUT = 0; + public static final int SLOT_OUTPUT = 1; + + public EnergyStorage storage = new EnergyStorage(300000); private final int speedSlowdown = ConfigIntValues.REPAIRER_SPEED_SLOWDOWN.getValue(); - public int coalTime; - public int coalTimeLeft; + public static int energyUsePerTick = ConfigIntValues.REPAIRER_ENERGY_USED.getValue(); public int nextRepairTick; public TileEntityItemRepairer(){ - super(3, "repairer"); + super(2, "repairer"); } @Override @SuppressWarnings("unchecked") public void updateEntity(){ if(!worldObj.isRemote){ - boolean theFlag = this.coalTimeLeft > 0; - - if(this.coalTimeLeft > 0) this.coalTimeLeft--; - - if(this.slots[SLOT_OUTPUT] == null){ - if(canBeRepaired(this.slots[SLOT_INPUT])){ - if(this.slots[SLOT_INPUT].getItemDamage() <= 0){ - this.slots[SLOT_OUTPUT] = this.slots[SLOT_INPUT].copy(); - this.slots[SLOT_INPUT] = null; - } - else{ - if(this.coalTimeLeft <= 0){ - this.coalTime = TileEntityFurnace.getItemBurnTime(this.slots[SLOT_COAL]); - this.coalTimeLeft = this.coalTime; - if(this.coalTime > 0){ - this.slots[SLOT_COAL].stackSize--; - if(this.slots[SLOT_COAL].stackSize <= 0) this.slots[SLOT_COAL] = this.slots[SLOT_COAL].getItem().getContainerItem(this.slots[SLOT_COAL]); - } - } - if(this.coalTimeLeft > 0){ - this.nextRepairTick++; - if(this.nextRepairTick >= this.speedSlowdown){ - this.nextRepairTick = 0; - this.slots[SLOT_INPUT].setItemDamage(this.slots[SLOT_INPUT].getItemDamage() - 1); - } + if(this.slots[SLOT_OUTPUT] == null && canBeRepaired(this.slots[SLOT_INPUT])){ + if(this.slots[SLOT_INPUT].getItemDamage() <= 0){ + this.slots[SLOT_OUTPUT] = this.slots[SLOT_INPUT].copy(); + this.slots[SLOT_INPUT] = null; + this.nextRepairTick = 0; + } + else{ + if(this.storage.getEnergyStored() >= energyUsePerTick){ + this.nextRepairTick++; + this.storage.extractEnergy(energyUsePerTick, false); + if(this.nextRepairTick >= this.speedSlowdown){ + this.nextRepairTick = 0; + this.slots[SLOT_INPUT].setItemDamage(this.slots[SLOT_INPUT].getItemDamage() - 1); } } } } - - if(theFlag != this.coalTimeLeft > 0){ - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, (this.coalTimeLeft > 0 ? 1 : 0), 2); - this.markDirty(); - } + else this.nextRepairTick = 0; } } @@ -72,23 +57,21 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I @Override public void writeToNBT(NBTTagCompound compound){ - compound.setInteger("CoalTime", this.coalTime); - compound.setInteger("CoalTimeLeft", this.coalTimeLeft); compound.setInteger("NextRepairTick", this.nextRepairTick); super.writeToNBT(compound); + this.storage.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound){ - this.coalTime = compound.getInteger("CoalTime"); - this.coalTimeLeft = compound.getInteger("CoalTimeLeft"); this.nextRepairTick = compound.getInteger("NextRepairTick"); super.readFromNBT(compound); + this.storage.readFromNBT(compound); } @SideOnly(Side.CLIENT) - public int getCoalTimeToScale(int i){ - return this.coalTimeLeft * i / this.coalTime; + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); } @SideOnly(Side.CLIENT) @@ -101,7 +84,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I @Override public boolean isItemValidForSlot(int i, ItemStack stack){ - return i == SLOT_COAL && TileEntityFurnace.getItemBurnTime(stack) > 0 || i == SLOT_INPUT; + return i == SLOT_INPUT; } @Override @@ -111,26 +94,26 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I @Override public boolean canExtractItem(int slot, ItemStack stack, int side){ - return slot == SLOT_OUTPUT || (slot == SLOT_COAL && stack.getItem() == Items.bucket); + return slot == SLOT_OUTPUT; } @Override - public void setBlockMetadataToOn(){ - worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.storage.receiveEnergy(maxReceive, simulate); } @Override - public void setPower(int power){ - this.coalTimeLeft = power; + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); } @Override - public void setItemPower(int power){ - this.coalTime = power; + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); } @Override - public int getItemPower(){ - return this.coalTime; + public boolean canConnectEnergy(ForgeDirection from){ + return true; } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java new file mode 100644 index 000000000..7ebae8bde --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java @@ -0,0 +1,99 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyReceiver{ + + public EnergyStorage storage = new EnergyStorage(3000000); + + public static int energyNeededToProduceLava = ConfigIntValues.LAVA_FACTORY_ENERGY_USED.getValue(); + + private final int maxWorkTime = ConfigIntValues.LAVA_FACTORY_TIME.getValue(); + private int currentWorkTime; + + @Override + @SuppressWarnings("unchecked") + public void updateEntity(){ + if(!worldObj.isRemote){ + if(this.storage.getEnergyStored() >= energyNeededToProduceLava && this.isMultiblock() == HAS_AIR){ + this.currentWorkTime++; + if(this.currentWorkTime >= this.maxWorkTime){ + this.currentWorkTime = 0; + worldObj.setBlock(xCoord, yCoord+1, zCoord, Blocks.lava); + this.storage.extractEnergy(energyNeededToProduceLava, false); + } + } + else this.currentWorkTime = 0; + } + } + + public int isMultiblock(){ + Block blockNorth = worldObj.getBlock(xCoord+ForgeDirection.NORTH.offsetX, yCoord+1, zCoord+ForgeDirection.NORTH.offsetZ); + Block blockEast = worldObj.getBlock(xCoord+ForgeDirection.EAST.offsetX, yCoord+1, zCoord+ForgeDirection.EAST.offsetZ); + Block blockSouth = worldObj.getBlock(xCoord+ForgeDirection.SOUTH.offsetX, yCoord+1, zCoord+ForgeDirection.SOUTH.offsetZ); + Block blockWest = worldObj.getBlock(xCoord+ForgeDirection.WEST.offsetX, yCoord+1, zCoord+ForgeDirection.WEST.offsetZ); + int metaNorth = worldObj.getBlockMetadata(xCoord+ForgeDirection.NORTH.offsetX, yCoord+1, zCoord+ForgeDirection.NORTH.offsetZ); + int metaEast = worldObj.getBlockMetadata(xCoord+ForgeDirection.EAST.offsetX, yCoord+1, zCoord+ForgeDirection.EAST.offsetZ); + int metaSouth = worldObj.getBlockMetadata(xCoord+ForgeDirection.SOUTH.offsetX, yCoord+1, zCoord+ForgeDirection.SOUTH.offsetZ); + int metaWest = worldObj.getBlockMetadata(xCoord+ForgeDirection.WEST.offsetX, yCoord+1, zCoord+ForgeDirection.WEST.offsetZ); + int metaNeeded = TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(); + + if(blockNorth == InitBlocks.blockMisc && blockEast == InitBlocks.blockMisc && blockSouth == InitBlocks.blockMisc && blockWest == InitBlocks.blockMisc){ + if(metaNorth == metaNeeded && metaEast == metaNeeded && metaSouth == metaNeeded && metaWest == metaNeeded){ + if(worldObj.getBlock(xCoord, yCoord+1, zCoord) == Blocks.lava || worldObj.getBlock(xCoord, yCoord+1, zCoord) == Blocks.flowing_lava){ + return HAS_LAVA; + } + if(worldObj.getBlock(xCoord, yCoord+1, zCoord) == null || worldObj.isAirBlock(xCoord, yCoord+1, zCoord)){ + return HAS_AIR; + } + } + } + return NOT_MULTI; + } + + public static final int NOT_MULTI = 0; + public static final int HAS_LAVA = 1; + public static final int HAS_AIR = 2; + + @Override + public void writeToNBT(NBTTagCompound compound){ + this.storage.writeToNBT(compound); + compound.setInteger("WorkTime", this.currentWorkTime); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.storage.readFromNBT(compound); + this.currentWorkTime = compound.getInteger("WorkTime"); + super.readFromNBT(compound); + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxExtract, boolean simulate){ + return from != ForgeDirection.UP ? this.storage.receiveEnergy(maxExtract, simulate) : 0; + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return from != ForgeDirection.UP ? this.storage.getEnergyStored() : 0; + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return from != ForgeDirection.UP ? this.storage.getMaxEnergyStored() : 0; + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return from != ForgeDirection.UP; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java new file mode 100644 index 000000000..78e01fa16 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java @@ -0,0 +1,178 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyProvider; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class TileEntityOilGenerator extends TileEntityInventoryBase implements IEnergyProvider, IFluidHandler{ + + public EnergyStorage storage = new EnergyStorage(50000); + + public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); + + public static int energyProducedPerTick = ConfigIntValues.OIL_GEN_ENERGY_PRODUCED.getValue(); + + public int fuelUsedPerBurnup = ConfigIntValues.OIL_GEN_FUEL_USED.getValue(); + public int maxBurnTime = ConfigIntValues.OIL_GEN_BURN_TIME.getValue(); + + public int currentBurnTime; + + public TileEntityOilGenerator(){ + super(2, "oilGenerator"); + } + + @Override + @SuppressWarnings("unchecked") + public void updateEntity(){ + if(!worldObj.isRemote){ + boolean flag = this.currentBurnTime > 0; + + if(this.currentBurnTime > 0){ + this.currentBurnTime--; + this.storage.receiveEnergy(energyProducedPerTick, false); + } + + if(energyProducedPerTick*this.maxBurnTime <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN)){ + if(this.currentBurnTime <= 0 && this.tank.getFluidAmount() >= this.fuelUsedPerBurnup){ + this.currentBurnTime = this.maxBurnTime; + this.tank.drain(this.fuelUsedPerBurnup, true); + } + } + + if(this.slots[0] != null && FluidContainerRegistry.containsFluid(this.slots[0], new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)) && (this.slots[1] == null || (this.slots[1].stackSize < this.slots[1].getMaxStackSize()))){ + if(FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount()){ + if(this.slots[1] == null) this.slots[1] = new ItemStack(Items.bucket); + else this.slots[1].stackSize++; + this.slots[0] = null; + this.tank.fill(new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME), true); + } + } + + if(this.getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.UP, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.DOWN, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.NORTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.EAST, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.SOUTH, storage); + WorldUtil.pushEnergy(worldObj, xCoord, yCoord, zCoord, ForgeDirection.WEST, storage); + } + + if(flag != this.currentBurnTime > 0){ + int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); + if(meta == 1){ + if(!(energyProducedPerTick*this.maxBurnTime <= this.getMaxEnergyStored(ForgeDirection.UNKNOWN)-this.getEnergyStored(ForgeDirection.UNKNOWN) && FluidContainerRegistry.BUCKET_VOLUME <= this.tank.getCapacity()-this.tank.getFluidAmount())) + worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); + } + else worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); + } + } + } + + @SideOnly(Side.CLIENT) + public int getEnergyScaled(int i){ + return this.getEnergyStored(ForgeDirection.UNKNOWN) * i / this.getMaxEnergyStored(ForgeDirection.UNKNOWN); + } + + @SideOnly(Side.CLIENT) + public int getTankScaled(int i){ + return this.tank.getFluidAmount() * i / this.tank.getCapacity(); + } + + @SideOnly(Side.CLIENT) + public int getBurningScaled(int i){ + return this.currentBurnTime * i / this.maxBurnTime; + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + compound.setInteger("BurnTime", this.currentBurnTime); + compound.setInteger("MaxBurnTime", this.maxBurnTime); + this.storage.writeToNBT(compound); + this.tank.writeToNBT(compound); + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + this.currentBurnTime = compound.getInteger("BurnTime"); + this.maxBurnTime = compound.getInteger("MaxBurnTime"); + this.storage.readFromNBT(compound); + this.tank.readFromNBT(compound); + super.readFromNBT(compound); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return FluidContainerRegistry.containsFluid(stack, new FluidStack(InitBlocks.fluidOil, FluidContainerRegistry.BUCKET_VOLUME)) && i == 0; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return slot == 1; + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ + return this.storage.extractEnergy(maxExtract, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from){ + return this.storage.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + return this.storage.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + return true; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ + if(resource.getFluid() == InitBlocks.fluidOil) return this.tank.fill(resource, doFill); + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid){ + return from != ForgeDirection.DOWN && fluid == InitBlocks.fluidOil; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid){ + return false; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from){ + return new FluidTankInfo[]{this.tank.getInfo()}; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java new file mode 100644 index 000000000..536335006 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java @@ -0,0 +1,5 @@ +package ellpeck.actuallyadditions.tile; + +public class TileEntityPhantomBooster extends TileEntityBase{ + +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java new file mode 100644 index 000000000..4a02b47f9 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java @@ -0,0 +1,157 @@ +package ellpeck.actuallyadditions.tile; + +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; + +public class TileEntityPhantomPlacer extends TileEntityInventoryBase{ + + public static class TileEntityPhantomBreaker extends TileEntityPhantomPlacer{ + + public TileEntityPhantomBreaker(){ + super(9, "phantomBreaker"); + this.isBreaker = true; + } + + } + + public ChunkCoordinates boundPosition; + public World boundWorld; + + public int currentTime; + public final int timeNeeded = ConfigIntValues.PHANTOM_PLACER_TIME.getValue(); + + public final int defaultRange = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue(); + public int range; + + public boolean isBreaker; + + public TileEntityPhantomPlacer(int slots, String name){ + super(slots, name); + } + + public TileEntityPhantomPlacer(){ + super(9, "phantomPlacer"); + this.isBreaker = false; + } + + @Override + public void updateEntity(){ + if(!worldObj.isRemote){ + this.range = TileEntityPhantomface.upgradeRange(defaultRange, worldObj, xCoord, yCoord, zCoord); + + if(!this.hasBoundPosition()){ + this.boundPosition = null; + this.boundWorld = null; + } + + if(this.isBoundPositionInRange()){ + if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ + if(this.currentTime > 0){ + this.currentTime--; + if(this.currentTime <= 0){ + if(this.isBreaker){ + Block blockToBreak = boundWorld.getBlock(boundPosition.posX, boundPosition.posY, boundPosition.posZ); + if(blockToBreak != null && blockToBreak.getBlockHardness(boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ) > -1.0F){ + ArrayList drops = new ArrayList(); + int meta = boundWorld.getBlockMetadata(boundPosition.posX, boundPosition.posY, boundPosition.posZ); + drops.addAll(blockToBreak.getDrops(boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ, meta, 0)); + + if(TileEntityBreaker.addToInventory(this.slots, drops, false)){ + boundWorld.playAuxSFX(2001, boundPosition.posX, boundPosition.posY, boundPosition.posZ, Block.getIdFromBlock(blockToBreak) + (meta << 12)); + WorldUtil.breakBlockAtSide(ForgeDirection.UNKNOWN, boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ); + TileEntityBreaker.addToInventory(this.slots, drops, true); + this.markDirty(); + } + } + } + else{ + if(boundWorld.getBlock(boundPosition.posX, boundPosition.posY, boundPosition.posZ).isReplaceable(boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ)){ + int theSlot = TileEntityBreaker.testInventory(this.slots); + this.setInventorySlotContents(theSlot, WorldUtil.placeBlockAtSide(ForgeDirection.UNKNOWN, boundWorld, boundPosition.posX, boundPosition.posY, boundPosition.posZ, this.slots[theSlot])); + if(this.slots[theSlot] != null && this.slots[theSlot].stackSize <= 0) this.slots[theSlot] = null; + } + } + } + } + else this.currentTime = this.timeNeeded; + } + } + } + } + + public boolean isBoundPositionInRange(){ + if(this.hasBoundPosition()){ + int xDif = this.boundPosition.posX-this.xCoord; + int yDif = this.boundPosition.posY-this.yCoord; + int zDif = this.boundPosition.posZ-this.zCoord; + + if(xDif >= -this.range && xDif <= this.range){ + if(yDif >= -this.range && yDif <= this.range){ + if(zDif >= -this.range && zDif <= this.range) return true; + } + } + } + return false; + } + + public boolean hasBoundPosition(){ + if(this.boundPosition != null && this.boundWorld != null){ + if(this.xCoord == this.boundPosition.posX && this.yCoord == this.boundPosition.posY && this.zCoord == this.boundPosition.posZ && this.worldObj == this.boundWorld){ + this.boundPosition = null; + this.boundWorld = null; + return false; + } + return this.boundWorld == this.worldObj; + } + return false; + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + super.writeToNBT(compound); + compound.setInteger("Time", currentTime); + if(this.hasBoundPosition()){ + compound.setInteger("XCoordOfTileStored", boundPosition.posX); + compound.setInteger("YCoordOfTileStored", boundPosition.posY); + compound.setInteger("ZCoordOfTileStored", boundPosition.posZ); + compound.setInteger("WorldOfTileStored", boundWorld.provider.dimensionId); + } + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + super.readFromNBT(compound); + int x = compound.getInteger("XCoordOfTileStored"); + int y = compound.getInteger("YCoordOfTileStored"); + int z = compound.getInteger("ZCoordOfTileStored"); + if(x != 0 && y != 0 && z != 0){ + this.boundPosition = new ChunkCoordinates(x, y, z); + this.boundWorld = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored")); + this.markDirty(); + } + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return !this.isBreaker; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isItemValidForSlot(slot, stack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return this.isBreaker; + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java new file mode 100644 index 000000000..8dc80323f --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java @@ -0,0 +1,414 @@ +package ellpeck.actuallyadditions.tile; + +import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyProvider; +import cofh.api.energy.IEnergyReceiver; +import ellpeck.actuallyadditions.blocks.BlockPhantomface; +import ellpeck.actuallyadditions.blocks.InitBlocks; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; +import ellpeck.actuallyadditions.util.WorldUtil; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class TileEntityPhantomface extends TileEntityInventoryBase{ + + public ChunkCoordinates boundPosition; + public World boundWorld; + + public int type; + + public final int defaultRange = ConfigIntValues.PHANTOMFACE_RANGE.getValue(); + public int range; + + public TileEntityPhantomface(String name){ + super(0, name); + } + + public static int upgradeRange(int defaultRange, World world, int x, int y, int z){ + int newRange = defaultRange; + for(int i = 0; i < 3; i++){ + Block block = world.getBlock(x, y+1+i, z); + if(block == InitBlocks.blockPhantomBooster) newRange = newRange*2; + else break; + } + return newRange; + } + + public static void updateAround(TileEntity tile){ + tile.getWorldObj().markBlockForUpdate(tile.xCoord+1, tile.yCoord, tile.zCoord); + tile.getWorldObj().markBlockForUpdate(tile.xCoord-1, tile.yCoord, tile.zCoord); + tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord+1, tile.zCoord); + tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord-1, tile.zCoord); + tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord+1); + tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord-1); + tile.markDirty(); + } + + public boolean isBoundTileInRage(){ + if(this.hasBoundTile()){ + int xDif = this.boundPosition.posX-this.xCoord; + int yDif = this.boundPosition.posY-this.yCoord; + int zDif = this.boundPosition.posZ-this.zCoord; + + if(xDif >= -this.range && xDif <= this.range){ + if(yDif >= -this.range && yDif <= this.range){ + if(zDif >= -this.range && zDif <= this.range) return true; + } + } + } + return false; + } + + @Override + public void updateEntity(){ + if(!worldObj.isRemote){ + this.range = upgradeRange(defaultRange, worldObj, xCoord, yCoord, zCoord); + + if(!this.hasBoundTile()){ + this.boundPosition = null; + this.boundWorld = null; + } + } + } + + public boolean hasBoundTile(){ + if(this.boundPosition != null && this.boundWorld != null){ + if(this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof TileEntityPhantomface || (this.xCoord == this.boundPosition.posX && this.yCoord == this.boundPosition.posY && this.zCoord == this.boundPosition.posZ && this.worldObj == this.boundWorld)){ + this.boundPosition = null; + this.boundWorld = null; + return false; + } + return this.boundWorld == this.worldObj; + } + return false; + } + + @Override + public void writeToNBT(NBTTagCompound compound){ + super.writeToNBT(compound); + if(this.hasBoundTile()){ + compound.setInteger("XCoordOfTileStored", boundPosition.posX); + compound.setInteger("YCoordOfTileStored", boundPosition.posY); + compound.setInteger("ZCoordOfTileStored", boundPosition.posZ); + compound.setInteger("WorldOfTileStored", boundWorld.provider.dimensionId); + } + } + + @Override + public void readFromNBT(NBTTagCompound compound){ + super.readFromNBT(compound); + int x = compound.getInteger("XCoordOfTileStored"); + int y = compound.getInteger("YCoordOfTileStored"); + int z = compound.getInteger("ZCoordOfTileStored"); + if(x != 0 && y != 0 && z != 0){ + this.boundPosition = new ChunkCoordinates(x, y, z); + this.boundWorld = DimensionManager.getWorld(compound.getInteger("WorldOfTileStored")); + this.markDirty(); + } + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return false; + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return false; + } + + public static class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{ + + public TileEntityPhantomLiquiface(){ + super("liquiface"); + this.type = BlockPhantomface.LIQUIFACE; + } + + @Override + public void updateEntity(){ + super.updateEntity(); + + if(!worldObj.isRemote){ + if(worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) && this.isBoundTileInRage() && this.getHandler() != null){ + this.pushFluid(ForgeDirection.UP); + this.pushFluid(ForgeDirection.DOWN); + this.pushFluid(ForgeDirection.NORTH); + this.pushFluid(ForgeDirection.EAST); + this.pushFluid(ForgeDirection.SOUTH); + this.pushFluid(ForgeDirection.WEST); + } + } + } + + private void pushFluid(ForgeDirection side){ + TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, xCoord, yCoord, zCoord); + if(tile != null && tile instanceof IFluidHandler && this.getTankInfo(side) != null && this.getTankInfo(side).length > 0 && ((IFluidHandler)tile).getTankInfo(side.getOpposite()) != null && ((IFluidHandler)tile).getTankInfo(side.getOpposite()).length > 0){ + for(FluidTankInfo myInfo : this.getTankInfo(side)){ + for(FluidTankInfo hisInfo : ((IFluidHandler)tile).getTankInfo(side.getOpposite())){ + if(myInfo != null && hisInfo != null && myInfo.fluid != null && myInfo.fluid.getFluid() != null){ + if(((IFluidHandler)tile).canFill(side.getOpposite(), myInfo.fluid.getFluid()) && this.canDrain(side, myInfo.fluid.getFluid())){ + FluidStack receive = this.drain(side, Math.min(hisInfo.capacity-(hisInfo.fluid == null ? 0 : hisInfo.fluid.amount), myInfo.fluid.amount), false); + if(receive != null){ + int actualReceive = ((IFluidHandler)tile).fill(side.getOpposite(), receive, true); + this.drain(side, new FluidStack(receive.getFluid(), actualReceive), true); + } + } + } + } + } + } + } + + @Override + public boolean isBoundTileInRage(){ + return super.isBoundTileInRage() && this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IFluidHandler; + } + + public IFluidHandler getHandler(){ + if(this.boundPosition != null && this.boundWorld != null){ + TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ); + if(tile instanceof IFluidHandler) return (IFluidHandler)tile; + } + return null; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill){ + if(this.isBoundTileInRage()) return this.getHandler().fill(from, resource, doFill); + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain){ + if(this.isBoundTileInRage()) return this.getHandler().drain(from, resource, doDrain); + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain){ + if(this.isBoundTileInRage()) return this.getHandler().drain(from, maxDrain, doDrain); + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid){ + return this.isBoundTileInRage() && this.getHandler().canFill(from, fluid); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid){ + return this.isBoundTileInRage() && this.getHandler().canDrain(from, fluid); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from){ + if(this.isBoundTileInRage()) return this.getHandler().getTankInfo(from); + return new FluidTankInfo[0]; + } + } + + public static class TileEntityPhantomEnergyface extends TileEntityPhantomface implements IEnergyHandler{ + + public TileEntityPhantomEnergyface(){ + super("energyface"); + this.type = BlockPhantomface.ENERGYFACE; + } + + @Override + public boolean isBoundTileInRage(){ + return super.isBoundTileInRage() && (this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IEnergyReceiver || this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IEnergyProvider); + } + + @Override + public void updateEntity(){ + super.updateEntity(); + + if(!worldObj.isRemote){ + if(this.isBoundTileInRage() && this.getProvider() != null){ + this.pushEnergy(ForgeDirection.UP); + this.pushEnergy(ForgeDirection.DOWN); + this.pushEnergy(ForgeDirection.NORTH); + this.pushEnergy(ForgeDirection.EAST); + this.pushEnergy(ForgeDirection.SOUTH); + this.pushEnergy(ForgeDirection.WEST); + } + } + } + + private void pushEnergy(ForgeDirection side){ + TileEntity tile = WorldUtil.getTileEntityFromSide(side, worldObj, xCoord, yCoord, zCoord); + if(tile != null && tile instanceof IEnergyReceiver && this.getProvider().getEnergyStored(ForgeDirection.UNKNOWN) > 0){ + if(((IEnergyReceiver)tile).canConnectEnergy(side.getOpposite()) && this.canConnectEnergy(side)){ + int receive = this.extractEnergy(side, Math.min(((IEnergyReceiver)tile).getMaxEnergyStored(ForgeDirection.UNKNOWN)-((IEnergyReceiver)tile).getEnergyStored(ForgeDirection.UNKNOWN), this.getEnergyStored(ForgeDirection.UNKNOWN)), true); + int actualReceive = ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), receive, false); + this.extractEnergy(side, actualReceive, false); + } + } + } + + public IEnergyProvider getProvider(){ + if(this.boundPosition != null && this.boundWorld != null){ + TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ); + if(tile instanceof IEnergyProvider) return (IEnergyProvider)tile; + } + return null; + } + + public IEnergyReceiver getReceiver(){ + if(this.boundPosition != null && this.boundWorld != null){ + TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ); + if(tile instanceof IEnergyReceiver) return (IEnergyReceiver)tile; + } + return null; + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate){ + return this.isBoundTileInRage() && this.getReceiver() != null ? this.getReceiver().receiveEnergy(from, maxReceive, simulate) : 0; + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate){ + return this.isBoundTileInRage() && this.getProvider() != null ? this.getProvider().extractEnergy(from, maxExtract, simulate) : 0; + } + + @Override + public int getEnergyStored(ForgeDirection from){ + if(this.isBoundTileInRage()){ + if(this.getProvider() != null) return this.getProvider().getEnergyStored(from); + if(this.getReceiver() != null) return this.getReceiver().getEnergyStored(from); + } + return 0; + } + + @Override + public int getMaxEnergyStored(ForgeDirection from){ + if(this.isBoundTileInRage()){ + if(this.getProvider() != null) return this.getProvider().getMaxEnergyStored(from); + if(this.getReceiver() != null) return this.getReceiver().getMaxEnergyStored(from); + } + return 0; + } + + @Override + public boolean canConnectEnergy(ForgeDirection from){ + if(this.isBoundTileInRage()){ + if(this.getProvider() != null) return this.getProvider().canConnectEnergy(from); + if(this.getReceiver() != null) return this.getReceiver().canConnectEnergy(from); + } + return false; + } + } + + public static class TileEntityPhantomItemface extends TileEntityPhantomface{ + + public TileEntityPhantomItemface(){ + super("phantomface"); + this.type = BlockPhantomface.FACE; + } + + public IInventory getInventory(){ + if(this.boundPosition != null && this.boundWorld != null){ + TileEntity tile = boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ); + if(tile instanceof IInventory) return (IInventory)tile; + } + return null; + } + + @Override + public boolean isBoundTileInRage(){ + return super.isBoundTileInRage() && this.boundWorld.getTileEntity(boundPosition.posX, boundPosition.posY, boundPosition.posZ) instanceof IInventory; + } + + public ISidedInventory getSided(){ + return this.getInventory() instanceof ISidedInventory ? (ISidedInventory)this.getInventory() : null; + } + + @Override + public int getInventoryStackLimit(){ + return this.isBoundTileInRage() ? this.getInventory().getInventoryStackLimit() : 0; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player){ + return false; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack stack){ + return this.isBoundTileInRage() && this.getInventory().isItemValidForSlot(i, stack); + } + + @Override + public ItemStack getStackInSlotOnClosing(int i){ + return this.isBoundTileInRage() ? this.getInventory().getStackInSlotOnClosing(i) : null; + } + + @Override + public void setInventorySlotContents(int i, ItemStack stack){ + if(this.isBoundTileInRage()) this.getInventory().setInventorySlotContents(i, stack); + this.markDirty(); + } + + @Override + public int getSizeInventory(){ + return this.isBoundTileInRage() ? this.getInventory().getSizeInventory() : 0; + } + + @Override + public ItemStack getStackInSlot(int i){ + return this.isBoundTileInRage() ? this.getInventory().getStackInSlot(i) : null; + } + + @Override + public ItemStack decrStackSize(int i, int j){ + return this.isBoundTileInRage() ? this.getInventory().decrStackSize(i, j) : null; + } + + @Override + public String getInventoryName(){ + return this.name; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side){ + if(this.isBoundTileInRage()){ + if(this.getSided() != null){ + return this.getSided().getAccessibleSlotsFromSide(side); + } + else{ + int[] theInt = new int[this.getSizeInventory()]; + for(int i = 0; i < theInt.length; i++){ + theInt[i] = i; + } + return theInt; + } + } + return new int[0]; + } + + @Override + public boolean canInsertItem(int slot, ItemStack stack, int side){ + return this.isBoundTileInRage() && (this.getSided() == null || this.getSided().canInsertItem(slot, stack, side)); + } + + @Override + public boolean canExtractItem(int slot, ItemStack stack, int side){ + return this.isBoundTileInRage() && (this.getSided() == null || this.getSided().canExtractItem(slot, stack, side)); + } + + } +} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityUpgradable.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityUpgradable.java deleted file mode 100644 index 864678128..000000000 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityUpgradable.java +++ /dev/null @@ -1,40 +0,0 @@ -package ellpeck.actuallyadditions.tile; - -import ellpeck.actuallyadditions.items.ItemUpgrade; -import net.minecraft.item.ItemStack; - -public abstract class TileEntityUpgradable extends TileEntityInventoryBase{ - - public int speedUpgradeSlot; - public int burnTimeAmplifier; - - public TileEntityUpgradable(int slots, String name){ - super(slots, name); - } - - public void speedUp(){ - ItemStack stack = this.slots[speedUpgradeSlot]; - if(stack != null && stack.getItem() instanceof ItemUpgrade && ((ItemUpgrade)stack.getItem()).type == ItemUpgrade.UpgradeType.SPEED){ - int newSpeed = this.getStandardSpeed() - 10*stack.stackSize; - this.speedUpBurnTimeBySpeed(stack.stackSize); - if(newSpeed < 5) newSpeed = 5; - this.setSpeed(newSpeed); - } - else{ - this.speedUpBurnTimeBySpeed(0); - this.setSpeed(this.getStandardSpeed()); - } - } - - public void speedUpBurnTimeBySpeed(int upgradeAmount){ - this.burnTimeAmplifier = upgradeAmount*2; - } - - public int getStandardSpeed(){ - return 0; - } - - public void setSpeed(int newSpeed){ - - } -} diff --git a/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java b/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java index 8d96556a1..d96162836 100644 --- a/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java +++ b/src/main/java/ellpeck/actuallyadditions/update/UpdateChecker.java @@ -6,6 +6,7 @@ import ellpeck.actuallyadditions.util.ModUtil; import ellpeck.actuallyadditions.util.Util; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.util.StatCollector; import org.apache.logging.log4j.Level; @@ -20,6 +21,7 @@ public class UpdateChecker{ public boolean checkFailed = false; public boolean notified = false; public String onlineVersion; + public String changelog; public void init(){ Util.logInfo("Initializing Update Checker..."); @@ -41,10 +43,12 @@ public class UpdateChecker{ if(update > client){ String notice1 = "info." + ModUtil.MOD_ID_LOWER + ".update.generic.desc"; String notice2 = "info." + ModUtil.MOD_ID_LOWER + ".update.versionComp.desc"; - String notice3 = "info." + ModUtil.MOD_ID_LOWER + ".update.download.desc"; + String notice3 = "info." + ModUtil.MOD_ID_LOWER + ".update.changelog.desc"; + String notice4 = "info." + ModUtil.MOD_ID_LOWER + ".update.download.desc"; player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocal(notice1))); player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice2, ModUtil.VERSION, this.onlineVersion))); - player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice3, "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files"))); + player.addChatComponentMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(notice3, changelog))); + player.addChatComponentMessage(IChatComponent.Serializer.func_150699_a(StatCollector.translateToLocalFormatted(notice4, "http://minecraft.curseforge.com/mc-mods/228404-actually-additions/files"))); } } @@ -64,14 +68,20 @@ public class UpdateChecker{ public void run(){ Util.logInfo("Starting Update Check..."); try{ - URL url = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/newestVersion.txt"); - BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); - onlineVersion = r.readLine(); - r.close(); + URL newestURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/newestVersion.txt"); + BufferedReader newestReader = new BufferedReader(new InputStreamReader(newestURL.openStream())); + onlineVersion = newestReader.readLine(); + newestReader.close(); + + URL changeURL = new URL("https://raw.githubusercontent.com/Ellpeck/ActuallyAdditions/master/update/changelog.txt"); + BufferedReader changeReader = new BufferedReader(new InputStreamReader(changeURL.openStream())); + changelog = changeReader.readLine(); + changeReader.close(); + Util.logInfo("Update Check done!"); } catch(Exception e){ - ModUtil.AA_LOGGER.log(Level.ERROR, "Update Check failed!"); + ModUtil.LOGGER.log(Level.ERROR, "Update Check failed!"); checkFailed = true; e.printStackTrace(); } diff --git a/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java b/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java index 4528b0a01..4db32fb3f 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/AssetUtil.java @@ -12,10 +12,8 @@ public class AssetUtil{ return new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/gui/" + file + ".png"); } - public static void displayNameAndInventoryString(FontRenderer font, int xSize, int yPositionOfInventoryText, int yPositionOfMachineText, String machineName){ + public static void displayNameString(FontRenderer font, int xSize, int yPositionOfMachineText, String machineName){ String localMachineName = StatCollector.translateToLocal(machineName + ".name"); - String inventoryName = StatCollector.translateToLocal("container.inventory"); font.drawString(localMachineName, xSize/2 - font.getStringWidth(localMachineName)/2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE); - font.drawString(inventoryName, xSize/2 - font.getStringWidth(inventoryName)/2, yPositionOfInventoryText-1, StringUtil.DECIMAL_COLOR_GRAY_TEXT); } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java b/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java index 86fc9e727..b3fac963e 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/BlockUtil.java @@ -8,6 +8,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; +import java.util.ArrayList; import java.util.List; public class BlockUtil{ @@ -26,20 +27,47 @@ public class BlockUtil{ else list.add(ItemUtil.shiftForInfo()); } - public static void register(Block block, Class itemBlock, Enum[] list){ - block.setCreativeTab(CreativeTab.instance); - block.setBlockName(createUnlocalizedName(block)); - GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName()); - for(Enum current : list){ - if(!((INameableItem)current).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)current).getOredictName(), new ItemStack(block, 1, current.ordinal())); + @SuppressWarnings("unchecked") + public static void addPowerUsageInfo(List list, int usage){ + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".uses.desc") + " " + usage + " RF/t"); } } - public static void register(Block block, Class itemBlock){ - block.setCreativeTab(CreativeTab.instance); - block.setBlockName(createUnlocalizedName(block)); - GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName()); - if(!((INameableItem)block).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)block).getOredictName(), new ItemStack(block, 1, Util.WILDCARD)); + @SuppressWarnings("unchecked") + public static void addPowerProductionInfo(List list, int produce){ + if(KeyUtil.isShiftPressed()){ + list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + ".produces.desc") + " " + produce + " RF/t"); + } } + public static final ArrayList wailaRegisterList = new ArrayList(); + + public static void register(Block block, Class itemBlock, boolean addTab, Enum[] list){ + if(addTab) block.setCreativeTab(CreativeTab.instance); + block.setBlockName(createUnlocalizedName(block)); + GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName()); + if(list != null){ + for(Enum current : list){ + if(!((INameableItem)current).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)current).getOredictName(), new ItemStack(block, 1, current.ordinal())); + } + } + else{ + if(!((INameableItem)block).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)block).getOredictName(), new ItemStack(block, 1, Util.WILDCARD)); + } + + wailaRegisterList.add(block); + } + + public static void register(Block block, Class itemBlock, Enum[] list){ + register(block, itemBlock, true, list); + } + + public static void register(Block block, Class itemBlock){ + register(block, itemBlock, true); + } + + public static void register(Block block, Class itemBlock, boolean addTab){ + register(block, itemBlock, addTab, null); + } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java b/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java new file mode 100644 index 000000000..e62396a11 --- /dev/null +++ b/src/main/java/ellpeck/actuallyadditions/util/CompatUtil.java @@ -0,0 +1,27 @@ +package ellpeck.actuallyadditions.util; + +import cpw.mods.fml.common.event.FMLInterModComms; +import ellpeck.actuallyadditions.items.ItemSeed; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class CompatUtil{ + + public static void registerMFRPlant(Block block){ + FMLInterModComms.sendMessage("MineFactoryReloaded", "registerHarvestable_Crop", new ItemStack(block, 1, 7)); + + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("plant", Block.blockRegistry.getNameForObject(block)); + FMLInterModComms.sendMessage("MineFactoryReloaded", "registerFertilizable_Crop", compound); + } + + public static void registerMFRSeed(Item item){ + NBTTagCompound compound = new NBTTagCompound(); + compound.setString("seed", Item.itemRegistry.getNameForObject(item)); + compound.setString("crop", Block.blockRegistry.getNameForObject(((ItemSeed)item).plant)); + FMLInterModComms.sendMessage("MineFactoryReloaded", "registerPlantable_Crop", compound); + } + +} diff --git a/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java b/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java index cfe583ece..df6eecfff 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/ItemUtil.java @@ -28,18 +28,28 @@ public class ItemUtil{ } public static void register(Item item){ - item.setCreativeTab(CreativeTab.instance); - item.setUnlocalizedName(createUnlocalizedName(item)); - GameRegistry.registerItem(item, ((INameableItem)item).getName()); - if(!((INameableItem)item).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)item).getOredictName(), new ItemStack(item, 1, Util.WILDCARD)); + register(item, true); + } + + public static void register(Item item, boolean addTab){ + register(item, addTab, null); } public static void register(Item item, Enum[] list){ - item.setCreativeTab(CreativeTab.instance); + register(item, true, list); + } + + public static void register(Item item, boolean addTab, Enum[] list){ + if(addTab) item.setCreativeTab(CreativeTab.instance); item.setUnlocalizedName(createUnlocalizedName(item)); GameRegistry.registerItem(item, ((INameableItem)item).getName()); - for(Enum current : list){ - if(!((INameableItem)current).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)current).getOredictName(), new ItemStack(item, 1, current.ordinal())); + if(list != null){ + for(Enum current : list){ + if(!((INameableItem)current).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)current).getOredictName(), new ItemStack(item, 1, current.ordinal())); + } + } + else{ + if(!((INameableItem)item).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)item).getOredictName(), new ItemStack(item, 1, Util.WILDCARD)); } } diff --git a/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java b/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java index 7db820f5f..a455ca1fa 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/KeyUtil.java @@ -12,4 +12,8 @@ public class KeyUtil{ return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL); } + public static boolean isAltPressed(){ + return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU); + } + } diff --git a/src/main/java/ellpeck/actuallyadditions/util/ModUtil.java b/src/main/java/ellpeck/actuallyadditions/util/ModUtil.java index 94584f60d..311925da6 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/ModUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/ModUtil.java @@ -5,12 +5,12 @@ import org.apache.logging.log4j.Logger; public class ModUtil{ - public static final String VERSION = "1.7.10-0.0.4.3"; + public static final String VERSION = "1.7.10-0.0.6.2"; public static final String MOD_ID = "ActuallyAdditions"; public static final String NAME = "Actually Additions"; public static final String MOD_ID_LOWER = MOD_ID.toLowerCase(); - public static final Logger AA_LOGGER = LogManager.getLogger(MOD_ID); + public static final Logger LOGGER = LogManager.getLogger(MOD_ID); } diff --git a/src/main/java/ellpeck/actuallyadditions/util/StringUtil.java b/src/main/java/ellpeck/actuallyadditions/util/StringUtil.java index 4319d7753..f5326be85 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/StringUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/StringUtil.java @@ -24,8 +24,6 @@ public class StringUtil{ public static final String OBFUSCATED = (char)167 + "k"; public static final String RESET = (char)167 + "r"; - public static final String[] ROMAN_NUMERALS = new String[]{"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"}; - public static final int DECIMAL_COLOR_WHITE = 16777215; public static final int DECIMAL_COLOR_GRAY_TEXT = 4210752; diff --git a/src/main/java/ellpeck/actuallyadditions/util/Util.java b/src/main/java/ellpeck/actuallyadditions/util/Util.java index 64e5b464a..10afb9096 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/Util.java +++ b/src/main/java/ellpeck/actuallyadditions/util/Util.java @@ -11,7 +11,7 @@ public class Util{ public static final int WILDCARD = OreDictionary.WILDCARD_VALUE; public static void logInfo(String text){ - ModUtil.AA_LOGGER.log(Level.INFO, text); + ModUtil.LOGGER.log(Level.INFO, text); } public static void registerEvent(Object o){ diff --git a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java index 05966627c..f374926bc 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java +++ b/src/main/java/ellpeck/actuallyadditions/util/WorldUtil.java @@ -1,12 +1,22 @@ package ellpeck.actuallyadditions.util; +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyReceiver; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; import net.minecraft.world.WorldServer; +import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; +import org.apache.logging.log4j.Level; + +import java.util.ArrayList; public class WorldUtil{ @@ -16,19 +26,70 @@ public class WorldUtil{ } public static void breakBlockAtSide(ForgeDirection side, World world, int x, int y, int z){ + if(side == ForgeDirection.UNKNOWN){ + world.setBlockToAir(x, y, z); + return; + } ChunkCoordinates c = getCoordsFromSide(side, x, y, z); if(c != null){ world.setBlockToAir(c.posX, c.posY, c.posZ); } } - public static boolean placeBlockAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){ - if(world instanceof WorldServer){ - if(side != ForgeDirection.UNKNOWN){ - return stack.tryPlaceItemIntoWorld(FakePlayerUtil.newFakePlayer(world), world, x, y, z, side.ordinal(), 0, 0, 0); + public static void pushEnergy(World world, int x, int y, int z, ForgeDirection side, EnergyStorage storage){ + TileEntity tile = getTileEntityFromSide(side, world, x, y, z); + if(tile != null && tile instanceof IEnergyReceiver && storage.getEnergyStored() > 0){ + if(((IEnergyReceiver)tile).canConnectEnergy(side.getOpposite())){ + int receive = ((IEnergyReceiver)tile).receiveEnergy(side.getOpposite(), Math.min(storage.getMaxExtract(), storage.getEnergyStored()), false); + storage.extractEnergy(receive, false); } } - return false; + } + + public static void pushFluid(World world, int x, int y, int z, ForgeDirection side, FluidTank tank){ + TileEntity tile = getTileEntityFromSide(side, world, x, y, z); + if(tile != null && tank.getFluid() != null && tile instanceof IFluidHandler){ + if(((IFluidHandler)tile).canFill(side.getOpposite(), tank.getFluid().getFluid())){ + int receive = ((IFluidHandler)tile).fill(side.getOpposite(), tank.getFluid(), true); + tank.drain(receive, true); + } + } + } + + public static ItemStack placeBlockAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){ + if(world instanceof WorldServer && stack != null && stack.getItem() != null){ + + //Fluids + FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack); + if(fluid != null && fluid.getFluid().getBlock() != null && fluid.getFluid().getBlock().canPlaceBlockAt(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ)){ + Block block = world.getBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ); + if(!(block instanceof IFluidBlock) && block != Blocks.lava && block != Blocks.water && block != Blocks.flowing_lava && block != Blocks.flowing_water){ + if(world.setBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ, fluid.getFluid().getBlock())){ + return stack.getItem().getContainerItem(stack); + } + } + } + + //Plants + if(stack.getItem() instanceof IPlantable){ + if(((IPlantable)stack.getItem()).getPlant(world, x, y, z).canPlaceBlockAt(world, x+side.offsetX, y+side.offsetY, z+side.offsetZ)){ + if(world.setBlock(x+side.offsetX, y+side.offsetY, z+side.offsetZ, ((IPlantable)stack.getItem()).getPlant(world, x, y, z))){ + stack.stackSize--; + return stack; + } + } + } + + try{ + //Blocks + stack.tryPlaceItemIntoWorld(FakePlayerUtil.newFakePlayer(world), world, x, y, z, side == ForgeDirection.UNKNOWN ? 0 : side.ordinal(), 0, 0, 0); + return stack; + } + catch(Exception e){ + ModUtil.LOGGER.log(Level.ERROR, "Something that places Blocks at "+x+", "+y+", "+z+" in World "+world.provider.dimensionId+" threw an Exception! Don't let that happen again!"); + } + } + return stack; } public static boolean dropItemAtSide(ForgeDirection side, World world, int x, int y, int z, ItemStack stack){ @@ -54,13 +115,25 @@ public class WorldUtil{ } public static ForgeDirection getDirectionByRotatingSide(int side){ - if(side == 0) return ForgeDirection.UP; - if(side == 1) return ForgeDirection.DOWN; - if(side == 2) return ForgeDirection.NORTH; - if(side == 3) return ForgeDirection.EAST; - if(side == 4) return ForgeDirection.SOUTH; - if(side == 5) return ForgeDirection.WEST; - else return ForgeDirection.UNKNOWN; + switch(side){ + case 0: return ForgeDirection.UP; + case 1: return ForgeDirection.DOWN; + case 2: return ForgeDirection.NORTH; + case 3: return ForgeDirection.EAST; + case 4: return ForgeDirection.SOUTH; + case 5: return ForgeDirection.WEST; + default: return ForgeDirection.UNKNOWN; + } + } + + public static ArrayList getMaterialsAround(World world, int x, int y, int z){ + ArrayList blocks = new ArrayList(); + blocks.add(world.getBlock(x+1, y, z).getMaterial()); + blocks.add(world.getBlock(x-1, y, z).getMaterial()); + blocks.add(world.getBlock(x, y, z+1).getMaterial()); + blocks.add(world.getBlock(x, y, z-1).getMaterial()); + + return blocks; } } diff --git a/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java b/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java index d2dd090fa..2ef1ef830 100644 --- a/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java +++ b/src/main/java/ellpeck/actuallyadditions/waila/WailaDataProvider.java @@ -1,16 +1,18 @@ package ellpeck.actuallyadditions.waila; -import ellpeck.actuallyadditions.tile.TileEntityCompost; -import ellpeck.actuallyadditions.util.ModUtil; +import ellpeck.actuallyadditions.config.values.ConfigBoolValues; +import ellpeck.actuallyadditions.util.BlockUtil; import ellpeck.actuallyadditions.util.Util; 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.block.Block; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.StatCollector; import net.minecraft.world.World; import java.util.List; @@ -18,59 +20,44 @@ import java.util.List; @SuppressWarnings("unused") public class WailaDataProvider implements IWailaDataProvider{ - private final String WAILA_PRE_LANG = "gui." + ModUtil.MOD_ID_LOWER + ".waila."; - @Override public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config){ return null; } @Override - public List getWailaHead(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){ - return currentTip; - } + public List getWailaHead(ItemStack stack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){ - @Override - public List getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){ - - if (accessor.getTileEntity() instanceof TileEntityCompost){ - this.compostBody(accessor, currentTip); - } - - return currentTip; - } - - public void compostBody(IWailaDataAccessor accessor, List currentTip){ - int meta = accessor.getMetadata(); - TileEntityCompost tile = (TileEntityCompost)accessor.getTileEntity(); - - if(meta <= tile.amountNeededToConvert){ - String tip1 = StatCollector.translateToLocal(WAILA_PRE_LANG + "compostAmount" + ".name") + ": " + meta + "/" + tile.amountNeededToConvert; - currentTip.add(tip1); - - if(meta == tile.amountNeededToConvert){ - currentTip.add(StatCollector.translateToLocal(WAILA_PRE_LANG + "compostConverting" + ".name")); + if(ConfigBoolValues.DO_WAILA_INFO.isEnabled()){ + if(BlockUtil.wailaRegisterList.contains(accessor.getBlock())){ + Item.getItemFromBlock(accessor.getBlock()).addInformation(stack, accessor.getPlayer(), currentTip, true); } } - if(meta == tile.amountNeededToConvert+1){ - currentTip.add(StatCollector.translateToLocal(WAILA_PRE_LANG + "compostDone" + ".name")); - } - } - - @Override - public List getWailaTail(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){ return currentTip; } @Override - public NBTTagCompound getNBTData(TileEntity te, NBTTagCompound tag, World world, int x, int y, int z){ + public List getWailaBody(ItemStack stack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){ + return currentTip; + } + + @Override + public List getWailaTail(ItemStack stack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config){ + return currentTip; + } + + @Override + public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z){ return tag; } public static void register(IWailaRegistrar registrar){ Util.logInfo("Initializing Waila Plugin..."); - registrar.registerBodyProvider(new WailaDataProvider(), TileEntityCompost.class); + WailaDataProvider provider = new WailaDataProvider(); + for(Block theBlock : BlockUtil.wailaRegisterList){ + registrar.registerHeadProvider(provider, theBlock.getClass()); + } } -} \ No newline at end of file +} diff --git a/src/main/java/invtweaks/api/IItemTree.java b/src/main/java/invtweaks/api/IItemTree.java new file mode 100644 index 000000000..143ba14a0 --- /dev/null +++ b/src/main/java/invtweaks/api/IItemTree.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api; + +import java.util.Collection; +import java.util.List; +import java.util.Random; + +public interface IItemTree { + void registerOre(String category, String name, String oreName, int order); + + boolean matches(List items, String keyword); + + boolean isKeywordValid(String keyword); + + Collection getAllCategories(); + + IItemTreeCategory getRootCategory(); + + void setRootCategory(IItemTreeCategory category); + + IItemTreeCategory getCategory(String keyword); + + boolean isItemUnknown(String id, int damage); + + List getItems(String id, int damage); + + List getItems(String name); + + IItemTreeItem getRandomItem(Random r); + + boolean containsItem(String name); + + boolean containsCategory(String name); + + IItemTreeCategory addCategory(String parentCategory, String newCategory) throws NullPointerException; + + void addCategory(String parentCategory, IItemTreeCategory newCategory) throws NullPointerException; + + IItemTreeItem addItem(String parentCategory, String name, String id, int damage, int order) + throws NullPointerException; + + void addItem(String parentCategory, IItemTreeItem newItem) throws NullPointerException; + + int getKeywordDepth(String keyword); + + int getKeywordOrder(String keyword); +} diff --git a/src/main/java/invtweaks/api/IItemTreeCategory.java b/src/main/java/invtweaks/api/IItemTreeCategory.java new file mode 100644 index 000000000..f1b5e9554 --- /dev/null +++ b/src/main/java/invtweaks/api/IItemTreeCategory.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api; + +import java.util.Collection; +import java.util.List; + +public interface IItemTreeCategory { + boolean contains(IItemTreeItem item); + + void addCategory(IItemTreeCategory category); + + void addItem(IItemTreeItem item); + + Collection getSubCategories(); + + Collection> getItems(); + + String getName(); + + int getCategoryOrder(); + + int findCategoryOrder(String keyword); + + int findKeywordDepth(String keyword); +} diff --git a/src/main/java/invtweaks/api/IItemTreeItem.java b/src/main/java/invtweaks/api/IItemTreeItem.java new file mode 100644 index 000000000..2b6ae2db5 --- /dev/null +++ b/src/main/java/invtweaks/api/IItemTreeItem.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api; + +public interface IItemTreeItem extends Comparable { + String getName(); + + String getId(); + + int getDamage(); + + int getOrder(); +} diff --git a/src/main/java/invtweaks/api/IItemTreeListener.java b/src/main/java/invtweaks/api/IItemTreeListener.java new file mode 100644 index 000000000..73a5815d5 --- /dev/null +++ b/src/main/java/invtweaks/api/IItemTreeListener.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api; + +import java.util.EventListener; + +public interface IItemTreeListener extends EventListener { + void onTreeLoaded(IItemTree tree); +} diff --git a/src/main/java/invtweaks/api/InvTweaksAPI.java b/src/main/java/invtweaks/api/InvTweaksAPI.java new file mode 100644 index 000000000..6bdb84a93 --- /dev/null +++ b/src/main/java/invtweaks/api/InvTweaksAPI.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api; + +import invtweaks.api.container.ContainerSection; +import net.minecraft.item.ItemStack; + +/** + * Interface to access functions exposed by Inventory Tweaks + *

+ * The main @Mod instance of the mod implements this interface, so a refernce to it can + * be obtained via @Instance("inventorytweaks") or methods in net.minecraftforge.fml.common.Loader + *

+ * All of these functions currently have no effect if called on a dedicated server. + */ +public interface InvTweaksAPI { + /** + * Add a listener for ItemTree load events + * + * @param listener + */ + void addOnLoadListener(IItemTreeListener listener); + + /** + * Remove a listener for ItemTree load events + * + * @param listener + * @return true if the listener was previously added + */ + boolean removeOnLoadListener(IItemTreeListener listener); + + /** + * Toggle sorting shortcut state. + * + * @param enabled + */ + void setSortKeyEnabled(boolean enabled); + + /** + * Toggle sorting shortcut supression. + * Unlike setSortKeyEnabled, this flag is automatically cleared when GUIs are closed. + * + * @param enabled + */ + void setTextboxMode(boolean enabled); + + /** + * Compare two items using the default (non-rule based) algorithm, + * sutable for an implementation of Comparator<ItemStack>. + * + * @param i + * @param j + * @return A value with a sign representing the relative order of the item stacks + */ + int compareItems(ItemStack i, ItemStack j); + + /** + * Initiate a sort as if the player had clicked on a sorting button or pressed the sort key. + * + * @param section + * @param method + */ + void sort(ContainerSection section, SortingMethod method); +} diff --git a/src/main/java/invtweaks/api/SortingMethod.java b/src/main/java/invtweaks/api/SortingMethod.java new file mode 100644 index 000000000..b824143ef --- /dev/null +++ b/src/main/java/invtweaks/api/SortingMethod.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api; + +public enum SortingMethod { + /** + * Standard 'r' sorting for generic inventories + */ + DEFAULT, + /** + * Sort method creating vertical columns of items. + * Used for chests only, requires container to have a valid row size for correct results. + */ + VERTICAL, + /** + * Sort method creating horizontal rows of items. + * Used for chests only, requires container to have a valid row size for correct results. + */ + HORIZONTAL, + /** + * Sort method for player inventory. + * Applies to extra player-specified sorting rules for the main inventory. + * Will always operate on main inventory. + */ + INVENTORY, + /** + * Attempts to even the number of items in each stack of the same type of item, without moving full stacks. + * Used in crafting grid sorting. + */ + EVEN_STACKS, +} diff --git a/src/main/java/invtweaks/api/container/ChestContainer.java b/src/main/java/invtweaks/api/container/ChestContainer.java new file mode 100644 index 000000000..a85c412a1 --- /dev/null +++ b/src/main/java/invtweaks/api/container/ChestContainer.java @@ -0,0 +1,38 @@ +package invtweaks.api.container; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A marker for containers that have a chest-like persistant storage component. Enables the Inventroy Tweaks sorting + * buttons for this container. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ChestContainer { + // Set to true if the Inventory Tweaks sorting buttons should be shown for this container. + boolean showButtons() default true; + + // Size of a chest row + int rowSize() default 9; + + // Uses 'large chest' mode for sorting buttons + // (Renders buttons vertically down the right side of the GUI) + boolean isLargeChest() default false; + + // Annotation for method to get size of a chest row if it is not a fixed size for this container class + // Signature int func() + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @interface RowSizeCallback { + } + + // Annotation for method to get size of a chest row if it is not a fixed size for this container class + // Signature int func() + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @interface IsLargeCallback { + } +} diff --git a/src/main/java/invtweaks/api/container/ContainerSection.java b/src/main/java/invtweaks/api/container/ContainerSection.java new file mode 100644 index 000000000..83c2e08a4 --- /dev/null +++ b/src/main/java/invtweaks/api/container/ContainerSection.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2013 Andrew Crocker + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package invtweaks.api.container; + +/** + * Names for specific parts of containers. For unknown container types (such as mod containers), only INVENTORY and + * CHEST sections are available. + */ +public enum ContainerSection { + /** + * The player's inventory + */ + INVENTORY, + /** + * The player's inventory (only the hotbar) + */ + INVENTORY_HOTBAR, + /** + * The player's inventory (all except the hotbar) + */ + INVENTORY_NOT_HOTBAR, + /** + * The chest or dispenser contents. Also used for unknown container contents. + */ + CHEST, + /** + * The crafting input + */ + CRAFTING_IN, + /** + * The crafting input, for containters that store it internally + */ + CRAFTING_IN_PERSISTENT, + /** + * The crafting output + */ + CRAFTING_OUT, + /** + * The armor slots + */ + ARMOR, + /** + * The furnace input + */ + FURNACE_IN, + /** + * The furnace output + */ + FURNACE_OUT, + /** + * The furnace fuel + */ + FURNACE_FUEL, + /** + * The enchantment table slot + */ + ENCHANTMENT, + /** + * The three bottles slots in brewing tables + * NOTE: Do not use without also using BREWING_INGREDIENT. + */ + BREWING_BOTTLES, + /** + * The top slot in brewing tables + * NOTE: Do not use without also using BREWING_BOTTLES. + */ + BREWING_INGREDIENT +} diff --git a/src/main/java/invtweaks/api/container/ContainerSectionCallback.java b/src/main/java/invtweaks/api/container/ContainerSectionCallback.java new file mode 100644 index 000000000..379206b37 --- /dev/null +++ b/src/main/java/invtweaks/api/container/ContainerSectionCallback.java @@ -0,0 +1,16 @@ +package invtweaks.api.container; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A marker for a method to call which returns the set of ContainerSections for this container. + *

+ * Signature of the method should be Map> func() + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) +public @interface ContainerSectionCallback { +} diff --git a/src/main/java/invtweaks/api/container/IgnoreContainer.java b/src/main/java/invtweaks/api/container/IgnoreContainer.java new file mode 100644 index 000000000..86e8aea12 --- /dev/null +++ b/src/main/java/invtweaks/api/container/IgnoreContainer.java @@ -0,0 +1,15 @@ +package invtweaks.api.container; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Use this annotation to override inherited annotation properties and mark a Container as unsortable. + * This effect is inherited as well. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface IgnoreContainer { +} diff --git a/src/main/java/invtweaks/api/container/InventoryContainer.java b/src/main/java/invtweaks/api/container/InventoryContainer.java new file mode 100644 index 000000000..d5a45b912 --- /dev/null +++ b/src/main/java/invtweaks/api/container/InventoryContainer.java @@ -0,0 +1,20 @@ +package invtweaks.api.container; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * A marker for containers that need special treatment, such as crafting inputs or alternate player inventory positions, + * but do not have a chest-like component. + *

+ * Does not enable the Inventory Tweaks sorting buttons for this container. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface InventoryContainer { + // Set to true if the Inventory Tweaks options button should be shown for this container. + // (For instance, if you are replacing a vanilla container such as the player's inventory) + boolean showOptions() default true; +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 9c5c10455..e2594c3db 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -1,6 +1,9 @@ itemGroup.actuallyadditions=Actually Additions achievement.page.actuallyadditions=Actually Additions +fluid.oil=Oil +fluid.canolaoil=Canola Oil + tile.actuallyadditions.blockCompost.name=Compost tile.actuallyadditions.blockMiscOreBlackQuartz.name=Black Quartz Ore tile.actuallyadditions.blockMiscBlackQuartz.name=Block of Black Quartz @@ -12,14 +15,162 @@ tile.actuallyadditions.blockGrinder.name=Crusher tile.actuallyadditions.blockGrinderDouble.name=Double Crusher tile.actuallyadditions.blockFurnaceDouble.name=Double Furnace tile.actuallyadditions.blockFishingNet.name=Fishing Net -tile.actuallyadditions.blockFurnaceSolar.name=Solar Panel [TEMPORARILY UNIMPLEMENTED] -tile.actuallyadditions.blockHeatCollector.name=Heat Collector [TEMPORARILY UNIMPLEMENTED] +tile.actuallyadditions.blockFurnaceSolar.name=Solar Panel +tile.actuallyadditions.blockHeatCollector.name=Heat Collector tile.actuallyadditions.blockItemRepairer.name=Item Repairer +item.actuallyadditions.itemDrill.name=Drill +tooltip.actuallyadditions.itemDrill.desc.1=Mines all the Blocks! +tooltip.actuallyadditions.itemDrill.desc.2=Powered by RF! Charge in an Energizer! Discharge in an Enervator! +tooltip.actuallyadditions.itemDrill.desc.3=Drill Upgrades can be applied through Sneak-Right-Clicking! + tile.actuallyadditions.blockMiscWoodCasing.name=Wood Casing tile.actuallyadditions.blockMiscStoneCasing.name=Stone Casing tile.actuallyadditions.blockGreenhouseGlass.name=Greenhouse Glass +tile.actuallyadditions.blockEnergizer.name=Energizer +tooltip.actuallyadditions.blockEnergizer.desc.1=A "Charger", if you will +tooltip.actuallyadditions.blockEnergizer.desc.2=Charges Items that can hold RF +tile.actuallyadditions.blockEnervator.name=Enervator +tooltip.actuallyadditions.blockEnervator.desc.1=A "Discharger", if you will +tooltip.actuallyadditions.blockEnervator.desc.2=Discharges Items that can hold RF + +tile.actuallyadditions.blockRice.name=Rice Plant +tooltip.actuallyadditions.blockRice.desc=It's growing... kind of.. +item.actuallyadditions.itemFoodRice.name=Rice +tooltip.actuallyadditions.itemFoodRice.desc=Used to make all kinds of useful stuff! +item.actuallyadditions.itemMiscRiceDough.name=Rice Dough +tooltip.actuallyadditions.itemMiscRiceDough.desc=It's Dough, but made from Rice +item.actuallyadditions.itemFoodRiceBread.name=Rice Bread +tooltip.actuallyadditions.itemFoodRiceBread.desc=It's like Bread, but ricey! +item.actuallyadditions.itemRiceSeed.name=Rice Seeds +tooltip.actuallyadditions.itemRiceSeed.desc=Grows on Farmland! Makes delicious Rice! + +item.actuallyadditions.itemMiscTinyCoal.name=Tiny Coal +tooltip.actuallyadditions.itemMiscTinyCoal.desc=Crafted from Coal, smelts one Item +item.actuallyadditions.itemMiscTinyCharcoal.name=Tiny Charcoal +tooltip.actuallyadditions.itemMiscTinyCharcoal.desc=Crafted from Charcoal, smelts one Item +tile.actuallyadditions.blockMiscCharcoal.name=Block of Charcoal +tooltip.actuallyadditions.blockMiscCharcoal.desc=Crafted from Charcoal +item.actuallyadditions.itemMiscRiceSlime.name=Rice Slimeball +tooltip.actuallyadditions.itemMiscRiceSlime.desc=It's sticky... and smells kinda good... + +item.actuallyadditions.itemBattery.name=Battery +tooltip.actuallyadditions.itemBattery.desc=Stores RF! Charge in an Energizer! Discharge in an Enervator! + +tile.actuallyadditions.blockCoalGenerator.name=Coal Generator +tooltip.actuallyadditions.blockCoalGenerator.desc=Produces Energy from Coal and other flammable Materials + +item.actuallyadditions.itemBucketCanolaOil.name=Canola Oil Bucket +tooltip.actuallyadditions.itemBucketCanolaOil.desc=A Bucket filled with Canola Oil +item.actuallyadditions.itemBucketOil.name=Oil Bucket +tooltip.actuallyadditions.itemBucketOil.desc=Made in a Fermenting Barrel from Canola Oil + +tile.actuallyadditions.blockPhantomface.name=Phantomface +tooltip.actuallyadditions.blockPhantomface.desc.1=Like a Hopper-Chain, only Wireless! Connect me with a Phantom Connector! +tooltip.actuallyadditions.blockPhantomface.desc.2=Input things into me to input into connected Blocks! + +tile.actuallyadditions.blockPhantomEnergyface.name=Phantom Energyface +tooltip.actuallyadditions.blockPhantomEnergyface.desc.1=Like a Conduit, only Wireless! Connect me with a Phantom Connector! +tooltip.actuallyadditions.blockPhantomEnergyface.desc.2=Put RF through me! + +tile.actuallyadditions.blockPhantomLiquiface.name=Phantom Liquiface +tooltip.actuallyadditions.blockPhantomLiquiface.desc.1=Like a Pipe, only Wireless! Connect me with a Phantom Connector! +tooltip.actuallyadditions.blockPhantomLiquiface.desc.2=Put Fluids through me! Apply Redstone Power to Auto-Output! +tooltip.actuallyadditions.blockPhantomLiquiface.desc.3=Important: Watch out when setting the Liquiface to Auto-Output! Doing that +tooltip.actuallyadditions.blockPhantomLiquiface.desc.4=could produce Fluids flowing back and forward indefinitely in some cases! + +tile.actuallyadditions.blockPhantomPlacer.name=Phantom Placer +tooltip.actuallyadditions.blockPhantomPlacer.desc.1=Places Blocks from a distance! Connect me with a Phantom Connector! +tooltip.actuallyadditions.blockPhantomPlacer.desc.2=Sneak-Right-Click with an empty hand to see its Connections! + +tile.actuallyadditions.blockPhantomBreaker.name=Phantom Breaker +tooltip.actuallyadditions.blockPhantomBreaker.desc.1=Breaks Blocks from a distance! Connect me with a Phantom Connector! +tooltip.actuallyadditions.blockPhantomBreaker.desc.2=Sneak-Right-Click with an empty hand to see its Connections! + +tile.actuallyadditions.blockLavaFactoryController.name=Lava Factory Controller +tooltip.actuallyadditions.blockLavaFactoryController.desc.1=Place Lava Factory Casings around in the right way to produce Lava: +tooltip.actuallyadditions.blockLavaFactoryController.desc.2=Go one block up above the Controller, that's where Lava is going to land +tooltip.actuallyadditions.blockLavaFactoryController.desc.3=Place 4 Casings around that empty space so that it is encased + +tile.actuallyadditions.blockMiscLavaFactoryCase.name=Lava Factory Casing +tooltip.actuallyadditions.blockMiscLavaFactoryCase.desc=Helps the Lava Factory Controller generate Lava + +tile.actuallyadditions.blockFluidPlacer.name=Fluid Placer +tooltip.actuallyadditions.blockFluidPlacer.desc=Places Fluids stored inside it + +tooltip.actuallyadditions.paxel.desc=It's an Axe, Shovel, Sword, Hoe and Pickaxe! Combined! +item.actuallyadditions.woodenPaxel.name=Wooden Paxelordoe +item.actuallyadditions.stonePaxel.name=Stone Paxelordoe +item.actuallyadditions.ironPaxel.name=Iron Paxelordoe +item.actuallyadditions.goldPaxel.name=Golden Paxelordoe +item.actuallyadditions.diamondPaxel.name=Diamond Paxelordoe +item.actuallyadditions.emeraldPaxel.name=Emerald Paxelordoe +item.actuallyadditions.obsidianPaxel.name=Obsidian Paxelordoe + +tile.actuallyadditions.blockFluidCollector.name=Fluid Collector +tooltip.actuallyadditions.blockFluidCollector.desc=Stores Fluids in front of it inside it + +tile.actuallyadditions.blockPhantomBooster.name=Phantom Booster +tooltip.actuallyadditions.blockPhantomBooster.desc.1=When placed above a Phantom Machine, it doubles its Range +tooltip.actuallyadditions.blockPhantomBooster.desc.2=(Max Amount above one Phantom Machine: 3) + +item.actuallyadditions.itemPhantomConnector.name=Phantom Connector +tooltip.actuallyadditions.itemPhantomConnector.desc.1=Connects a Phantom Face to any Inventory Block! +tooltip.actuallyadditions.itemPhantomConnector.desc.2=Hold ALT to clear the stored TileEntity + +item.actuallyadditions.itemMiscCup.name=Empty Cup +tooltip.actuallyadditions.itemMiscCup.desc=Used to make Coffee in a Coffee Machine! + +item.actuallyadditions.itemCoffee.name=Cup with Coffee +tooltip.actuallyadditions.itemCoffee.desc.1=Brewed in a Coffee Machine! See Effects below! +tooltip.actuallyadditions.itemCoffee.desc.2=You can drink me %s times! + +item.actuallyadditions.itemCoffeeSeed.name=Coffee Seeds +tooltip.actuallyadditions.itemCoffeeSeed.desc=Grows Coffee on Farmland + +tile.actuallyadditions.blockCoffee.name=Coffee Plant +tooltip.actuallyadditions.blockCoffee.desc=Grows Coffee! Noms! + +item.actuallyadditions.itemCoffeeBeans.name=Coffee Beans +tooltip.actuallyadditions.itemCoffeeBeans.desc=Used in a Coffee Machine... delicious! + +tile.actuallyadditions.blockWildCanola.name=Wild Canola +tile.actuallyadditions.blockWildRice.name=Wild Rice +tile.actuallyadditions.blockWildCoffee.name=Wild Coffee +tile.actuallyadditions.blockWildFlax.name=Wild Flax +tooltip.actuallyadditions.blockWildCanola.desc=Grows in the Wild... Gets you Canola Seeds! +tooltip.actuallyadditions.blockWildRice.desc=Grows in the Wild... Gets you Rice Seeds! +tooltip.actuallyadditions.blockWildCoffee.desc=Grows in the Wild... Gets you Coffee Seeds! +tooltip.actuallyadditions.blockWildFlax.desc=Grows in the Wild... Gets you Flax Seeds! + +item.actuallyadditions.itemCanolaSeed.name=Canola Seeds +tooltip.actuallyadditions.itemCanolaSeed.desc=Grows on Farmland! Makes Canola! +item.actuallyadditions.itemMiscCanola.name=Canola +tooltip.actuallyadditions.itemMiscCanola.desc=Used to make Oil in a Canola Press +tile.actuallyadditions.blockCanola.name=Canola Plant +tooltip.actuallyadditions.blockCanola.desc=It's growing... making Canola.. slowly! + +item.actuallyadditions.itemResonantRice.name=Resonant Rice +tooltip.actuallyadditions.itemResonantRice.desc=Don't know what it does... maybe if you right-click it? +tooltip.actuallyadditions.itemResonantRice.uncraftable.desc=Uncraftable because there's no Mod installed that adds Enderium :( + +tile.actuallyadditions.blockCanolaPress.name=Canola Press +tooltip.actuallyadditions.blockCanolaPress.desc=Makes Canola Oil from Canola +tile.actuallyadditions.blockFermentingBarrel.name=Fermenting Barrel +tooltip.actuallyadditions.blockFermentingBarrel.desc=Ferments Canola Oil made in a Press to Canola + +tile.actuallyadditions.blockCanolaOil.name=Canola Oil +tooltip.actuallyadditions.blockCanolaOil.desc=Oil made from Canola +tile.actuallyadditions.blockOil.name=Oil +tooltip.actuallyadditions.blockOil.desc=Can be used to power Machines + +tile.actuallyadditions.blockMiscEnderpearl.name=Block of Enderpearl +tooltip.actuallyadditions.blockMiscEnderpearl.desc=It's a Block. Made of Pearls. Wow. + +tile.actuallyadditions.blockOilGenerator.name=Oil Generator +tooltip.actuallyadditions.blockOilGenerator.desc=Generates Power from Oil + tile.actuallyadditions.blockBreaker.name=Auto-Breaker tile.actuallyadditions.blockPlacer.name=Auto-Placer tile.actuallyadditions.blockDropper.name=Automatic Precision Dropper @@ -40,7 +191,45 @@ tile.actuallyadditions.blockInputter.add.11.name=Extra-Long Solidifying Dissocia tile.actuallyadditions.blockInputter.add.12.name=Energetic Solo Dancer tile.actuallyadditions.blockInputter.add.13.name=Efficient Sucking Dilettant tile.actuallyadditions.blockInputter.add.14.name=Extreme Sand Digger -tile.actuallyadditions.blockInputter.add.15.name=MISSINGNO +tile.actuallyadditions.blockInputter.add.15.name=Ending Serious Daughter + +item.actuallyadditions.itemDrillUpgradeSpeed.name=Drill Speed Augment I +item.actuallyadditions.itemDrillUpgradeSpeedII.name=Drill Speed Augment II +item.actuallyadditions.itemDrillUpgradeSpeedIII.name=Drill Speed Augment III +item.actuallyadditions.itemDrillUpgradeSilkTouch.name=Drill Silk Touch Augment +item.actuallyadditions.itemDrillUpgradeFortune.name=Drill Fortune Augment I +item.actuallyadditions.itemDrillUpgradeFortuneII.name=Drill Fortune Augment II (That gives you Fortune III as it says in the tooltip...) +item.actuallyadditions.itemDrillUpgradeBlockPlacing.name=Drill Block Placing Augment +item.actuallyadditions.itemDrillUpgradeThreeByThree.name=Drill Mining Augment I +item.actuallyadditions.itemDrillUpgradeFiveByFive.name=Drill Mining Augment II + +tooltip.actuallyadditions.itemDrillUpgradeSpeed.desc=Makes the Drill faster! +tooltip.actuallyadditions.itemDrillUpgradeSpeedII.desc=Makes the Drill even faster! Requires Tier 1. +tooltip.actuallyadditions.itemDrillUpgradeSpeedIII.desc=Insta-Mine! Requires Tier 1 and 2. +tooltip.actuallyadditions.itemDrillUpgradeSilkTouch.desc=Makes the Drill silky. +tooltip.actuallyadditions.itemDrillUpgradeFortune.desc=Gives the Drill Fortune I. +tooltip.actuallyadditions.itemDrillUpgradeFortuneII.desc=Gives the Drill Fortune III! Requires Tier 1. +tooltip.actuallyadditions.itemDrillUpgradeBlockPlacing.desc.1=Places Blocks from your Hotbar when Right-Clicking with the Drill! +tooltip.actuallyadditions.itemDrillUpgradeBlockPlacing.desc.2=You can define the Slot on your Hotbar to place from! +tooltip.actuallyadditions.itemDrillUpgradeBlockPlacing.desc.3=Sneak-Right-Click this Upgrade in the desired Slot to store it! +tooltip.actuallyadditions.itemDrillUpgradeThreeByThree.desc=Lets you mine a 3x3 Area! +tooltip.actuallyadditions.itemDrillUpgradeFiveByFive.desc=Lets you mine a 5x5 Area! Requires the 3x3 Upgrade. +tooltip.actuallyadditions.itemDrillUpgrade.desc=Sneak-Right-Click the Drill to apply Upgrades! + +tile.actuallyadditions.blockMiscEnderCasing.name=Ender Casing +tooltip.actuallyadditions.blockMiscEnderCasing.desc=Extremely sturdy casing, used for crafting + +tooltip.actuallyadditions.phantom.connected.desc= +tooltip.actuallyadditions.phantom.stored.desc= +tooltip.actuallyadditions.phantom.unbound.desc=The Connection was cleared! +tooltip.actuallyadditions.phantom.inWorld.desc=In World +tooltip.actuallyadditions.phantom.boundTo.desc=Bound to +tooltip.actuallyadditions.phantom.connectedBlock.desc=Connected to Block at %s, %s, %s +tooltip.actuallyadditions.phantom.connectedNoRange.desc=Connected to Block at %s, %s, %s but it is not in Range, not loaded or not the right type of Inventory! +tooltip.actuallyadditions.phantom.notConnected.desc=This isn't connected to anything! + +tooltip.actuallyadditions.factory.notPart.desc=The Controller isn't part of the right Multi-Block! Look at the Controller's Description! +tooltip.actuallyadditions.factory.works.desc=This Lava Factory is complete and can produce Lava! item.actuallyadditions.itemMiscMashedFood.name=Mashed Food item.actuallyadditions.itemFertilizer.name=Fertilizer @@ -58,6 +247,7 @@ item.actuallyadditions.itemJamChApCi.name=ChApCi-Jam item.actuallyadditions.itemJamHoMeKi.name=HoMeKi-Jam item.actuallyadditions.itemJamPiCo.name=PiCo-Jam +item.actuallyadditions.itemHairyBall.name=Ball of Hair item.actuallyadditions.itemLeafBlower.name=Leaf Blower item.actuallyadditions.itemLeafBlowerAdvanced.name=Advanced Leaf Blower item.actuallyadditions.itemKnife.name=Knife @@ -105,6 +295,13 @@ item.actuallyadditions.itemSpecialHeartPart.name=Part of a Heart item.actuallyadditions.itemSpecialPearlShard.name=Ender Pearl Shard item.actuallyadditions.itemSpecialEmeraldShard.name=Emerald Shard +tile.actuallyadditions.blockCoffeeMachine.name=Coffee Machine +tooltip.actuallyadditions.blockCoffeeMachine.desc.1=Makes endless different Coffee Combinations! +tooltip.actuallyadditions.blockCoffeeMachine.desc.2=Just add Coffee Beans and a Cup and the Ingredients: +tooltip.actuallyadditions.blockCoffeeMachine.desc.3=There's a lot of ingredients that add different Effects +tooltip.actuallyadditions.blockCoffeeMachine.desc.4=to the Coffee! Just put them into the slots on the right +tooltip.actuallyadditions.blockCoffeeMachine.desc.5=in the desired Order! It'll be your CUSTOM COFFEE! + item.actuallyadditions.itemDustIron.name=Crushed Iron item.actuallyadditions.itemDustGold.name=Crushed Gold item.actuallyadditions.itemDustDiamond.name=Crushed Diamond @@ -131,53 +328,8 @@ tooltip.actuallyadditions.itemJamChApCi.desc=Cherry, Apple and Cinnamon tooltip.actuallyadditions.itemJamHoMeKi.desc=Honeydew Melon and Kiwi tooltip.actuallyadditions.itemJamPiCo.desc=Pineapple and Coconut -tile.actuallyadditions.blockCompactIronSingle.name=Single Compact Iron -tile.actuallyadditions.blockCompactIronDouble.name=Double Compact Iron -tile.actuallyadditions.blockCompactIronTriple.name=Triple Compact Iron -tile.actuallyadditions.blockCompactIronQuadruple.name=Quadruple Compact Iron -tile.actuallyadditions.blockCompactIronQuintuple.name=Quintuple Compact Iron -tile.actuallyadditions.blockCompactIronSextuple.name=Sextuple Compact Iron -tooltip.actuallyadditions.blockCompactIron.desc=Iron, but bunched together! - -tile.actuallyadditions.blockCompactGoldSingle.name=Single Compact Gold -tile.actuallyadditions.blockCompactGoldDouble.name=Double Compact Gold -tile.actuallyadditions.blockCompactGoldTriple.name=Triple Compact Gold -tile.actuallyadditions.blockCompactGoldQuadruple.name=Quadruple Compact Gold -tile.actuallyadditions.blockCompactGoldQuintuple.name=Quintuple Compact Gold -tile.actuallyadditions.blockCompactGoldSextuple.name=Sextuple Compact Gold -tooltip.actuallyadditions.blockCompactGold.desc=Gold, but bunched together! - -tile.actuallyadditions.blockCompactDiamondSingle.name=Single Compact Diamond -tile.actuallyadditions.blockCompactDiamondDouble.name=Double Compact Diamond -tile.actuallyadditions.blockCompactDiamondTriple.name=Triple Compact Diamond -tile.actuallyadditions.blockCompactDiamondQuadruple.name=Quadruple Compact Diamond -tile.actuallyadditions.blockCompactDiamondQuintuple.name=Quintuple Compact Diamond -tile.actuallyadditions.blockCompactDiamondSextuple.name=Sextuple Compact Diamond -tooltip.actuallyadditions.blockCompactDiamond.desc=Diamond, but bunched together! - -tile.actuallyadditions.blockCompactRedstoneSingle.name=Single Compact Redstone -tile.actuallyadditions.blockCompactRedstoneDouble.name=Double Compact Redstone -tile.actuallyadditions.blockCompactRedstoneTriple.name=Triple Compact Redstone -tile.actuallyadditions.blockCompactRedstoneQuadruple.name=Quadruple Compact Redstone -tile.actuallyadditions.blockCompactRedstoneQuintuple.name=Quintuple Compact Redstone -tile.actuallyadditions.blockCompactRedstoneSextuple.name=Sextuple Compact Redstone -tooltip.actuallyadditions.blockCompactRedstone.desc=Redstone, but bunched together! - -tile.actuallyadditions.blockCompactCoalSingle.name=Single Compact Coal -tile.actuallyadditions.blockCompactCoalDouble.name=Double Compact Coal -tile.actuallyadditions.blockCompactCoalTriple.name=Triple Compact Coal -tile.actuallyadditions.blockCompactCoalQuadruple.name=Quadruple Compact Coal -tile.actuallyadditions.blockCompactCoalQuintuple.name=Quintuple Compact Coal -tile.actuallyadditions.blockCompactCoalSextuple.name=Sextuple Compact Coal -tooltip.actuallyadditions.blockCompactCoal.desc=Coal, but bunched together! - -tile.actuallyadditions.blockCompactLapisSingle.name=Single Compact Lapis -tile.actuallyadditions.blockCompactLapisDouble.name=Double Compact Lapis -tile.actuallyadditions.blockCompactLapisTriple.name=Triple Compact Lapis -tile.actuallyadditions.blockCompactLapisQuadruple.name=Quadruple Compact Lapis -tile.actuallyadditions.blockCompactLapisQuintuple.name=Quintuple Compact Lapis -tile.actuallyadditions.blockCompactLapisSextuple.name=Sextuple Compact Lapis -tooltip.actuallyadditions.blockCompactLapis.desc=Lapis, but bunched together! +tooltip.actuallyadditions.itemHairyBall.desc.1=A Ball of Hair dropped from a Cat... +tooltip.actuallyadditions.itemHairyBall.desc.2=Maybe you can get something from it by using it... tooltip.actuallyadditions.itemUpgradeSpeed.desc.1=Speeds up Machines when placed in their Upgrade Slot tooltip.actuallyadditions.itemUpgradeSpeed.desc.2=Works in: @@ -185,6 +337,8 @@ tooltip.actuallyadditions.itemUpgradeSpeed.desc.3=-Double Furnace tooltip.actuallyadditions.itemUpgradeSpeed.desc.4=-Crusher tooltip.actuallyadditions.itemUpgradeSpeed.desc.5=-Double Crusher +tooltip.actuallyadditions.blockPhantomRange.desc=Range + tooltip.actuallyadditions.blockCompost.desc=Used to make Fertilizer with Mashed Food tooltip.actuallyadditions.blockMiscOreBlackQuartz.desc=The darkest form of Quartz. tooltip.actuallyadditions.blockMiscBlackQuartz.desc=Black, eerie Quartz! Nice for decorating. @@ -205,15 +359,21 @@ tooltip.actuallyadditions.blockInputter.desc.2=Acts like a more advanced Hopper tooltip.actuallyadditions.blockInputter.desc.3=Turn me off with Redstone! tooltip.actuallyadditions.blockInputter.desc.4=Configurable: tooltip.actuallyadditions.blockInputter.desc.5=-Side to Output to and Input from -tooltip.actuallyadditions.blockInputter.desc.6=-Slot in the other Inventory to Output to and Input from -tooltip.actuallyadditions.blockInputterAdvanced.desc=Has an Input and Output Filter! +tooltip.actuallyadditions.blockInputter.desc.6=-A Range of Slots in the other Inventory to Output to and Input from +tooltip.actuallyadditions.blockInputter.desc.7=-> Just input the Minimum and Maximum Slots into the input Fields! +tooltip.actuallyadditions.blockInputterAdvanced.desc=Has an Input and Output Filter! (White- and Blacklist!) tooltip.actuallyadditions.blockFishingNet.desc=Catches Fish automatically when placed above Water -tooltip.actuallyadditions.blockFurnaceSolar.desc=Powers Actually Additions Machines and Vanilla Furnaces below it in Daylight -tooltip.actuallyadditions.blockHeatCollector.desc.1=Powers Actually Additions Machines and Vanilla Furnaces above it +tooltip.actuallyadditions.blockFurnaceSolar.desc=Produces RF in Daylight +tooltip.actuallyadditions.blockHeatCollector.desc.1=Produces RF tooltip.actuallyadditions.blockHeatCollector.desc.2=Needs a bunch of Lava around it tooltip.actuallyadditions.blockHeatCollector.desc.3=Occasionally steals the Lava. Watch out! tooltip.actuallyadditions.blockItemRepairer.desc=Repairs Tools and Armor automatically +tile.actuallyadditions.blockFlax.name=Flax Plant +tooltip.actuallyadditions.blockFlax.desc=Gives you String when grown! Yay! +item.actuallyadditions.itemFlaxSeed.name=Flax Seeds +tooltip.actuallyadditions.itemFlaxSeed.desc=Grows Plants that give you String! + tooltip.actuallyadditions.blockBreaker.desc=Breaks Blocks and stores them in its internal Inventory tooltip.actuallyadditions.blockPlacer.desc=Places Blocks stored in its internal Inventory tooltip.actuallyadditions.blockDropper.desc=Drops Items automatically (Without spewing them all over the Place!) @@ -234,8 +394,6 @@ tooltip.actuallyadditions.blockCrafter.desc=Automatically crafts Items without n tooltip.actuallyadditions.itemPotionRing.desc.1=Gives Potion Effect of Level 1 tooltip.actuallyadditions.itemPotionRing.desc.2=Needs to be held in Hand -tooltip.actuallyadditions.itemPotionRing.desc.off.1=Crafting Recipe of this particular Potion Effect is turned OFF by default -tooltip.actuallyadditions.itemPotionRing.desc.off.2=as it is extremely overpowered! Turn it on in the Config File if needed. tooltip.actuallyadditions.itemMiscCoil.desc=Lower Tier Coil, used for Crafting tooltip.actuallyadditions.itemMiscCoilAdvanced.desc=Higher Tier Coil, used for Crafting @@ -271,14 +429,15 @@ tooltip.actuallyadditions.itemFoodChocolateCake.desc=Looks delicious. With redbe tooltip.actuallyadditions.itemFoodNoodle.desc=Just one. Like... that's not much. tooltip.actuallyadditions.itemFoodSpaghetti.desc=The most generic food ever. So clichée. tooltip.actuallyadditions.itemFoodFrenchFry.desc=French. Fry. -tooltip.actuallyadditions.itemFoodFrenchFries.desc=Much like French Fires, but actually taste good. +tooltip.actuallyadditions.itemFoodFrenchFries.desc=Much like French Fires, not as hot though... tooltip.actuallyadditions.itemFoodFishNChips.desc=It's Fish. It's Chips. Or French Fries. Whatevs. tooltip.actuallyadditions.itemFoodCarrotJuice.desc=Carrots, but pressed! tooltip.actuallyadditions.itemFoodPumpkinStew.desc=Like Mushroom Stew or Rabbit Stew, but pumpykinny. tooltip.actuallyadditions.itemFoodCheese.desc=Cheese. tooltip.actuallyadditions.itemSpecialUnknownSubstance.desc=Dropped by Skeletons. BETA INFO: Useless as of yet. -tooltip.actuallyadditions.itemSpecialSolidifiedExperience.desc=Dropped by everyone. Right-Click to get XP. +tooltip.actuallyadditions.itemSpecialSolidifiedExperience.desc.1=Dropped by everyone. Right-Click to get XP. +tooltip.actuallyadditions.itemSpecialSolidifiedExperience.desc.2=Sneak-Right-Click to consume the whole Stack. tooltip.actuallyadditions.itemSpecialBloodFragment.desc=Dropped by everyone. BETA INFO: Useless as of yet. tooltip.actuallyadditions.itemSpecialHeartPart.desc=Dropped by everyone. BETA INFO: Useless as of yet. tooltip.actuallyadditions.itemSpecialPearlShard.desc=Dropped by Endermen. 3x3 Crafting to an Ender Pearl @@ -305,21 +464,15 @@ info.actuallyadditions.gui.east=East info.actuallyadditions.gui.south=South info.actuallyadditions.gui.west=West info.actuallyadditions.gui.all=All -info.actuallyadditions.gui.slot=Slot info.actuallyadditions.gui.put=Put info.actuallyadditions.gui.pull=Pull +info.actuallyadditions.gui.whitelist=Whitelist +info.actuallyadditions.gui.blacklist=Blacklist +info.actuallyadditions.gui.coffee=Coffee +info.actuallyadditions.gui.ok=Ok -effect.actuallyadditions.speed.name=Speed -effect.actuallyadditions.haste.name=Haste -effect.actuallyadditions.strength.name=Strength -effect.actuallyadditions.jumpBoost.name=Jump Boost -effect.actuallyadditions.regen.name=Regeneration -effect.actuallyadditions.resistance.name=Resistance -effect.actuallyadditions.fireResistance.name=Fire Resistance -effect.actuallyadditions.waterBreathing.name=Water Breathing -effect.actuallyadditions.invisibility.name=Invisibility -effect.actuallyadditions.nightVision.name=Night Vision -effect.actuallyadditions.saturation.name=Saturation +tooltip.actuallyadditions.uses.desc=Uses +tooltip.actuallyadditions.produces.desc=Produces container.actuallyadditions.inputter.name=ESD container.actuallyadditions.inputterAdvanced.name=Advanced ESD @@ -333,19 +486,39 @@ container.actuallyadditions.placer.name=Placer container.actuallyadditions.breaker.name=Breaker container.actuallyadditions.dropper.name=Precision Dropper container.actuallyadditions.crafting.name=Crafting Table On A Stick +container.actuallyadditions.canolaPress.name=Canola Press +container.actuallyadditions.fermentingBarrel.name=Fermenting Barrel +container.actuallyadditions.coalGenerator.name=Coal Generator +container.actuallyadditions.oilGenerator.name=Oil Generator +container.actuallyadditions.phantomPlacer.name=Phantom Placer +container.actuallyadditions.phantomBreaker.name=Phantom Breaker +container.actuallyadditions.phantomface.name=Phantomface +container.actuallyadditions.liquiface.name=Liquiface +container.actuallyadditions.energyface.name=Energyface +container.actuallyadditions.fluidPlacer.name=Fluid Placer +container.actuallyadditions.fluidCollector.name=Fluid Collector +container.actuallyadditions.coffeeMachine.name=Coffee Machine +container.actuallyadditions.drill.name=Drill +container.actuallyadditions.energizer.name=Energizer +container.actuallyadditions.enervator.name=Enervator -container.actuallyadditions.nei.crushing.name=Crusher +container.nei.actuallyadditions.crushing.name=Crusher +container.nei.actuallyadditions.ballOfHair.name=Ball Of Hair Usage +container.nei.actuallyadditions.compost.name=Compost -gui.actuallyadditions.waila.compostAmount.name=Amount of Mashed Food -gui.actuallyadditions.waila.compostDone.name=Done! -gui.actuallyadditions.waila.compostConverting.name=Converting... +container.nei.actuallyadditions.coffee.name=Coffee Machine +container.nei.actuallyadditions.coffee.special=Special Feature +container.nei.actuallyadditions.coffee.maxAmount=Max Amount +container.nei.actuallyadditions.coffee.shift=[SHIFT]! +container.nei.actuallyadditions.coffee.extra.milk=+01:00, -1 Level info.actuallyadditions.update.generic.desc=[{"text":"There is an "},{"text":"Update ","bold":"true"},{"text":"for ","bold":"false"},{"text":"Actually Additions ","color":"dark_green","bold":"true"},{"text":"available!","color":"none","bold":"false"}] info.actuallyadditions.update.versionComp.desc=[{"text":"You have Version "},{"text":"%s","color":"dark_red","italic":"false"},{"text":", the newest one is ","color":"none","italic":"false"},{"text":"%s","color":"dark_green","underlined":"false"},{"text":"!","color":"none","underlined":"false"}] info.actuallyadditions.update.download.desc=[{"text":"Download the newest Version "},{"text":"here! (Click me!)","color":"dark_green","underlined":"true","clickEvent":{"action":"open_url","value":"%s"},"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"Click here to open your Browser and download the newest Version!"}]}}}] info.actuallyadditions.update.failed.desc=[{"text":"The Update Check for "},{"text":"Actually Additions ","color":"dark_green","bold":"true"},{"text":"failed! Check your Internet Connection and the Logs for more Info!","color":"none"}] +info.actuallyadditions.update.changelog.desc=Updates: %s -achievement.actuallyadditions.pickUpSolidXP=Hard and Rich and Stuff +achievement.actuallyadditions.pickUpSolidXP=Square and yummy! achievement.actuallyadditions.pickUpSolidXP.desc=Pick up some Solidified Experience achievement.actuallyadditions.craftKnifeBlade=Sharp! So Sharp! achievement.actuallyadditions.craftKnifeBlade.desc=Craft a Knife Blade diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilFlowing.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilFlowing.png new file mode 100644 index 000000000..f5982ec90 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilFlowing.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilFlowing.png.mcmeta b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilFlowing.png.mcmeta new file mode 100644 index 000000000..4f0718ac9 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilFlowing.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilStill.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilStill.png new file mode 100644 index 000000000..59569bc40 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilStill.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilStill.png.mcmeta b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilStill.png.mcmeta new file mode 100644 index 000000000..0645f48c6 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaOilStill.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaPress.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaPress.png new file mode 100644 index 000000000..75726f79d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaPress.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaPressTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaPressTop.png new file mode 100644 index 000000000..17144ed53 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaPressTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage1.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage1.png new file mode 100644 index 000000000..e0b7862a0 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage1.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage2.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage2.png new file mode 100644 index 000000000..67c69118c Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage2.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage3.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage3.png new file mode 100644 index 000000000..d51b6a7af Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage3.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage4.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage4.png new file mode 100644 index 000000000..163a73904 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCanolaStage4.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoalGenerator.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoalGenerator.png new file mode 100644 index 000000000..d551df5e2 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoalGenerator.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoalGeneratorTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoalGeneratorTop.png new file mode 100644 index 000000000..85181259b Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoalGeneratorTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage1.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage1.png new file mode 100644 index 000000000..52a8b8b82 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage1.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage2.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage2.png new file mode 100644 index 000000000..90274425f Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage2.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage3.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage3.png new file mode 100644 index 000000000..ba3d2bf7c Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage3.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage4.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage4.png new file mode 100644 index 000000000..60fb42c24 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage4.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage5.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage5.png new file mode 100644 index 000000000..794403d4d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage5.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage6.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage6.png new file mode 100644 index 000000000..da8d1cfc1 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockCoffeeStage6.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFermentingBarrel.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFermentingBarrel.png new file mode 100644 index 000000000..c0340d0e5 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFermentingBarrel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFermentingBarrelTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFermentingBarrelTop.png new file mode 100644 index 000000000..494a7328d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFermentingBarrelTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage1.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage1.png new file mode 100644 index 000000000..6543c9466 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage1.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage2.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage2.png new file mode 100644 index 000000000..9a48e693b Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage2.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage3.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage3.png new file mode 100644 index 000000000..0b4544dd1 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage3.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage4.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage4.png new file mode 100644 index 000000000..a9aff1f14 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage4.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage5.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage5.png new file mode 100644 index 000000000..54abf3f7e Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage5.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage6.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage6.png new file mode 100644 index 000000000..d89928166 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFlaxStage6.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollector.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollector.png new file mode 100644 index 000000000..b6168bcb2 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollector.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollectorFront.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollectorFront.png new file mode 100644 index 000000000..15812568d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollectorFront.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollectorTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollectorTop.png new file mode 100644 index 000000000..819a89861 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidCollectorTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacer.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacer.png new file mode 100644 index 000000000..2d23a1e63 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacer.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacerFront.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacerFront.png new file mode 100644 index 000000000..f0c7e1bd5 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacerFront.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacerTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacerTop.png new file mode 100644 index 000000000..819a89861 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockFluidPlacerTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockGrinderOn.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockGrinderOn.png index 13fa3fc54..5fe0e0687 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/blocks/blockGrinderOn.png and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockGrinderOn.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockItemRepairerOn.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockItemRepairerOn.png deleted file mode 100644 index 04b071e53..000000000 Binary files a/src/main/resources/assets/actuallyadditions/textures/blocks/blockItemRepairerOn.png and /dev/null differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockLavaFactoryController.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockLavaFactoryController.png new file mode 100644 index 000000000..808eecb19 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockLavaFactoryController.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockLavaFactoryControllerTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockLavaFactoryControllerTop.png new file mode 100644 index 000000000..b8719b608 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockLavaFactoryControllerTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscCharcoal.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscCharcoal.png new file mode 100644 index 000000000..31c637308 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscCharcoal.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscEnderCasing.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscEnderCasing.png new file mode 100644 index 000000000..9b6ca8cd3 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscEnderCasing.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscEnderpearl.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscEnderpearl.png new file mode 100644 index 000000000..87acd223d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscEnderpearl.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscLavaFactoryCase.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscLavaFactoryCase.png new file mode 100644 index 000000000..808eecb19 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockMiscLavaFactoryCase.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilFlowing.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilFlowing.png new file mode 100644 index 000000000..d40c0a2f2 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilFlowing.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilFlowing.png.mcmeta b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilFlowing.png.mcmeta new file mode 100644 index 000000000..4f0718ac9 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilFlowing.png.mcmeta @@ -0,0 +1,3 @@ +{ + "animation": {} +} \ No newline at end of file diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilGenerator.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilGenerator.png new file mode 100644 index 000000000..120541747 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilGenerator.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilGeneratorTop.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilGeneratorTop.png new file mode 100644 index 000000000..85181259b Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilGeneratorTop.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilStill.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilStill.png new file mode 100644 index 000000000..b00fa0ae4 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilStill.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilStill.png.mcmeta b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilStill.png.mcmeta new file mode 100644 index 000000000..0645f48c6 --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/textures/blocks/blockOilStill.png.mcmeta @@ -0,0 +1,5 @@ +{ + "animation": { + "frametime": 2 + } +} diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomBreaker.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomBreaker.png new file mode 100644 index 000000000..8a28eb99e Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomBreaker.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomEnergyface.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomEnergyface.png new file mode 100644 index 000000000..e960e02d0 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomEnergyface.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomLiquiface.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomLiquiface.png new file mode 100644 index 000000000..e8aba089c Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomLiquiface.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomPlacer.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomPlacer.png new file mode 100644 index 000000000..374c256a0 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomPlacer.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomface.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomface.png new file mode 100644 index 000000000..b11ae7923 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockPhantomface.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage1.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage1.png new file mode 100644 index 000000000..aa5312e75 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage1.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage2.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage2.png new file mode 100644 index 000000000..42f2c1181 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage2.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage3.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage3.png new file mode 100644 index 000000000..da2986f47 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage3.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage4.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage4.png new file mode 100644 index 000000000..69085b702 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage4.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage5.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage5.png new file mode 100644 index 000000000..16b768803 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage5.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage6.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage6.png new file mode 100644 index 000000000..e75005dd1 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/blockRiceStage6.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/models/modelCoffeeMachine.png b/src/main/resources/assets/actuallyadditions/textures/blocks/models/modelCoffeeMachine.png new file mode 100644 index 000000000..99aac9c19 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/models/modelCoffeeMachine.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/models/modelPhantomBooster.png b/src/main/resources/assets/actuallyadditions/textures/blocks/models/modelPhantomBooster.png new file mode 100644 index 000000000..cd01ff0ab Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/models/modelPhantomBooster.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelEllpeck.png b/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelEllpeck.png index cd769c4ca..af45ac1fa 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelEllpeck.png and b/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelEllpeck.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelLordi.png b/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelLordi.png new file mode 100644 index 000000000..05cdffccf Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/blocks/models/special/modelLordi.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiCanolaPress.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiCanolaPress.png new file mode 100644 index 000000000..4472e793f Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiCanolaPress.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiCoalGenerator.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiCoalGenerator.png new file mode 100644 index 000000000..7ee6c1cbc Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiCoalGenerator.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiCoffeeMachine.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiCoffeeMachine.png new file mode 100644 index 000000000..338f8beb8 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiCoffeeMachine.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiFermentingBarrel.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiFermentingBarrel.png new file mode 100644 index 000000000..68f68415e Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiFermentingBarrel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiFluidCollector.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiFluidCollector.png new file mode 100644 index 000000000..33714d691 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiFluidCollector.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiFurnaceDouble.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiFurnaceDouble.png index c4a1f8bf9..8be70aae5 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiFurnaceDouble.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiFurnaceDouble.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinder.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinder.png index 9c94d97ff..b29234c8f 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinder.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinder.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinderDouble.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinderDouble.png index 608242579..49ca77cda 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinderDouble.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiGrinderDouble.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiInputter.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiInputter.png index 11b8583ad..a6cb89c47 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiInputter.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiInputter.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiInputterAdvanced.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiInputterAdvanced.png index 673ce121b..8dc118cc9 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiInputterAdvanced.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiInputterAdvanced.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICoffeeMachine.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICoffeeMachine.png new file mode 100644 index 000000000..9316922ce Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICoffeeMachine.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICompost.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICompost.png new file mode 100644 index 000000000..8f0ac2bc8 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEICompost.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiNEIHairyBall.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEIHairyBall.png new file mode 100644 index 000000000..8f0ac2bc8 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiNEIHairyBall.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiOilGenerator.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiOilGenerator.png new file mode 100644 index 000000000..2b139a7f5 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/guiOilGenerator.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiRepairer.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiRepairer.png index a00a0fc68..6ba8a00ae 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/guiRepairer.png and b/src/main/resources/assets/actuallyadditions/textures/gui/guiRepairer.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/diamondPaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/diamondPaxel.png new file mode 100644 index 000000000..6c809a312 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/diamondPaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/emeraldPaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/emeraldPaxel.png new file mode 100644 index 000000000..e184b2400 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/emeraldPaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/goldPaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/goldPaxel.png new file mode 100644 index 000000000..c0750f43d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/goldPaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/ironPaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/ironPaxel.png new file mode 100644 index 000000000..7cea9949f Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/ironPaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemBucketCanolaOil.png b/src/main/resources/assets/actuallyadditions/textures/items/itemBucketCanolaOil.png new file mode 100644 index 000000000..2e06004fe Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemBucketCanolaOil.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemBucketOil.png b/src/main/resources/assets/actuallyadditions/textures/items/itemBucketOil.png new file mode 100644 index 000000000..487a0e50f Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemBucketOil.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemCanolaSeed.png b/src/main/resources/assets/actuallyadditions/textures/items/itemCanolaSeed.png new file mode 100644 index 000000000..f5773f314 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemCanolaSeed.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemCoffee.png b/src/main/resources/assets/actuallyadditions/textures/items/itemCoffee.png new file mode 100644 index 000000000..63cefb7fa Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemCoffee.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemCoffeeBeans.png b/src/main/resources/assets/actuallyadditions/textures/items/itemCoffeeBeans.png new file mode 100644 index 000000000..94fdee80c Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemCoffeeBeans.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemCoffeeSeed.png b/src/main/resources/assets/actuallyadditions/textures/items/itemCoffeeSeed.png new file mode 100644 index 000000000..8afdc027c Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemCoffeeSeed.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemFlaxSeed.png b/src/main/resources/assets/actuallyadditions/textures/items/itemFlaxSeed.png new file mode 100644 index 000000000..f0feb7fa0 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemFlaxSeed.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemFoodRice.png b/src/main/resources/assets/actuallyadditions/textures/items/itemFoodRice.png new file mode 100644 index 000000000..e927b9e97 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemFoodRice.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemFoodRiceBread.png b/src/main/resources/assets/actuallyadditions/textures/items/itemFoodRiceBread.png new file mode 100644 index 000000000..fdbf09679 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemFoodRiceBread.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemHairyBall.png b/src/main/resources/assets/actuallyadditions/textures/items/itemHairyBall.png new file mode 100644 index 000000000..f8d9492a7 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemHairyBall.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscCanola.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscCanola.png new file mode 100644 index 000000000..b02f176eb Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscCanola.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscCup.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscCup.png new file mode 100644 index 000000000..7fc88085d Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscCup.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscRiceDough.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscRiceDough.png new file mode 100644 index 000000000..d25613c55 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscRiceDough.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscRiceSlime.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscRiceSlime.png new file mode 100644 index 000000000..63769bd18 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscRiceSlime.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscTinyCharcoal.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscTinyCharcoal.png new file mode 100644 index 000000000..6d10d84c5 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscTinyCharcoal.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemMiscTinyCoal.png b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscTinyCoal.png new file mode 100644 index 000000000..101113cff Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemMiscTinyCoal.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemPhantomConnector.png b/src/main/resources/assets/actuallyadditions/textures/items/itemPhantomConnector.png new file mode 100644 index 000000000..dd07fae4f Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemPhantomConnector.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemResonantRice.png b/src/main/resources/assets/actuallyadditions/textures/items/itemResonantRice.png new file mode 100644 index 000000000..9c1dd1183 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemResonantRice.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/itemRiceSeed.png b/src/main/resources/assets/actuallyadditions/textures/items/itemRiceSeed.png new file mode 100644 index 000000000..2e13afcc4 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/itemRiceSeed.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/obsidianPaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/obsidianPaxel.png new file mode 100644 index 000000000..4915838bb Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/obsidianPaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/stonePaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/stonePaxel.png new file mode 100644 index 000000000..449737ee1 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/stonePaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/items/woodenPaxel.png b/src/main/resources/assets/actuallyadditions/textures/items/woodenPaxel.png new file mode 100644 index 000000000..d80876661 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/items/woodenPaxel.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/logo.png b/src/main/resources/assets/actuallyadditions/textures/logo.png index 4c278518b..08cf37077 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/logo.png and b/src/main/resources/assets/actuallyadditions/textures/logo.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/logoBig.png b/src/main/resources/assets/actuallyadditions/textures/logoBig.png index 4931ee359..6059f0e6a 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/logoBig.png and b/src/main/resources/assets/actuallyadditions/textures/logoBig.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/logoSquare.png b/src/main/resources/assets/actuallyadditions/textures/logoSquare.png index f0d7e8095..6b5cce0a0 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/logoSquare.png and b/src/main/resources/assets/actuallyadditions/textures/logoSquare.png differ diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 435c78154..97204162e 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -2,15 +2,13 @@ { "modid": "ActuallyAdditions", "name": "Actually Additions", - "description": "Actually Additions is a Mod that offers a bunch of things from Machines for Automation and tons of food to advanced Hopper Mechanisms and Effect Rings!", - "version": "0.0.4.3", - "mcversion": "1.7.10", - "url": "https://github.com/Ellpeck/ActuallyAdditions", + "description": "Do you want Automation? Wireless Transport? Better Machines? A cup o' Coffee? Chests? Better Hoppers? Leaf Blowers? Faster Growth? Plants? Well, Actually Additions has all that and a lot more!", + "version": "${version}", + "mcversion": "${mcversion}", + "url": "http://github.com/Ellpeck/ActuallyAdditions", "updateUrl": "", - "authorList": [ - "Ellpeck" - ], - "credits": "xdqmhose, GlenthorLP, Paktosan", + "authorList": [ "Ellpeck" ], + "credits": "Author: Ellpeck; Thanks to: xdqmhose, GlenthorLP, Lordhallo, canitzp", "logoFile": "assets/actuallyadditions/textures/logo.png", "screenshots": [ ], diff --git a/update/changelog.txt b/update/changelog.txt new file mode 100644 index 000000000..cb483726c --- /dev/null +++ b/update/changelog.txt @@ -0,0 +1 @@ +Really Important Fix for the Drill! \ No newline at end of file diff --git a/update/newestVersion.txt b/update/newestVersion.txt new file mode 100644 index 000000000..469a92910 --- /dev/null +++ b/update/newestVersion.txt @@ -0,0 +1 @@ +1.7.10-0.0.6.2 \ No newline at end of file