diff --git a/build.gradle b/build.gradle index 0b7cfd8c..cb711198 100644 --- a/build.gradle +++ b/build.gradle @@ -17,13 +17,13 @@ buildscript { apply plugin: 'forge' -version = "1.7.2-v0.9.1-Beta" +version = "1.7.10-v0.9.2-Beta-Pre6" group= "com.brandon3055.draconicevolution" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "Draconic-Evolution" minecraft { - version = "1.7.2-10.12.2.1126" - assetDir = "run/assets" + version = "1.7.10-10.13.0.1187" + //assetDir = "run/assets" } dependencies { 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 00000000..591b75d9 --- /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("EnergyHelper"); + + if (energy > capacity) { + energy = capacity; + } + return this; + } + + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + + if (energy < 0) { + energy = 0; + } + nbt.setInteger("EnergyHelper", 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 00000000..63faffb9 --- /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 00000000..0bcfda60 --- /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 00000000..3df31234 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyHandler.java @@ -0,0 +1,51 @@ +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 IEnergyConnection { + + /** + * Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler. + * + * @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); + + /** + * Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler. + * + * @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/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java new file mode 100644 index 00000000..43cfdd42 --- /dev/null +++ b/src/main/java/cofh/api/energy/IEnergyStorage.java @@ -0,0 +1,45 @@ +package cofh.api.energy; + +/** + * An energy storage is the unit of interaction with EnergyHelper inventories. + * + * 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 00000000..81610e52 --- /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("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @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 00000000..a7fabeb7 --- /dev/null +++ b/src/main/java/cofh/api/energy/TileEnergyHandler.java @@ -0,0 +1,62 @@ +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); + } + + /* IEnergyHandler */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + + return true; + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + + return storage.receiveEnergy(maxReceive, simulate); + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + + return storage.extractEnergy(maxExtract, simulate); + } + + @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 00000000..a2b937f5 --- /dev/null +++ b/src/main/java/cofh/api/energy/package-info.java @@ -0,0 +1,9 @@ +/** + * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub + * http://www.teamcofh.com + */ +@API(apiVersion = "1.0", owner = "CoFHCore", provides = "CoFHAPI|energy") +package cofh.api.energy; + +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 00000000..13a02b26 --- /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 = "1.0", owner = "CoFHCore", provides = "CoFHAPI") +package cofh.api; + +import cpw.mods.fml.common.API; + diff --git a/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java b/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java index 8f69524d..db0946f9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java +++ b/src/main/java/com/brandon3055/draconicevolution/DraconicEvolution.java @@ -2,6 +2,10 @@ package com.brandon3055.draconicevolution; import java.util.Arrays; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import net.minecraft.stats.Achievement; +import net.minecraftforge.common.AchievementPage; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -17,7 +21,7 @@ import com.brandon3055.draconicevolution.common.core.network.ChannelHandler; import com.brandon3055.draconicevolution.common.core.proxy.CommonProxy; import com.brandon3055.draconicevolution.common.lib.References; -@Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION) +@Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION, canBeDeactivated = false) public class DraconicEvolution { @Mod.Instance(References.MODID) @@ -30,9 +34,8 @@ public class DraconicEvolution { private static CreativeTabs tolkienTabBlocksItems = new TolkienTab(CreativeTabs.getNextID(), References.MODID, "blocksAndItems"); public static final String networkChannelName = "DraconicEvolution"; public static ChannelHandler channelHandler = new ChannelHandler(References.MODID, networkChannelName); - public static FMLEventChannel channel; + //public static FMLEventChannel channel; public static boolean debug = false; - public static final Logger logger = LogManager.getLogger("DraconicEvolution"); public DraconicEvolution() { @@ -42,17 +45,25 @@ public class DraconicEvolution { @Mod.EventHandler public static void preInit(final FMLPreInitializationEvent event) {if(debug) - System.out.println("preInit()" + event.getModMetadata().name); + LogHelper.info("Initialization"); event.getModMetadata().autogenerated = false; event.getModMetadata().credits = ""; event.getModMetadata().description = "This is a mod originally made for the Tolkiencraft mod pack"; event.getModMetadata().authorList = Arrays.asList("brandon3055"); event.getModMetadata().logoFile = "banner.png"; - event.getModMetadata().url = "http://dragontalk.net/node/71"; - event.getModMetadata().version = References.VERSION + "-MC1.7.2"; + event.getModMetadata().url = "http://dragontalk.net/draconic_evolution"; + event.getModMetadata().version = References.VERSION + "-MC1.7.10"; proxy.preInit(event); + + /* + public static Achievement ultimatePower; + ultimatePower = new Achievement("achievment.ultimatePower", "Ultimate Power!!!", 1, -2, ModItems.draconicDistructionStaff, null).registerStat(); + AchievementPage draconicEvolution = new AchievementPage("Draconic Evolution", ultimatePower); + AchievementPage.registerAchievementPage(draconicEvolution); + */ + } @Mod.EventHandler diff --git a/src/main/java/com/brandon3055/draconicevolution/client/creativetab/TolkienTab.java b/src/main/java/com/brandon3055/draconicevolution/client/creativetab/TolkienTab.java index abfa6a5f..c9ba5d54 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/creativetab/TolkienTab.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/creativetab/TolkienTab.java @@ -1,10 +1,15 @@ package com.brandon3055.draconicevolution.client.creativetab; +import cofh.api.energy.IEnergyContainerItem; import com.brandon3055.draconicevolution.common.blocks.ModBlocks; import com.brandon3055.draconicevolution.common.core.handler.ConfigHandler; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; public class TolkienTab extends CreativeTabs { private String label; @@ -16,8 +21,9 @@ public class TolkienTab extends CreativeTabs { @Override public Item getTabIconItem() { + if(this.label.equals("toolsAndWeapons")) - return ModItems.draconicDistructionStaff; + return ModItems.draconicBow; else if(this.label.equals("blocksAndItems")) return ConfigHandler.disableSunDial == 2 ? Item.getItemFromBlock(ModBlocks.weatherController) : Item.getItemFromBlock(ModBlocks.sunDial); else diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIEnergyInfuser.java new file mode 100644 index 00000000..5dad837c --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIEnergyInfuser.java @@ -0,0 +1,175 @@ +package com.brandon3055.draconicevolution.client.interfaces; + +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.container.ContainerEnergyInfuser; +import com.brandon3055.draconicevolution.common.container.ContainerGrinder; +import com.brandon3055.draconicevolution.common.core.utills.GuiHelper; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import com.brandon3055.draconicevolution.common.tileentities.TileGrinder; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import java.util.ArrayList; +import java.util.Random; + +@SideOnly(Side.CLIENT) +public class GUIEnergyInfuser extends GuiContainer { + + public EntityPlayer player; + private TileEnergyInfuser tile; + private int guiUpdateTick; + private float rotation = 0; + + public GUIEnergyInfuser(InventoryPlayer invPlayer, TileEnergyInfuser tile) { + super(new ContainerEnergyInfuser(invPlayer, tile)); + + xSize = 176; + ySize = 140; + + this.tile = tile; + this.player = invPlayer.player; + } + + private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/EnergyInfuser.png"); + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor4f(1F, 1F, 1F, 1F); + Minecraft.getMinecraft().getTextureManager().bindTexture(texture); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + if (tile.getStackInSlot(0) == null) + drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box + + + float power = (float) tile.energy.getEnergyStored() / (float) tile.energy.getMaxEnergyStored() * -1F + 1F; + drawTexturedModalRect(guiLeft + 49, guiTop + 7 + (int) (power * 45), xSize, 0 + (int) (power * 45), 8, 45 - (int) (power * 45));//Power bar + + if (tile.running && tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) tile.getStackInSlot(0).getItem(); + float charge = (float) item.getEnergyStored(tile.getStackInSlot(0)) / (float) item.getMaxEnergyStored(tile.getStackInSlot(0)) * -1F + 1F; + drawTexturedModalRect(guiLeft + 119, guiTop + 7 + (int) (charge * 45), xSize, 0 + (int) (charge * 45), 8, 45 - (int) (charge * 45));//Item Power bar + } + + drawAnimatedParts(); + } + + @Override + protected void drawGuiContainerForegroundLayer(int x, int y) { + fontRendererObj.drawStringWithShadow("Energy Infuser", 49, -9, 0x00FFFF); + + drawEnergyBarHoverText(x - guiLeft, y - guiTop); + //bindTexture(texture); + + //fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000); + //drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0); + + } + + @Override + public void initGui() { + super.initGui(); + + //ID + //buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text)); + } + + @Override + protected void actionPerformed(GuiButton button) { + + + } + + @Override + public void updateScreen() { + super.updateScreen(); + + } + + private void drawEnergyBarHoverText(int x, int y) { + if (GuiHelper.isInRect(48, 6, 57, 52, x, y)) { + ArrayList internal = new ArrayList(); + internal.add("Internal Storage"); + internal.add("" + EnumChatFormatting.DARK_BLUE + tile.energy.getEnergyStored() + "/" + tile.energy.getMaxEnergyStored()); + drawHoveringText(internal, x, y, fontRendererObj); + } + + if (GuiHelper.isInRect(118, 6, 128, 52, x, y) && tile.running && tile.getStackInSlot(0) != null && tile.getStackInSlot(0).getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) tile.getStackInSlot(0).getItem(); + ArrayList internal = new ArrayList(); + internal.add("Item Energy Storage"); + internal.add("" + EnumChatFormatting.DARK_BLUE + item.getEnergyStored(tile.getStackInSlot(0)) + "/" + item.getMaxEnergyStored(tile.getStackInSlot(0))); + drawHoveringText(internal, x, y, fontRendererObj); + } + } + + private void drawAnimatedParts() { + if (!tile.running) drawTexturedModalRect(guiLeft + 79, guiTop + 21, xSize, 45, 18, 18); + if (tile.running) rotation += 0.2F; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glTranslatef(guiLeft + 62, guiTop + 4, 0); + {//Draw Ring + GL11.glTranslatef(26, 26, 0); + GL11.glRotatef(rotation, 0, 0, 1); + GL11.glTranslatef(-26, -26, 0); + drawTexturedModalRect(0, 0, xSize, 63, 52, 52); + } + if (tile.running && tile.energy.getEnergyStored() > 0){ + Random rand = tile.getWorldObj().rand; + int boltL = rand.nextInt(4); + int boltS = rand.nextInt(3); + int boltT = rand.nextInt(10); + drawTexturedModalRect(0, 0, xSize, 115, 52, 52); + + GL11.glColor4f(1F, 1F, 1F, 0.5F + (rand.nextFloat() / 2F)); + drawTexturedModalRect(0, 0, xSize, 167, 52, 52); + GL11.glColor4f(1F, 1F, 1F, 1F); + + if (boltT == 5) { + GL11.glTranslatef(26, 26, 0); + GL11.glRotatef(boltL * 90, 0, 0, 1); + GL11.glTranslatef(-26, -26, 0); + + if (boltS == 0) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 23, 0); + drawTexturedModalRect(0, 0, 0, ySize, 27, 15); + } + if (boltS == 1) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 26, 0); + drawTexturedModalRect(0, 0, 0, 156, 25, 8); + } + if (boltS == 2) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 27, 0); + drawTexturedModalRect(0, 0, 0, 165, 23, 7); + } + if (boltS == 3) { + GL11.glTranslatef(-(guiLeft + 62), -(guiTop + 4), 0); + GL11.glTranslatef(guiLeft + 68, guiTop + 26, 0); + drawTexturedModalRect(0, 0, 0, 173, 26, 8); + } + } + + } + + + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIParticleGenerator.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIParticleGenerator.java index 6618c411..3cae5585 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIParticleGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUIParticleGenerator.java @@ -17,8 +17,7 @@ import com.brandon3055.draconicevolution.common.core.network.ParticleGenPacket; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator; -public class GUIParticleGenerator extends GuiScreen -{ +public class GUIParticleGenerator extends GuiScreen { private final int xSize = 212; private final int ySize = 198; private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/ParticleGenerator.png"); @@ -66,92 +65,73 @@ public class GUIParticleGenerator extends GuiScreen syncWithServer(); } - String[] InfoText = { "" + "The Particle Generator is a decorative device that allows you to create your own custom particle effects. " + "It is fairly easy you use this device you simply adjust the fields (variables) in the interface to change how the generated particles look and behave. " + "This block is a work in progress and new features and particles are likely to be added in future versions. " + "The following is a list of all of the fields in the interface and what they do.", - "The first thing to note is that most fields have a random modifier which will add a random number between 0 and whatever max (or min) value you give it to the field. " + "-The first 3 fields (Red, Green & Blue) control the colour of the particle. Most people should be familiar with this colour system if not google RGB colours. Note: the max value for each colour can not go higher then 255 so the colour field limits the random modifier e.g. if the colour field is set to 255 and the random modifier is set to 20 the result will always be 255", - "-The next 3 fields (Motion X, Y & Z) control the direction and speed of the particle " + "-The \"Life\" field sets how long (in ticks) before the particle despawns. " + "-The \"Size\" field sets the size of the particle. " + "-The next 3 fields (Spawn X, Y & Z) Sets the spawn location of the particle (relative to the location of the particle generator)", - "-The \"Delay\" field sets the delay (in ticks) between each particle spawn e.g. 1=20/s, 20=1/s, 100=1/5s " + "-The \"Fade\" field sets how long (in ticks) it takes the partile to fade out of existance. Note: This adds to the life of the particle " + "-The \"Gravity\" field sets how the particle is affected by gravity. " + "-\"Block Collision\" Toggles weather or not the particle will collide with blocks " + "-\"Particle Selected\" Switches between the different particles available.", - EnumChatFormatting.DARK_RED + " Redstone Control" + EnumChatFormatting.BLACK + "\nBy default a redstone signal is required for the generator to run." + "\n\nHowever if you shift right click the generator with an empty hand it will switch to inverted mode." + "\nThe redstone mode is indicated by the 8 cubes at the corners of the block." }; + String[] InfoText = {"" + "The Particle Generator is a decorative device that allows you to create your own custom particle effects. " + "It is fairly easy you use this device you simply adjust the fields (variables) in the interface to change how the generated particles look and behave. " + "This block is a work in progress and new features and particles are likely to be added in future versions. " + "The following is a list of all of the fields in the interface and what they do.", "The first thing to note is that most fields have a random modifier which will add a random number between 0 and whatever max (or min) value you give it to the field. " + "-The first 3 fields (Red, Green & Blue) control the colour of the particle. Most people should be familiar with this colour system if not google RGB colours. Note: the max value for each colour can not go higher then 255 so the colour field limits the random modifier e.g. if the colour field is set to 255 and the random modifier is set to 20 the result will always be 255", "-The next 3 fields (Motion X, Y & Z) control the direction and speed of the particle " + "-The \"Life\" field sets how long (in ticks) before the particle despawns. " + "-The \"Size\" field sets the size of the particle. " + "-The next 3 fields (Spawn X, Y & Z) Sets the spawn location of the particle (relative to the location of the particle generator)", "-The \"Delay\" field sets the delay (in ticks) between each particle spawn e.g. 1=20/s, 20=1/s, 100=1/5s " + "-The \"Fade\" field sets how long (in ticks) it takes the partile to fade out of existance. Note: This adds to the life of the particle " + "-The \"Gravity\" field sets how the particle is affected by gravity. " + "-\"Block Collision\" Toggles weather or not the particle will collide with blocks " + "-\"Particle Selected\" Switches between the different particles available.", EnumChatFormatting.DARK_RED + " Redstone Control" + EnumChatFormatting.BLACK + "\nBy default a redstone signal is required for the generator to run." + "\n\nHowever if you shift right click the generator with an empty hand it will switch to inverted mode." + "\nThe redstone mode is indicated by the 8 cubes at the corners of the block."}; //@formatter:off @Override - public void drawScreen(int x, int y, float f) - { + public void drawScreen(int x, int y, float f) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture); int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; drawTexturedModalRect(posX, posY, 0, 0, xSize, ySize); - if (page < 3) - fontRendererObj.drawStringWithShadow("Particle Generator",posX + 60, posY + 5, 0x00FFFF); - else - fontRendererObj.drawStringWithShadow("Information",posX + 75, posY + 5, 0x00FFFF); - - if (page == 1) - page1Txt(); - else if (page == 2) - page2Txt(); - else{ - fontRendererObj.drawSplitString(InfoText[page-3], posX + 5, posY + 20, 200, 0x000000); - fontRendererObj.drawSplitString("Page: " + (page-3), posX + 88, posY + 180, 200, 0xFF0000); + if (page < 3) fontRendererObj.drawStringWithShadow("Particle Generator", posX + 60, posY + 5, 0x00FFFF); + else fontRendererObj.drawStringWithShadow("Information", posX + 75, posY + 5, 0x00FFFF); + + if (page == 1) page1Txt(); + else if (page == 2) page2Txt(); + else { + fontRendererObj.drawSplitString(InfoText[page - 3], posX + 5, posY + 20, 200, 0x000000); + fontRendererObj.drawSplitString("Page: " + (page - 3), posX + 88, posY + 180, 200, 0xFF0000); } - - fontRendererObj.drawStringWithShadow("Hold:", posX + 215, posY + 11, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Shift +- 10", posX + 215, posY + 21, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Ctrl +- 50", posX + 215, posY + 31, 0xFFFFFF); - fontRendererObj.drawStringWithShadow("Shift+Ctrl +- 100",posX + 215, posY + 41, 0xFFFFFF); + + fontRendererObj.drawStringWithShadow("Hold:", posX + 215, posY + 11, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Shift +- 10", posX + 215, posY + 21, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Ctrl +- 50", posX + 215, posY + 31, 0xFFFFFF); + fontRendererObj.drawStringWithShadow("Shift+Ctrl +- 100", posX + 215, posY + 41, 0xFFFFFF); super.drawScreen(x, y, f); - + ArrayList lines = new ArrayList(); lines.add("test"); - + //drawHoveringText(lines, x, y, fontRendererObj); - - + + } //@formatter:on @Override - protected void mouseClicked(int x, int y, int button) - { + protected void mouseClicked(int x, int y, int button) { super.mouseClicked(x, y, button); } @SuppressWarnings("unchecked") @Override - public void initGui() - { + public void initGui() { int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; buttonList.clear(); - if (page == 1) - page1Buttons(); - else if (page == 2) - page2Buttons(); - else - { + if (page == 1) page1Buttons(); + else if (page == 2) page2Buttons(); + else { buttonList.add(new GuiButton(57, posX + 4, posY + 174, 80, 20, "Previous page")); buttonList.add(new GuiButton(56, posX + 128, posY + 174, 80, 20, "Next page")); } - if (page < 3) - buttonList.add(new GuiButton(54, posX - 21, posY + 3, 20, 20, "i")); - else - buttonList.add(new GuiButton(55, posX - 31, posY + 23, 30, 20, "Back")); + if (page < 3) buttonList.add(new GuiButton(54, posX - 21, posY + 3, 20, 20, "i")); + else buttonList.add(new GuiButton(55, posX - 31, posY + 23, 30, 20, "Back")); } @Override - protected void actionPerformed(GuiButton button) - { + protected void actionPerformed(GuiButton button) { int value = 1; float value_F; short packetValue = 0; - if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) - value = 10; - if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) - value = 50; + if (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)) value = 10; + if (Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) value = 50; if ((Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54))) value = 100; @@ -161,272 +141,263 @@ public class GUIParticleGenerator extends GuiScreen case 0://Red + red = (red + value) > 255 ? 255 : red + value; packetValue = (short) red; - break; + break; case 1://Green + green = (green + value) > 255 ? 255 : green + value; packetValue = (short) green; - break; + break; case 2://Blue + blue = (blue + value) > 255 ? 255 : blue + value; packetValue = (short) blue; - break; + break; case 3://MX + motion_x = (motion_x + value_F) > 5F ? 5F : motion_x + value_F; packetValue = (short) (motion_x * 1000F); - break; + break; case 4://MY + motion_y = (motion_y + value_F) > 5F ? 5F : motion_y + value_F; packetValue = (short) (motion_y * 1000F); - break; + break; case 5://MZ + motion_z = (motion_z + value_F) > 5F ? 5F : motion_z + value_F; packetValue = (short) (motion_z * 1000F); - break; + break; case 6://Red - red = (red - value) < 0 ? 0 : red - value; packetValue = (short) red; - break; + break; case 7://Green - green = (green - value) < 0 ? 0 : green - value; packetValue = (short) green; - break; + break; case 8://Blue - blue = (blue - value) < 0 ? 0 : blue - value; packetValue = (short) blue; - break; + break; case 9://MX - motion_x = (motion_x - value_F) < -5F ? -5F : motion_x - value_F; packetValue = (short) (motion_x * 1000F); - break; + break; case 10://MY - motion_y = (motion_y - value_F) < -5F ? -5F : motion_y - value_F; packetValue = (short) (motion_y * 1000F); - break; + break; case 11://MZ - motion_z = (motion_z - value_F) < -5F ? -5F : motion_z - value_F; packetValue = (short) (motion_z * 1000F); - break; + break; case 12://RRed + random_red = (random_red + value) > 255 ? 255 : random_red + value; packetValue = (short) random_red; - break; + break; case 13://RGreen + random_green = (random_green + value) > 255 ? 255 : random_green + value; packetValue = (short) random_green; - break; + break; case 14://RBlue + random_blue = (random_blue + value) > 255 ? 255 : random_blue + value; packetValue = (short) random_blue; - break; + break; case 15://RMX + random_motion_x = (random_motion_x + value_F) > 5F ? 5F : random_motion_x + value_F; packetValue = (short) (random_motion_x * 1000F); - break; + break; case 16://RMY + random_motion_y = (random_motion_y + value_F) > 5F ? 5F : random_motion_y + value_F; packetValue = (short) (random_motion_y * 1000F); - break; + break; case 17://RMZ + random_motion_z = (random_motion_z + value_F) > 5F ? 5F : random_motion_z + value_F; packetValue = (short) (random_motion_z * 1000F); - break; + break; case 18://RRed - random_red = (random_red - value) < 0 ? 0 : random_red - value; packetValue = (short) random_red; - break; + break; case 19://RGreen - random_green = (random_green - value) < 0 ? 0 : random_green - value; packetValue = (short) random_green; - break; + break; case 20://RBlue - random_blue = (random_blue - value) < 0 ? 0 : random_blue - value; packetValue = (short) random_blue; - break; + break; case 21://RMX - random_motion_x = (random_motion_x - value_F) < -5F ? -5F : random_motion_x - value_F; packetValue = (short) (random_motion_x * 1000F); - break; + break; case 22://RMY - random_motion_y = (random_motion_y - value_F) < -5F ? -5F : random_motion_y - value_F; packetValue = (short) (random_motion_y * 1000F); - break; + break; case 23://RMZ - random_motion_z = (random_motion_z - value_F) < -5F ? -5F : random_motion_z - value_F; packetValue = (short) (random_motion_z * 1000F); - break; + break; case 24://Life + life = (life + value) > 1000 ? 1000 : life + value; packetValue = (short) life; - break; + break; case 25://Life - life = (life - value) < 0 ? 0 : life - value; packetValue = (short) life; - break; + break; case 26://RLife + random_life = (random_life + value) > 1000 ? 1000 : random_life + value; packetValue = (short) random_life; - break; + break; case 27://RLife - random_life = (random_life - value) < 0 ? 0 : random_life - value; packetValue = (short) random_life; - break; + break; case 28://Size + scale = (scale + value_F * 10F) > 50F ? 50F : scale + value_F * 10F; packetValue = (short) (scale * 100F); - break; + break; case 29://Size - scale = (scale - value_F * 10F) < 0.01F ? 0.01F : scale - value_F * 10F; packetValue = (short) (scale * 100F); - break; + break; case 30://RSize + random_scale = (random_scale + value_F * 10F) > 50F ? 50F : random_scale + value_F * 10F; packetValue = (short) (random_scale * 100F); - break; + break; case 31://RSize - random_scale = (random_scale - value_F * 10F) < 0.0F ? 0.0F : random_scale - value_F * 10F; packetValue = (short) (random_scale * 100F); - break; + break; case 32://Page 2 page = 2; packetValue = (short) page; initGui(); - break; + break; case 33://Page 1 page = 1; initGui(); packetValue = (short) page; - break; + break; case 34://SX + spawn_x = (spawn_x + value_F * 100F) > 50F ? 50F : spawn_x + value_F * 100F; packetValue = (short) (spawn_x * 100F); - break; + break; case 35://SX - spawn_x = (spawn_x - value_F * 100F) < -50F ? -50F : spawn_x - value_F * 100F; packetValue = (short) (spawn_x * 100F); - break; + break; case 36://RSX + random_spawn_x = (random_spawn_x + value_F * 100F) > 50F ? 50F : random_spawn_x + value_F * 100F; packetValue = (short) (random_spawn_x * 100F); - break; + break; case 37://RSX - random_spawn_x = (random_spawn_x - value_F * 100F) < -50F ? -50F : random_spawn_x - value_F * 100F; packetValue = (short) (random_spawn_x * 100F); - break; + break; case 38://SY + spawn_y = (spawn_y + value_F * 100F) > 50F ? 50F : spawn_y + value_F * 100F; packetValue = (short) (spawn_y * 100F); - break; + break; case 39://SY - spawn_y = (spawn_y - value_F * 100F) < -50F ? -50F : spawn_y - value_F * 100F; packetValue = (short) (spawn_y * 100F); - break; + break; case 40://RSY + random_spawn_y = (random_spawn_y + value_F * 100F) > 50F ? 50F : random_spawn_y + value_F * 100F; packetValue = (short) (random_spawn_y * 100F); - break; + break; case 41://RSY - random_spawn_y = (random_spawn_y - value_F * 100F) < -50F ? -50F : random_spawn_y - value_F * 100F; packetValue = (short) (random_spawn_y * 100F); - break; + break; case 42://SZ + spawn_z = (spawn_z + value_F * 100F) > 50F ? 50F : spawn_z + value_F * 100F; packetValue = (short) (spawn_z * 100F); - break; + break; case 43://SZ - spawn_z = (spawn_z - value_F * 100F) < -50F ? -50F : spawn_z - value_F * 100F; packetValue = (short) (spawn_z * 100F); - break; + break; case 44://RSZ + random_spawn_z = (random_spawn_z + value_F * 100F) > 50F ? 50F : random_spawn_z + value_F * 100F; packetValue = (short) (random_spawn_z * 100F); - break; + break; case 45://RSZ - random_spawn_z = (random_spawn_z - value_F * 100F) < -50F ? -50F : random_spawn_z - value_F * 100F; packetValue = (short) (random_spawn_z * 100F); - break; + break; case 46://Delay + spawn_rate = (spawn_rate + value) > 200 ? 200 : spawn_rate + value; packetValue = (short) spawn_rate; - break; + break; case 47://Delay - spawn_rate = (spawn_rate - value) < 1 ? 1 : spawn_rate - value; packetValue = (short) spawn_rate; - break; + break; case 48://Fade + fade = (fade + value) > 100 ? 100 : fade + value; packetValue = (short) fade; - break; + break; case 49://Fade - fade = (fade - value) < 0 ? 0 : fade - value; packetValue = (short) fade; - break; + break; case 50://Toggle Collision collide = !collide; packetValue = (short) (collide ? 1 : 0); initGui(); - break; + break; case 51://cycle particle selection selected_particle = selected_particle < selected_max ? selected_particle + 1 : 1; packetValue = (short) selected_particle; initGui(); - break; + break; case 52://RSZ + gravity = (gravity + value_F) > 5F ? 5F : gravity + value_F; packetValue = (short) (gravity * 1000F); - break; + break; case 53://RSZ - gravity = (gravity - value_F) < -5F ? -5F : gravity - value_F; packetValue = (short) (gravity * 1000F); - break; + break; case 54://Info Page page = 3; initGui(); packetValue = (short) page; - break; + break; case 55://Back Page page = 1; initGui(); packetValue = (short) page; - break; + break; case 56://Info Next Page - if (page < 7) - page++; - else - initGui(); - break; + if (page < 7) page++; + else initGui(); + break; case 57://Info Previous Page - if (page > 3) - page--; - else - initGui(); - break; + if (page > 3) page--; + else initGui(); + break; } DraconicEvolution.channelHandler.sendToServer(new ParticleGenPacket((byte) button.id, packetValue, tile.xCoord, tile.yCoord, tile.zCoord)); } @Override - public void keyTyped(char key, int keyN) - { - if ((key == 'e') || key == '') - { + public void keyTyped(char key, int keyN) { + if ((key == 'e') || key == '') { this.mc.displayGuiScreen(null); this.mc.setIngameFocus(); } } @Override - public void updateScreen() - { + public void updateScreen() { } @Override - public boolean doesGuiPauseGame() - { + public boolean doesGuiPauseGame() { return false; } - private void syncWithServer() - { + private void syncWithServer() { red = tile.red; green = tile.green; blue = tile.blue; @@ -458,66 +429,64 @@ public class GUIParticleGenerator extends GuiScreen } //@formatter:off - private void page1Txt() - { + private void page1Txt() { int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; - - String motionX = String.valueOf(Math.round(motion_x*1000F)/1000F); - String motionY = String.valueOf(Math.round(motion_y*1000F)/1000F); - String motionZ = String.valueOf(Math.round(motion_z*1000F)/1000F); - String random_motionX = String.valueOf(Math.round(random_motion_x*1000F)/1000F); - String random_motionY = String.valueOf(Math.round(random_motion_y*1000F)/1000F); - String random_motionZ = String.valueOf(Math.round(random_motion_z*1000F)/1000F); - String scale1 = String.valueOf(Math.round(scale*100F)/100F); - String random_scale1 = String.valueOf(Math.round(random_scale*100F)/100F); - + + String motionX = String.valueOf(Math.round(motion_x * 1000F) / 1000F); + String motionY = String.valueOf(Math.round(motion_y * 1000F) / 1000F); + String motionZ = String.valueOf(Math.round(motion_z * 1000F) / 1000F); + String random_motionX = String.valueOf(Math.round(random_motion_x * 1000F) / 1000F); + String random_motionY = String.valueOf(Math.round(random_motion_y * 1000F) / 1000F); + String random_motionZ = String.valueOf(Math.round(random_motion_z * 1000F) / 1000F); + String scale1 = String.valueOf(Math.round(scale * 100F) / 100F); + String random_scale1 = String.valueOf(Math.round(random_scale * 100F) / 100F); + int col1 = posX + 30; int col2 = posX + 141; int ln1 = 20; int ln2 = 30; - - fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(red), col1, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false); + + fontRendererObj.drawString("Red:", col1, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(red), col1, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Green:", col1, posY + ln1 + 1 * 22, 0x000000, false); fontRendererObj.drawString(String.valueOf(green), col1, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString(String.valueOf(blue), col1, posY + ln2 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("Motion X:", col1, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString(motionX, col1, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Motion Y:", col1, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString(motionY, col1, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Motion Z:", col1, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString(motionZ, col1, posY + ln2 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("Life:", col1, posY + ln1 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("" + life + " T", col1, posY + ln2 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("Size:", col1, posY + ln1 + 7 * 22, 0x000000, false); - fontRendererObj.drawString("" + scale1, col1, posY + ln2 + 7 * 22, 0x000000, false); - + fontRendererObj.drawString("Blue:", col1, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString(String.valueOf(blue), col1, posY + ln2 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("Motion X:", col1, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString(motionX, col1, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Motion Y:", col1, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString(motionY, col1, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Motion Z:", col1, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString(motionZ, col1, posY + ln2 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("Life:", col1, posY + ln1 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("" + life + " T", col1, posY + ln2 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("Size:", col1, posY + ln1 + 7 * 22, 0x000000, false); + fontRendererObj.drawString("" + scale1, col1, posY + ln2 + 7 * 22, 0x000000, false); + for (int i = 0; i < 8; i++) fontRendererObj.drawStringWithShadow("(+)", posX + 98, posY + 25 + i * 22, 0xFFFFFF); - - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_red, col2, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_green, col2, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_blue, col2, posY + ln2 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_motionX,col2, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_motionY,col2, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_motionZ,col2, posY + ln2 + 5 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_life, col2, posY + ln2 + 6 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 7 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_scale1, col2, posY + ln2 + 7 * 22, 0x000000, false); + + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_red, col2, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_green, col2, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_blue, col2, posY + ln2 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_motionX, col2, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_motionY, col2, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_motionZ, col2, posY + ln2 + 5 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_life, col2, posY + ln2 + 6 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 7 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_scale1, col2, posY + ln2 + 7 * 22, 0x000000, false); } @SuppressWarnings("unchecked") - private void page1Buttons() - { + private void page1Buttons() { int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; int DX1 = 5; @@ -526,92 +495,90 @@ public class GUIParticleGenerator extends GuiScreen int DX4 = DX3 + 71; int y1 = 19; - buttonList.add(new GuiButton(0, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(1, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(2, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(3, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(4, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(5, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(24,posX + DX1, posY + y1 + 6 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(28,posX + DX1, posY + y1 + 7 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(0, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(1, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(2, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(3, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(4, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(5, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(24, posX + DX1, posY + y1 + 6 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(28, posX + DX1, posY + y1 + 7 * 22, 20, 20, "+")); buttonList.add(new GuiButton(6, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); buttonList.add(new GuiButton(7, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); buttonList.add(new GuiButton(8, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); buttonList.add(new GuiButton(9, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(10,posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(11,posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(25,posX + DX2, posY + y1 + 6 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(29,posX + DX2, posY + y1 + 7 * 22, 20, 20, "-")); - - buttonList.add(new GuiButton(12,posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(13,posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(14,posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(15,posX + DX3, posY + y1 + 3 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(16,posX + DX3, posY + y1 + 4 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(17,posX + DX3, posY + y1 + 5 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(26,posX + DX3, posY + y1 + 6 * 22, 20, 20, "+")); - buttonList.add(new GuiButton(30,posX + DX3, posY + y1 + 7 * 22, 20, 20, "+")); - - buttonList.add(new GuiButton(18,posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(19,posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(20,posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(21,posX + DX4, posY + y1 + 3 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(22,posX + DX4, posY + y1 + 4 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(23,posX + DX4, posY + y1 + 5 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(27,posX + DX4, posY + y1 + 6 * 22, 20, 20, "-")); - buttonList.add(new GuiButton(31,posX + DX4, posY + y1 + 7 * 22, 20, 20, "-")); - - buttonList.add(new GuiButton(32,posX + 213, posY + 177, 47, 20, "Page 2")); + buttonList.add(new GuiButton(10, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(11, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(25, posX + DX2, posY + y1 + 6 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(29, posX + DX2, posY + y1 + 7 * 22, 20, 20, "-")); + + buttonList.add(new GuiButton(12, posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(13, posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(14, posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(15, posX + DX3, posY + y1 + 3 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(16, posX + DX3, posY + y1 + 4 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(17, posX + DX3, posY + y1 + 5 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(26, posX + DX3, posY + y1 + 6 * 22, 20, 20, "+")); + buttonList.add(new GuiButton(30, posX + DX3, posY + y1 + 7 * 22, 20, 20, "+")); + + buttonList.add(new GuiButton(18, posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(19, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(20, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(21, posX + DX4, posY + y1 + 3 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(22, posX + DX4, posY + y1 + 4 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(23, posX + DX4, posY + y1 + 5 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(27, posX + DX4, posY + y1 + 6 * 22, 20, 20, "-")); + buttonList.add(new GuiButton(31, posX + DX4, posY + y1 + 7 * 22, 20, 20, "-")); + + buttonList.add(new GuiButton(32, posX + 213, posY + 177, 47, 20, "Page 2")); } - private void page2Txt() - { + private void page2Txt() { int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; - + int col1 = posX + 30; int col2 = posX + 141; int ln1 = 20; int ln2 = 30; - - String spawn_X = String.valueOf(Math.round(spawn_x*10F)/10F); - String spawn_Y = String.valueOf(Math.round(spawn_y*10F)/10F); - String spawn_Z = String.valueOf(Math.round(spawn_z*10F)/10F); - String random_spawn_X = String.valueOf(Math.round(random_spawn_x*10F)/10F); - String random_spawn_Y = String.valueOf(Math.round(random_spawn_y*10F)/10F); - String random_spawn_Z = String.valueOf(Math.round(random_spawn_z*10F)/10F); - String Gravity = String.valueOf(Math.round(gravity*1000F)/1000F); - - fontRendererObj.drawString("Spawn X:", col1, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString(spawn_X, col1, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Spawn Y:", col1, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString(spawn_Y, col1, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Spawn Z:", col1, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString(spawn_Z, col1, posY + ln2 + 2 * 22, 0x000000, false); - + + String spawn_X = String.valueOf(Math.round(spawn_x * 10F) / 10F); + String spawn_Y = String.valueOf(Math.round(spawn_y * 10F) / 10F); + String spawn_Z = String.valueOf(Math.round(spawn_z * 10F) / 10F); + String random_spawn_X = String.valueOf(Math.round(random_spawn_x * 10F) / 10F); + String random_spawn_Y = String.valueOf(Math.round(random_spawn_y * 10F) / 10F); + String random_spawn_Z = String.valueOf(Math.round(random_spawn_z * 10F) / 10F); + String Gravity = String.valueOf(Math.round(gravity * 1000F) / 1000F); + + fontRendererObj.drawString("Spawn X:", col1, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString(spawn_X, col1, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Spawn Y:", col1, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString(spawn_Y, col1, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Spawn Z:", col1, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString(spawn_Z, col1, posY + ln2 + 2 * 22, 0x000000, false); + for (int i = 0; i < 3; i++) fontRendererObj.drawStringWithShadow("(+)", posX + 98, posY + 25 + i * 22, 0xFFFFFF); - - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_spawn_X,col2, posY + ln2 + 0 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_spawn_Y,col2, posY + ln2 + 1 * 22, 0x000000, false); - fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); - fontRendererObj.drawString("> "+random_spawn_Z,col2, posY + ln2 + 2 * 22, 0x000000, false); - - fontRendererObj.drawString("Delay:", col1, posY + ln1 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("" + spawn_rate,col1, posY + ln2 + 3 * 22, 0x000000, false); - fontRendererObj.drawString("Fade:", col1, posY + ln1 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("" + fade, col1, posY + ln2 + 4 * 22, 0x000000, false); - fontRendererObj.drawString("Gravity:", col1, posY + ln1 + 5 * 22, 0x000000, false); - fontRendererObj.drawString(Gravity, col1, posY + ln2 + 5 * 22, 0x000000, false); + + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_spawn_X, col2, posY + ln2 + 0 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_spawn_Y, col2, posY + ln2 + 1 * 22, 0x000000, false); + fontRendererObj.drawString("Random:0", col2, posY + ln1 + 2 * 22, 0x000000, false); + fontRendererObj.drawString("> " + random_spawn_Z, col2, posY + ln2 + 2 * 22, 0x000000, false); + + fontRendererObj.drawString("Delay:", col1, posY + ln1 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("" + spawn_rate, col1, posY + ln2 + 3 * 22, 0x000000, false); + fontRendererObj.drawString("Fade:", col1, posY + ln1 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("" + fade, col1, posY + ln2 + 4 * 22, 0x000000, false); + fontRendererObj.drawString("Gravity:", col1, posY + ln1 + 5 * 22, 0x000000, false); + fontRendererObj.drawString(Gravity, col1, posY + ln2 + 5 * 22, 0x000000, false); } - + @SuppressWarnings("unchecked") - private void page2Buttons() - { + private void page2Buttons() { int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; int DX1 = 5; @@ -619,29 +586,29 @@ public class GUIParticleGenerator extends GuiScreen int DX3 = DX2 + 40; int DX4 = DX3 + 71; int y1 = 19; - + buttonList.add(new GuiButton(34, posX + DX1, posY + y1 + 0 * 22, 20, 20, "+")); buttonList.add(new GuiButton(38, posX + DX1, posY + y1 + 1 * 22, 20, 20, "+")); buttonList.add(new GuiButton(42, posX + DX1, posY + y1 + 2 * 22, 20, 20, "+")); buttonList.add(new GuiButton(46, posX + DX1, posY + y1 + 3 * 22, 20, 20, "+")); buttonList.add(new GuiButton(48, posX + DX1, posY + y1 + 4 * 22, 20, 20, "+")); buttonList.add(new GuiButton(52, posX + DX1, posY + y1 + 5 * 22, 20, 20, "+")); - + buttonList.add(new GuiButton(35, posX + DX2, posY + y1 + 0 * 22, 20, 20, "-")); buttonList.add(new GuiButton(39, posX + DX2, posY + y1 + 1 * 22, 20, 20, "-")); buttonList.add(new GuiButton(43, posX + DX2, posY + y1 + 2 * 22, 20, 20, "-")); buttonList.add(new GuiButton(47, posX + DX2, posY + y1 + 3 * 22, 20, 20, "-")); buttonList.add(new GuiButton(49, posX + DX2, posY + y1 + 4 * 22, 20, 20, "-")); buttonList.add(new GuiButton(53, posX + DX2, posY + y1 + 5 * 22, 20, 20, "-")); - + buttonList.add(new GuiButton(36, posX + DX3, posY + y1 + 0 * 22, 20, 20, "+")); buttonList.add(new GuiButton(40, posX + DX3, posY + y1 + 1 * 22, 20, 20, "+")); buttonList.add(new GuiButton(44, posX + DX3, posY + y1 + 2 * 22, 20, 20, "+")); - + buttonList.add(new GuiButton(37, posX + DX4, posY + y1 + 0 * 22, 20, 20, "-")); buttonList.add(new GuiButton(41, posX + DX4, posY + y1 + 1 * 22, 20, 20, "-")); buttonList.add(new GuiButton(45, posX + DX4, posY + y1 + 2 * 22, 20, 20, "-")); - + buttonList.add(new GuiButton(33, posX - 47, posY + 177, 47, 20, "Page 1")); buttonList.add(new GuiButton(50, posX + DX3 - 11, posY + y1 + 3 * 22, 102, 20, "Block Collision: " + (collide ? "on" : "off"))); buttonList.add(new GuiButton(51, posX + DX3 - 11, posY + y1 + 4 * 22, 102, 20, "Particle Selected: " + selected_particle)); diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java index 362198cf..51a58564 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GUITeleporter.java @@ -18,7 +18,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.core.handler.ConfigHandler; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.core.network.TeleporterPacket; import com.brandon3055.draconicevolution.common.core.network.TeleporterStringPacket; import com.brandon3055.draconicevolution.common.items.ModItems; diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GuiHandler.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GuiHandler.java index 38d01ca4..18a6c870 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GuiHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/GuiHandler.java @@ -1,22 +1,14 @@ package com.brandon3055.draconicevolution.client.interfaces; import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.container.*; +import com.brandon3055.draconicevolution.common.tileentities.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; -import com.brandon3055.draconicevolution.common.container.ContainerGrinder; -import com.brandon3055.draconicevolution.common.container.ContainerPlayerDetector; -import com.brandon3055.draconicevolution.common.container.ContainerReader; -import com.brandon3055.draconicevolution.common.container.ContainerSunDial; -import com.brandon3055.draconicevolution.common.container.ContainerWeatherController; import com.brandon3055.draconicevolution.common.core.utills.InventoryReader; -import com.brandon3055.draconicevolution.common.tileentities.TileGrinder; -import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator; -import com.brandon3055.draconicevolution.common.tileentities.TilePlayerDetectorAdvanced; -import com.brandon3055.draconicevolution.common.tileentities.TileSunDial; -import com.brandon3055.draconicevolution.common.tileentities.TileWeatherController; public class GuiHandler implements IGuiHandler { @@ -27,6 +19,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUIID_READER = 4; public static final int GUIID_PARTICLEGEN = 5; public static final int GUIID_PLAYERDETECTOR = 6; + public static final int GUIID_ENERGY_INFUSER = 7; public GuiHandler() { NetworkRegistry.INSTANCE.registerGuiHandler(DraconicEvolution.instance, this); @@ -62,7 +55,13 @@ public class GuiHandler implements IGuiHandler { return new ContainerPlayerDetector(player.inventory, (TilePlayerDetectorAdvanced) detector); } break; + case GUIID_ENERGY_INFUSER: + TileEntity infuser = world.getTileEntity(x, y, z); + if (infuser != null && infuser instanceof TileEnergyInfuser) { + return new ContainerEnergyInfuser(player.inventory, (TileEnergyInfuser) infuser); } + break; + } return null; } @@ -101,6 +100,11 @@ public class GuiHandler implements IGuiHandler { if (detector != null && detector instanceof TilePlayerDetectorAdvanced) { return new GUIPlayerDetector(player.inventory, (TilePlayerDetectorAdvanced) detector); } + case GUIID_ENERGY_INFUSER: + TileEntity infuser = world.getTileEntity(x, y, z); + if (infuser != null && infuser instanceof TileEnergyInfuser) { + return new GUIEnergyInfuser(player.inventory, (TileEnergyInfuser) infuser); + } } return null; diff --git a/src/main/java/com/brandon3055/draconicevolution/client/interfaces/SlotChargable.java b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/SlotChargable.java new file mode 100644 index 00000000..dd5e153e --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/interfaces/SlotChargable.java @@ -0,0 +1,39 @@ +package com.brandon3055.draconicevolution.client.interfaces; + +import com.brandon3055.draconicevolution.common.core.utills.EnergyHelper; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import net.minecraft.block.Block; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class SlotChargable extends Slot { + + + public SlotChargable(IInventory inventory, int id, int x, int y) { + super(inventory, id, x, y); + + } + + @Override + public boolean isItemValid(ItemStack stack) + { + if (super.isItemValid(stack)) + { + return EnergyHelper.isEnergyContainerItem(stack); + } + return false; + } + + @Override + public int getSlotStackLimit() + { + return 1; + } + + + @Override + public boolean func_111238_b() { + return !((TileEnergyInfuser)inventory).running; + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/BowRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/BowRenderer.java index f59af987..e368f65e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/BowRenderer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/BowRenderer.java @@ -1,15 +1,25 @@ package com.brandon3055.draconicevolution.client.render; +import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @@ -45,21 +55,21 @@ public class BowRenderer implements IItemRenderer { //Credit to SanAndreasP on minecraftforge forums for this code. public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - EntityClientPlayerMP entity = (EntityClientPlayerMP) data[1]; + EntityLivingBase entity = (EntityLivingBase) data[1]; //ItemRenderer irInstance = this.mc.entityRenderer.itemRenderer; - GL11.glPopMatrix(); // prevents Forge from pre-translating the item + GL11.glPushMatrix(); // prevents Forge from pre-translating the item if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { this.renderItem(entity, item, 0); } else { GL11.glPushMatrix(); // contra-translate the item from it's standard translation // also apply some more scale or else the bow is tiny - float f2 = 3F - (1F / 3F); - GL11.glRotatef(-20.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(-60.0F, 0.0F, 0.0F, 1.0F); + float f2 = 3F - (1F / 1.3F); + GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //Roll left-right + GL11.glRotatef(110.0F, 1.0F, 0.0F, 0.0F);//aim up-down + GL11.glRotatef(-10.0F, 0.0F, 0.0F, 1.0F);//aim left-right GL11.glScalef(f2, f2, f2); - GL11.glTranslatef(-0.25F, -0.1875F, 0.1875F); + GL11.glTranslatef(0.15F, -0.1875F, 0.1875F); // render the item as 'real' bow //This is pulled from RenderBiped @@ -73,27 +83,63 @@ public class BowRenderer implements IItemRenderer { this.renderItem(entity, item, 0); GL11.glPopMatrix(); } - GL11.glPushMatrix(); // prevents GL Underflow errors + GL11.glPopMatrix(); // prevents GL Underflow errors } //This actually renders an Icon to be worked with. //All of this code is directly pulled from ItemRenderer.class - private void renderItem(EntityClientPlayerMP par1EntityLiving, ItemStack par2ItemStack, int par3) + private void renderItem(EntityLivingBase par1EntityLivingBase, ItemStack par2ItemStack, int par3) { + RenderBlocks renderBlocksIr = new RenderBlocks(); + + ItemRenderType type = ItemRenderType.EQUIPPED_FIRST_PERSON; + + GL11.glPushMatrix(); + TextureManager texturemanager = this.mc.getTextureManager(); + Item item = par2ItemStack.getItem(); + Block block = Block.getBlockFromItem(item); + + IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(par2ItemStack, type); + if (customRenderer != null) { -//If you for whatever reason aren't registering icons with iconRegister, I'm assuming you'll need to change the code below. - IIcon icon = par2ItemStack.getIconIndex(); - if (icon == null) { + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + ForgeHooksClient.renderEquippedItem(type, customRenderer, renderBlocksIr, par1EntityLivingBase, par2ItemStack); + } + else if (par2ItemStack.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) + { + texturemanager.bindTexture(texturemanager.getResourceLocation(0)); + + if (par2ItemStack != null && par2ItemStack.getItem() instanceof ItemCloth) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + renderBlocksIr.renderBlockAsItem(block, par2ItemStack.getItemDamage(), 1.0F); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + } + else + { + renderBlocksIr.renderBlockAsItem(block, par2ItemStack.getItemDamage(), 1.0F); + } + } + else + { + IIcon iicon = par1EntityLivingBase.getItemIcon(par2ItemStack, par3); + + if (iicon == null) + { GL11.glPopMatrix(); return; } - TextureManager texturemanager = this.mc.getTextureManager(); - texturemanager.getTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + //TextureUtil.func_147950_a(false, false); Tessellator tessellator = Tessellator.instance; - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); + float f = iicon.getMinU(); + float f1 = iicon.getMaxU(); + float f2 = iicon.getMinV(); + float f3 = iicon.getMaxV(); float f4 = 0.0F; float f5 = 0.3F; GL11.glEnable(GL12.GL_RESCALE_NORMAL); @@ -103,28 +149,30 @@ public class BowRenderer implements IItemRenderer { GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); - ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); -//This checks for enchantments. - if (par2ItemStack.hasEffect(par3)) { + ItemRenderer.renderItemIn2D(tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F); + + if (par2ItemStack.hasEffect(par3)) + { + ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); - texturemanager.bindTexture(new ResourceLocation("textures/misc/enchanted_item_glint.png")); + texturemanager.bindTexture(RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); + OpenGlHelper.glBlendFunc(768, 1, 1, 0); float f7 = 0.76F; GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); - float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F; + float f9 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); - f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; + f9 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F); @@ -134,7 +182,14 @@ public class BowRenderer implements IItemRenderer { GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + texturemanager.bindTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber())); + TextureUtil.func_147945_b(); } + + GL11.glPopMatrix(); } + + } diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/CustonSpawnerRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/CustonSpawnerRenderer.java new file mode 100644 index 00000000..dd990f7a --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/CustonSpawnerRenderer.java @@ -0,0 +1,84 @@ +package com.brandon3055.draconicevolution.client.render; + +/** + * Created by Brandon on 5/07/2014. + */ + +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.tileentities.CustomSpawnerBaseLogic; +import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class CustonSpawnerRenderer extends TileEntitySpecialRenderer +{ + private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/items/draconicCore.png"); + + public void renderTileEntityAt(TileCustomSpawner tile, double x, double y, double z, float p_147518_8_) + { + GL11.glPushMatrix(); + GL11.glTranslatef((float)x + 0.5F, (float)y, (float)z + 0.5F); + renderTile(tile.getBaseLogic(), x, y, z, p_147518_8_); + GL11.glPopMatrix(); + } + + public void renderTile(CustomSpawnerBaseLogic customSpawnerBaseLogic, double x, double y, double z, float p_147517_7_) + { + Tessellator tessellator = Tessellator.instance; + + Entity entity = customSpawnerBaseLogic.getEntityForRenderer(); + + if (entity != null) + { + GL11.glPushMatrix(); + entity.setWorld(customSpawnerBaseLogic.getSpawnerWorld()); + float f1 = 0.4375F; + GL11.glTranslatef(0.0F, 0.4F, 0.0F); + GL11.glRotatef((float) (customSpawnerBaseLogic.renderRotation1 + (customSpawnerBaseLogic.renderRotation0 - customSpawnerBaseLogic.renderRotation1) * (double) p_147517_7_) * 10.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-30.0F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.4F, 0.0F); + GL11.glScalef(f1, f1, f1); + entity.setLocationAndAngles(x, y, z, 0.0F, 0.0F); + RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, p_147517_7_); + GL11.glPopMatrix(); + } + { + GL11.glPushMatrix(); + bindTexture(texture); + + tessellator.setColorRGBA(255, 255, 255, 255); + tessellator.setBrightness(200); + + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + GL11.glTranslatef(-0.5F, 0F, -0.5F); + + tessellator.addVertexWithUV(0, 0.99D, 0, 0, 0); + tessellator.addVertexWithUV(1, 0.99D, 0, 1, 0); + tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1); + tessellator.addVertexWithUV(0, 0.99D, 1, 0, 1); + + tessellator.addVertexWithUV(0, 0.99D, 0, 0, 0); + tessellator.addVertexWithUV(0, 0.99D, 1, 1, 0); + tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1); + tessellator.addVertexWithUV(1, 0.99D, 0, 0, 1); + + tessellator.draw(); + + GL11.glPopMatrix(); + } + } + @Override + public void renderTileEntityAt(TileEntity p_147500_1_, double p_147500_2_, double p_147500_4_, double p_147500_6_, float p_147500_8_) + { + this.renderTileEntityAt((TileCustomSpawner)p_147500_1_, p_147500_2_, p_147500_4_, p_147500_6_, p_147500_8_); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/EnergyInfiserRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/EnergyInfiserRenderer.java new file mode 100644 index 00000000..6e909c93 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/EnergyInfiserRenderer.java @@ -0,0 +1,295 @@ +package com.brandon3055.draconicevolution.client.render; + +import com.brandon3055.draconicevolution.common.core.handler.ParticleHandler; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.Random; + +import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED; + +public class EnergyInfiserRenderer extends TileEntitySpecialRenderer +{ + + private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/EnergyInfuserTextureSheet.png"); + + private static float pxl = 1F / 256F; + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) + { + GL11.glPushMatrix(); + + GL11.glTranslatef((float) x, (float) y, (float) z); + TileEnergyInfuser tile = (TileEnergyInfuser) tileEntity; + renderBlock(tile, tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)); + + GL11.glPopMatrix(); + } + + //And this method actually renders your tile entity + public void renderBlock(TileEnergyInfuser tile, World world, int x, int y, int z, Block block) + { + Tessellator tessellator = Tessellator.instance; + bindTexture(texture); + + tessellator.setColorRGBA(255, 255, 255, 255); + tessellator.setBrightness(200); + int l = world.getLightBrightnessForSkyBlocks(x, y, z, 0); + int l1 = l % 65536; + int l2 = l / 65536; + tessellator.setColorOpaque_F(1f, 1f, 1f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); + + drawBase(tessellator); + drawWings(tessellator, tile); + renderChargingItem(tile); + + } + + private void drawBase(Tessellator tess){ + GL11.glPushMatrix(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, 1.0F); + + double srcXMin = 0D; + double srcYMin = 0D; + double srcXMax = 64D * pxl; + double srcYMax = 64D * pxl; + + tess.addVertexWithUV(0, 0.0005D, 0, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0.0005D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.0005D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0.0005D, 1, srcXMin, srcYMax); + + + srcXMin = 128D * pxl; + srcYMin = 0D; + srcXMax = 192D * pxl; + srcYMax = 64D * pxl; + + tess.addVertexWithUV(0, 0.3745D, 0, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0.3745D, 1, srcXMax, srcYMin); + tess.addVertexWithUV(1, 0.3745D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.3745D, 0, srcXMin, srcYMax); + + srcXMin = 64D * pxl; + srcYMin = 0D; + srcXMax = 128D * pxl; + srcYMax = 24D * pxl; + + tess.addVertexWithUV(1, 0, 0, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMin); + tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.375D, 0, srcXMin, srcYMax); + + tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMax); + tess.addVertexWithUV(0, 0.375D, 1, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0, 1, srcXMax, srcYMin); + + tess.addVertexWithUV(0, 0.375D, 1, srcXMin, srcYMin); + tess.addVertexWithUV(0, 0.375D, 0, srcXMax, srcYMin); + tess.addVertexWithUV(0, 0, 0, srcXMax, srcYMax); + tess.addVertexWithUV(0, 0, 1, srcXMin, srcYMax); + + tess.addVertexWithUV(1, 0.375D, 1, srcXMin, srcYMin); + tess.addVertexWithUV(1, 0, 1, srcXMin, srcYMax); + tess.addVertexWithUV(1, 0, 0, srcXMax, srcYMax); + tess.addVertexWithUV(1, 0.375D, 0, srcXMax, srcYMin); + + tess.draw(); + GL11.glPopMatrix(); + + } + + private void drawWings(Tessellator tess, TileEnergyInfuser tile){ + GL11.glPushMatrix(); + float srcXMin = 0F; //iicon.getMinU(); + float srcYMin = 64F * pxl; //iicon.getMaxU(); + float srcXMax = 92F * pxl; //iicon.getMinV(); + float srcYMax = 115F * pxl; //iicon.getMaxV(); + + GL11.glTranslatef(-0.64F, 0.365F, 0.51F); + GL11.glScalef(0.7F, 0.7F, 0.7F); + float xTrans = 0.025F; + + + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(tile.rotation, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + GL11.glTranslatef(1.62F, 0F, -xTrans); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glTranslatef(-1.62F, 0F, xTrans); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 92, 51, 0.0625F); + } + { + srcXMin = 64F * pxl; //iicon.getMinU(); + srcYMin = 24F * pxl; //iicon.getMaxU(); + srcXMax = 96F * pxl; //iicon.getMinV(); + srcYMax = 56F * pxl; //iicon.getMaxV(); + GL11.glTranslatef(1.26F, 0F, 0.31F); + GL11.glTranslatef(0F, 0F, 0F); + GL11.glRotatef(90, 0F, 1F, 0F); + GL11.glRotatef(90, 1F, 0F, 0F); + GL11.glTranslatef(-0F, 0F, 0F); + GL11.glScalef(1.4F, 1.4F, 1.4F); + render2DWithThicness(tess, srcXMax, srcYMin, srcXMin, srcYMax, 32, 32, 0.0625F); + } + GL11.glPopMatrix(); + } + + public static void render2DWithThicness(Tessellator tess, float maxU, float minV, float minU, float maxV, int width, int height, float thickness) + { + double pix = 1D / 64D; + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, 1.0F); + tess.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)maxU, (double)maxV); + tess.addVertexWithUV(width*pix, 0.0D, 0.0D, (double)minU, (double)maxV); + tess.addVertexWithUV(width*pix, height*pix, 0.0D, (double)minU, (double)minV); + tess.addVertexWithUV(0.0D, height*pix, 0.0D, (double) maxU, (double) minV); + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 0.0F, -1.0F); + tess.addVertexWithUV(0.0D, height*pix, (double) (0.0F - thickness), (double) maxU, (double) minV); + tess.addVertexWithUV(width*pix, height*pix, (double) (0.0F - thickness), (double) minU, (double) minV); + tess.addVertexWithUV(width*pix, 0.0D, (double)(0.0F - thickness), (double)minU, (double)maxV); + tess.addVertexWithUV(0.0D, 0.0D, (double)(0.0F - thickness), (double)maxU, (double)maxV); + tess.draw(); + float f5 = 0.5F * (maxU - minU) / (float)width; + float f6 = 0.5F * (maxV - minV) / (float)height; + tess.startDrawingQuads(); + tess.setNormal(-1.0F, 0.0F, 0.0F); + int k; + float f7; + float f8; + double d; + + for (k = 0; k < width; ++k) + { + d = k*pix; + f7 = (float)k / (float)width; + f8 = maxU + (minU - maxU) * f7 - f5; + tess.addVertexWithUV(d, 0.0D, (double)(0.0F - thickness), (double)f8, (double)maxV); + tess.addVertexWithUV(d, 0.0D, 0.0D, (double)f8, (double)maxV); + tess.addVertexWithUV(d, height*pix, 0.0D, (double)f8, (double)minV); + tess.addVertexWithUV(d, height*pix, (double)(0.0F - thickness), (double)f8, (double)minV); + } + + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(1.0F, 0.0F, 0.0F); + + for (k = 0; k < width; ++k) + { + d = (k+1)*pix; + f7 = (float)k / (float)width; + f8 = maxU + (minU - maxU) * f7 - f5; + tess.addVertexWithUV(d, height*pix, (double)(0.0F - thickness), (double)f8, (double)minV); + tess.addVertexWithUV(d, height*pix, 0.0D, (double)f8, (double)minV); + tess.addVertexWithUV(d, 0.0D, 0.0D, (double)f8, (double)maxV); + tess.addVertexWithUV(d, 0.0D, (double)(0.0F - thickness), (double)f8, (double)maxV); + } + + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, 1.0F, 0.0F); + + for (k = 0; k < height; ++k) + { + d = (k+1)*pix; + f7 = (float)k / (float)height; + f8 = maxV + (minV - maxV) * f7 - f6; + tess.addVertexWithUV(0.0D, d, 0.0D, (double)maxU, (double)f8); + tess.addVertexWithUV(width*pix, d, 0.0D, (double)minU, (double)f8); + tess.addVertexWithUV(width*pix, d, (double)(0.0F - thickness), (double)minU, (double)f8); + tess.addVertexWithUV(0.0D, d, (double)(0.0F - thickness), (double)maxU, (double)f8); + } + + tess.draw(); + tess.startDrawingQuads(); + tess.setNormal(0.0F, -1.0F, 0.0F); + + for (k = 0; k < height; ++k) + { + d = k*pix; + f7 = (float)k / (float)height; + f8 = maxV + (minV - maxV) * f7 - f6; + tess.addVertexWithUV(width*pix, d, 0.0D, (double)minU, (double)f8); + tess.addVertexWithUV(0.0D, d, 0.0D, (double)maxU, (double)f8); + tess.addVertexWithUV(0.0D, d, (double)(0.0F - thickness), (double)maxU, (double)f8); + tess.addVertexWithUV(width*pix, d, (double)(0.0F - thickness), (double)minU, (double)f8); + } + + tess.draw(); + } + + public void renderChargingItem(TileEnergyInfuser tile){ + if (tile.getStackInSlot(0) != null) { + GL11.glPushMatrix(); + + ItemStack stack = tile.getStackInSlot(0); + EntityItem itemEntity = new EntityItem(tile.getWorldObj(), 0, 0, 0, tile.getStackInSlot(0)); + itemEntity.hoverStart = 0.0F; + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1F, 1F, 1F); + if (tile.getWorldObj().getWorldInfo().getGameRulesInstance().getGameRuleBooleanValue("doDaylightCycle")) + GL11.glRotatef(tile.getWorldObj().getWorldTime(), 0F, -1F, 0F); + else + GL11.glRotatef(tile.rotation, 0F, -1F, 0F); + if (stack.getItem() instanceof ItemBlock) + { + GL11.glScalef(1F, 1F, 1F); + GL11.glTranslatef(0F, 0.045F, 0.0f); + } + + RenderItem.renderInFrame = true; + RenderManager.instance.renderEntityWithPosYaw(itemEntity, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderItem.renderInFrame = false; + + GL11.glPopMatrix(); + } + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/EnergyParticle.java b/src/main/java/com/brandon3055/draconicevolution/client/render/EnergyParticle.java new file mode 100644 index 00000000..0a7dcf59 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/EnergyParticle.java @@ -0,0 +1,139 @@ +package com.brandon3055.draconicevolution.client.render; + +import com.brandon3055.draconicevolution.common.lib.References; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +public class EnergyParticle extends EntityFX { + public double originalX; + public double originalY; + public double originalZ; + public double targetX; + public double targetY; + public double targetZ; + public int particle; + public boolean expand = true; + + public EnergyParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int particle, boolean expand) { + this(world, x, y, z, tX, tY, tZ, particle); + this.expand = expand; + this.particleRed = 185F / 255F; + this.particleGreen = 0.0F; + this.particleBlue = 197F / 255F; + this.particleScale = 0F; + } + + public EnergyParticle(World world, double x, double y, double z, double tX, double tY, double tZ, int particle) { + super(world, x, y, z, 0.0D, 0.0D, 0.0D); + this.motionX = 0; + this.motionY = 0; + this.motionZ = 0; + this.originalX = x; + this.originalY = y; + this.originalZ = z; + this.targetX = tX; + this.targetY = tY; + this.targetZ = tZ; + this.particle = particle; + + this.particleTextureIndexX = 0; + this.particleTextureIndexY = 0; + + this.particleRed = particle == 1 ? 0F : 1.0F; + this.particleGreen = particle == 1 ? 1F : 0.2F; + this.particleBlue = particle == 1 ? 1F : 0.0F; + //this.particleScale *= 0.05f + world.rand.nextFloat()*0.005; + //this.particleScale *= par8; + this.particleScale = 0.5F; + this.particleMaxAge = 80; + this.noClip = true; + } + + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (!expand && particleScale < 0.7){ + particleScale += 0.05; + } + + particleAlpha = (1F - ((float) particleAge / (float) particleMaxAge)) * 0.5F; + + if (particleAge++ >= particleMaxAge) { + setDead(); + } + moveEntity(motionX, motionY, motionZ);// also important if you want your particle to move + float speedMultiplyer = 0.0501F; + float ySpeedMultiplyer = 0.1006F; + if (expand) { + motionX = motionX + (targetX - posX) * speedMultiplyer; + motionY = motionY + (targetY - posY) * speedMultiplyer; + motionZ = motionZ + (targetZ - posZ) * speedMultiplyer; + }else + { + motionX = (targetX - posX) * speedMultiplyer; + motionY = (targetY - posY) * ySpeedMultiplyer; + motionZ = (targetZ - posZ) * speedMultiplyer; + } + if (expand && Math.abs(targetX - posX) < 0.01 && Math.abs(targetY - posY) < 0.01 && Math.abs(targetZ - posZ) < 0.01){ + motionX = 0; + motionY = 0; + motionZ = 0; + particleRed = 0F; + particleGreen = 1F; + particleBlue = 1F; + particleScale = 2; + particleAlpha = (1F - ((float) particleAge / (float) particleMaxAge)) * 1F; + } + + } + + @Override + //@SideOnly(Side.CLIENT) + public void renderParticle(Tessellator tesselator, float par2, float par3, float par4, float par5, float par6, float par7) {//Note U=X V=Y + + tesselator.draw(); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(References.RESOURCESPREFIX + "textures/particle/particles.png")); + tesselator.startDrawingQuads(); + tesselator.setBrightness(200);//make sure you have this!! + + + float minU = 0.0F + 0F;//(float)this.particleTextureIndexX / 32.0F; + float maxU = 0.0F + 0.1245F;//minU + 0.124F; + float minV = 0F;//(float)this.particleTextureIndexY / 32.0F; + float maxV = 0.1245F;//minV + 0.124F; + float drawScale = 0.1F * this.particleScale; + + if (this.particleIcon != null) { + minU = this.particleIcon.getMinU(); + maxU = this.particleIcon.getMaxU(); + minV = this.particleIcon.getMinV(); + maxV = this.particleIcon.getMaxV(); + } + + float drawX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX); + float drawY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY); + float drawZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ); + + tesselator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha); + //tesselator.setColorRGBA(0, 255, 255, (int) (this.particleAlpha * 255F)); + + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ - par5 * drawScale - par7 * drawScale), (double) maxU, (double) maxV); + tesselator.addVertexWithUV((double) (drawX - par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ - par5 * drawScale + par7 * drawScale), (double) maxU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale + par6 * drawScale), (double) (drawY + par4 * drawScale), (double) (drawZ + par5 * drawScale + par7 * drawScale), (double) minU, (double) minV); + tesselator.addVertexWithUV((double) (drawX + par3 * drawScale - par6 * drawScale), (double) (drawY - par4 * drawScale), (double) (drawZ + par5 * drawScale - par7 * drawScale), (double) minU, (double) maxV); + + tesselator.draw(); + Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/particle/particles.png")); + tesselator.startDrawingQuads(); + + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/ItemEnergyInfuserRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/ItemEnergyInfuserRenderer.java new file mode 100644 index 00000000..0a9b4e3b --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/ItemEnergyInfuserRenderer.java @@ -0,0 +1,49 @@ +package com.brandon3055.draconicevolution.client.render; + +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.client.IItemRenderer; +import org.lwjgl.opengl.GL11; + +public class ItemEnergyInfuserRenderer implements IItemRenderer +{ + TileEntitySpecialRenderer render; + private TileEnergyInfuser dummytile; + + public ItemEnergyInfuserRenderer(TileEntitySpecialRenderer render, TileEnergyInfuser dummy) { + this.render = render; + this.dummytile = dummy; + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) + { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) + { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) + { + if (type == ItemRenderType.ENTITY) + GL11.glTranslatef(-0.5F, 0.0F, -0.5F); + dummytile.xCoord = 0; + dummytile.yCoord = 0; + dummytile.zCoord = 0; + dummytile.setWorldObj(Minecraft.getMinecraft().theWorld); + dummytile.rotation = 0F; + dummytile.running = false; + render.renderTileEntityAt(this.dummytile, 0.0D, 0.0D, 0.0D, 0.0F); + } + + + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java index dc6976f2..e93fd675 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/ItemParticleGenRenderer.java @@ -1,6 +1,8 @@ package com.brandon3055.draconicevolution.client.render; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/ParticleGenRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/ParticleGenRenderer.java index 7ba95897..29a52fd2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/ParticleGenRenderer.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/ParticleGenRenderer.java @@ -42,6 +42,7 @@ public class ParticleGenRenderer extends TileEntitySpecialRenderer tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); tessellator.setColorRGBA(255, 255, 255, 255); //tessellator.setBrightness(200); diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/SoulItemRenderer.java b/src/main/java/com/brandon3055/draconicevolution/client/render/SoulItemRenderer.java new file mode 100644 index 00000000..f6a8409f --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/SoulItemRenderer.java @@ -0,0 +1,102 @@ +package com.brandon3055.draconicevolution.client.render; + +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.entity.RenderLiving; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureUtil; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemCloth; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.ForgeHooksClient; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +public class SoulItemRenderer implements IItemRenderer { + private Minecraft mc; + + public SoulItemRenderer() { + this.mc = Minecraft.getMinecraft(); + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY || type == ItemRenderType.ENTITY; + } + + @Override + + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return false; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + Entity mob = EntityList.createEntityByName(ItemNBTHelper.getString(item, "Name", "Pig"), mc.theWorld); + + GL11.glPushMatrix(); + //GL11.glEnable(GL11.GL_BLEND); + GL11.glScalef(0.5F, 0.5F, 0.5F); + //GL11.glColor4f(1F, 1F, 1F, 0.5F); + + if (type == ItemRenderType.INVENTORY) + { + GL11.glPushMatrix(); + //RenderHelper.enableStandardItemLighting(); + GL11.glScalef(13F, 13F, 13F); + GL11.glTranslated(1.2, 2.2, 0); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + //RenderHelper.disableStandardItemLighting(); + GL11.glPopMatrix(); + } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) + { + GL11.glPushMatrix(); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(2, 0.5, 0); + GL11.glRotatef(20F, 0F, 0F, 1F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + GL11.glPopMatrix(); + } else if (type == ItemRenderType.EQUIPPED) + { + GL11.glPushMatrix(); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslated(1, 0.5, 0); + GL11.glRotatef(20F, 0F, 0F, 1F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F); + GL11.glPopMatrix(); + + } else + { + GL11.glPushMatrix(); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glRotatef(mc.getSystemTime() / -10, 0F, 1F, 0F); + GL11.glRotatef(-20F, 1F, 0F, 0F); + RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 0F); + GL11.glPopMatrix(); + + } + + //GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockSunDial.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockSunDial.java index f7a4ecc6..f7c758a9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockSunDial.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/BlockSunDial.java @@ -14,7 +14,7 @@ import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TileSunDial; -public class BlockSunDial extends TolkienBlock { +public class BlockSunDial extends DraconicEvolutionBlock { //@SideOnly(Side.CLIENT) public IIcon icon_front; public IIcon icon_front_active; @@ -91,5 +91,4 @@ public class BlockSunDial extends TolkienBlock { } return true; } - } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java new file mode 100644 index 00000000..a4fb6216 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/CustomSpawner.java @@ -0,0 +1,224 @@ +package com.brandon3055.draconicevolution.common.blocks; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.BlockMobSpawner; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.Random; + +/** + * Created by Brandon on 5/07/2014. + */ +public class CustomSpawner extends Block{ + public CustomSpawner() + { + super(Material.rock); + this.setBlockName(Strings.customSpawnerName); + this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); + this.setHardness(10F); + this.setHarvestLevel("pickaxe", 3); + GameRegistry.registerBlock(this, this.getUnlocalizedName()); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; + if (spawner != null) + { + ItemStack item = player.getHeldItem(); + if (item != null && item.getItem().equals(ModItems.mobSoul)) + { + String name = ItemNBTHelper.getString(item, "Name", "Pig"); + if (name.equals(spawner.getBaseLogic().entityName)){return false;} + spawner.getBaseLogic().entityName = name; + spawner.isSetToSpawn = true; + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + }else if (item != null && item.getItem().equals(Items.nether_star) && spawner.getBaseLogic().requiresPlayer){ + spawner.getBaseLogic().requiresPlayer = false; + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + }else if (item != null && item.getItem().equals(ModItems.infusedCompound) && spawner.getBaseLogic().spawnSpeed == 0){ + spawner.getBaseLogic().setSpawnRate(1); + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + }else if (item != null && item.getItem().equals(ModItems.draconicCompound) && spawner.getBaseLogic().spawnSpeed == 1){ + spawner.getBaseLogic().setSpawnRate(2); + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + }else if (item != null && item.getItem().equals(Item.getItemFromBlock(Blocks.dragon_egg)) && spawner.getBaseLogic().spawnSpeed == 2){ + spawner.getBaseLogic().setSpawnRate(3); + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + }else if (item != null && item.getItem().equals(Items.golden_apple) && item.getItemDamage() == 1 && !spawner.getBaseLogic().ignoreSpawnRequirements){ + spawner.getBaseLogic().ignoreSpawnRequirements = true; + world.markBlockForUpdate(x, y, z); + item.splitStack(1); + return true; + }else + { + if (world.isRemote && !player.isSneaking()) { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo1.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().entityName)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo2.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().requiresPlayer)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo3.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().ignoreSpawnRequirements)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo4.txt").appendText(": " + EnumChatFormatting.DARK_AQUA + spawner.getBaseLogic().spawnSpeed)); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo5.txt")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + }else if (world.isRemote && player.isSneaking()) + { + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo6.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo7.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo8.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo9.txt")); + player.addChatMessage(new ChatComponentTranslation("msg.spawnerInfo10.txt")); + player.addChatMessage(new ChatComponentText(EnumChatFormatting.GOLD + "#################################")); + } + return true; + } + } + LogHelper.error("Invalid or nonexistent TileEntity"); + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileCustomSpawner(); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public int getHarvestLevel(int metadata) { + return 4; + } + + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) { + return Item.getItemFromBlock(ModBlocks.customSpawner); + } + + @Override + public int quantityDropped(Random p_149745_1_) { + return 1; + } + + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("mob_spawner"); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; + if (spawner != null) + { + spawner.getBaseLogic().powered = world.isBlockIndirectlyGettingPowered(x, y, z); + world.markBlockForUpdate(x, y, z); + spawner.getBaseLogic().setSpawnRate(spawner.getBaseLogic().spawnSpeed); + } + } + + @Override + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { + return new ItemStack(ModBlocks.customSpawner); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block p_149749_5_, int p_149749_6_) { + TileCustomSpawner spawner = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileCustomSpawner) ? (TileCustomSpawner)world.getTileEntity(x, y, z) : null; + if (spawner != null && !world.isRemote) + { + float multiplyer = 0.05F; + + if (spawner.getBaseLogic().ignoreSpawnRequirements) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Items.golden_apple, 1, 1)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (spawner.getBaseLogic().spawnSpeed > 0) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.infusedCompound)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (spawner.getBaseLogic().spawnSpeed > 1) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.draconicCompound)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (spawner.getBaseLogic().spawnSpeed > 2) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Item.getItemFromBlock(Blocks.dragon_egg))); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + if (!spawner.getBaseLogic().requiresPlayer) + { + EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(Items.nether_star)); + item.motionX = (-0.5F + world.rand.nextFloat()) * multiplyer; + item.motionY = (4 + world.rand.nextFloat()) * multiplyer; + item.motionZ = (-0.5F + world.rand.nextFloat()) * multiplyer; + world.spawnEntityInWorld(item); + } + } + super.breakBlock(world, x, y, z, p_149749_5_, p_149749_6_); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TolkienBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicEvolutionBlock.java similarity index 86% rename from src/main/java/com/brandon3055/draconicevolution/common/blocks/TolkienBlock.java rename to src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicEvolutionBlock.java index 2412c3d0..068bb169 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TolkienBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconicEvolutionBlock.java @@ -7,14 +7,14 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.common.lib.References; -public class TolkienBlock extends Block { +public class DraconicEvolutionBlock extends Block { - public TolkienBlock(final Material material) { + public DraconicEvolutionBlock(final Material material) { super(material); } - public TolkienBlock() { + public DraconicEvolutionBlock() { super(Material.rock); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java index a59d120f..07fc79d3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/DraconiumOre.java @@ -17,7 +17,7 @@ import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import net.minecraft.world.IBlockAccess; -public class DraconiumOre extends TolkienBlock { +public class DraconiumOre extends DraconicEvolutionBlock { public IIcon icon; public IIcon iconEnd; public IIcon iconNether; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/EnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/EnergyInfuser.java new file mode 100644 index 00000000..b9ad5fd4 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/EnergyInfuser.java @@ -0,0 +1,100 @@ +package com.brandon3055.draconicevolution.common.blocks; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.client.interfaces.GuiHandler; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.lib.Strings; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +/** + * Created by Brandon on 27/06/2014. + */ +public class EnergyInfuser extends BlockContainer{ + public EnergyInfuser() { + super(Material.iron); + this.setBlockName(Strings.energyInfuserName); + this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); + this.setStepSound(soundTypeStone); + this.setHardness(1f); + this.setResistance(200.0f); + this.setBlockBounds(0f, 0f, 0f, 1f, 0.375f, 1f); + GameRegistry.registerBlock(this, this.getUnlocalizedName()); + } + + @Override + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEnergyInfuser(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float prx, float pry, float prz) { + if (!world.isRemote) { + FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_ENERGY_INFUSER, world, x, y, z); + } + world.markBlockForUpdate(x, y, z); + return true; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) + { + TileEntity te = world.getTileEntity(x, y, z); + if (te != null && te instanceof IInventory) { + IInventory inventory = (IInventory) te; + + for (int i = 0; i < inventory.getSizeInventory(); i++) { + ItemStack stack = inventory.getStackInSlot(i); + + if (stack != null) { + float spawnX = x + world.rand.nextFloat(); + float spawnY = y + world.rand.nextFloat(); + float spawnZ = z + world.rand.nextFloat(); + + EntityItem droppedItem = new EntityItem(world, spawnX, spawnY, spawnZ, stack); + + float multiplier = 0.05F; + + droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * multiplier; + droppedItem.motionY = (4 + world.rand.nextFloat()) * multiplier; + droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * multiplier; + + world.spawnEntityInWorld(droppedItem); + } + } + } + + super.breakBlock(world, x, y, z, block, meta); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java index 3806b905..3f4d68d5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ModBlocks.java @@ -17,6 +17,8 @@ public class ModBlocks { public static Block particleGenerator; public static Block playerDetector; public static Block playerDetectorAdvanced; + public static Block energyInfuser; + public static Block customSpawner; public static void init() { @@ -30,13 +32,15 @@ public class ModBlocks { particleGenerator = new ParticleGenerator(); playerDetector = new PlayerDetector(); playerDetectorAdvanced = new PlayerDetectorAdvanced(); + energyInfuser = new EnergyInfuser(); + customSpawner = new CustomSpawner(); if(DraconicEvolution.debug) testBlock = new TestBlock(); //testBlock = new TestBlock(); } - public static void register(final TolkienBlock block) + public static void register(final DraconicEvolutionBlock block) { GameRegistry.registerBlock(block, block.getUnwrappedUnlocalizedName(block.getUnlocalizedName())); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetector.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetector.java index b348874c..200c802d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetector.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetector.java @@ -13,8 +13,9 @@ import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TilePlayerDetector; +import net.minecraftforge.common.util.ForgeDirection; -public class PlayerDetector extends TolkienBlock +public class PlayerDetector extends DraconicEvolutionBlock { IIcon side_inactive; IIcon side_active; @@ -66,8 +67,17 @@ public class PlayerDetector extends TolkienBlock else return side_active; } - - + + @Override + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { + return true; + } + + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } + @Override public boolean hasTileEntity(int meta) { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetectorAdvanced.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetectorAdvanced.java index f5c2f97e..caeb522b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetectorAdvanced.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/PlayerDetectorAdvanced.java @@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; public class PlayerDetectorAdvanced extends BlockContainer { @@ -45,7 +46,17 @@ public class PlayerDetectorAdvanced extends BlockContainer top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0"); bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side"); } - + + @Override + public boolean isBlockSolid(IBlockAccess p_149747_1_, int p_149747_2_, int p_149747_3_, int p_149747_4_, int p_149747_5_) { + return true; + } + + @Override + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } + @Override public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java index 99eb7905..8aa08316 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/Potentiometer.java @@ -24,7 +24,7 @@ import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import com.brandon3055.draconicevolution.common.tileentities.TilePotentiometer; -public class Potentiometer extends TolkienBlock +public class Potentiometer extends DraconicEvolutionBlock { IIcon icons[] = new IIcon[16]; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java index 53559ec3..036caafd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/RainSensor.java @@ -14,7 +14,7 @@ import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class RainSensor extends TolkienBlock +public class RainSensor extends DraconicEvolutionBlock { IIcon icon_inactive; IIcon icon_active; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java index e2f31d72..400bc45d 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestBlock.java @@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.common.blocks; import java.util.List; import java.util.Random; +import com.brandon3055.draconicevolution.common.tileentities.TileTestBlock; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -10,18 +11,16 @@ import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.handler.ParticleHandler; -import com.brandon3055.draconicevolution.common.core.network.ExamplePacket; -public class TestBlock extends TolkienBlock { +public class TestBlock extends DraconicEvolutionBlock { protected TestBlock() { super(Material.rock); @@ -40,6 +39,16 @@ public class TestBlock extends TolkienBlock { //return null; } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return null;//new TileTestBlock(); + } + @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { return new ItemStack(Item.getItemFromBlock(world.getBlock(x,y,z)), 1, world.getBlockMetadata(x,y,z)); @@ -56,16 +65,16 @@ public class TestBlock extends TolkienBlock { { return false; } - @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float px, float py, float pz) { - //EntityLightningBolt bolt = new EntityLightningBolt(world, x, y, z + 5); - System.out.println(world.getBlockMetadata(x,y,z)); - //world.spawnEntityInWorld(bolt); + EntityLightningBolt bolt = new EntityLightningBolt(world, x, y, z + 5); + //System.out.println(world.getBlockMetadata(x,y,z)); + world.spawnEntityInWorld(bolt); /* + if (!world.isRemote && !player.isSneaking()) { System.out.println("Sending from server"); @@ -96,7 +105,6 @@ public class TestBlock extends TolkienBlock { return super.getItemDropped( p_149650_1_, p_149650_2_, p_149650_3_); } - @Override public void randomDisplayTick(World world, int x, int y, int z, Random rand) { diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestItemBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestItemBlock.java index 0c4a3f49..53793624 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestItemBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/TestItemBlock.java @@ -10,7 +10,8 @@ import net.minecraft.item.ItemStack; public class TestItemBlock extends ItemBlock { public TestItemBlock(Block block) { super(block); - this.hasSubtypes = true; + setHasSubtypes(true); + //this.hasSubtypes = true; } @Override diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java index 20469501..eb061d13 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/XRayBlock.java @@ -18,7 +18,7 @@ import com.brandon3055.draconicevolution.common.core.handler.ParticleHandler; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.Strings; -public class XRayBlock extends TolkienBlock { +public class XRayBlock extends DraconicEvolutionBlock { protected XRayBlock() { super(Material.rock); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java new file mode 100644 index 00000000..351bf62e --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/container/ContainerEnergyInfuser.java @@ -0,0 +1,89 @@ +package com.brandon3055.draconicevolution.common.container; + +import com.brandon3055.draconicevolution.client.interfaces.SlotChargable; +import com.brandon3055.draconicevolution.client.interfaces.SlotItemValid; +import com.brandon3055.draconicevolution.common.core.utills.EnergyHelper; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import com.brandon3055.draconicevolution.common.tileentities.TileGrinder; +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; + +public class ContainerEnergyInfuser extends Container { + + private TileEnergyInfuser tile; + private EntityPlayer player; + + public ContainerEnergyInfuser(InventoryPlayer invPlayer, TileEnergyInfuser tile) { + this.tile = tile; + this.player = invPlayer.player; + + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 116)); + } + + for (int y = 0; y < 3; y++) { + for (int x = 0; x < 9; x++) { + addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 58 + y * 18)); + } + } + + addSlotToContainer(new SlotChargable(tile, 0, 80, 22)); + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return tile.isUseableByPlayer(player); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int i) + { + Slot slot = getSlot(i); + + if (slot != null && slot.getHasStack()) + { + ItemStack stack = slot.getStack(); + ItemStack result = stack.copy(); + + if (i >= 36){ + if (!mergeItemStack(stack, 0, 36, false)){ + return null; + } + }else if (!EnergyHelper.isEnergyContainerItem(stack) || !mergeItemStack(stack, 36, 36 + tile.getSizeInventory(), false)){ + return null; + } + + if (stack.stackSize == 0) { + slot.putStack(null); + }else{ + slot.onSlotChanged(); + } + + slot.onPickupFromSlot(player, stack); + + return result; + } + + return null; + } + + @Override + public void addCraftingToCrafters(ICrafting par1ICrafting) { + super.addCraftingToCrafters(par1ICrafting); + } + + @Override + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ConfigHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ConfigHandler.java index 57105c6f..9093b958 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ConfigHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ConfigHandler.java @@ -2,27 +2,41 @@ package com.brandon3055.draconicevolution.common.core.handler; import java.io.File; +import com.brandon3055.draconicevolution.DraconicEvolution; import net.minecraftforge.common.config.Configuration; -public class ConfigHandler -{ - public static void init(File confFile) - { - Configuration config = new Configuration(confFile); - - config.load(); - - disableSunDial = config.get("Misc", "'Disable Sun Dial' 0:Default, 1:Disable recipe, 2:Disable compleatly", 0).getInt(0); - disableXrayBlock = config.get("Misc", "'Disable Distortion Flame' 0:Default, 1:Disable recipe, 2:Disable compleatly", 0).getInt(0); - teleporterUsesPerPearl = config.get("Misc", "Charm of Dislocation uses per pearl", 10).getInt(10); - bowBlockDamage = config.get("Misc", "Draconic bow explosion damages blocks", true).getBoolean(true); - - config.save(); - } - +public class ConfigHandler { + public static int disableSunDial; public static int teleporterUsesPerPearl; public static int disableXrayBlock; public static boolean bowBlockDamage; + public static String[] spawnerList; + public static boolean spawnerListType; + public static int soulDropChance; + private static String[] defaultList = new String[] {"ExampleMob1", "ExampleMob2", "ExampleMob3 (these examples can be deleted)"}; + + + public static void init(File confFile) { + Configuration config = new Configuration(confFile); + + try { + config.load(); + + disableSunDial = config.get(Configuration.CATEGORY_GENERAL, "disableSunDial", 0, "Disable Sun Dial 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0); + disableXrayBlock = config.get(Configuration.CATEGORY_GENERAL, "disableXrayBlock", 0, "Disable Distortion Flame 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0); + teleporterUsesPerPearl = config.get(Configuration.CATEGORY_GENERAL, "teleporterUsesPerPearl", 10, "Charm of Dislocation uses per Ender pearl").getInt(10); + bowBlockDamage = config.get(Configuration.CATEGORY_GENERAL, "bowBlockDamage", true, "Dose Draconic bow explosion damage blocks").getBoolean(true); + spawnerListType = config.get("Spawner", "listType", false, "Sets weather the spawner list is a white list or a black list (true = white list false = black list)").getBoolean(false); + spawnerList = config.getStringList("Spawn List", "Spawner", defaultList, "List of names that will be ether accepted or rejected by the spawner depending on the list type"); + soulDropChance = config.get("Spawner", "soulDropChance", 1000, "Mobs have a 1 in this number chance to drop a soul", 1, Integer.MAX_VALUE).getInt(1000); + } + catch (Exception e) { + //DraconicEvolution.logger.error("Unable to load Config"); + } + finally { + config.save(); + } + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/CraftingHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/CraftingHandler.java index e58e23f4..8f24a4a6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/CraftingHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/CraftingHandler.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.core.handler; import com.brandon3055.draconicevolution.common.blocks.ModBlocks; import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.items.armor.DraconicArmor; +import com.brandon3055.draconicevolution.common.items.armor.WyvernArmor; import com.brandon3055.draconicevolution.common.items.tools.DraconicAxe; import com.brandon3055.draconicevolution.common.items.tools.DraconicDistructionStaff; import com.brandon3055.draconicevolution.common.items.tools.DraconicHoe; @@ -27,10 +29,10 @@ public class CraftingHandler { registerShapedRecipes(); registerSmeltingRecipes(); registerShapelessRecipes(); - registerToolRecipes(); + registerRemoteRecipes(); } - private static void registerToolRecipes() + private static void registerRemoteRecipes() { DraconicPickaxe.registerRecipe(); DraconicAxe.registerRecipe(); @@ -45,6 +47,8 @@ public class CraftingHandler { WyvernBow.registerRecipe(); TeleporterMKI.registerRecipe(); TeleporterMKII.registerRecipe(); + DraconicArmor.registerRecipe(); + WyvernArmor.registerRecipe(); } public static void registerShapedRecipes() @@ -76,7 +80,6 @@ public class CraftingHandler { public static void registerShapelessRecipes() { - //CraftingManager.getInstance().addShapelessRecipe(new ItemStack(ModItems.tcPickaxe), ModItems.tcPickHead, Items.stick); //CraftingManager.getInstance().addShapelessRecipe(new ItemStack(ModItems.tcSword), ModItems.tcSwordBlade, Items.stick); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/MinecraftForgeEventHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/MinecraftForgeEventHandler.java new file mode 100644 index 00000000..94aed886 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/MinecraftForgeEventHandler.java @@ -0,0 +1,113 @@ +package com.brandon3055.draconicevolution.common.core.handler; + + +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.IBossDisplayData; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.IMob; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import net.minecraftforge.event.entity.living.LivingDeathEvent; +import net.minecraftforge.event.entity.living.LivingDropsEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class MinecraftForgeEventHandler { + + Random random = new Random(); + public static List playersWithUphillStep = new ArrayList(); + public static List playersWithFlight = new ArrayList(); + + @SubscribeEvent + public void onEntityUpdate(LivingUpdateEvent event){ + EntityLivingBase entityLiving = event.entityLiving; + + if (entityLiving.worldObj.isRemote && entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entityLiving; + boolean hasUphillStep = playersWithUphillStep.contains(player.getDisplayName()); + boolean shouldHaveUphillStep = player.getEquipmentInSlot(1) != null && player.getEquipmentInSlot(1).getItem() == ModItems.draconicBoots && !player.isSneaking(); + + if (!hasUphillStep && shouldHaveUphillStep) + { + playersWithUphillStep.add(player.getDisplayName()); + player.stepHeight = 1; + } + if (hasUphillStep && !shouldHaveUphillStep) + { + playersWithUphillStep.remove(player.getDisplayName()); + player.stepHeight = 0.5F; + } + } + + if(entityLiving instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) entityLiving; + boolean hasFlight = playersWithFlight.contains(player.getDisplayName()); + boolean shouldHaveFlight = player.getEquipmentInSlot(3) != null && player.getEquipmentInSlot(3).getItem() == ModItems.draconicChest; + + if ((!hasFlight || !player.capabilities.allowFlying) && shouldHaveFlight) + { + if (!playersWithFlight.contains(player.getDisplayName())) + playersWithFlight.add(player.getDisplayName()); + player.capabilities.allowFlying = true; + } + if (hasFlight && !shouldHaveFlight) + { + playersWithFlight.remove(player.getDisplayName()); + player.capabilities.allowFlying = false; + player.capabilities.isFlying = false; + if (player.capabilities.isCreativeMode) + player.capabilities.allowFlying = true; + player.sendPlayerAbilities(); + } + } + } + + @SubscribeEvent + public void onDropEvent(LivingDropsEvent event){ + if (event.entity.worldObj.isRemote || !(event.source.damageType.equals("player") || event.source.damageType.equals("arrow")) || !isValidEntity(event.entityLiving)){ return; } + EntityLivingBase entity = event.entityLiving; + Entity attacker = event.source.getEntity(); + if (attacker == null || !(attacker instanceof EntityPlayer)) { return; } + if (!(((EntityPlayer) attacker).getHeldItem().getItem().equals(ModItems.draconicSword) || ((EntityPlayer) attacker).getHeldItem().getItem().equals(ModItems.draconicDistructionStaff) || ((EntityPlayer) attacker).getHeldItem().getItem().equals(ModItems.draconicBow) || ((EntityPlayer) attacker).getHeldItem().getItem().equals(ModItems.wyvernBow) || ((EntityPlayer) attacker).getHeldItem().getItem().equals(ModItems.wyvernSword))) { return; } + World world = entity.worldObj; + int rand = random.nextInt(ConfigHandler.soulDropChance); + if (rand == 0) { + ItemStack soul = new ItemStack(ModItems.mobSoul); + ItemNBTHelper.setString(soul, "Name", entity.getCommandSenderName()); + world.spawnEntityInWorld(new EntityItem(world, entity.posX, entity.posY, entity.posZ, soul)); + } + } + + private boolean isValidEntity(EntityLivingBase entity) + { + if (entity instanceof IBossDisplayData) { return false; } + for (int i = 0; i < ConfigHandler.spawnerList.length; i++) + { + if (ConfigHandler.spawnerList[i].equals(entity.getCommandSenderName()) && ConfigHandler.spawnerListType) + { + return true; + } else if (ConfigHandler.spawnerList[i].equals(entity.getCommandSenderName()) && !ConfigHandler.spawnerListType) + { + return false; + } + } + if (ConfigHandler.spawnerListType) { + return false; + }else { + return true; + } + } + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ModEventHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ModEventHandler.java deleted file mode 100644 index 1065cbfc..00000000 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ModEventHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.brandon3055.draconicevolution.common.core.handler; - - -public class ModEventHandler { - - /* - //Allow Flight when holding item - @SubscribeEvent - public void onLivingUpdateEvent(LivingUpdateEvent event) { - if (event.entity instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer)event.entity; - ItemStack heldItem = player.getHeldItem(); - if (heldItem != null && heldItem.isItemEqual(new ItemStack(Items.arrow))) { - System.out.println("True"); - player.capabilities.allowFlying = true; - } else { - player.capabilities.allowFlying = player.capabilities.isCreativeMode ? true : false; - } - } - }*/ - - - - /* - @SubscribeEvent - public void removedeathemesage(ClientChatReceivedEvent event) - { - String player = event.message.getUnformattedText().substring(0, event.message.getUnformattedText().indexOf(" ") + 1); - System.out.println(player); - - if(event.message.getUnformattedText().contains(player + " fell out of the world")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + " was slain by")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + "was pricked to death")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + "drowned")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + "blew up")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + "was blown up")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + "was doomed to fall")) - { - event.setCanceled(true); - } - if(event.message.getUnformattedText().contains(player + "was shot")) - { - event.setCanceled(true); - } - //Etc - }*/ - - - -} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ParticleHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ParticleHandler.java index 8eb3041d..1f1e4810 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ParticleHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/handler/ParticleHandler.java @@ -9,8 +9,7 @@ public class ParticleHandler { private static Minecraft mc = Minecraft.getMinecraft(); private static World theWorld = mc.theWorld; - //private static TextureManager renderEngine = mc.renderEngine; - + public static EntityFX spawnParticle(String particleName, double x, double y, double z, double motionX, double motionY, double motionZ, float scale) { if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) @@ -44,8 +43,12 @@ public class ParticleHandler } return null; } - - public static EntityFX spawnCustomParticle(EntityFX particle) + + public static EntityFX spawnCustomParticle(EntityFX particle){ + return spawnCustomParticle(particle, 256); + } + + public static EntityFX spawnCustomParticle(EntityFX particle, double vewRange) { if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null) { @@ -57,8 +60,7 @@ public class ParticleHandler double var15 = mc.renderViewEntity.posX - particle.posX; double var17 = mc.renderViewEntity.posY - particle.posY; double var19 = mc.renderViewEntity.posZ - particle.posZ; - double var22 = 256.0D; - if (var15 * var15 + var17 * var17 + var19 * var19 > var22 * var22) + if (var15 * var15 + var17 * var17 + var19 * var19 > vewRange * vewRange) { return null; } else if (var14 > 1) diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java index 1960fe6b..72ac4a04 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterPacket.java @@ -1,7 +1,7 @@ package com.brandon3055.draconicevolution.common.core.network; import com.brandon3055.draconicevolution.common.core.handler.ConfigHandler; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import io.netty.buffer.ByteBuf; import net.minecraft.client.network.NetHandlerPlayClient; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterStringPacket.java b/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterStringPacket.java index 305cd71f..15dc64d5 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterStringPacket.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/network/TeleporterStringPacket.java @@ -5,7 +5,7 @@ import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.item.ItemStack; import net.minecraft.network.NetHandlerPlayServer; import cpw.mods.fml.common.network.ByteBufUtils; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; public class TeleporterStringPacket implements IPacket diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java index 65c65f9a..818c7964 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/ClientProxy.java @@ -1,5 +1,9 @@ package com.brandon3055.draconicevolution.common.core.proxy; +import com.brandon3055.draconicevolution.client.render.*; +import com.brandon3055.draconicevolution.common.tileentities.TileCustomSpawner; +import com.brandon3055.draconicevolution.common.tileentities.TileEnergyInfuser; +import net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.Item; import net.minecraftforge.client.MinecraftForgeClient; @@ -7,9 +11,6 @@ import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import com.brandon3055.draconicevolution.client.render.BowRenderer; -import com.brandon3055.draconicevolution.client.render.ItemParticleGenRenderer; -import com.brandon3055.draconicevolution.client.render.ParticleGenRenderer; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.blocks.ModBlocks; import com.brandon3055.draconicevolution.common.items.ModItems; @@ -50,10 +51,17 @@ public class ClientProxy extends CommonProxy { { MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new BowRenderer()); MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new BowRenderer()); + MinecraftForgeClient.registerItemRenderer(ModItems.mobSoul, new SoulItemRenderer()); TileEntitySpecialRenderer render = new ParticleGenRenderer(); ClientRegistry.bindTileEntitySpecialRenderer(TileParticleGenerator.class, render); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new ItemParticleGenRenderer(render, new TileParticleGenerator())); - + + render = new EnergyInfiserRenderer(); + ClientRegistry.bindTileEntitySpecialRenderer(TileEnergyInfuser.class, render); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.energyInfuser), new ItemEnergyInfuserRenderer(render, new TileEnergyInfuser())); + + render = new CustonSpawnerRenderer(); + ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, render); } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java index 28ee78d5..e84be694 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/proxy/CommonProxy.java @@ -1,7 +1,11 @@ package com.brandon3055.draconicevolution.common.core.proxy; +import com.brandon3055.draconicevolution.common.core.handler.MinecraftForgeEventHandler; import com.brandon3055.draconicevolution.common.core.network.*; +import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon; +import com.brandon3055.draconicevolution.common.tileentities.*; import com.brandon3055.draconicevolution.common.world.DraconicWorldGenerator; +import cpw.mods.fml.common.registry.EntityRegistry; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -14,15 +18,7 @@ import com.brandon3055.draconicevolution.common.blocks.ModBlocks; import com.brandon3055.draconicevolution.common.core.handler.ConfigHandler; import com.brandon3055.draconicevolution.common.core.handler.CraftingHandler; import com.brandon3055.draconicevolution.common.core.handler.FMLEventHandler; -import com.brandon3055.draconicevolution.common.core.handler.ModEventHandler; import com.brandon3055.draconicevolution.common.items.ModItems; -import com.brandon3055.draconicevolution.common.tileentities.TileGrinder; -import com.brandon3055.draconicevolution.common.tileentities.TileParticleGenerator; -import com.brandon3055.draconicevolution.common.tileentities.TilePlayerDetector; -import com.brandon3055.draconicevolution.common.tileentities.TilePlayerDetectorAdvanced; -import com.brandon3055.draconicevolution.common.tileentities.TilePotentiometer; -import com.brandon3055.draconicevolution.common.tileentities.TileSunDial; -import com.brandon3055.draconicevolution.common.tileentities.TileWeatherController; public class CommonProxy { private final static boolean debug = DraconicEvolution.debug; @@ -44,6 +40,7 @@ public class CommonProxy { registerWorldGen(); DraconicEvolution.channelHandler.initialise(); registerPackets(); + registerEntitys(); } public void postInit(FMLPostInitializationEvent event) @@ -60,11 +57,15 @@ public class CommonProxy { GameRegistry.registerTileEntity(TileParticleGenerator.class, "TileParticleGenerator"); GameRegistry.registerTileEntity(TilePlayerDetector.class, "TilePlayerDetector"); GameRegistry.registerTileEntity(TilePlayerDetectorAdvanced.class, "TilePlayerDetectorAdvanced"); + GameRegistry.registerTileEntity(TileEnergyInfuser.class, "TileEnergyInfuser"); + GameRegistry.registerTileEntity(TileCustomSpawner.class, "TileCustomSpawner"); + if(DraconicEvolution.debug) + GameRegistry.registerTileEntity(TileTestBlock.class, "TileTestBlock"); } public void registerEventListeners() { - MinecraftForge.EVENT_BUS.register(new ModEventHandler()); + MinecraftForge.EVENT_BUS.register(new MinecraftForgeEventHandler()); FMLCommonHandler.instance().bus().register(new FMLEventHandler()); } @@ -92,4 +93,10 @@ public class CommonProxy { { GameRegistry.registerWorldGenerator(new DraconicWorldGenerator(), 1); } + + public void registerEntitys(){ + int dragonID = EntityRegistry.findGlobalUniqueEntityId(); + int cyan = (0 << 16) + (255 << 8) + 255; + EntityRegistry.registerGlobalEntityID(EntityCustomDragon.class, "enderDragon", dragonID, cyan, 0); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/utills/EnergyHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/EnergyHelper.java new file mode 100644 index 00000000..d99c3f4c --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/EnergyHelper.java @@ -0,0 +1,20 @@ +package com.brandon3055.draconicevolution.common.core.utills; + +import cofh.api.energy.IEnergyContainerItem; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Created by Brandon on 28/06/2014. + */ +public class EnergyHelper { + + public static boolean isEnergyContainerItem(ItemStack stack) + { + return (stack != null) && ((stack.getItem() instanceof IEnergyContainerItem)); + } + +} + + diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/utills/GuiHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/GuiHelper.java new file mode 100644 index 00000000..309cb553 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/GuiHelper.java @@ -0,0 +1,10 @@ +package com.brandon3055.draconicevolution.common.core.utills; + +/** + * Created by Brandon on 28/06/2014. + */ +public class GuiHelper { + public static boolean isInRect(int x1, int y1, int x2, int y2, int x, int y){ + return ((x >= x1 && x <= x2) && (y >= y1 && y <= y2)); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/utills/InventoryHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/InventoryHelper.java new file mode 100644 index 00000000..b1ad2f71 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/InventoryHelper.java @@ -0,0 +1,17 @@ +package com.brandon3055.draconicevolution.common.core.utills; + +import net.minecraft.block.BlockHopper; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Facing; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by Brandon on 28/06/2014. + */ +public class InventoryHelper { + + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/utills/ItemInfoHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/ItemInfoHelper.java new file mode 100644 index 00000000..672e4786 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/ItemInfoHelper.java @@ -0,0 +1,33 @@ +package com.brandon3055.draconicevolution.common.core.utills; + +import cofh.api.energy.IEnergyContainerItem; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Created by Brandon on 1/07/2014. + */ +public class ItemInfoHelper { + public static void energyDisplayInfo(ItemStack stack, List list) { + IEnergyContainerItem item = (IEnergyContainerItem)stack.getItem(); + int energy = item.getEnergyStored(stack); + int maxEnergy = item.getMaxEnergyStored(stack); + String eS = ""; + String eM = ""; + if (energy < 1000) + eS = String.valueOf(energy); + else if (energy < 1000000) + eS = String.valueOf(Math.round((float)energy / 100F)/10F)+"k"; + else + eS = String.valueOf(Math.round((float)energy / 10000F)/100F)+"m"; + if (maxEnergy < 1000) + eM = String.valueOf(maxEnergy); + else if (maxEnergy < 1000000) + eM = String.valueOf(Math.round((float)maxEnergy / 100F)/10F)+"k"; + else + eM = String.valueOf(Math.round((float)maxEnergy / 10000F)/100F)+"m"; + + list.add(eS + " / " + eM + " RF"); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/helper/ItemNBTHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/ItemNBTHelper.java similarity index 97% rename from src/main/java/com/brandon3055/draconicevolution/common/core/helper/ItemNBTHelper.java rename to src/main/java/com/brandon3055/draconicevolution/common/core/utills/ItemNBTHelper.java index cbaba0ae..f5b21e08 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/core/helper/ItemNBTHelper.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/ItemNBTHelper.java @@ -1,4 +1,4 @@ -package com.brandon3055.draconicevolution.common.core.helper; +package com.brandon3055.draconicevolution.common.core.utills; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/core/utills/LogHelper.java b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/LogHelper.java new file mode 100644 index 00000000..e1ea510e --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/core/utills/LogHelper.java @@ -0,0 +1,33 @@ +package com.brandon3055.draconicevolution.common.core.utills; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.lib.References; +import cpw.mods.fml.common.FMLLog; +import org.apache.logging.log4j.Level; + +/** + * Created by Brandon on 3/07/2014. + */ +public class LogHelper { + + public static void log(Level logLevel, Object object) + { + FMLLog.log(logLevel, "Draconic Evolution", String.valueOf(object)); + } + + public static void all(Object object){ log(Level.ALL, object); } + + public static void debug(Object object){ log(Level.DEBUG, object); } + + public static void error(Object object){ log(Level.ERROR, object); } + + public static void fatal(Object object){ log(Level.FATAL, object); } + + public static void info(Object object){ log(Level.INFO, object); } + + public static void off(Object object){ log(Level.OFF, object); } + + public static void trace(Object object){ log(Level.TRACE, object); } + + public static void warn(Object object){ log(Level.WARN, object); } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java new file mode 100644 index 00000000..60ee8e95 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityCustomDragon.java @@ -0,0 +1,558 @@ +package com.brandon3055.draconicevolution.common.entity; + +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import net.minecraft.block.Block; +import net.minecraft.block.BlockEndPortal; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityDragonPart; +import net.minecraft.entity.effect.EntityLightningBolt; +import net.minecraft.entity.item.EntityEnderCrystal; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; + +import java.util.Iterator; +import java.util.List; + +/** + * Created by Brandon on 4/07/2014. + */ +public class EntityCustomDragon extends EntityDragon { + + private Entity target; + private int portalX = 0; + private int portalY = 67; + private int portalZ = 0; + private boolean createPortal = true; + + public EntityCustomDragon(World par1World) { + super(par1World); + this.serverPosX = (int) this.posX; + this.serverPosY = (int) this.posY; + this.serverPosZ = (int) this.posZ; + } + + protected void applyEntityAttributes() { + super.applyEntityAttributes(); + this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); + } + + @Override + public void onLivingUpdate() { + + float f; + float f1; + + if (this.worldObj.isRemote) { + f = MathHelper.cos(this.animTime * (float) Math.PI * 2.0F); + f1 = MathHelper.cos(this.prevAnimTime * (float) Math.PI * 2.0F); + + if (f1 <= -0.3F && f >= -0.3F) { + this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); + } + } + + this.prevAnimTime = this.animTime; + float f2; + + if (this.getHealth() <= 0.0F) { + f = (this.rand.nextFloat() - 0.5F) * 8.0F; + f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("largeexplode", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); + } else { + this.updateDragonEnderCrystal(); + f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); + f *= (float) Math.pow(2.0D, this.motionY); + + if (this.slowed) { + this.animTime += f * 0.5F; + } else { + this.animTime += f; + } + + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + + if (this.ringBufferIndex < 0) { + for (int i = 0; i < this.ringBuffer.length; ++i) { + this.ringBuffer[i][0] = (double) this.rotationYaw; + this.ringBuffer[i][1] = this.posY; + } + } + + if (++this.ringBufferIndex == this.ringBuffer.length) { + this.ringBufferIndex = 0; + } + + this.ringBuffer[this.ringBufferIndex][0] = (double) this.rotationYaw; + this.ringBuffer[this.ringBufferIndex][1] = this.posY; + double d0; + double d1; + double d2; + double d10; + float f12; + + if (this.worldObj.isRemote) { + if (this.newPosRotationIncrements > 0) { + d10 = this.posX + (this.newPosX - this.posX) / (double) this.newPosRotationIncrements; + d0 = this.posY + (this.newPosY - this.posY) / (double) this.newPosRotationIncrements; + d1 = this.posZ + (this.newPosZ - this.posZ) / (double) this.newPosRotationIncrements; + d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double) this.rotationYaw); + this.rotationYaw = (float) ((double) this.rotationYaw + d2 / (double) this.newPosRotationIncrements); + this.rotationPitch = (float) ((double) this.rotationPitch + (this.newRotationPitch - (double) this.rotationPitch) / (double) this.newPosRotationIncrements); + --this.newPosRotationIncrements; + this.setPosition(d10, d0, d1); + this.setRotation(this.rotationYaw, this.rotationPitch); + } + } else { + d10 = this.targetX - this.posX; + d0 = this.targetY - this.posY; + d1 = this.targetZ - this.posZ; + d2 = d10 * d10 + d0 * d0 + d1 * d1; + + if (this.target != null) { + this.targetX = this.target.posX; + this.targetZ = this.target.posZ; + double d3 = this.targetX - this.posX; + double d5 = this.targetZ - this.posZ; + double d7 = Math.sqrt(d3 * d3 + d5 * d5); + double d8 = 0.4000000059604645D + d7 / 80.0D - 1.0D; + + if (d8 > 10.0D) { + d8 = 10.0D; + } + + this.targetY = this.target.boundingBox.minY + d8; + } else { + this.targetX += this.rand.nextGaussian() * 2.0D; + this.targetZ += this.rand.nextGaussian() * 2.0D; + } + + if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) { + this.setNewTarget(); + } + + d0 /= (double) MathHelper.sqrt_double(d10 * d10 + d1 * d1); + f12 = 0.6F; + + if (d0 < (double) (-f12)) { + d0 = (double) (-f12); + } + + if (d0 > (double) f12) { + d0 = (double) f12; + } + + this.motionY += d0 * 0.10000000149011612D; + this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); + double d4 = 180.0D - Math.atan2(d10, d1) * 180.0D / Math.PI; + double d6 = MathHelper.wrapAngleTo180_double(d4 - (double) this.rotationYaw); + + if (d6 > 50.0D) { + d6 = 50.0D; + } + + if (d6 < -50.0D) { + d6 = -50.0D; + } + + Vec3 vec3 = Vec3.createVectorHelper(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); + Vec3 vec32 = Vec3.createVectorHelper((double) MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F), this.motionY, (double) (-MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F))).normalize(); + float f5 = (float) (vec32.dotProduct(vec3) + 0.5D) / 1.5F; + + if (f5 < 0.0F) { + f5 = 0.0F; + } + + this.randomYawVelocity *= 0.8F; + float f6 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; + double d9 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; + + if (d9 > 40.0D) { + d9 = 40.0D; + } + + this.randomYawVelocity = (float) ((double) this.randomYawVelocity + d6 * (0.699999988079071D / d9 / (double) f6)); + this.rotationYaw += this.randomYawVelocity * 0.1F; + float f7 = (float) (2.0D / (d9 + 1.0D)); + float f8 = 0.06F; + this.moveFlying(0.0F, -1.0F, f8 * (f5 * f7 + (1.0F - f7))); + + if (this.slowed) { + this.moveEntity(this.motionX * 0.800000011920929D, this.motionY * 0.800000011920929D, this.motionZ * 0.800000011920929D); + } else { + this.moveEntity(this.motionX, this.motionY, this.motionZ); + } + + Vec3 vec31 = Vec3.createVectorHelper(this.motionX, this.motionY, this.motionZ).normalize(); + float f9 = (float) (vec31.dotProduct(vec32) + 1.0D) / 2.0F; + f9 = 0.8F + 0.15F * f9; + this.motionX *= (double) f9; + this.motionZ *= (double) f9; + this.motionY *= 0.9100000262260437D; + } + + this.renderYawOffset = this.rotationYaw; + this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; + this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; + this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; + this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; + this.dragonPartBody.height = 3.0F; + this.dragonPartBody.width = 5.0F; + this.dragonPartWing1.height = 2.0F; + this.dragonPartWing1.width = 4.0F; + this.dragonPartWing2.height = 3.0F; + this.dragonPartWing2.width = 4.0F; + f1 = (float) (this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float) Math.PI; + f2 = MathHelper.cos(f1); + float f10 = -MathHelper.sin(f1); + float f3 = this.rotationYaw * (float) Math.PI / 180.0F; + float f11 = MathHelper.sin(f3); + float f4 = MathHelper.cos(f3); + this.dragonPartBody.onUpdate(); + this.dragonPartBody.setLocationAndAngles(this.posX + (double) (f11 * 0.5F), this.posY, this.posZ - (double) (f4 * 0.5F), 0.0F, 0.0F); + this.dragonPartWing1.onUpdate(); + this.dragonPartWing1.setLocationAndAngles(this.posX + (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ + (double) (f11 * 4.5F), 0.0F, 0.0F); + this.dragonPartWing2.onUpdate(); + this.dragonPartWing2.setLocationAndAngles(this.posX - (double) (f4 * 4.5F), this.posY + 2.0D, this.posZ - (double) (f11 * 4.5F), 0.0F, 0.0F); + + if (!this.worldObj.isRemote && this.hurtTime == 0) { + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); + this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); + } + + double[] adouble1 = this.getMovementOffsets(5, 1.0F); + double[] adouble = this.getMovementOffsets(0, 1.0F); + f12 = MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + float f13 = MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F - this.randomYawVelocity * 0.01F); + this.dragonPartHead.onUpdate(); + this.dragonPartHead.setLocationAndAngles(this.posX + (double) (f12 * 5.5F * f2), this.posY + (adouble[1] - adouble1[1]) * 1.0D + (double) (f10 * 5.5F), this.posZ - (double) (f13 * 5.5F * f2), 0.0F, 0.0F); + + for (int j = 0; j < 3; ++j) { + EntityDragonPart entitydragonpart = null; + + if (j == 0) { + entitydragonpart = this.dragonPartTail1; + } + + if (j == 1) { + entitydragonpart = this.dragonPartTail2; + } + + if (j == 2) { + entitydragonpart = this.dragonPartTail3; + } + + double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); + float f14 = this.rotationYaw * (float) Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble1[0]) * (float) Math.PI / 180.0F * 1.0F; + float f15 = MathHelper.sin(f14); + float f16 = MathHelper.cos(f14); + float f17 = 1.5F; + float f18 = (float) (j + 1) * 2.0F; + entitydragonpart.onUpdate(); + entitydragonpart.setLocationAndAngles(this.posX - (double) ((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble1[1]) * 1.0D - (double) ((f18 + f17) * f10) + 1.5D, this.posZ + (double) ((f4 * f17 + f16 * f18) * f2), 0.0F, 0.0F); + } + + if (!this.worldObj.isRemote) { + this.slowed = this.destroyBlocksInAABB(this.dragonPartHead.boundingBox) | this.destroyBlocksInAABB(this.dragonPartBody.boundingBox); + } + } + + } + + @Override + protected void onDeathUpdate() { + + if (deathTicks == 0) + { + for (int ix = -150; ix < 150; ix++) { + for (int iz = -150; iz < 150; iz++) { + if (worldObj.getBlock(ix, portalY, iz) == Blocks.bedrock && worldObj.getBlock(ix, portalY - 1, iz) == Blocks.bedrock) { + portalX = ix; + portalZ = iz; + createPortal = false; + break; + } + } + } + } + + ++this.deathTicks; + + if (worldObj.rand.nextInt(5) == 2) + { + worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, portalX, portalY + 1, portalZ)); + } + + if (this.deathTicks >= 180 && this.deathTicks <= 200) { + float f = (this.rand.nextFloat() - 0.5F) * 8.0F; + float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; + float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; + this.worldObj.spawnParticle("hugeexplosion", this.posX + (double) f, this.posY + 2.0D + (double) f1, this.posZ + (double) f2, 0.0D, 0.0D, 0.0D); + } + + int i; + int j; + + if (!this.worldObj.isRemote) { + if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { + i = 1000; + + while (i > 0) { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + + float mm = 0.3F; + EntityItem item = new EntityItem(worldObj, posX, posY, posZ, new ItemStack(ModItems.draconiumDust, 3 + worldObj.rand.nextInt(3))); + item.motionX = mm * ((((float)worldObj.rand.nextInt(100))/100F) - 0.5F); + item.motionY = mm * ((((float)worldObj.rand.nextInt(100))/100F) - 0.5F); + item.motionZ = mm * ((((float)worldObj.rand.nextInt(100))/100F) - 0.5F); + worldObj.spawnEntityInWorld(item); + + } + + if (this.deathTicks == 1) { + this.worldObj.playBroadcastSound(1018, (int) this.posX, (int) this.posY, (int) this.posZ, 0); + } + } + + this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); + this.renderYawOffset = this.rotationYaw += 20.0F; + + if (this.deathTicks == 200 && !this.worldObj.isRemote) { + i = 2000; + + while (i > 0) { + j = EntityXPOrb.getXPSplit(i); + i -= j; + this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); + } + + spawnEgg(); + setDead(); + } + } + + private void collideWithEntities(List par1List) { + double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; + double d1 = (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D; + Iterator iterator = par1List.iterator(); + + while (iterator.hasNext()) { + Entity entity = (Entity) iterator.next(); + + if (entity instanceof EntityLivingBase) { + double d2 = entity.posX - d0; + double d3 = entity.posZ - d1; + double d4 = d2 * d2 + d3 * d3; + entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); + } + } + } + + private void attackEntitiesInList(List par1List) { + for (int i = 0; i < par1List.size(); ++i) { + Entity entity = (Entity) par1List.get(i); + + if (entity instanceof EntityLivingBase) { + entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F); + } + } + } + + private void updateDragonEnderCrystal() { + if (this.healingEnderCrystal != null) { + if (this.healingEnderCrystal.isDead) { + if (!this.worldObj.isRemote) { + this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F); + } + + this.healingEnderCrystal = null; + } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) { + this.setHealth(this.getHealth() + 1.0F); + } + } + + if (this.rand.nextInt(10) == 0) { + float f = 32.0F; + List list = this.worldObj.getEntitiesWithinAABB(EntityEnderCrystal.class, this.boundingBox.expand((double) f, (double) f, (double) f)); + EntityEnderCrystal entityendercrystal = null; + double d0 = Double.MAX_VALUE; + Iterator iterator = list.iterator(); + + while (iterator.hasNext()) { + EntityEnderCrystal entityendercrystal1 = (EntityEnderCrystal) iterator.next(); + double d1 = entityendercrystal1.getDistanceSqToEntity(this); + + if (d1 < d0) { + d0 = d1; + entityendercrystal = entityendercrystal1; + } + } + + this.healingEnderCrystal = entityendercrystal; + } + } + + private void setNewTarget() { + this.forceNewTarget = false; + + if (this.rand.nextInt(2) == 0 && !this.worldObj.playerEntities.isEmpty()) { + this.target = (Entity) this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size())); + } else { + boolean flag = false; + + do { + this.targetX = 0.0D; + this.targetY = (double) (70.0F + this.rand.nextFloat() * 50.0F); + this.targetZ = 0.0D; + this.targetX += (double) (this.rand.nextFloat() * 120.0F - 60.0F); + this.targetZ += (double) (this.rand.nextFloat() * 120.0F - 60.0F); + double d0 = this.posX - this.targetX; + double d1 = this.posY - this.targetY; + double d2 = this.posZ - this.targetZ; + flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; + } while (!flag); + + this.target = null; + } + } + + private float simplifyAngle(double par1) { + return (float) MathHelper.wrapAngleTo180_double(par1); + } + + private boolean destroyBlocksInAABB(AxisAlignedBB par1AxisAlignedBB) { + int i = MathHelper.floor_double(par1AxisAlignedBB.minX); + int j = MathHelper.floor_double(par1AxisAlignedBB.minY); + int k = MathHelper.floor_double(par1AxisAlignedBB.minZ); + int l = MathHelper.floor_double(par1AxisAlignedBB.maxX); + int i1 = MathHelper.floor_double(par1AxisAlignedBB.maxY); + int j1 = MathHelper.floor_double(par1AxisAlignedBB.maxZ); + boolean flag = false; + boolean flag1 = false; + + for (int k1 = i; k1 <= l; ++k1) { + for (int l1 = j; l1 <= i1; ++l1) { + for (int i2 = k; i2 <= j1; ++i2) { + Block block = this.worldObj.getBlock(k1, l1, i2); + + if (!block.isAir(worldObj, k1, l1, i2)) { + if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) { + flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1; + } else { + flag = true; + } + } + } + } + } + + if (flag1) { + double d1 = par1AxisAlignedBB.minX + (par1AxisAlignedBB.maxX - par1AxisAlignedBB.minX) * (double) this.rand.nextFloat(); + double d2 = par1AxisAlignedBB.minY + (par1AxisAlignedBB.maxY - par1AxisAlignedBB.minY) * (double) this.rand.nextFloat(); + double d0 = par1AxisAlignedBB.minZ + (par1AxisAlignedBB.maxZ - par1AxisAlignedBB.minZ) * (double) this.rand.nextFloat(); + this.worldObj.spawnParticle("largeexplode", d1, d2, d0, 0.0D, 0.0D, 0.0D); + } + + return flag; + } + + private void spawnEgg() + { + BlockEndPortal.field_149948_a = true; + + if (createPortal) { + createEnderPortal(portalX, portalZ); + } + if (worldObj.getBlock(portalX, portalY + 1, portalZ) == Blocks.air) { + worldObj.setBlock(portalX, portalY + 1, portalZ, Blocks.dragon_egg); + }else { + for (int i = portalY + 1; i < 250; i++) { + if (worldObj.getBlock(portalX, i, portalZ) == Blocks.air) { + worldObj.setBlock(portalX, i, portalZ, Blocks.dragon_egg); + break; + } + } + } + + for (int iX = portalX - 2; iX <= portalX + 2; iX++) + { + for (int iZ = portalZ - 2; iZ <= portalZ + 2; iZ++) + { + + if (worldObj.getBlock(iX, portalY - 4, iZ) == Blocks.bedrock && !(iX == portalX && iZ == portalZ)) + { + worldObj.setBlock(iX, portalY - 3, iZ, Blocks.end_portal); + } + } + } + + + worldObj.setBlock(portalX - 1, portalY - 1, portalZ, Blocks.torch); + worldObj.setBlock(portalX + 1, portalY - 1, portalZ, Blocks.torch); + worldObj.setBlock(portalX, portalY - 1, portalZ - 1, Blocks.torch); + worldObj.setBlock(portalX, portalY - 1, portalZ + 1, Blocks.torch); + + + BlockEndPortal.field_149948_a = false; + } + + private void createEnderPortal(int par1, int par2) + { + byte b0 = 64; + byte b1 = 4; + + for (int k = b0 - 1; k <= b0 + 32; ++k) + { + for (int l = par1 - b1; l <= par1 + b1; ++l) + { + for (int i1 = par2 - b1; i1 <= par2 + b1; ++i1) + { + double d0 = (double)(l - par1); + double d1 = (double)(i1 - par2); + double d2 = d0 * d0 + d1 * d1; + + if (d2 <= ((double)b1 - 0.5D) * ((double)b1 - 0.5D)) + { + if (k < b0) + { + if (d2 <= ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) + { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } + else if (k > b0) + { + this.worldObj.setBlock(l, k, i1, Blocks.air); + } + else if (d2 > ((double)(b1 - 1) - 0.5D) * ((double)(b1 - 1) - 0.5D)) + { + this.worldObj.setBlock(l, k, i1, Blocks.bedrock); + } + } + } + } + } + + this.worldObj.setBlock(par1, b0 + 0, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 1, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 2, par2, Blocks.bedrock); + this.worldObj.setBlock(par1, b0 + 3, par2, Blocks.bedrock); + } + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java index bb516268..012b7183 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/entity/EntityDraconicArrow.java @@ -143,7 +143,7 @@ public class EntityDraconicArrow extends EntityArrow implements IProjectile { block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f); - if (axisalignedbb != null && axisalignedbb.isVecInside(this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ))) { + if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ))) { this.inGround = true; } } @@ -171,14 +171,14 @@ public class EntityDraconicArrow extends EntityArrow implements IProjectile { } } else { ++this.ticksInAir; - Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); - Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false); - vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ); - vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); + vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ); + vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { - vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); + vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCompound.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCompound.java index ccc516e8..ffdfca39 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCompound.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCompound.java @@ -7,7 +7,7 @@ import com.brandon3055.draconicevolution.common.lib.Strings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public class DraconicCompound extends TolkienItem { +public class DraconicCompound extends DraconicEvolutionItem { public DraconicCompound() { this.setUnlocalizedName(Strings.draconicCompoundName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java index 8d601496..e8a73f4c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicCore.java @@ -1,13 +1,36 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.blocks.ModBlocks; import com.brandon3055.draconicevolution.common.lib.Strings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; -public class DraconicCore extends TolkienItem { +import java.util.List; + +public class DraconicCore extends DraconicEvolutionItem { public DraconicCore() { this.setUnlocalizedName(Strings.draconicCoreName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); ModItems.register(this); } + @Override + public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { + par3List.add(StatCollector.translateToLocal("info.draconicCore.txt")); + } + + @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.getBlock(x, y, z) == Blocks.mob_spawner) + { + world.setBlock(x, y, z, ModBlocks.customSpawner); + stack.splitStack(1); + return true; + } + return false; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/TolkienItem.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicEvolutionItem.java similarity index 95% rename from src/main/java/com/brandon3055/draconicevolution/common/items/TolkienItem.java rename to src/main/java/com/brandon3055/draconicevolution/common/items/DraconicEvolutionItem.java index 97894a20..a2a83812 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/TolkienItem.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconicEvolutionItem.java @@ -8,7 +8,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.common.lib.References; -public class TolkienItem extends Item { +public class DraconicEvolutionItem extends Item { public String getUnwrappedUnlocalizedName(final String unlocalizedName) { return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java index a04c76c3..0b3c0289 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumBlend.java @@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconiumBlend extends TolkienItem { +public class DraconiumBlend extends DraconicEvolutionItem { public DraconiumBlend() { this.setUnlocalizedName(Strings.draconiumBlendName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java index ad8c7b99..86fed180 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumDust.java @@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconiumDust extends TolkienItem { +public class DraconiumDust extends DraconicEvolutionItem { public DraconiumDust() { this.setUnlocalizedName(Strings.draconiumDustName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java index 472ecc90..1fc3de77 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DraconiumIngot.java @@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconiumIngot extends TolkienItem { +public class DraconiumIngot extends DraconicEvolutionItem { public DraconiumIngot() { this.setUnlocalizedName(Strings.draconiumIngotName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java b/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java index 5c1b6f0d..8f76653f 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/DragonHeart.java @@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DragonHeart extends TolkienItem { +public class DragonHeart extends DraconicEvolutionItem { public DragonHeart() { this.setUnlocalizedName(Strings.dragonHeartName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/InfusedCompound.java b/src/main/java/com/brandon3055/draconicevolution/common/items/InfusedCompound.java index cc5bb30a..b7d6634a 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/InfusedCompound.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/InfusedCompound.java @@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.Strings; -public class InfusedCompound extends TolkienItem { +public class InfusedCompound extends DraconicEvolutionItem { public InfusedCompound() { this.setUnlocalizedName(Strings.infusedCompoundName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java b/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java new file mode 100644 index 00000000..2548f3e8 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/MobSoul.java @@ -0,0 +1,25 @@ +package com.brandon3055.draconicevolution.common.items; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.lib.Strings; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * Created by Brandon on 7/07/2014. + */ +public class MobSoul extends DraconicEvolutionItem { + public MobSoul() { + this.setUnlocalizedName(Strings.MobSoulName); + ModItems.register(this); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + String name = ItemNBTHelper.getString(stack, "Name", "Pig"); + list.add(name); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/ModItems.java b/src/main/java/com/brandon3055/draconicevolution/common/items/ModItems.java index 2d29c81c..0fbdfb9c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/ModItems.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/ModItems.java @@ -1,5 +1,8 @@ package com.brandon3055.draconicevolution.common.items; +import com.brandon3055.draconicevolution.common.items.armor.DraconicArmor; +import com.brandon3055.draconicevolution.common.items.armor.WyvernArmor; +import com.brandon3055.draconicevolution.common.lib.Strings; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; @@ -21,6 +24,7 @@ import com.brandon3055.draconicevolution.common.items.weapons.WyvernSword; public class ModItems { public static ArmorMaterial DRACONIUMARMOR_T1 = EnumHelper.addArmorMaterial("DRACONIUMARMOR_T1", -1, new int[] { 3, 8, 6, 3 }, 30); + public static ArmorMaterial DRACONIUMARMOR_T2 = EnumHelper.addArmorMaterial("DRACONIUMARMOR_T2", -1, new int[] { 3, 8, 6, 3 }, 30); public static ToolMaterial DRACONIUM_T1 = EnumHelper.addToolMaterial("DRACONIUM_T1", 4, -1, 12.0F, 11.0F, 35); public static ToolMaterial DRACONIUM_T2 = EnumHelper.addToolMaterial("DRACONIUM_T2", 4, -1, 16.0F, 15.0F, 40); public static ToolMaterial DRACONIUM_T3 = EnumHelper.addToolMaterial("DRACONIUM_T3", 4, -1, 400.0F, 20.0F, 45); @@ -31,18 +35,21 @@ public class ModItems { public static Item draconicAxe; public static Item draconicSword; public static Item draconicBow; + public static Item draconicHelm; + public static Item draconicChest; + public static Item draconicLeggs; + public static Item draconicBoots; public static Item wyvernPickaxe; public static Item wyvernShovel; public static Item wyvernSword; public static Item wyvernBow; - public static Item wyvernChestPlate; + public static Item wyvernHelm; + public static Item wyvernChest; + public static Item wyvernLeggs; + public static Item wyvernBoots; public static Item infusedCompound; - public static Item rawDraconicPickHead; - public static Item rawDraconicSwordBlade; - public static Item draconicPickHead; - public static Item draconicSwordBlade; public static Item draconiumDust; public static Item draconiumIngot; public static Item draconiumBlend; @@ -52,13 +59,11 @@ public class ModItems { public static Item tclogo; public static Item draconicCore; public static Item sunFocus; - + public static Item mobSoul; + public static Item teleporterMKI; public static Item teleporterMKII; - public static Item reader; - - public static Item testPick; public static void init() { @@ -69,13 +74,20 @@ public class ModItems { draconicHoe = new DraconicHoe(); draconicSword = new DraconicSword(); draconicBow = new DraconicBow(); + draconicHelm = new DraconicArmor(DRACONIUMARMOR_T2, 0, Strings.draconicHelmName); + draconicChest = new DraconicArmor(DRACONIUMARMOR_T2, 1, Strings.draconicChestName); + draconicLeggs = new DraconicArmor(DRACONIUMARMOR_T2, 2, Strings.draconicLeggsName); + draconicBoots = new DraconicArmor(DRACONIUMARMOR_T2, 3, Strings.draconicBootsName); wyvernPickaxe = new WyvernPickaxe(); wyvernShovel = new WyvernShovel(); wyvernSword = new WyvernSword(); wyvernBow = new WyvernBow(); - //wyvernChestPlate = new WyvernChestPlate(); - + wyvernHelm = new WyvernArmor(DRACONIUMARMOR_T1, 0, Strings.wyvernHelmName); + wyvernChest = new WyvernArmor(DRACONIUMARMOR_T1, 1, Strings.wyvernChestName); + wyvernLeggs = new WyvernArmor(DRACONIUMARMOR_T1, 2, Strings.wyvernLeggsName); + wyvernBoots = new WyvernArmor(DRACONIUMARMOR_T1, 3, Strings.wyvernBootsName); + infusedCompound = new InfusedCompound(); draconiumDust = new DraconiumDust(); draconiumIngot = new DraconiumIngot(); @@ -87,12 +99,11 @@ public class ModItems { tclogo = new Tclogo(); draconicCore = new DraconicCore(); sunFocus = new SunFocus(); - //reader = new Reader(); + mobSoul = new MobSoul(); - //testPick = new TestPick(); } - public static void register(final TolkienItem item) + public static void register(final DraconicEvolutionItem item) { GameRegistry.registerItem(item, item.getUnwrappedUnlocalizedName(item.getUnlocalizedName())); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java b/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java index fbfb17ae..6e35a9bd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/SunFocus.java @@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.items; import com.brandon3055.draconicevolution.DraconicEvolution; import com.brandon3055.draconicevolution.common.lib.Strings; -public class SunFocus extends TolkienItem { +public class SunFocus extends DraconicEvolutionItem { public SunFocus() { this.setUnlocalizedName(Strings.sunFocusName); this.setCreativeTab(DraconicEvolution.getCreativeTab(2)); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java b/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java index 7ddd1e0b..32d4bf33 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/Tclogo.java @@ -2,8 +2,11 @@ package com.brandon3055.draconicevolution.common.items; import java.util.List; +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.entity.EntityCustomDragon; import com.brandon3055.draconicevolution.common.items.tools.ToolHandler; import net.minecraft.entity.Entity; +import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumAction; import net.minecraft.item.ItemStack; @@ -14,7 +17,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.common.lib.Strings; -public class Tclogo extends TolkienItem { +public class Tclogo extends DraconicEvolutionItem { public Tclogo() { this.setUnlocalizedName(Strings.tclogoName); //this.setCreativeTab(draconicevolution.getCreativeTab()); @@ -72,6 +75,10 @@ public class Tclogo extends TolkienItem { @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + + + world.spawnEntityInWorld(new EntityLightningBolt(world, player.posX, player.posY, player.posZ + 5)); + int xPos = (int) player.posX; int yPos = (int) player.posY; int zPos = (int) player.posZ; @@ -88,8 +95,7 @@ public class Tclogo extends TolkienItem { public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) { //player.worldObj.scheduleBlockUpdate(X, Y, Z, player.worldObj.getBlock(X, Y, Z), 10); - MovingObjectPosition mop = ToolHandler.raytraceFromEntity(player.worldObj, player, 4.5D); - System.out.println(mop.sideHit); + return true; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ArmorPropertiesHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ArmorPropertiesHandler.java new file mode 100644 index 00000000..953fef34 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ArmorPropertiesHandler.java @@ -0,0 +1,107 @@ +package com.brandon3055.draconicevolution.common.items.armor; + +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraftforge.common.ISpecialArmor; + +/** + * Created by Brandon on 3/07/2014. + */ +public class ArmorPropertiesHandler { + + public static ISpecialArmor.ArmorProperties draconicHelm(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (source == DamageSource.fallingBlock || source == DamageSource.anvil) + return new ISpecialArmor.ArmorProperties(1, 1, Integer.MAX_VALUE); + else if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.15, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.14, Integer.MAX_VALUE); + + } + + public static ISpecialArmor.ArmorProperties draconicChest(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (hasFullSetDraconic(player) && source == DamageSource.wither || source == DamageSource.magic) + return new ISpecialArmor.ArmorProperties(1, 1, Integer.MAX_VALUE); + else if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.50, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.50, Integer.MAX_VALUE); + } + + public static ISpecialArmor.ArmorProperties draconicLeggs(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.20, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.18, Integer.MAX_VALUE); + } + + public static ISpecialArmor.ArmorProperties draconicBoots(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.15, Integer.MAX_VALUE); + else if (source == DamageSource.fall) + return new ISpecialArmor.ArmorProperties(1, 1, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.14, Integer.MAX_VALUE); + } + + public static boolean isFireDamage(DamageSource damage){ + return damage == DamageSource.inFire || damage == DamageSource.onFire || damage == DamageSource.lava; + } + + public static boolean hasFullSetDraconic(EntityLivingBase player){ + ItemStack slotBoots = player.getEquipmentInSlot(1); + ItemStack slotLeggs = player.getEquipmentInSlot(2); + ItemStack slotChest = player.getEquipmentInSlot(3); + ItemStack slotHelmet = player.getEquipmentInSlot(4); + if (slotBoots == null || slotHelmet == null || slotChest == null || slotHelmet == null) + return false; + if(slotBoots.getItem() == ModItems.draconicBoots && slotLeggs.getItem() == ModItems.draconicLeggs && slotChest.getItem() == ModItems.draconicChest && slotHelmet.getItem() == ModItems.draconicHelm) + return true; + return false; + } + + + public static ISpecialArmor.ArmorProperties wyvernHelm(EntityLivingBase player, ItemStack armor, DamageSource source){ + return new ISpecialArmor.ArmorProperties(1, 0.12, Integer.MAX_VALUE); + } + + public static ISpecialArmor.ArmorProperties wyvernChest(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (hasFullSetWyvern(player) && source == DamageSource.magic) + return new ISpecialArmor.ArmorProperties(1, 0.9, Integer.MAX_VALUE); + else if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.49, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.48, Integer.MAX_VALUE); + } + + public static ISpecialArmor.ArmorProperties wyvernLeggs(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.19, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.16, Integer.MAX_VALUE); + } + + public static ISpecialArmor.ArmorProperties wyvernBoots(EntityLivingBase player, ItemStack armor, DamageSource source){ + if (isFireDamage(source)) + return new ISpecialArmor.ArmorProperties(1, 0.14, Integer.MAX_VALUE); + else + return new ISpecialArmor.ArmorProperties(1, 0.12, Integer.MAX_VALUE); + } + + public static boolean hasFullSetWyvern(EntityLivingBase player){ + ItemStack slotBoots = player.getEquipmentInSlot(1); + ItemStack slotLeggs = player.getEquipmentInSlot(2); + ItemStack slotChest = player.getEquipmentInSlot(3); + ItemStack slotHelmet = player.getEquipmentInSlot(4); + if (slotBoots == null || slotHelmet == null || slotChest == null || slotHelmet == null) + return false; + if(slotBoots.getItem() == ModItems.wyvernBoots && slotLeggs.getItem() == ModItems.wyvernLeggs && slotChest.getItem() == ModItems.wyvernChest && slotHelmet.getItem() == ModItems.wyvernHelm) + return true; + return false; + } + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java new file mode 100644 index 00000000..168a4f81 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java @@ -0,0 +1,200 @@ +package com.brandon3055.draconicevolution.common.items.armor; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.lib.References; +import com.brandon3055.draconicevolution.common.lib.Strings; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.ISpecialArmor; +import org.lwjgl.input.Keyboard; +import sun.net.www.content.text.plain; + +import java.util.List; + +/** + * Created by Brandon on 3/07/2014. + */ +public class DraconicArmor extends ItemArmor implements ISpecialArmor{ + private IIcon helmIcon; + private IIcon chestIcon; + private IIcon leggsIcon; + private IIcon bootsIcon; + + public DraconicArmor(ArmorMaterial material, int armorType, String name) { + super(material, 0, armorType); + this.setUnlocalizedName(name); + this.setCreativeTab(DraconicEvolution.getCreativeTab(1)); + GameRegistry.registerItem(this, name); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + helmIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_helmet"); + chestIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_chestplate"); + leggsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_leggings"); + bootsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_boots"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack.getItem() == ModItems.draconicHelm) return helmIcon; + else if (stack.getItem() == ModItems.draconicChest) return chestIcon; + else if (stack.getItem() == ModItems.draconicLeggs) return leggsIcon; + else return bootsIcon; + } + + @Override + public IIcon getIconIndex(ItemStack stack) { + if (stack.getItem() == ModItems.draconicHelm) return helmIcon; + else if (stack.getItem() == ModItems.draconicChest) return chestIcon; + else if (stack.getItem() == ModItems.draconicLeggs) return leggsIcon; + else return bootsIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (stack.getItem() == ModItems.draconicHelm || stack.getItem() == ModItems.draconicChest || stack.getItem() == ModItems.draconicBoots) { + return References.RESOURCESPREFIX + "textures/models/armor/draconic_layer_1.png"; + } else { + return References.RESOURCESPREFIX + "textures/models/armor/draconic_layer_2.png"; + } + } + + //##################################################################################### + + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + switch(slot){ + case 0: + return ArmorPropertiesHandler.draconicBoots(player, armor, source); + case 1: + return ArmorPropertiesHandler.draconicLeggs(player, armor, source); + case 2: + return ArmorPropertiesHandler.draconicChest(player, armor, source); + case 3: + return ArmorPropertiesHandler.draconicHelm(player, armor, source); + default: + LogHelper.error("[Draconic Armor] Invalid slot"); + return new ArmorProperties(0, 0, 0); + + } + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + switch(slot){ + case 0: + return 3; + case 1: + return 6; + case 2: + return 8; + case 3: + return 3; + default: + return 0; + } + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if (player.isBurning() && ArmorPropertiesHandler.hasFullSetDraconic(player)) { + player.addPotionEffect(new PotionEffect(12, 10, 0, true)); + } + if(stack != null && stack.getItem() == ModItems.draconicHelm) { + if (player.worldObj.getBlockLightValue((int)player.posX, (int)player.posY, (int)player.posZ) < 5) + player.addPotionEffect(new PotionEffect(16, 210, 0, true)); + } + if(stack != null && stack.getItem() == ModItems.draconicLeggs) { + if (player.isSprinting()) + player.addPotionEffect(new PotionEffect(1, 10, 3, true)); + else + player.addPotionEffect(new PotionEffect(1, 10, 1, true)); + } + if(stack != null && stack.getItem() == ModItems.draconicBoots) { + if (player.isSprinting()) + player.addPotionEffect(new PotionEffect(8, 10, 3, true)); + else + player.addPotionEffect(new PotionEffect(8, 10, 1, true)); + } + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { + list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); + }else{ + if (stack.getItem() == ModItems.draconicHelm) { + list.add(StatCollector.translateToLocal("info.draconicArmorInfoHelm.txt")); + } + else if (stack.getItem() == ModItems.draconicChest) { + list.add(StatCollector.translateToLocal("info.draconicArmorInfoChest.txt")); + list.add(StatCollector.translateToLocal("info.draconicArmorInfoChest1.txt")); + list.add(StatCollector.translateToLocal("info.draconicArmorInfoChest2.txt")); + list.add(StatCollector.translateToLocal("info.draconicArmorInfoChest3.txt")); + } + else if (stack.getItem() == ModItems.draconicLeggs) { + list.add(StatCollector.translateToLocal("info.draconicArmorInfoLeggs.txt")); + } + else if (stack.getItem() == ModItems.draconicBoots) { + list.add(StatCollector.translateToLocal("info.draconicArmorInfoBoots.txt")); + list.add(StatCollector.translateToLocal("info.draconicArmorInfoBoots1.txt")); + } + list.add(""); + list.add("" + EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicArmorLegend1.txt")); + list.add("" + EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicArmorLegend2.txt")); + } + } + + public static void registerRecipe(){ + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicHelm), + "ISI", + "DAD", + "CIC", + 'I', ModItems.draconiumIngot, 'S', ModItems.sunFocus, 'D', ModItems.draconicCompound, 'C', ModItems.draconicCore, 'A', ModItems.wyvernHelm); + + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicChest), + "ISI", + "DAD", + "CDC", + 'I', ModItems.draconiumIngot, 'S', ModItems.sunFocus, 'D', ModItems.draconicCompound, 'C', ModItems.draconicCore, 'A', ModItems.wyvernChest); + + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicLeggs), + "ISI", + "DAD", + "CIC", + 'I', ModItems.draconiumIngot, 'S', ModItems.sunFocus, 'D', ModItems.draconicCompound, 'C', ModItems.draconicCore, 'A', ModItems.wyvernLeggs); + + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicBoots), + "ISI", + "DAD", + "CIC", + 'I', ModItems.draconiumIngot, 'S', ModItems.sunFocus, 'D', ModItems.draconicCompound, 'C', ModItems.draconicCore, 'A', ModItems.wyvernBoots); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java new file mode 100644 index 00000000..f1d664bb --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java @@ -0,0 +1,172 @@ +package com.brandon3055.draconicevolution.common.items.armor; + +import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.lib.References; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.potion.PotionEffect; +import net.minecraft.potion.PotionHelper; +import net.minecraft.util.DamageSource; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.ISpecialArmor; +import org.lwjgl.input.Keyboard; + +import java.util.List; + +/** + * Created by Brandon on 3/07/2014. + */ +public class WyvernArmor extends ItemArmor implements ISpecialArmor{ + private IIcon helmIcon; + private IIcon chestIcon; + private IIcon leggsIcon; + private IIcon bootsIcon; + + public WyvernArmor(ArmorMaterial material, int armorType, String name) { + super(material, 0, armorType); + this.setUnlocalizedName(name); + this.setCreativeTab(DraconicEvolution.getCreativeTab(1)); + GameRegistry.registerItem(this, name); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + helmIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_helmet"); + chestIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_chestplate"); + leggsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_leggings"); + bootsIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_boots"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; + else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; + else if (stack.getItem() == ModItems.wyvernLeggs) return leggsIcon; + else return bootsIcon; + } + + @Override + public IIcon getIconIndex(ItemStack stack) { + if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; + else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; + else if (stack.getItem() == ModItems.wyvernLeggs) return leggsIcon; + else return bootsIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + if (stack.getItem() == ModItems.wyvernHelm || stack.getItem() == ModItems.wyvernChest || stack.getItem() == ModItems.wyvernBoots) { + return References.RESOURCESPREFIX + "textures/models/armor/wyvern_layer_1.png"; + } else { + return References.RESOURCESPREFIX + "textures/models/armor/wyvern_layer_2.png"; + } + } + + //##################################################################################### + + @Override + public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) { + switch(slot){ + case 0: + return ArmorPropertiesHandler.wyvernBoots(player, armor, source); + case 1: + return ArmorPropertiesHandler.wyvernLeggs(player, armor, source); + case 2: + return ArmorPropertiesHandler.wyvernChest(player, armor, source); + case 3: + return ArmorPropertiesHandler.wyvernHelm(player, armor, source); + default: + LogHelper.error("[Draconic Armor] Invalid slot"); + return new ArmorProperties(0, 0, 0); + + } + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + switch(slot){ + case 0: + return 3; + case 1: + return 6; + case 2: + return 8; + case 3: + return 3; + default: + return 0; + } + } + + @Override + public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { + + } + + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { + if(stack != null && stack.getItem() == ModItems.wyvernLeggs) { + if (player.isSprinting()) + player.addPotionEffect(new PotionEffect(1, 10, 1, true)); + else + player.addPotionEffect(new PotionEffect(1, 10, 0, true)); + } + if(stack != null && stack.getItem() == ModItems.wyvernBoots) { + if (player.isSprinting()) + player.addPotionEffect(new PotionEffect(8, 10, 1, true)); + else + player.addPotionEffect(new PotionEffect(8, 10, 0, true)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { + list.add("" + EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.wyvernArmorLegend1.txt")); + list.add("" + EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.wyvernArmorLegend2.txt")); + } + + public static void registerRecipe(){ + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernHelm), + " I ", + "IDI", + " C ", + 'I', ModItems.infusedCompound, 'D', Items.diamond_helmet, 'C', ModItems.draconicCore); + + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernChest), + "PIP", + "IDI", + "ICI", + 'I', ModItems.infusedCompound, 'D', Items.diamond_chestplate, 'C', ModItems.draconicCore, 'P', new ItemStack(Items.potionitem, 1, 8259)); + + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernLeggs), + "PIP", + "IDI", + " C ", + 'I', ModItems.infusedCompound, 'D', Items.diamond_leggings, 'C', ModItems.draconicCore, 'P', new ItemStack(Items.potionitem, 1, 8258)); + + CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernBoots), + " I ", + "IDI", + "PCP", + 'I', ModItems.infusedCompound, 'D', Items.diamond_boots, 'C', ModItems.draconicCore, 'P', Blocks.piston); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernChestPlate.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernChestPlate.java deleted file mode 100644 index e2c0e296..00000000 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernChestPlate.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.brandon3055.draconicevolution.common.items.armor; - -import java.util.List; - -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.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; - -import org.lwjgl.input.Keyboard; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.items.ModItems; -import com.brandon3055.draconicevolution.common.lib.References; -import com.brandon3055.draconicevolution.common.lib.Strings; - -public class WyvernChestPlate extends ItemArmor { - public IIcon itemIcon1; - - public WyvernChestPlate() { - super(ModItems.DRACONIUMARMOR_T1, 1, 1); - this.setUnlocalizedName(Strings.wyvernChestPlateName); - this.setCreativeTab(DraconicEvolution.getCreativeTab(1)); - GameRegistry.registerItem(this, Strings.wyvernChestPlateName); - } - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - return "draconicevolution:textures/diamond_layer_1.png"; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvernPickaxe0"); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) - { - return itemIcon; - } - - @Override - @SideOnly(Side.CLIENT) - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) - { - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) - list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); - else { - list.add(EnumChatFormatting.GREEN + "Shift Right-click to change mode"); - list.add(""); - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "Weary of plain tools you begin to understand"); - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "ways to use Draconic energy to upgrade"); - } - } - - @Override - public EnumRarity getRarity(ItemStack stack) - { - return EnumRarity.uncommon; - } - - public static void registerRecipe() - { - //CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernPickaxe), " C ", "CPC", " C ", 'C', ModItems.infusedCompound, 'P', Items.diamond_pickaxe); - } -} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java index af66e43f..bbd7baf3 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicAxe.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -11,6 +13,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -23,7 +26,11 @@ import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; import org.lwjgl.input.Keyboard; -public class DraconicAxe extends ItemAxe { +public class DraconicAxe extends ItemAxe implements IEnergyContainerItem{ + + protected int capacity = References.DRACONICCAPACITY; + protected int maxReceive = References.DRACONICTRANSFER; + protected int maxExtract = References.DRACONICTRANSFER; public DraconicAxe() { super(ModItems.DRACONIUM_T1); @@ -145,6 +152,7 @@ public class DraconicAxe extends ItemAxe { if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.draconicAxe1.txt")); list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); + ItemInfoHelper.energyDisplayInfo(stack, list); } else { list.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("info.draconicAxe2.txt")); list.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("info.draconicAxe3.txt")); @@ -164,4 +172,66 @@ public class DraconicAxe extends ItemAxe { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicAxe), "DFD", "CAC", "DTD", 'F', ModItems.sunFocus, 'C', ModItems.draconicCompound, 'D', ModItems.draconiumIngot, 'T', ModItems.draconicCore, 'A', Items.diamond_axe); } + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK) + return super.getDigSpeed(stack, block, meta); + else + return 1F; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java index f90b7bbe..9015c348 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicDistructionStaff.java @@ -3,6 +3,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; import java.util.Set; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -16,6 +18,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -30,18 +33,21 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconicDistructionStaff extends ItemTool { +public class DraconicDistructionStaff extends ItemTool implements IEnergyContainerItem { public IIcon itemIcon0; public IIcon itemIcon1; public IIcon itemIcon2; + protected int capacity = References.DRACONICCAPACITY; + protected int maxReceive = References.DRACONICTRANSFER; + protected int maxExtract = References.DRACONICTRANSFER * 50; private static Set minableBlocks = Sets.newHashSet(); - private static final Set field_150915_c = Sets.newHashSet(new Block[]{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}); +/* private static final Set field_150915_c = Sets.newHashSet(new Block[]{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}); private static final Set field_150916_c = Sets.newHashSet(new Block[]{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 field_150917_c = Sets.newHashSet(new Block[]{Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin}); @@ -57,7 +63,7 @@ public class DraconicDistructionStaff extends ItemTool { minableBlocks.add(block); } - } + }*/ public DraconicDistructionStaff() { super(0F, ModItems.DRACONIUM_T3, minableBlocks); @@ -70,13 +76,13 @@ public class DraconicDistructionStaff extends ItemTool { } @Override - public boolean func_150897_b(Block p_150897_1_) { - return p_150897_1_ == Blocks.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (p_150897_1_ != Blocks.diamond_block && p_150897_1_ != Blocks.diamond_ore ? (p_150897_1_ != Blocks.emerald_ore && p_150897_1_ != Blocks.emerald_block ? (p_150897_1_ != Blocks.gold_block && p_150897_1_ != Blocks.gold_ore ? (p_150897_1_ != Blocks.iron_block && p_150897_1_ != Blocks.iron_ore ? (p_150897_1_ != Blocks.lapis_block && p_150897_1_ != Blocks.lapis_ore ? (p_150897_1_ != Blocks.redstone_ore && p_150897_1_ != Blocks.lit_redstone_ore ? (p_150897_1_.getMaterial() == Material.rock ? true : (p_150897_1_.getMaterial() == Material.iron ? true : p_150897_1_.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); + public boolean func_150897_b(Block block) { + return block == Blocks.obsidian ? 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 ? true : (block.getMaterial() == Material.iron ? true : 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 - public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_) { - return p_150893_2_.getMaterial() != Material.iron && p_150893_2_.getMaterial() != Material.anvil && p_150893_2_.getMaterial() != Material.rock ? super.func_150893_a(p_150893_1_, p_150893_2_) : this.efficiencyOnProperMaterial; + public float func_150893_a(ItemStack stack, Block block) { + return block.getMaterial() != Material.iron && block.getMaterial() != Material.anvil && block.getMaterial() != Material.rock ? super.func_150893_a(stack, block) : this.efficiencyOnProperMaterial; } @Override @@ -144,8 +150,10 @@ public class DraconicDistructionStaff extends ItemTool { public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { int size = (ItemNBTHelper.getShort(stack, "size", (short) 0) * 2) + 1; boolean oblit = ItemNBTHelper.getBoolean(stack, "obliterate", false); - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); + ItemInfoHelper.energyDisplayInfo(stack, list); + } else { list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size); list.add(EnumChatFormatting.GREEN + "Shift Right-click to change minning mode"); @@ -167,4 +175,66 @@ public class DraconicDistructionStaff extends ItemTool { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicDistructionStaff), "DFD", "PTS", "DWD", 'F', ModItems.sunFocus, 'D', ModItems.draconicCompound, 'T', ModItems.draconicCore, 'P', ModItems.draconicPickaxe, 'S', ModItems.draconicShovel, 'W', ModItems.draconicSword); } + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK) + return super.getDigSpeed(stack, block, meta); + else + return 1F; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java index 27fd2d26..88a21626 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicHoe.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -13,6 +15,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; @@ -27,7 +30,12 @@ import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconicHoe extends ItemHoe { +public class DraconicHoe extends ItemHoe implements IEnergyContainerItem{ + + protected int capacity = References.DRACONICCAPACITY; + protected int maxReceive = References.DRACONICTRANSFER; + protected int maxExtract = References.DRACONICTRANSFER; + public DraconicHoe() { super(ModItems.DRACONIUM_T1); this.setUnlocalizedName(Strings.draconicHoeName); @@ -49,6 +57,10 @@ public class DraconicHoe extends ItemHoe { int size = 4; for (int x1 = -size; x1 <= size; x1++) { for (int z1 = -size; z1 <= size; z1++) { + if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return false; + } Block topBlock = world.getBlock(x + x1, y + 1, z + z1); if (topBlock.isReplaceable(world, x + x1, y + 1, z + z1)) { world.setBlockToAir(x + x1, y + 1, z + z1); @@ -86,6 +98,13 @@ public class DraconicHoe extends ItemHoe { } private boolean hoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7) { + if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return false; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem) stack.getItem()).extractEnergy(stack, References.ENERGYPERBLOCK, false); + } if (!player.canPlayerEdit(x, y, z, par7, stack)) { return false; } else { @@ -121,6 +140,7 @@ public class DraconicHoe extends ItemHoe { @Override public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { + ItemInfoHelper.energyDisplayInfo(stack, list); list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicLaw1.txt")); list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicLaw2.txt")); } @@ -128,4 +148,59 @@ public class DraconicHoe extends ItemHoe { public static void registerRecipe() { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicHoe), "ISI", "DHD", "ITI", 'H', Items.diamond_hoe, 'T', ModItems.draconicCore, 'S', ModItems.sunFocus, 'D', ModItems.draconiumIngot, 'I', Items.diamond); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java index 07d462fd..19706f07 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicPickaxe.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -11,6 +13,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -22,15 +25,18 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconicPickaxe extends ItemPickaxe { +public class DraconicPickaxe extends ItemPickaxe implements IEnergyContainerItem{ public IIcon itemIcon0; public IIcon itemIcon1; public IIcon itemIcon2; + protected int capacity = References.DRACONICCAPACITY; + protected int maxReceive = References.DRACONICTRANSFER; + protected int maxExtract = References.DRACONICTRANSFER; public DraconicPickaxe() { super(ModItems.DRACONIUM_T2); @@ -104,9 +110,10 @@ public class DraconicPickaxe extends ItemPickaxe { { int size = (ItemNBTHelper.getShort(stack, "size", (short)0) * 2) + 1; boolean oblit = ItemNBTHelper.getBoolean(stack, "obliterate", false); - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); - else { + ItemInfoHelper.energyDisplayInfo(stack, list); + }else { list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size); list.add(EnumChatFormatting.GREEN + "Shift Right-click to change minning mode"); list.add(StatCollector.translateToLocal("msg.oblit" + oblit + ".txt")); @@ -128,4 +135,67 @@ public class DraconicPickaxe extends ItemPickaxe { { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicPickaxe), "ISI", "DPD", "ITI", 'P', ModItems.wyvernPickaxe, 'D', ModItems.draconicCompound, 'S', ModItems.sunFocus, 'T', ModItems.draconicCore, 'I', ModItems.draconiumIngot); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK) + return super.getDigSpeed(stack, block, meta); + else + return 1F; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java index 879201ba..5dc030ca 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/DraconicShovel.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -11,6 +13,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; @@ -22,15 +25,18 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconicShovel extends ItemSpade { +public class DraconicShovel extends ItemSpade implements IEnergyContainerItem{ public IIcon itemIcon0; public IIcon itemIcon1; public IIcon itemIcon2; + protected int capacity = References.DRACONICCAPACITY; + protected int maxReceive = References.DRACONICTRANSFER; + protected int maxExtract = References.DRACONICTRANSFER; public DraconicShovel() { super(ModItems.DRACONIUM_T2); @@ -104,9 +110,10 @@ public class DraconicShovel extends ItemSpade { { int size = (ItemNBTHelper.getShort(stack, "size", (short)0) * 2) + 1; boolean oblit = ItemNBTHelper.getBoolean(stack, "obliterate", false); - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); - else { + ItemInfoHelper.energyDisplayInfo(stack, list); + }else { list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size); list.add(EnumChatFormatting.GREEN + "Shift Right-click to change minning mode"); list.add(StatCollector.translateToLocal("msg.oblit" + oblit + ".txt")); @@ -128,4 +135,67 @@ public class DraconicShovel extends ItemSpade { { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicShovel), "ISI", "DPD", "ITI", 'P', ModItems.wyvernShovel, 'D', ModItems.draconicCompound, 'S', ModItems.sunFocus, 'T', ModItems.draconicCore, 'I', ModItems.draconiumIngot); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK) + return super.getDigSpeed(stack, block, meta); + else + return 1F; + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java index 9ab1fd70..cd37d455 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKI.java @@ -21,7 +21,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.core.utills.Teleporter; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java index 9db6d3a0..f72853e8 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TeleporterMKII.java @@ -21,7 +21,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.client.interfaces.GuiHandler; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.core.utills.Teleporter; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TestPick.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TestPick.java deleted file mode 100644 index 3ec02e6d..00000000 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/TestPick.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.brandon3055.draconicevolution.common.items.tools; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -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.enchantment.EnchantmentHelper; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import com.google.common.collect.Sets; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class TestPick extends ItemTool { - - public static Material[] materialsPick = { Material.anvil, Material.circuits, Material.coral, Material.glass, Material.ice, Material.iron, Material.rock }; - private static Set minableBlocks = Sets.newHashSet(); - public TestPick() { - super(0, ToolMaterial.EMERALD, minableBlocks); - this.setUnlocalizedName("testPick"); - this.setCreativeTab(CreativeTabs.tabTools); - GameRegistry.registerItem(this, "testPick"); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(final IIconRegister iconRegister) - { - this.itemIcon = iconRegister.registerIcon("minecraft:diamond_pickaxe"); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int par1) - { - return itemIcon; - } - - @Override - public boolean onBlockStartBreak(final ItemStack stack, final int x, final int y, final int z, final EntityPlayer player) - { - World world = player.worldObj; - int fortune = EnchantmentHelper.getFortuneModifier(player); - boolean silk = EnchantmentHelper.getSilkTouchModifier(player); - - disSquare(x, y, z, player, world, silk, fortune, stack); - - return false; - } - - public static void disSquare(int x, int y, int z, final EntityPlayer player, final World world, final boolean silk, final int fortune, ItemStack stack) - { - int sizeX = 1; - int sizeY = 1; - int sizeZ = 1; - - for (int x1 = x - sizeX; x1 <= x + sizeX; x1++) { - for (int y1 = y - sizeY; y1 <= y + sizeY; y1++) { - for (int z1 = z - sizeZ; z1 <= z + sizeZ; z1++) { - mineBlock(x1, y1, z1, player, world, silk, fortune, stack); - } - } - } - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - public static void mineBlock(int x, int y, int z, EntityPlayer player, World world, boolean silk, int fortune, ItemStack stack) - { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); - Material mat = block.getMaterial(); - - if ((block != null) && (!block.isAir(world, x, y, z)) && (block.getPlayerRelativeBlockHardness(player, world, x, y, z) != 0.0F)) { - List items = new ArrayList(); - - if ((!block.canHarvestBlock(player, meta)) || (!isRightMaterial(mat, materialsPick))) { - return; - } - - if ((silk) && (block.canSilkHarvest(world, player, x, y, z, meta))) { - if (block == Blocks.lit_redstone_ore) - items.add(new ItemStack(Item.getItemFromBlock(Blocks.redstone_ore))); - else - items.add(new ItemStack(block.getItem(world, x, y, z), 1, meta)); - } else { - items.addAll(block.getDrops(world, x, y, z, meta, fortune)); - block.dropXpOnBlockBreak(world, x, y, z, block.getExpDrop(world, meta, fortune)); - } - - world.setBlockToAir(x, y, z); - - if (!world.isRemote) { - for (final ItemStack item : items) { - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, item)); - } - } - } - } - - public static boolean isRightMaterial(final Material material, final Material[] materialsListing) - { - for (final Material mat : materialsListing) { - if (material == mat) { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ToolHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ToolHandler.java index 4eb77461..f745b7b2 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ToolHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/ToolHandler.java @@ -4,8 +4,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; +import com.brandon3055.draconicevolution.common.lib.References; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.enchantment.EnchantmentHelper; @@ -62,7 +64,7 @@ public class ToolHandler { int yOff = (size * -1); Block targetBlock = world.getBlock(x, y, z); if (size > 0) yOff++; - if (size == 0) return false; + //if (size == 0) return false; int side = (stack.getItem().equals(ModItems.draconicAxe)) ? 6 : mop.sideHit; switch (side) { case 0: @@ -79,11 +81,12 @@ public class ToolHandler { sizeX = 0; break; } + for (int x1 = x - sizeX; x1 <= x + sizeX; x1++) { for (int y1 = y - (sizeY + yOff); y1 <= y + (sizeY - yOff); y1++) { for (int z1 = z - sizeZ; z1 <= z + sizeZ; z1++) { mineBlock(x1, y1, z1, player, world, silk, fortune, materialsListing, stack); - player.worldObj.scheduleBlockUpdate(x1, y1, z1, Blocks.stone, 100); + //player.worldObj.scheduleBlockUpdate(x1, y1, z1, Blocks.stone, 100); } } } @@ -105,6 +108,14 @@ public class ToolHandler { world.setBlockToAir(x, y, z); return; } + if (!(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, References.ENERGYPERBLOCK, false); + } + if ((stack.getItem().equals(ModItems.draconicAxe) ? 2 : ItemNBTHelper.getShort(stack, "size", (short) 0)) == 0) return; if ((silk) && (block.canSilkHarvest(world, player, x, y, z, meta))) { if (block == Blocks.lit_redstone_ore) items.add(new ItemStack(Item.getItemFromBlock(Blocks.redstone_ore))); @@ -145,19 +156,41 @@ public class ToolHandler { public static void demageEntytyBasedOnHealth(Entity entity, EntityPlayer player, float dmg) { World world = player.worldObj; + ItemStack stack = player.getCurrentEquippedItem(); if (entity instanceof EntityLivingBase) { float entHealth = ((EntityLivingBase) entity).getHealth(); if (!world.isRemote) { if (entHealth > 20) { + if (stack == null || !(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, References.ENERGYPERATTACK + (int)((entHealth) * 100), false); + } entity.attackEntityFrom(DamageSource.causePlayerDamage(player), (entHealth) * dmg); } } } else if (entity instanceof EntityDragonPart) { if (!world.isRemote) { + if (stack == null || !(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, References.ENERGYPERATTACK + (int)((200F) * 100), false); + } entity.attackEntityFrom(DamageSource.causePlayerDamage(player), 200F * dmg); } } else { if (!world.isRemote) { + if (stack == null || !(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, References.ENERGYPERATTACK + (int)((100F) * 100), false); + } entity.attackEntityFrom(DamageSource.causePlayerDamage(player), 100F * dmg); } } @@ -167,13 +200,18 @@ public class ToolHandler { public static void AOEAttack(EntityPlayer player, Entity entity, ItemStack stack, int dmg, int range) { Map enchants = EnchantmentHelper.getEnchantments(stack); int sharp = 0; - int loot = 0; if (enchants.get(16) != null) sharp = (Integer) enchants.get(16); - if (enchants.get(21) != null) loot = (Integer) enchants.get(21); World world = player.worldObj; - AxisAlignedBB box = AxisAlignedBB.getAABBPool().getAABB(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range).expand(1.0D, 1.0D, 1.0D); + AxisAlignedBB box = AxisAlignedBB.getBoundingBox(entity.posX - range, entity.posY - range, entity.posZ - range, entity.posX + range, entity.posY + range, entity.posZ + range).expand(1.0D, 1.0D, 1.0D); List list = world.getEntitiesWithinAABBExcludingEntity(player, box); for (Object o : list) { + if (stack == null || !(stack.getItem() instanceof IEnergyContainerItem) || ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) < References.ENERGYPERBLOCK) { + if (!player.capabilities.isCreativeMode) + return; + } else { + if (!player.capabilities.isCreativeMode) + ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, References.ENERGYPERATTACK, false); + } if (((Entity) o) instanceof EntityLivingBase) ((Entity) o).attackEntityFrom(DamageSource.causePlayerDamage(player), dmg + sharp); @@ -191,7 +229,7 @@ public class ToolHandler { if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D; double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f; - Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2); + Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2); float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); float f5 = -MathHelper.cos(-f1 * 0.017453292F); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java index 6e077e05..fd2dc6eb 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernPickaxe.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -12,6 +14,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; @@ -22,14 +25,17 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class WyvernPickaxe extends ItemPickaxe { +public class WyvernPickaxe extends ItemPickaxe implements IEnergyContainerItem{ public IIcon itemIcon0; public IIcon itemIcon1; + protected int capacity = References.WYVERNCAPACITY; + protected int maxReceive = References.WYVERNTRANSFER; + protected int maxExtract = References.WYVERNTRANSFER; public WyvernPickaxe() { super(ModItems.DRACONIUM_T1); @@ -99,9 +105,10 @@ public class WyvernPickaxe extends ItemPickaxe { { int size = (ItemNBTHelper.getShort(stack, "size", (short)0) * 2) + 1; - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); - else { + ItemInfoHelper.energyDisplayInfo(stack, list); + } else { list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size); list.add(EnumChatFormatting.GREEN + "Shift Right-click to change mode"); list.add(""); @@ -120,5 +127,69 @@ public class WyvernPickaxe extends ItemPickaxe { { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernPickaxe), " C ", "CPC", " C ", 'C', ModItems.infusedCompound, 'P', Items.diamond_pickaxe); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK) + return super.getDigSpeed(stack, block, meta); + else + return 1F; + } } + diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java index 47245edc..c9313ad9 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/tools/WyvernShovel.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.tools; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; @@ -12,6 +14,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.world.World; @@ -22,14 +25,17 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class WyvernShovel extends ItemSpade { +public class WyvernShovel extends ItemSpade implements IEnergyContainerItem{ public IIcon itemIcon0; public IIcon itemIcon1; + protected int capacity = References.WYVERNCAPACITY; + protected int maxReceive = References.WYVERNTRANSFER; + protected int maxExtract = References.WYVERNTRANSFER; public WyvernShovel() { super(ModItems.DRACONIUM_T1); @@ -98,9 +104,10 @@ public class WyvernShovel extends ItemSpade { { int size = (ItemNBTHelper.getShort(stack, "size", (short)0) * 2) + 1; - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) + if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information"); - else { + ItemInfoHelper.energyDisplayInfo(stack, list); + } else { list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size); list.add(EnumChatFormatting.GREEN + "Shift Right-click to change mode"); list.add(""); @@ -119,4 +126,68 @@ public class WyvernShovel extends ItemSpade { { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernShovel), " C ", "CDC", " C ", 'C', ModItems.infusedCompound, 'D', Items.diamond_shovel); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } + + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + if ((stack.getItem() instanceof IEnergyContainerItem) && ((IEnergyContainerItem)stack.getItem()).getEnergyStored(stack) >= References.ENERGYPERBLOCK) + return super.getDigSpeed(stack, block, meta); + else + return 1F; + } } + diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java index 3112e618..b3f4a28e 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicBow.java @@ -17,20 +17,17 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowNockEvent; -import org.lwjgl.input.Keyboard; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; public class DraconicBow extends ItemBow { - public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" }; @SideOnly(Side.CLIENT) private IIcon[] iconArray; @@ -195,16 +192,11 @@ public class DraconicBow extends ItemBow public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { list.add(EnumChatFormatting.DARK_PURPLE + "" + StatCollector.translateToLocal("msg.bowmode" + ItemNBTHelper.getString(stack, "mode", "rapidfire") + ".txt")); - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) - { - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "Hold shift for info"); - } else - { - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "After being imbued with the heart of a dragon the bow pulses"); - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "with a great power and roars to be unleashed"); - list.add(""); - list.add(EnumChatFormatting.BLUE + "" + EnumChatFormatting.ITALIC + "Enchants are twice as effective on this bow"); - } + list.add(""); + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "After being imbued with the heart of a dragon the bow pulses"); + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "with a great power and roars to be unleashed"); + list.add(""); + list.add(EnumChatFormatting.BLUE + "" + EnumChatFormatting.ITALIC + "Enchants are twice as effective on this bow"); } public static void registerRecipe() diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java index a8b6bfc2..6a5c78f1 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/DraconicSword.java @@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.items.weapons; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import com.brandon3055.draconicevolution.common.core.utills.ItemInfoHelper; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -9,6 +11,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; @@ -19,7 +22,11 @@ import com.brandon3055.draconicevolution.common.items.tools.ToolHandler; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class DraconicSword extends ItemSword { +public class DraconicSword extends ItemSword implements IEnergyContainerItem{ + protected int capacity = References.DRACONICCAPACITY; + protected int maxReceive = References.DRACONICTRANSFER; + protected int maxExtract = References.DRACONICTRANSFER * 50; + public DraconicSword() { super(ModItems.DRACONIUM_T2); this.setUnlocalizedName(Strings.draconicSwordName); @@ -47,7 +54,7 @@ public class DraconicSword extends ItemSword { public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { list.add(EnumChatFormatting.DARK_RED + "Your enemy's strength will be their undoing"); - list.add(""); + ItemInfoHelper.energyDisplayInfo(stack, list); list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "Further Draconic research has allowed"); list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "you to unlock even better methods"); } @@ -62,4 +69,59 @@ public class DraconicSword extends ItemSword { { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicSword), "ISI", "DPD", "ITI", 'P', ModItems.wyvernSword, 'D', ModItems.draconicCompound, 'S', ModItems.sunFocus, 'T', ModItems.draconicCore, 'I', ModItems.draconiumIngot); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java index e713c4c1..55402f82 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernBow.java @@ -17,13 +17,11 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowNockEvent; -import org.lwjgl.input.Keyboard; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import com.brandon3055.draconicevolution.DraconicEvolution; -import com.brandon3055.draconicevolution.common.core.helper.ItemNBTHelper; +import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.common.items.ModItems; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; @@ -147,7 +145,6 @@ public class WyvernBow extends ItemBow { return this.itemIcon; } - //@Override @Override @SideOnly(Side.CLIENT) public IIcon getItemIconForUseDuration(int par1) @@ -162,14 +159,11 @@ public class WyvernBow extends ItemBow { public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation) { list.add(EnumChatFormatting.DARK_PURPLE + "" + StatCollector.translateToLocal("msg.bowmode" + ItemNBTHelper.getString(stack, "mode", "rapidfire") + ".txt")); - if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54))) { - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "Hold shift for info"); - } else { - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "You have learned how to use draconic power to upgrade"); - list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "your bow, what benefits does it have?"); - list.add(""); - list.add(EnumChatFormatting.BLUE + "" + EnumChatFormatting.ITALIC + "Enchants are twice as effective on this bow"); - } + list.add(""); + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "You have learned how to use draconic power to upgrade"); + list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "your bow, what benefits does it have?"); + list.add(""); + list.add(EnumChatFormatting.BLUE + "" + EnumChatFormatting.ITALIC + "Enchants are twice as effective on this bow"); } public static void registerRecipe() @@ -177,3 +171,4 @@ public class WyvernBow extends ItemBow { CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernBow), " I ", "CBC", " I ", 'C', ModItems.infusedCompound, 'B', Items.bow, 'I', ModItems.draconiumIngot); } } + diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java index b3d19800..590f1281 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/weapons/WyvernSword.java @@ -2,6 +2,7 @@ package com.brandon3055.draconicevolution.common.items.weapons; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -11,6 +12,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; @@ -21,7 +23,12 @@ import com.brandon3055.draconicevolution.common.items.tools.ToolHandler; import com.brandon3055.draconicevolution.common.lib.References; import com.brandon3055.draconicevolution.common.lib.Strings; -public class WyvernSword extends ItemSword { +public class WyvernSword extends ItemSword implements IEnergyContainerItem{ + + protected int capacity = References.WYVERNCAPACITY; + protected int maxReceive = References.WYVERNTRANSFER; + protected int maxExtract = References.WYVERNTRANSFER; + public WyvernSword() { super(ModItems.DRACONIUM_T1); this.setUnlocalizedName(Strings.wyvernSwordName); @@ -72,4 +79,60 @@ public class WyvernSword extends ItemSword { System.out.println(par3EntityLivingBase.isEntityAlive()); return super.hitEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase); } + + @Override + public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { + + if (container.stackTagCompound == null) { + container.stackTagCompound = new NBTTagCompound(); + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); + + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyReceived; + } + + @Override + public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { + + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + int energy = container.stackTagCompound.getInteger("EnergyHelper"); + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); + + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("EnergyHelper", energy); + } + return energyExtracted; + } + + @Override + public int getEnergyStored(ItemStack container) { + if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("EnergyHelper")) { + return 0; + } + return container.stackTagCompound.getInteger("EnergyHelper"); + } + + @Override + public int getMaxEnergyStored(ItemStack container) { + return capacity; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return !(getEnergyStored(stack) == getMaxEnergyStored(stack)); + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - ((double)getEnergyStored(stack) / (double)getMaxEnergyStored(stack)); + } } + diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java index 8c7cc2d0..eab0753b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java @@ -4,7 +4,17 @@ public class References { public static final String MODID = "DraconicEvolution"; public static final String MODNAME = "Draconic Evolution"; public static final String VERSION = "0.9.1-Beta"; + public static final String MCVERSION = "1.7.10"; public static final String CLIENTPROXYLOCATION = "com.brandon3055.draconicevolution.common.core.proxy.ClientProxy"; public static final String COMMONPROXYLOCATION = "com.brandon3055.draconicevolution.common.core.proxy.CommonProxy"; public static final String RESOURCESPREFIX = MODID.toLowerCase() + ":"; + + + //======================Tools & Weapons========================// + public static final int WYVERNCAPACITY = 1000000; + public static final int WYVERNTRANSFER = 1000; + public static final int DRACONICCAPACITY = 10000000; + public static final int DRACONICTRANSFER = 10000; + public static final int ENERGYPERBLOCK = 450; + public static final int ENERGYPERATTACK = 1000; } \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java index ab1f8174..5004814b 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/Strings.java @@ -10,12 +10,6 @@ public class Strings {// public sta public static final String draconicPickaxeName = "draconicPickaxe"; public static final String draconicSwordName = "draconicSword"; public static final String infusedCompoundName = "infusedCompound"; - public static final String rawDraconicPickHeadName = "rawDraconicPickHead"; - public static final String rawDraconicSwordBladeName = "rawDraconicSwordBlade"; - public static final String draconicSwordBladeName = "draconicSwordBlade"; - public static final String draconicPickHeadName = "draconicPickHead"; - public static final String draconiumOreEndName = "draconiumOreEnd"; - public static final String draconiumOreNetherName = "draconiumOreNether"; public static final String draconiumDustName = "draconiumDust"; public static final String draconiumIngotName = "draconiumIngot"; public static final String draconiumBlendName = "draconiumBlend"; @@ -26,10 +20,8 @@ public class Strings {// public sta public static final String draconicDStaffName = "draconicDistructionStaff"; public static final String draconicCompoundName = "draconicCompound"; public static final String wyvernSwordName = "wyvernSword"; - public static final String testFurnaceName = "testFurnace"; public static final String wyvernBowName = "wyvernBow"; public static final String draconicBowName = "draconicBow"; - public static final String wyvernChestPlateName = "wyvernChestPlate"; public static final String draconiumOreName = "draconiumOre"; public static final String teleporterMKIName = "teleporterMKI"; public static final String draconicHoeName = "draconicHoe"; @@ -42,4 +34,15 @@ public class Strings {// public sta public static final String particleGeneratorName = "particleGenerator"; public static final String playerDetectorName = "playerDetector"; public static final String playerDetectorAdvancedName = "playerDetectorAdvanced"; + public static final String energyInfuserName = "energyInfuser"; + public static final String draconicHelmName = "draconicHelm"; + public static final String draconicChestName = "draconicChest"; + public static final String draconicLeggsName = "draconicLeggs"; + public static final String draconicBootsName = "draconicBoots"; + public static final String wyvernHelmName = "wyvernHelm"; + public static final String wyvernChestName = "wyvernChest"; + public static final String wyvernLeggsName = "wyvernLeggs"; + public static final String wyvernBootsName = "wyvernBoots"; + public static final String customSpawnerName = "customSpawner"; + public static final String MobSoulName = "mobSoul"; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java new file mode 100644 index 00000000..1b8300cc --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/CustomSpawnerBaseLogic.java @@ -0,0 +1,265 @@ +package com.brandon3055.draconicevolution.common.tileentities; + +/** + * Created by Brandon on 5/07/2014. + */ + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.IEntityLivingData; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; + +public abstract class CustomSpawnerBaseLogic { + /** + * The delay to spawn. + */ + public int spawnDelay = 20; + /** + * The entity theis spawner will spawn. + */ + public String entityName = ""; + + public double renderRotation0; + public double renderRotation1; + private int minSpawnDelay = 400; + private int maxSpawnDelay = 600; + /** + * A counter for spawn tries. + */ + private int spawnCount = 4; + private Entity renderedEntity; + private int maxNearbyEntities = 20; + /** + * Is receiving a redstone signal + */ + public boolean powered = false; + /** + * Dose the spawner require a player nearby + */ + public boolean requiresPlayer = true; + /** + * Ignore Mob Spawn Requirements + */ + public boolean ignoreSpawnRequirements = false; + /** + * Spawn Speed + */ + public int spawnSpeed = 0; + /** + * The distance from which a player activates the spawner. + */ + private int activatingRangeFromPlayer = 24; + /** + * The range coefficient for spawning entities around. + */ + private int spawnRange = 4; + /** + * Gets the entity name that should be spawned. + */ + public String getEntityNameToSpawn() { + return this.entityName; + } + + public void setEntityName(String name) { + this.entityName = name; + } + + /** + * Returns true if there's a player close enough to this mob spawner to activate it. + */ + public boolean isActivated() { + if (!requiresPlayer) + return true; + else + return this.getSpawnerWorld().getClosestPlayer((double) this.getSpawnerX() + 0.5D, (double) this.getSpawnerY() + 0.5D, (double) this.getSpawnerZ() + 0.5D, (double) this.activatingRangeFromPlayer) != null; + } + + public void updateSpawner() { + if (isActivated() && !powered) { + double d2; + + if (this.getSpawnerWorld().isRemote) { + double d0 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat()); + double d1 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat()); + d2 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat()); + this.getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); + this.getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); + + if (this.spawnDelay > 0) { + --this.spawnDelay; + } + + this.renderRotation1 = this.renderRotation0; + this.renderRotation0 = (this.renderRotation0 + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; + } else { + if (this.spawnDelay == -1) { + this.resetTimer(); + } + + if (this.spawnDelay > 0) { + --this.spawnDelay; + return; + } + + boolean flag = false; + + for (int i = 0; i < this.spawnCount; ++i) { + Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld()); + + if (entity == null) { + return; + } + + int j = this.getSpawnerWorld().getEntitiesWithinAABB(entity.getClass(), AxisAlignedBB.getBoundingBox((double) this.getSpawnerX(), (double) this.getSpawnerY(), (double) this.getSpawnerZ(), (double) (this.getSpawnerX() + 1), (double) (this.getSpawnerY() + 1), (double) (this.getSpawnerZ() + 1)).expand((double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))).size(); + + if (j >= this.maxNearbyEntities) { + this.resetTimer(); + return; + } + + int x = this.getSpawnerX() + (int)((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); + int y = this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1; + int z = this.getSpawnerZ() + (int)((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); + EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; + entity.setLocationAndAngles(x + 0.5, y + 0.5, z + 0.5, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); + + if (entityliving == null || (entityliving.getCanSpawnHere() || ignoreSpawnRequirements && getSpawnerWorld().getBlock(x, y, z) == Blocks.air)) { + this.spawnEntity(entity); + this.getSpawnerWorld().playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0); + + if (entityliving != null) { + entityliving.spawnExplosionParticle(); + } + + flag = true; + + if (spawnCount > 4) spawnCount --; + }else if (spawnCount < 10){ + spawnCount ++; + } + } + + if (flag) { + this.resetTimer(); + } + } + } + } + + public Entity spawnEntity(Entity par1Entity) { + if (par1Entity instanceof EntityLivingBase && par1Entity.worldObj != null) { + + ((EntityLiving) par1Entity).onSpawnWithEgg((IEntityLivingData) null); + this.getSpawnerWorld().spawnEntityInWorld(par1Entity); + } + + return par1Entity; + } + + private void resetTimer() { + if (this.maxSpawnDelay <= this.minSpawnDelay) { + this.spawnDelay = this.minSpawnDelay; + } else { + int i = this.maxSpawnDelay - this.minSpawnDelay; + this.spawnDelay = this.minSpawnDelay + this.getSpawnerWorld().rand.nextInt(i); + } + + this.blockEvent(1); + } + + public void readFromNBT(NBTTagCompound par1NBTTagCompound) { + this.entityName = par1NBTTagCompound.getString("EntityId"); + this.spawnDelay = par1NBTTagCompound.getShort("Delay"); + powered = par1NBTTagCompound.getBoolean("Powered"); + spawnSpeed = par1NBTTagCompound.getShort("Speed"); + requiresPlayer = par1NBTTagCompound.getBoolean("RequiresPlayer"); + ignoreSpawnRequirements = par1NBTTagCompound.getBoolean("IgnoreSpawnRequirements"); + + if (par1NBTTagCompound.hasKey("MinSpawnDelay", 99)) { + this.minSpawnDelay = par1NBTTagCompound.getShort("MinSpawnDelay"); + this.maxSpawnDelay = par1NBTTagCompound.getShort("MaxSpawnDelay"); + this.spawnCount = par1NBTTagCompound.getShort("SpawnCount"); + } + + if (par1NBTTagCompound.hasKey("MaxNearbyEntities", 99)) { + this.maxNearbyEntities = par1NBTTagCompound.getShort("MaxNearbyEntities"); + this.activatingRangeFromPlayer = par1NBTTagCompound.getShort("RequiredPlayerRange"); + } + + if (par1NBTTagCompound.hasKey("SpawnRange", 99)) { + this.spawnRange = par1NBTTagCompound.getShort("SpawnRange"); + } + + if (this.getSpawnerWorld() != null && this.getSpawnerWorld().isRemote) { + this.renderedEntity = null; + } + } + + public void writeToNBT(NBTTagCompound par1NBTTagCompound) { + par1NBTTagCompound.setString("EntityId", getEntityNameToSpawn()); + par1NBTTagCompound.setShort("Delay", (short) spawnDelay); + par1NBTTagCompound.setShort("MinSpawnDelay", (short) minSpawnDelay); + par1NBTTagCompound.setShort("MaxSpawnDelay", (short) maxSpawnDelay); + par1NBTTagCompound.setShort("SpawnCount", (short) spawnCount); + par1NBTTagCompound.setShort("MaxNearbyEntities", (short) maxNearbyEntities); + par1NBTTagCompound.setShort("RequiredPlayerRange", (short) activatingRangeFromPlayer); + par1NBTTagCompound.setShort("SpawnRange", (short) spawnRange); + par1NBTTagCompound.setBoolean("Powered", powered); + par1NBTTagCompound.setShort("Speed", (short) spawnSpeed); + par1NBTTagCompound.setBoolean("RequiresPlayer", requiresPlayer); + par1NBTTagCompound.setBoolean("IgnoreSpawnRequirements", ignoreSpawnRequirements); + } + + /** + * Sets the delay to minDelay if parameter given is 1, else return false. + */ + public boolean setDelayToMin(int par1) { + if (par1 == 1 && this.getSpawnerWorld().isRemote) { + this.spawnDelay = this.minSpawnDelay; + return true; + } else { + return false; + } + } + + @SideOnly(Side.CLIENT) + public Entity getEntityForRenderer() { + if (this.renderedEntity == null) { + Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), (World) null); + entity = this.spawnEntity(entity); + this.renderedEntity = entity; + } + + return this.renderedEntity; + } + + public abstract void blockEvent(int var1); + + public abstract World getSpawnerWorld(); + + public abstract int getSpawnerX(); + + public abstract int getSpawnerY(); + + public abstract int getSpawnerZ(); + + public void setSpawnRate(int i){ + spawnSpeed = i; + minSpawnDelay = 400 - (i * 150); + maxSpawnDelay = 600 - (i * 200); + if (i == 3){ + minSpawnDelay = 40; + maxSpawnDelay = 40; + } + if (minSpawnDelay < 0) minSpawnDelay = 0; + if (maxSpawnDelay < 1) maxSpawnDelay = 1; + resetTimer(); + } +} \ No newline at end of file diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java new file mode 100644 index 00000000..7450ce92 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileCustomSpawner.java @@ -0,0 +1,170 @@ +package com.brandon3055.draconicevolution.common.tileentities; + +import com.brandon3055.draconicevolution.client.render.EnergyParticle; +import com.brandon3055.draconicevolution.common.core.handler.ParticleHandler; +import com.brandon3055.draconicevolution.common.core.utills.LogHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; +import sun.rmi.runtime.Log; + +import java.util.Iterator; +import java.util.List; + +public class TileCustomSpawner extends TileEntity +{ + public boolean isSetToSpawn = false; + public boolean trySet = false; + public EntityPlayer owner; + private EntityLivingBase target; + private int setTick = 0; + boolean foundTarget = false; + + private final CustomSpawnerBaseLogic spawnerBaseLogic = new CustomSpawnerBaseLogic(){ + public void blockEvent(int par1) + { + worldObj.addBlockEvent(xCoord, yCoord, zCoord, Blocks.mob_spawner, par1, 0); + } + public World getSpawnerWorld() + { + return worldObj; + } + public int getSpawnerX() + { + return xCoord; + } + public int getSpawnerY() + { + return yCoord; + } + public int getSpawnerZ() + { + return zCoord; + } + }; + + public void updateEntity(){ + if (isSetToSpawn) { + spawnerBaseLogic.updateSpawner(); + } + /* + else if (trySet && owner != null){ + + if (worldObj.isRemote) spawnParticles(false); + + if (!foundTarget && setTick > 70 && target == null && setTick % 10 == 0) + { + foundTarget = findTargetEntity(); + setTick = 71; + } + + if (foundTarget) + { + target.setHealth(10); + if (setTick < 150) { + target.setPosition(xCoord + 0.5, yCoord, zCoord + 0.5); + } else { + target.setPosition(xCoord + 0.5, yCoord - 0.5, zCoord + 0.5); + } + spawnParticles(true); + if (setTick > 151){ + spawnerBaseLogic.entityName = target.getCommandSenderName(); + target.setDead(); + setTick = 0; + trySet = false; + isSetToSpawn = true; + } + + + } + + setTick++; + if (setTick > 200){ + setTick = 0; + trySet = false; + } + } else { + trySet = false; + } + */ + } + + public void writeToNBT(NBTTagCompound tagCompound){ + super.writeToNBT(tagCompound); + spawnerBaseLogic.writeToNBT(tagCompound); + tagCompound.setBoolean("Running", isSetToSpawn); + } + + public void readFromNBT(NBTTagCompound tagCompound){ + super.readFromNBT(tagCompound); + spawnerBaseLogic.readFromNBT(tagCompound); + isSetToSpawn = tagCompound.getBoolean("Running"); + } + + public Packet getDescriptionPacket(){ + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + + public CustomSpawnerBaseLogic getBaseLogic() + { + return spawnerBaseLogic; + } + + private boolean findTargetEntity(){ + List candidates = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord+0.5 - 2.5, yCoord+0.5 - 1, zCoord+0.5 - 2.5, xCoord+0.5 + 2.5, yCoord+0.5 + 2, zCoord+0.5 + 2.5)); + + if (candidates.isEmpty()) + return false; + + Iterator i = candidates.iterator(); + while(i.hasNext()) + { + EntityLivingBase ent = i.next(); + if (!(ent instanceof EntityPlayer)) + { + target = ent; + LogHelper.info(target); + return true; + } + } + return false; + } + + @SideOnly(Side.CLIENT) + private void spawnParticles(boolean flag){ + if (!flag) { + for (int i = 0; i < 5; i++) { + float rotation = worldObj.rand.nextFloat() * 6.5F; + double x = (double) xCoord + 0.5 + (Math.sin(rotation) * 3); + double y = (double) yCoord - 1 + worldObj.rand.nextInt(4); + double z = (double) zCoord + 0.5 + (Math.cos(rotation) * 3); + EnergyParticle particle = new EnergyParticle(worldObj, x, y, z, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0, false); + ParticleHandler.spawnCustomParticle(particle, 20); + } + }else + { + double x = (double) xCoord + (worldObj.rand.nextDouble()); + double y = (double) yCoord + (double)target.getEyeHeight() + worldObj.rand.nextDouble(); + double z = (double) zCoord + (worldObj.rand.nextDouble()); + EnergyParticle particle = new EnergyParticle(worldObj, x, y, z, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle, 20); + } + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java new file mode 100644 index 00000000..4aab4ccf --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileEnergyInfuser.java @@ -0,0 +1,334 @@ +package com.brandon3055.draconicevolution.common.tileentities; + +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyContainerItem; +import cofh.api.energy.IEnergyHandler; +import com.brandon3055.draconicevolution.client.render.EnergyParticle; +import com.brandon3055.draconicevolution.common.core.handler.ParticleHandler; +import com.brandon3055.draconicevolution.common.core.utills.EnergyHelper; +import com.brandon3055.draconicevolution.common.core.utills.InventoryHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.Random; + +import static net.minecraftforge.common.util.ForgeDirection.UP; + +/** + * Created by Brandon on 27/06/2014. + */ +public class TileEnergyInfuser extends TileEntity implements IEnergyHandler, ISidedInventory { + ItemStack[] items = new ItemStack[1]; + public EnergyStorage energy = new EnergyStorage(1000000); + public int maxInput = 81920; + public boolean running = false; + private int tick = 0; + private int longTick = 0; + public float rotation = 0; + public boolean transfer = false; + + //==============================================LOGIC=======================================================// + + @Override + public void updateEntity() { + tick(); + if (worldObj.isRemote) + spawnParticles(); + if (worldObj.isRemote) + return; + if(running && tryStartOrStop()) + { + IEnergyContainerItem item = (IEnergyContainerItem)items[0].getItem(); + if (energy.extractEnergy(item.receiveEnergy(items[0], energy.getEnergyStored(), false), false) > 0 && !transfer) + setTransfer(true); + else if (energy.extractEnergy(item.receiveEnergy(items[0], energy.getEnergyStored(), false), false) <= 0 && transfer) + setTransfer(false); + } + } + + private boolean tryStartOrStop(){ + if (items[0] != null && items[0].stackSize == 1 && EnergyHelper.isEnergyContainerItem(items[0])) { + IEnergyContainerItem item = (IEnergyContainerItem)items[0].getItem(); + if (item.getEnergyStored(items[0]) < item.getMaxEnergyStored(items[0])) + running = true; + else{ + if (running) worldObj.markBlockForUpdate(xCoord, yCoord ,zCoord); + running = false; + } + }else { + if (running) worldObj.markBlockForUpdate(xCoord, yCoord ,zCoord); + running = false; + } + + return running; + } + + private void tick() + { + if (tick >= 20) { + tick = 0; + if (running) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + else + tick++; + if (longTick >= 100) { + longTick = 0; + tryStartOrStop(); + }else + longTick++; + if(rotation >= 360F) + rotation = 0F; + else if (running) + rotation += 0.5F; + + } + + private void setTransfer(boolean t){ + transfer = t; + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + @SideOnly(Side.CLIENT) + private void spawnParticles(){ + if (worldObj.isRemote && running && transfer) { + Random rand = worldObj.rand; + double rotationF; + double yRand; + double radRand; + EnergyParticle particle; + float y = 0.6f; + + yRand = ((rand.nextFloat()-0.5)/2); + radRand = 1 - rand.nextFloat()/2; + rotationF = rotation / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); + + yRand = ((rand.nextFloat()-0.5)/2); + radRand = 1 - rand.nextFloat()/2; + rotationF = (rotation + 90) / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); + + yRand = ((rand.nextFloat()-0.5)/2); + radRand = 1 - rand.nextFloat()/2; + rotationF = (rotation + 180) / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); + + yRand = ((rand.nextFloat()-0.5)/2); + radRand = 1 - rand.nextFloat()/2; + rotationF = (rotation + 270) / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y + yRand, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 1); + ParticleHandler.spawnCustomParticle(particle); + + y = 0.79f; + radRand = 0.35; + rotationF = rotation / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); + + rotationF = (rotation + 90) / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); + + rotationF = (rotation + 180) / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); + + rotationF = (rotation + 270) / 57F; + particle = new EnergyParticle(worldObj, xCoord + 0.5 + radRand*Math.sin(rotationF), yCoord + y, zCoord + 0.5 + radRand*Math.cos(rotationF), xCoord + 0.5, yCoord + 0.7, zCoord + 0.5, 0); + ParticleHandler.spawnCustomParticle(particle); + } + } + //==============================================ENERGY======================================================// + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (tick == 0) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + return this.energy.receiveEnergy(Math.min(maxInput, maxReceive), simulate); + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {; + return this.energy.extractEnergy(maxExtract, simulate); + } + + @Override + public int getEnergyStored(ForgeDirection from) { + return energy.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return energy.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } + + //==========================================SYNCHRONIZATION==================================================// + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + this.writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + + //==============================================INVENTORY====================================================// + + @Override + public int getSizeInventory() { + return items.length; + } + + @Override + public ItemStack getStackInSlot(int i) { + return items[i]; + } + + @Override + public ItemStack decrStackSize(int i, int count) { + ItemStack itemstack = getStackInSlot(i); + + if (itemstack != null) { + if (itemstack.stackSize <= count) { + setInventorySlotContents(i, null); + } else { + itemstack = itemstack.splitStack(count); + if (itemstack.stackSize == 0) { + setInventorySlotContents(i, null); + } + } + } + return itemstack; + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + ItemStack item = getStackInSlot(i); + if (item != null) setInventorySlotContents(i, null); + return item; + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + items[i] = itemstack; + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + tryStartOrStop(); + } + + @Override + public String getInventoryName() { + return "InventoryWeatherController"; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer player) { + return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; + } + + @Override + public void openInventory() {System.out.println("open");} + + @Override + public void closeInventory() {System.out.println("close");} + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return EnergyHelper.isEnergyContainerItem(itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(int var1) { + return new int[] {0}; + } + + @Override + public boolean canInsertItem(int slot, ItemStack item, int side) { + return true; + } + + @Override + public boolean canExtractItem(int slot, ItemStack item, int side) { + if (item != null && item.getItem() instanceof IEnergyContainerItem && (((IEnergyContainerItem)item.getItem()).getEnergyStored(item) >= ((IEnergyContainerItem)item.getItem()).getMaxEnergyStored(item))) + return true; + else + return false; + } + + //===========================================================================================================// + + @Override + public void writeToNBT(NBTTagCompound compound) + { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; + + for (int i = 0; i < items.length; i++) + { + tag[i] = new NBTTagCompound(); + + if (items[i] != null) + { + tag[i] = items[i].writeToNBT(tag[i]); + } + + compound.setTag("Item" + i, tag[i]); + } + compound.setBoolean("Running", running); + compound.setBoolean("Transfer", transfer); + energy.writeToNBT(compound); + + super.writeToNBT(compound); + } + + @Override + public void readFromNBT(NBTTagCompound compound) + { + NBTTagCompound[] tag = new NBTTagCompound[items.length]; + + for (int i = 0; i < items.length; i++) + { + tag[i] = compound.getCompoundTag("Item" + i); + items[i] = ItemStack.loadItemStackFromNBT(tag[i]); + } + running = compound.getBoolean("Running"); + transfer = compound.getBoolean("Transfer"); + energy.readFromNBT(compound); + + super.readFromNBT(compound); + } +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java index 2986c5ca..0d776a50 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileGrinder.java @@ -28,8 +28,7 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; import cpw.mods.fml.common.registry.GameRegistry; -public class TileGrinder extends TileEntity implements ISidedInventory -{ +public class TileGrinder extends TileEntity implements ISidedInventory { //########### variables #############// public int meta = -1; List killList; @@ -43,144 +42,119 @@ public class TileGrinder extends TileEntity implements ISidedInventory public int energy = 0; public int burnTime = 1; public int burnTimeRemaining = 0; - public boolean disabled = false; + public boolean disabled = false; private boolean readyNext = false; - - public void updateVariables() - { + + public void updateVariables() { if (meta == -1) meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); - - if (centreY == -1) - { - switch (meta){ - case 0: - centreX = xCoord + 0.5; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5 - 4; - break; - case 1: - centreX = xCoord + 0.5 + 4; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5; - break; - case 2: - centreX = xCoord + 0.5; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5 + 4; - break; - case 3: - centreX = xCoord + 0.5 - 4; - centreY = yCoord + 0.5; - centreZ = zCoord + 0.5; - break; + + if (centreY == -1) { + switch (meta) { + case 0: + centreX = xCoord + 0.5; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5 - 4; + break; + case 1: + centreX = xCoord + 0.5 + 4; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5; + break; + case 2: + centreX = xCoord + 0.5; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5 + 4; + break; + case 3: + centreX = xCoord + 0.5 - 4; + centreY = yCoord + 0.5; + centreZ = zCoord + 0.5; + break; } } - - if (burnTimeRemaining > 0) - { - burnTimeRemaining-=2; + + if (burnTimeRemaining > 0) { + burnTimeRemaining -= 2; energy += 2; if (burnTimeRemaining < 0) burnTimeRemaining = 0; } if (energy > 5000) energy = 5000; } //##################################// - - public TileGrinder() - { + + public TileGrinder() { items = new ItemStack[1]; } - + @Override - public void updateEntity() - { - if ((burnTimeRemaining == 1 || (burnTimeRemaining == 0 && updateTick == 20)) && !disabled && energy < 2500) - { + public void updateEntity() { + if ((burnTimeRemaining == 1 || (burnTimeRemaining == 0 && updateTick == 20)) && !disabled && energy < 2500) { updateVariables(); tryRefuel(); - }else - updateVariables(); - - if (!worldObj.isRemote && updateTick >= 50 && readyNext && !disabled && energy >= 100) - { - if (killNextEntity()) - { + } else updateVariables(); + + if (!worldObj.isRemote && updateTick >= 50 && readyNext && !disabled && energy >= 100) { + if (killNextEntity()) { energy -= 100; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } } - - if (updateTick >= 50) - { - updateTick = 0; - } - if (!disabled)updateTick+=worldObj.rand.nextInt(10); - - if (tick >= 100) - { - tick = 0; - checkSignal(); - readyNext = true; - if (burnTimeRemaining > 0) - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - }else - tick++; + + if (updateTick >= 50) { + updateTick = 0; + } + if (!disabled) updateTick += worldObj.rand.nextInt(10); + + if (tick >= 100) { + tick = 0; + checkSignal(); + readyNext = true; + if (burnTimeRemaining > 0) worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } else tick++; } - - public void checkSignal() - { + + public void checkSignal() { disabled = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); } - - private void tryRefuel() - { - if (items[0] != null && items[0].stackSize > 0) - { + + private void tryRefuel() { + if (items[0] != null && items[0].stackSize > 0) { int itemBurnTime = getItemBurnTime(items[0]); - - if (itemBurnTime > 0) - { + + if (itemBurnTime > 0) { decrStackSize(0, 1); burnTime = itemBurnTime; burnTimeRemaining = itemBurnTime; } } } - + @SuppressWarnings("unchecked") - public boolean killNextEntity() - { - killBox = AxisAlignedBB.getAABBPool().getAABB(centreX - 3.5, centreY - 1, centreZ - 3.5, centreX + 3.5, centreY + 3, centreZ + 3.5); + public boolean killNextEntity() { + killBox = AxisAlignedBB.getBoundingBox(centreX - 3.5, centreY - 1, centreZ - 3.5, centreX + 3.5, centreY + 3, centreZ + 3.5); killList = worldObj.getEntitiesWithinAABB(EntityLiving.class, killBox); - - if (killList.size() > 0) - { + + if (killList.size() > 0) { EntityLiving mob = killList.get(worldObj.rand.nextInt(killList.size())); - if (mob instanceof EntityCreature) - { - if (((EntityCreature)mob).isEntityAlive()) - { - ((EntityCreature)mob).attackEntityFrom(DamageSource.magic, 50000F); + if (mob instanceof EntityCreature) { + if (((EntityCreature) mob).isEntityAlive()) { + ((EntityCreature) mob).attackEntityFrom(DamageSource.magic, 50000F); dropXP(mob); readyNext = true; - if (mob instanceof EntitySkeleton) - { - if (((EntitySkeleton)mob).getSkeletonType() == 1) - { + if (mob instanceof EntitySkeleton) { + if (((EntitySkeleton) mob).getSkeletonType() == 1) { int random = worldObj.rand.nextInt(100); - if(random == 55) - ((EntityCreature)mob).entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F); + if (random == 55) + ((EntityCreature) mob).entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F); } } return true; } readyNext = true; return false; - }else if (mob instanceof EntityLiving) - { - if (((EntityLiving)mob).isEntityAlive()) - { - ((EntityLiving)mob).attackEntityFrom(DamageSource.magic, 50000F); + } else if (mob instanceof EntityLiving) { + if (((EntityLiving) mob).isEntityAlive()) { + ((EntityLiving) mob).attackEntityFrom(DamageSource.magic, 50000F); dropXP(mob); readyNext = true; return true; @@ -190,87 +164,70 @@ public class TileGrinder extends TileEntity implements ISidedInventory } } readyNext = false; - return false; + return false; } - - public void dropXP(Entity mob) - { + + public void dropXP(Entity mob) { int count = 1 + worldObj.rand.nextInt(3); - for (int i = 0; i < count; i++) - { - worldObj.spawnEntityInWorld(new EntityXPOrb(worldObj, mob.lastTickPosX, mob.lastTickPosY, mob.lastTickPosZ, 1)); + for (int i = 0; i < count; i++) { + worldObj.spawnEntityInWorld(new EntityXPOrb(worldObj, mob.lastTickPosX, mob.lastTickPosY, mob.lastTickPosZ, 1)); } } - - public static int getItemBurnTime(ItemStack stack) - { - if (stack == null) - { - return 0; - } - else - { - Item item = stack.getItem(); - if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) - { - Block block = Block.getBlockFromItem(item); + public static int getItemBurnTime(ItemStack stack) { + if (stack == null) { + return 0; + } else { + Item item = stack.getItem(); - if (block == Blocks.wooden_slab) - { - return 150; - } + if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { + Block block = Block.getBlockFromItem(item); - if (block.getMaterial() == Material.wood) - { - return 300; - } + if (block == Blocks.wooden_slab) { + return 150; + } - if (block == Blocks.coal_block) - { - return 16000; - } - } + if (block.getMaterial() == Material.wood) { + return 300; + } - if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200; - if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200; - if (item == Items.stick) return 100; - if (item == Items.coal) return 1600; - if (item == Items.lava_bucket) return 20000; - if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; - if (item == Items.blaze_rod) return 2400; - return GameRegistry.getFuelValue(stack); - } - } + if (block == Blocks.coal_block) { + return 16000; + } + } + + if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD")) return 200; + if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD")) return 200; + if (item == Items.stick) return 100; + if (item == Items.coal) return 1600; + if (item == Items.lava_bucket) return 20000; + if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; + if (item == Items.blaze_rod) return 2400; + return GameRegistry.getFuelValue(stack); + } + } @Override - public int getSizeInventory() - { + public int getSizeInventory() { return items.length; } @Override - public ItemStack getStackInSlot(int i) - { + public ItemStack getStackInSlot(int i) { return items[i]; } @Override - public ItemStack decrStackSize(int i, int count) - { + public ItemStack decrStackSize(int i, int count) { ItemStack itemstack = getStackInSlot(i); - if (itemstack != null) - { - if (itemstack.stackSize <= count) - { + if (itemstack != null) { + if (itemstack.stackSize <= count) { setInventorySlotContents(i, null); - } else - { + } else { itemstack = itemstack.splitStack(count); - if (itemstack.stackSize == 0) - { + if (itemstack.stackSize == 0) { setInventorySlotContents(i, null); } } @@ -279,100 +236,83 @@ public class TileGrinder extends TileEntity implements ISidedInventory } @Override - public ItemStack getStackInSlotOnClosing(int i) - { + public ItemStack getStackInSlotOnClosing(int i) { ItemStack item = getStackInSlot(i); - if (item != null) - setInventorySlotContents(i, null); + if (item != null) setInventorySlotContents(i, null); return item; } @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { + public void setInventorySlotContents(int i, ItemStack itemstack) { items[i] = itemstack; - if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } @Override - public String getInventoryName() - { + public String getInventoryName() { return ""; } @Override - public boolean hasCustomInventoryName() - { + public boolean hasCustomInventoryName() { return false; } @Override - public int getInventoryStackLimit() - { + public int getInventoryStackLimit() { return 64; } @Override - public boolean isUseableByPlayer(EntityPlayer player) - { + public boolean isUseableByPlayer(EntityPlayer player) { return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64; } @Override - public void openInventory() - { + public void openInventory() { } @Override - public void closeInventory() - { + public void closeInventory() { } @Override - public boolean isItemValidForSlot(int i, ItemStack stack) - { + public boolean isItemValidForSlot(int i, ItemStack stack) { return getItemBurnTime(stack) > 0; } @Override - public int[] getAccessibleSlotsFromSide(int var1) - { + public int[] getAccessibleSlotsFromSide(int var1) { return new int[1]; } @Override - public boolean canInsertItem(int var1, ItemStack var2, int var3) - { + public boolean canInsertItem(int var1, ItemStack var2, int var3) { return true; } @Override - public boolean canExtractItem(int var1, ItemStack var2, int var3) - { + public boolean canExtractItem(int var1, ItemStack var2, int var3) { return false; } @Override - public void writeToNBT(NBTTagCompound compound) - { + public void writeToNBT(NBTTagCompound compound) { NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { + for (int i = 0; i < items.length; i++) { tag[i] = new NBTTagCompound(); - if (items[i] != null) - { + if (items[i] != null) { tag[i] = items[i].writeToNBT(tag[i]); } compound.setTag("Item" + i, tag[i]); } - compound.setInteger("Energy", energy); + compound.setInteger("EnergyHelper", energy); compound.setBoolean("Disabled", disabled); compound.setInteger("BurnTime", burnTime); compound.setInteger("BurnTimeRemaining", burnTimeRemaining); @@ -381,35 +321,31 @@ public class TileGrinder extends TileEntity implements ISidedInventory } @Override - public void readFromNBT(NBTTagCompound compound) - { + public void readFromNBT(NBTTagCompound compound) { NBTTagCompound[] tag = new NBTTagCompound[items.length]; - for (int i = 0; i < items.length; i++) - { + for (int i = 0; i < items.length; i++) { tag[i] = compound.getCompoundTag("Item" + i); items[i] = ItemStack.loadItemStackFromNBT(tag[i]); } - energy = compound.getInteger("Energy"); + energy = compound.getInteger("EnergyHelper"); disabled = compound.getBoolean("Disabled"); burnTime = compound.getInteger("BurnTime"); burnTimeRemaining = compound.getInteger("BurnTimeRemaining"); super.readFromNBT(compound); } - + @Override - public Packet getDescriptionPacket() - { + public Packet getDescriptionPacket() { NBTTagCompound tagCompound = new NBTTagCompound(); - this.writeToNBT(tagCompound); + writeToNBT(tagCompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tagCompound); } @Override - public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) - { + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java new file mode 100644 index 00000000..22e6a715 --- /dev/null +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/TileTestBlock.java @@ -0,0 +1,68 @@ +package com.brandon3055.draconicevolution.common.tileentities; + +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; +import cofh.api.energy.EnergyStorage; +import cofh.api.energy.IEnergyHandler; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Created by Brandon on 24/06/2014. + */ +public class TileTestBlock extends TileEntity implements IEnergyHandler { + public EnergyStorage energy = new EnergyStorage(100000000); + public int maxInput = 100000000; + + @Override + public void updateEntity() { + int test = 4; + if (!worldObj.isRemote) + System.out.println(energy.getEnergyStored()); + + if ((this.energy.getEnergyStored() > 0)) { + + TileEntity tile = worldObj.getTileEntity(xCoord + UP.offsetX, yCoord + UP.offsetY, zCoord + UP.offsetZ); + + if ((tile instanceof IEnergyHandler)) { + this.energy.extractEnergy(((IEnergyHandler)tile).receiveEnergy(UP.getOpposite(), this.energy.extractEnergy(maxInput, true), false), false); + } + } + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if(from != UP) + return this.energy.receiveEnergy(Math.min(maxInput, maxReceive), simulate); + else + return 0; + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {; + if (from == UP) + return this.energy.extractEnergy(maxExtract, simulate); + else + return 0; + } + + @Override + public int getEnergyStored(ForgeDirection from) { + return energy.getEnergyStored(); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return energy.getMaxEnergyStored(); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } + +} diff --git a/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java index b4cbcb04..92a8dcff 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/world/DraconicWorldGenerator.java @@ -24,7 +24,7 @@ public class DraconicWorldGenerator implements IWorldGenerator { generateNether(random, chunkX * 16, chunkZ * 16, world); break; default: - ; + break; } } diff --git a/src/main/resources/assets/draconicevolution/lang/en_US.lang b/src/main/resources/assets/draconicevolution/lang/en_US.lang index 252a61f4..b648401c 100644 --- a/src/main/resources/assets/draconicevolution/lang/en_US.lang +++ b/src/main/resources/assets/draconicevolution/lang/en_US.lang @@ -16,6 +16,8 @@ tile.rainSensor.name=Rain Sensor tile.particleGenerator.name=Particle Generator tile.playerDetector.name=Player Detector tile.playerDetectorAdvanced.name=Advanced Player Detector +tile.energyInfuser.name=Energy Infuser +Tile.customSpawner.name=Stabilized Monster Spawner msg.range.txt=Range: @@ -75,46 +77,60 @@ info.teleporterInfSet2.txt=Uses remaining //###################################Wyvern###################################// + item.wyvernPickaxe.name=Pickaxe of the Wyvern - - item.wyvernShovel.name=Shovel of the Wyvern - - item.wyvernSword.name=Sword of the Wyvern - - item.wyvernBow.name=Bow of the Wyvern - +item.wyvernHelm.name=Wyvern Helm +item.wyvernChest.name=Wyvern Chestplate +item.wyvernLeggs.name=Wyvern Leggings +item.wyvernBoots.name=Wyvern Boots info.wyvernLaw1.txt=Weary of plain tools you begin to understand info.wyvernLaw2.txt=ways to use Draconic energy to upgrade +info.wyvernArmorLegend1.txt=Mundane armor was too weak +info.wyvernArmorLegend2.txt=you use Draconic knowledge to improve it + //###################################Draconic###################################// item.draconicPickaxe.name=Draconic Pickaxe - - item.draconicAxe.name=Draconic Axe - - item.draconicShovel.name=Draconic Shovel - - item.draconicHoe.name=Draconic Hoe - - item.draconicSword.name=Draconic Sword - - item.draconicBow.name=Draconic Bow - - +item.draconicHelm.name=Draconic Helm +item.draconicChest.name=Draconic Chestplate +item.draconicLeggs.name=Draconic Leggings +item.draconicBoots.name=Draconic Boots item.draconicDistructionStaff.name=Draconic Staff of Power - +item.mobSoul.name=Mob Soul info.draconicLaw1.txt=Further Draconic research has allowed info.draconicLaw2.txt=you to unlock even better methods - info.draconicAxe1.txt=Timber!!!!!! info.draconicAxe2.txt=Will fall an entire tree info.draconicAxe3.txt=or break out a 5x5x5 chunk of anything wood. -info.draconicAxe4.txt=Hold shift to mine a single block. \ No newline at end of file +info.draconicAxe4.txt=Hold shift to mine a single block. +info.draconicArmorLegend1.txt=Using forgotten knowledge +info.draconicArmorLegend2.txt=you have created the ultimate armor +info.draconicArmorInfoBoots.txt=Leap high into the air!!! +info.draconicArmorInfoBoots1.txt=and fall like a feather +info.draconicArmorInfoLeggs.txt=Run like the wind!!! +info.draconicArmorInfoChest.txt=Take to the sky!!! +info.draconicArmorInfoChest1.txt=and with the set complete +info.draconicArmorInfoChest2.txt=walk through fire and fear +info.draconicArmorInfoChest3.txt=not the dark magic magic!!! +info.draconicArmorInfoHelm.txt=See through the darkness what lies beyond +info.draconicCore.txt=Can be used to stabilize mob spawners + +msg.spawnerInfo1.txt=Mob Type +msg.spawnerInfo2.txt=Requires Player +msg.spawnerInfo3.txt=Ignore Spawn Requirements +msg.spawnerInfo4.txt=Spawner Tier +msg.spawnerInfo5.txt=Shift Right click for upgrade info +msg.spawnerInfo6.txt=Requires players : Nether Star +msg.spawnerInfo7.txt=Ignore Spawn Requirements : Notch Apple +msg.spawnerInfo8.txt=Tier 1 : Infused Compound +msg.spawnerInfo9.txt=Tier 2 : Draconic Compound +msg.spawnerInfo10.txt=Tier 3 : ???... \ No newline at end of file diff --git a/src/main/resources/assets/draconicevolution/textures/diamond_layer_1.png b/src/main/resources/assets/draconicevolution/textures/diamond_layer_1.png deleted file mode 100644 index 14fecf21..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/diamond_layer_1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/diamond_layer_2.png b/src/main/resources/assets/draconicevolution/textures/diamond_layer_2.png deleted file mode 100644 index 2cca0566..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/diamond_layer_2.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/gui/EnergyInfuser.png b/src/main/resources/assets/draconicevolution/textures/gui/EnergyInfuser.png new file mode 100644 index 00000000..6f8ce60b Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/gui/EnergyInfuser.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/ichor1.png b/src/main/resources/assets/draconicevolution/textures/ichor1.png deleted file mode 100644 index 9f75dee0..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/ichor1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/ichor2.png b/src/main/resources/assets/draconicevolution/textures/ichor2.png deleted file mode 100644 index 6f81719e..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/ichor2.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/ichorGem2.png b/src/main/resources/assets/draconicevolution/textures/ichorGem2.png deleted file mode 100644 index d4248675..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/ichorGem2.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/ichorclothChest.png b/src/main/resources/assets/draconicevolution/textures/ichorclothChest.png deleted file mode 100644 index e1c43f65..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/ichorclothChest.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/ichorclothChestGem.png b/src/main/resources/assets/draconicevolution/textures/ichorclothChestGem.png deleted file mode 100644 index d3563c4f..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/ichorclothChestGem.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_0.png b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_0.png index f6000884..28c81ea0 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_0.png and b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_0.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_1.png b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_1.png index fb9f70c9..28c81ea0 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_1.png and b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_1.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_2.png b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_2.png index 041bcd40..24b4eafe 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_2.png and b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_pulling_2.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_standby.png b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_standby.png index b6815e51..7687f21a 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/draconicBow_standby.png and b/src/main/resources/assets/draconicevolution/textures/items/draconicBow_standby.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconic_boots.png b/src/main/resources/assets/draconicevolution/textures/items/draconic_boots.png new file mode 100644 index 00000000..6f0438f1 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/draconic_boots.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconic_chestplate.png b/src/main/resources/assets/draconicevolution/textures/items/draconic_chestplate.png new file mode 100644 index 00000000..c7ee4722 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/draconic_chestplate.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconic_helmet.png b/src/main/resources/assets/draconicevolution/textures/items/draconic_helmet.png new file mode 100644 index 00000000..ecfe4279 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/draconic_helmet.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/draconic_leggings.png b/src/main/resources/assets/draconicevolution/textures/items/draconic_leggings.png new file mode 100644 index 00000000..f9c6a4cd Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/draconic_leggings.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff0.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff0.png deleted file mode 100644 index 76801e58..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff0.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff1.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff1.png deleted file mode 100644 index 5d585b2b..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff2.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff2.png deleted file mode 100644 index b64dbe6d..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicDStaff2.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe0.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe0.png deleted file mode 100644 index 9bb690e2..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe0.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe1.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe1.png deleted file mode 100644 index 1c13a28c..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe2.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe2.png deleted file mode 100644 index 6492e656..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicPickaxe2.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel0.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel0.png deleted file mode 100644 index a743d228..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel0.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel1.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel1.png deleted file mode 100644 index 6a5218c0..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel2.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel2.png deleted file mode 100644 index 46584ced..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicShovel2.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/draconicSword.png b/src/main/resources/assets/draconicevolution/textures/items/old/draconicSword.png deleted file mode 100644 index 20cfaaa4..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/draconicSword.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernPickaxe0.png b/src/main/resources/assets/draconicevolution/textures/items/old/wyvernPickaxe0.png deleted file mode 100644 index 6591f589..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernPickaxe0.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernPickaxe1.png b/src/main/resources/assets/draconicevolution/textures/items/old/wyvernPickaxe1.png deleted file mode 100644 index 74e5fd13..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernPickaxe1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernShovel0.png b/src/main/resources/assets/draconicevolution/textures/items/old/wyvernShovel0.png deleted file mode 100644 index 1e90279a..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernShovel0.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernShovel1.png b/src/main/resources/assets/draconicevolution/textures/items/old/wyvernShovel1.png deleted file mode 100644 index 8f3d8780..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernShovel1.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernSword.png b/src/main/resources/assets/draconicevolution/textures/items/old/wyvernSword.png deleted file mode 100644 index e58027b1..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/old/wyvernSword.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/reader.png b/src/main/resources/assets/draconicevolution/textures/items/reader.png deleted file mode 100644 index 30005440..00000000 Binary files a/src/main/resources/assets/draconicevolution/textures/items/reader.png and /dev/null differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_0.png b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_0.png index c8ffe065..50c036b9 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_0.png and b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_0.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_1.png b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_1.png index 73d59765..50c036b9 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_1.png and b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_1.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_2.png b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_2.png index ee6633e2..28b73c09 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_2.png and b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_pulling_2.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_standby.png b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_standby.png index 63ff3b92..1491c033 100644 Binary files a/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_standby.png and b/src/main/resources/assets/draconicevolution/textures/items/wyvernBow_standby.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvern_boots.png b/src/main/resources/assets/draconicevolution/textures/items/wyvern_boots.png new file mode 100644 index 00000000..5cf95731 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/wyvern_boots.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvern_chestplate.png b/src/main/resources/assets/draconicevolution/textures/items/wyvern_chestplate.png new file mode 100644 index 00000000..e72e8b2c Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/wyvern_chestplate.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvern_helmet.png b/src/main/resources/assets/draconicevolution/textures/items/wyvern_helmet.png new file mode 100644 index 00000000..8ee83906 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/wyvern_helmet.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/items/wyvern_leggings.png b/src/main/resources/assets/draconicevolution/textures/items/wyvern_leggings.png new file mode 100644 index 00000000..a4b55172 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/items/wyvern_leggings.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/models/EnergyInfuserTextureSheet.png b/src/main/resources/assets/draconicevolution/textures/models/EnergyInfuserTextureSheet.png new file mode 100644 index 00000000..cd9e53de Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/models/EnergyInfuserTextureSheet.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/models/armor/draconic_layer_1.png b/src/main/resources/assets/draconicevolution/textures/models/armor/draconic_layer_1.png new file mode 100644 index 00000000..49cf85e4 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/models/armor/draconic_layer_1.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/models/armor/draconic_layer_2.png b/src/main/resources/assets/draconicevolution/textures/models/armor/draconic_layer_2.png new file mode 100644 index 00000000..58c4c865 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/models/armor/draconic_layer_2.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/models/armor/wyvern_layer_1.png b/src/main/resources/assets/draconicevolution/textures/models/armor/wyvern_layer_1.png new file mode 100644 index 00000000..215face3 Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/models/armor/wyvern_layer_1.png differ diff --git a/src/main/resources/assets/draconicevolution/textures/models/armor/wyvern_layer_2.png b/src/main/resources/assets/draconicevolution/textures/models/armor/wyvern_layer_2.png new file mode 100644 index 00000000..fb4e57bc Binary files /dev/null and b/src/main/resources/assets/draconicevolution/textures/models/armor/wyvern_layer_2.png differ