mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-11-20 20:22:10 +00:00
made changes
This commit is contained in:
1 parent
ed7de6f643
commit
c047d24fbd
46 files changed
+2152
-225
No files matched your search
@@ -155,4 +155,25 @@ public class EnergyStorage implements IEnergyStorage {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
/* Added By Brandon3055 24/07/2014 */
|
||||
|
||||
public EnergyStorage readFromNBT(NBTTagCompound nbt, String tag) {
|
||||
|
||||
this.energy = nbt.getInteger(tag);
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt, String tag) {
|
||||
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
}
|
||||
nbt.setInteger(tag, energy);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
/**
|
||||
* An energy storage is the unit of interaction with EnergyHelper inventories.
|
||||
* An energy internalGenBuffer is the unit of interaction with EnergyHelper inventories.
|
||||
*
|
||||
* A reference implementation can be found at {@link EnergyStorage}.
|
||||
*
|
||||
@@ -11,24 +11,24 @@ package cofh.api.energy;
|
||||
public interface IEnergyStorage {
|
||||
|
||||
/**
|
||||
* Adds energy to the storage. Returns quantity of energy that was accepted.
|
||||
* Adds energy to the internalGenBuffer. 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.
|
||||
* @return Amount of energy that was (or would have been, if simulated) accepted by the internalGenBuffer.
|
||||
*/
|
||||
int receiveEnergy(int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from the storage. Returns quantity of energy that was removed.
|
||||
* Removes energy from the internalGenBuffer. 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.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the internalGenBuffer.
|
||||
*/
|
||||
int extractEnergy(int maxExtract, boolean simulate);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class DraconicEvolution {
|
||||
public static final String networkChannelName = "DraconicEvolution";
|
||||
public static ChannelHandler channelHandler = new ChannelHandler(References.MODID, networkChannelName);
|
||||
//public static FMLEventChannel channel;
|
||||
public static boolean debug = false;
|
||||
public static boolean debug = true;
|
||||
|
||||
public DraconicEvolution()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import com.brandon3055.draconicevolution.common.container.ContainerGenerator;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.GuiHelper;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGenerator;
|
||||
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.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GUIGenerator extends GuiContainer {
|
||||
|
||||
public EntityPlayer player;
|
||||
private TileGenerator tile;
|
||||
private int guiUpdateTick;
|
||||
|
||||
public GUIGenerator(InventoryPlayer invPlayer, TileGenerator tile) {
|
||||
super(new ContainerGenerator(invPlayer, tile));
|
||||
|
||||
xSize = 176;
|
||||
ySize = 162;
|
||||
|
||||
this.tile = tile;
|
||||
this.player = invPlayer.player;
|
||||
}
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/Grinder.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int X, int Y)
|
||||
{
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box
|
||||
drawTexturedModalRect(guiLeft + 97, guiTop + 34, 18, ySize, 18, 18);//flame box
|
||||
if (tile.getStackInSlot(0) == null)
|
||||
drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box
|
||||
|
||||
float power = (float)tile.getEnergyStored(ForgeDirection.DOWN) / (float)tile.getMaxEnergyStored(ForgeDirection.DOWN) * -1 + 1;
|
||||
float fuel = tile.burnTimeRemaining / ((float)tile.burnTime) * -1 + 1;
|
||||
|
||||
drawTexturedModalRect(guiLeft + 83, guiTop + 11 + (int)(power*40), xSize, 0 + (int)(power*40), 12, 40 - (int)(power*40));//Power bar
|
||||
drawTexturedModalRect(guiLeft + 100, guiTop + 37 + (int)(fuel*13), xSize, 40 + (int)(fuel*13), 18, 18 - (int)(fuel*13));//Power bar
|
||||
|
||||
fontRendererObj.drawStringWithShadow("Generator", guiLeft + 64, guiTop + 0, 0x00FFFF);
|
||||
|
||||
int x = X - guiLeft;
|
||||
int y = Y - guiTop;
|
||||
if (GuiHelper.isInRect(83, 10, 95, 50, x, y)) {
|
||||
ArrayList<String> internal = new ArrayList<String>();
|
||||
internal.add("Internal Storage");
|
||||
internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP));
|
||||
drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int X, int Y)
|
||||
{
|
||||
|
||||
int x = X - guiLeft;
|
||||
int y = Y - guiTop;
|
||||
/* if (GuiHelper.isInRect(83, 10, 95, 50, x, y)) {
|
||||
ArrayList<String> internal = new ArrayList<String>();
|
||||
internal.add("Internal Storage");
|
||||
internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP));
|
||||
drawHoveringText(internal, x, y, fontRendererObj);
|
||||
}
|
||||
*/ }
|
||||
|
||||
@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()
|
||||
{
|
||||
guiUpdateTick++;
|
||||
if (guiUpdateTick >= 10){
|
||||
initGui();
|
||||
guiUpdateTick = 0;
|
||||
}
|
||||
super.updateScreen();
|
||||
|
||||
}
|
||||
|
||||
// ####Draw at############ read from size
|
||||
//drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38);
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.brandon3055.draconicevolution.client.interfaces;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.core.utills.GuiHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -15,6 +18,8 @@ import com.brandon3055.draconicevolution.common.container.ContainerGrinder;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGrinder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GUIGrinder extends GuiContainer {
|
||||
|
||||
@@ -35,23 +40,44 @@ public class GUIGrinder extends GuiContainer {
|
||||
private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/Grinder.png");
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
||||
{
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int X, int Y) {
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box
|
||||
if (!tile.isExternallyPowered())
|
||||
drawTexturedModalRect(guiLeft + 63, guiTop + 34, 0, ySize, 18, 18);//fuel box
|
||||
drawTexturedModalRect(guiLeft + 97, guiTop + 34, 18, ySize, 18, 18);//flame box
|
||||
if (tile.getStackInSlot(0) == null)
|
||||
if (tile.getStackInSlot(0) == null && !tile.isExternallyPowered())
|
||||
drawTexturedModalRect(guiLeft + 63, guiTop + 34, 36, ySize, 18, 18);//fuel box
|
||||
|
||||
float power = tile.energy / 5000f * -1 + 1;
|
||||
|
||||
float power;
|
||||
if (tile.isExternallyPowered()){
|
||||
power = (float) tile.getEnergyStored(ForgeDirection.DOWN) / (float) tile.getMaxEnergyStored(ForgeDirection.DOWN) * -1 + 1;
|
||||
}else {
|
||||
power = (float) tile.getInternalBuffer().getEnergyStored() / (float) tile.getInternalBuffer().getMaxEnergyStored() * -1 + 1;
|
||||
}
|
||||
float fuel = tile.burnTimeRemaining / ((float)tile.burnTime) * -1 + 1;
|
||||
|
||||
drawTexturedModalRect(guiLeft + 83, guiTop + 11 + (int)(power*40), xSize, 0 + (int)(power*40), 12, 40 - (int)(power*40));//Power bar
|
||||
drawTexturedModalRect(guiLeft + 100, guiTop + 37 + (int)(fuel*13), xSize, 40 + (int)(fuel*13), 18, 18 - (int)(fuel*13));//Power bar
|
||||
|
||||
if (tile.isExternallyPowered())
|
||||
drawTexturedModalRect(guiLeft + 100, guiTop + 37, xSize, 66, 13, 13);
|
||||
|
||||
fontRendererObj.drawStringWithShadow("Grinder", guiLeft + 71, guiTop + 0, 0x00FFFF);
|
||||
|
||||
int x = X - guiLeft;
|
||||
int y = Y - guiTop;
|
||||
if (GuiHelper.isInRect(83, 10, 95, 50, x, y)) {
|
||||
ArrayList<String> internal = new ArrayList<String>();
|
||||
internal.add("Energy Buffer");
|
||||
if (tile.isExternallyPowered()) {
|
||||
internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getEnergyStored(ForgeDirection.UP) + "/" + tile.getMaxEnergyStored(ForgeDirection.UP));
|
||||
} else {
|
||||
internal.add("" + EnumChatFormatting.DARK_BLUE + tile.getInternalBuffer().getEnergyStored() + "/" + tile.getInternalBuffer().getMaxEnergyStored());
|
||||
}
|
||||
drawHoveringText(internal, x + guiLeft, y + guiTop, fontRendererObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.brandon3055.draconicevolution.common.core.utills.InventoryReader;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static final int GUIID_WEATHER_CONTROLLER = 0;
|
||||
public static final int GUIID_WEATHER_CONTROLLER = 0;
|
||||
public static final int GUIID_SUN_DIAL = 1;
|
||||
public static final int GUIID_GRINDER = 2;
|
||||
public static final int GUIID_TELEPORTER = 3;
|
||||
@@ -20,91 +20,101 @@ public class GuiHandler implements IGuiHandler {
|
||||
public static final int GUIID_PARTICLEGEN = 5;
|
||||
public static final int GUIID_PLAYERDETECTOR = 6;
|
||||
public static final int GUIID_ENERGY_INFUSER = 7;
|
||||
|
||||
public static final int GUIID_GENERATOR = 8;
|
||||
|
||||
public GuiHandler() {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(DraconicEvolution.instance, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case GUIID_WEATHER_CONTROLLER:
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileWeatherController) {
|
||||
return new ContainerWeatherController(player.inventory, (TileWeatherController) te);
|
||||
}
|
||||
break;
|
||||
case GUIID_SUN_DIAL:
|
||||
TileEntity te1 = world.getTileEntity(x, y, z);
|
||||
if (te1 != null && te1 instanceof TileSunDial) {
|
||||
return new ContainerSunDial(player.inventory, (TileSunDial) te1);
|
||||
}
|
||||
break;
|
||||
case GUIID_GRINDER:
|
||||
TileEntity te2 = world.getTileEntity(x, y, z);
|
||||
if (te2 != null && te2 instanceof TileGrinder) {
|
||||
return new ContainerGrinder(player.inventory, (TileGrinder) te2);
|
||||
}
|
||||
break;
|
||||
case GUIID_READER:
|
||||
return new ContainerReader(player.inventory, new InventoryReader(player));
|
||||
case GUIID_PLAYERDETECTOR:
|
||||
TileEntity detector = world.getTileEntity(x, y, z);
|
||||
if (detector != null && detector instanceof TilePlayerDetectorAdvanced) {
|
||||
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);
|
||||
case GUIID_WEATHER_CONTROLLER:
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileWeatherController) {
|
||||
return new ContainerWeatherController(player.inventory, (TileWeatherController) te);
|
||||
}
|
||||
break;
|
||||
case GUIID_SUN_DIAL:
|
||||
TileEntity te1 = world.getTileEntity(x, y, z);
|
||||
if (te1 != null && te1 instanceof TileSunDial) {
|
||||
return new ContainerSunDial(player.inventory, (TileSunDial) te1);
|
||||
}
|
||||
break;
|
||||
case GUIID_GRINDER:
|
||||
TileEntity te2 = world.getTileEntity(x, y, z);
|
||||
if (te2 != null && te2 instanceof TileGrinder) {
|
||||
return new ContainerGrinder(player.inventory, (TileGrinder) te2);
|
||||
}
|
||||
break;
|
||||
case GUIID_READER:
|
||||
return new ContainerReader(player.inventory, new InventoryReader(player));
|
||||
case GUIID_PLAYERDETECTOR:
|
||||
TileEntity detector = world.getTileEntity(x, y, z);
|
||||
if (detector != null && detector instanceof TilePlayerDetectorAdvanced) {
|
||||
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;
|
||||
case GUIID_GENERATOR:
|
||||
TileEntity generator = world.getTileEntity(x, y, z);
|
||||
if (generator != null && generator instanceof TileGenerator) {
|
||||
return new ContainerGenerator(player.inventory, (TileGenerator) generator);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
switch (ID) {
|
||||
case GUIID_WEATHER_CONTROLLER:
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileWeatherController) {
|
||||
return new GUIWeatherController(player.inventory, (TileWeatherController) te);
|
||||
}
|
||||
break;
|
||||
case GUIID_SUN_DIAL:
|
||||
TileEntity te1 = world.getTileEntity(x, y, z);
|
||||
if (te1 != null && te1 instanceof TileSunDial) {
|
||||
return new GUISunDial(player.inventory, (TileSunDial) te1);
|
||||
}
|
||||
break;
|
||||
case GUIID_TELEPORTER:
|
||||
return new GUITeleporter(player);
|
||||
case GUIID_GRINDER:
|
||||
TileEntity te2 = world.getTileEntity(x, y, z);
|
||||
if (te2 != null && te2 instanceof TileGrinder) {
|
||||
return new GUIGrinder(player.inventory, (TileGrinder) te2);
|
||||
}
|
||||
break;
|
||||
case GUIID_READER:
|
||||
return new GUIReader(player.inventory, new InventoryReader(player));
|
||||
case GUIID_PARTICLEGEN:
|
||||
TileEntity gen = world.getTileEntity(x, y, z);
|
||||
return (gen != null && gen instanceof TileParticleGenerator) ? new GUIParticleGenerator((TileParticleGenerator)gen, player) : null;
|
||||
case GUIID_PLAYERDETECTOR:
|
||||
TileEntity detector = world.getTileEntity(x, y, z);
|
||||
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);
|
||||
}
|
||||
case GUIID_WEATHER_CONTROLLER:
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if (te != null && te instanceof TileWeatherController) {
|
||||
return new GUIWeatherController(player.inventory, (TileWeatherController) te);
|
||||
}
|
||||
break;
|
||||
case GUIID_SUN_DIAL:
|
||||
TileEntity te1 = world.getTileEntity(x, y, z);
|
||||
if (te1 != null && te1 instanceof TileSunDial) {
|
||||
return new GUISunDial(player.inventory, (TileSunDial) te1);
|
||||
}
|
||||
break;
|
||||
case GUIID_TELEPORTER:
|
||||
return new GUITeleporter(player);
|
||||
case GUIID_GRINDER:
|
||||
TileEntity te2 = world.getTileEntity(x, y, z);
|
||||
if (te2 != null && te2 instanceof TileGrinder) {
|
||||
return new GUIGrinder(player.inventory, (TileGrinder) te2);
|
||||
}
|
||||
break;
|
||||
case GUIID_READER:
|
||||
return new GUIReader(player.inventory, new InventoryReader(player));
|
||||
case GUIID_PARTICLEGEN:
|
||||
TileEntity gen = world.getTileEntity(x, y, z);
|
||||
return (gen != null && gen instanceof TileParticleGenerator) ? new GUIParticleGenerator((TileParticleGenerator) gen, player) : null;
|
||||
case GUIID_PLAYERDETECTOR:
|
||||
TileEntity detector = world.getTileEntity(x, y, z);
|
||||
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);
|
||||
}
|
||||
case GUIID_GENERATOR:
|
||||
TileEntity generator = world.getTileEntity(x, y, z);
|
||||
if (generator != null && generator instanceof TileGenerator) {
|
||||
return new GUIGenerator(player.inventory, (TileGenerator) generator);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
+10
@@ -71,6 +71,16 @@ public class CustonSpawnerRenderer extends TileEntitySpecialRenderer
|
||||
tessellator.addVertexWithUV(1, 0.99D, 1, 1, 1);
|
||||
tessellator.addVertexWithUV(1, 0.99D, 0, 0, 1);
|
||||
|
||||
tessellator.addVertexWithUV(0, 0.01D, 0, 0, 0);
|
||||
tessellator.addVertexWithUV(1, 0.01D, 0, 1, 0);
|
||||
tessellator.addVertexWithUV(1, 0.01D, 1, 1, 1);
|
||||
tessellator.addVertexWithUV(0, 0.01D, 1, 0, 1);
|
||||
|
||||
tessellator.addVertexWithUV(0, 0.01D, 0, 0, 0);
|
||||
tessellator.addVertexWithUV(0, 0.01D, 1, 1, 0);
|
||||
tessellator.addVertexWithUV(1, 0.01D, 1, 1, 1);
|
||||
tessellator.addVertexWithUV(1, 0.01D, 0, 0, 1);
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class EnergyParticle extends EntityFX {
|
||||
setDead();
|
||||
}
|
||||
moveEntity(motionX, motionY, motionZ);// also important if you want your particle to move
|
||||
float speedMultiplyer = 0.0501F;
|
||||
float speedMultiplyer = 0.000501F;
|
||||
float ySpeedMultiplyer = 0.1006F;
|
||||
if (expand) {
|
||||
motionX = motionX + (targetX - posX) * speedMultiplyer;
|
||||
|
||||
+9
-11
@@ -47,23 +47,21 @@ public class SoulItemRenderer implements IItemRenderer {
|
||||
Entity mob = EntityList.createEntityByName(ItemNBTHelper.getString(item, "Name", "Pig"), mc.theWorld);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
//GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
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)
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.8F, 0.8F, 0.8F);
|
||||
@@ -73,7 +71,8 @@ public class SoulItemRenderer implements IItemRenderer {
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
} else if (type == ItemRenderType.EQUIPPED)
|
||||
}
|
||||
else if (type == ItemRenderType.EQUIPPED)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(0.8F, 0.8F, 0.8F);
|
||||
@@ -83,19 +82,18 @@ public class SoulItemRenderer implements IItemRenderer {
|
||||
GL11.glRotatef(-20F, 1F, 0F, 0F);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
} else
|
||||
}
|
||||
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);
|
||||
RenderManager.instance.renderEntityWithPosYaw(mob, 0, 0, 0, 0F, 1F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
//GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.brandon3055.draconicevolution.client.render;
|
||||
|
||||
import com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileTestBlock;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 24/07/2014.
|
||||
*/
|
||||
public class TestBlockRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final ResourceLocation iner_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_1.png");
|
||||
private static final ResourceLocation outer_model_texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/power_sphere_layer_2.png");
|
||||
private IModelCustom iner_model;
|
||||
private IModelCustom outer_model;
|
||||
|
||||
public TestBlockRenderer()
|
||||
{
|
||||
iner_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_1.obj"));
|
||||
outer_model = AdvancedModelLoader.loadModel(new ResourceLocation(References.MODID.toLowerCase(), "models/power_sphere_layer_2.obj"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity var1, double x, double y, double z, float var8)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) 100, (float) 100);
|
||||
|
||||
GL11.glTranslated(x+0.5, y+0.5, z+0.5);
|
||||
|
||||
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(iner_model_texture);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glRotatef(((TileTestBlock)var1).modelRotation, 0F, 1F, 0.5F);
|
||||
GL11.glColor4f(2F, 2F, 2F, 1F);
|
||||
iner_model.renderAll();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glScalef(1.1F, 1.1F, 1.1F);
|
||||
|
||||
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(outer_model_texture);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 200F, 200F);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glRotatef(((TileTestBlock)var1).modelRotation*0.5F, 0F, -1F, -0.5F);
|
||||
GL11.glColor4f(0.5F, 2F, 2F, 0.7F);
|
||||
outer_model.renderAll();
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGenerator;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGrinder;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 23/07/2014.
|
||||
*/
|
||||
public class Generator extends BlockContainer {
|
||||
|
||||
public IIcon icon_front;
|
||||
public IIcon icon_side;
|
||||
public IIcon icon_back;
|
||||
public IIcon icon_back_inactive;
|
||||
public IIcon icon_front_inactive;
|
||||
public IIcon icon_top[] = new IIcon[4];
|
||||
|
||||
protected Generator() {
|
||||
super(Material.rock);
|
||||
this.setBlockName(Strings.generatorName);
|
||||
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
|
||||
this.setStepSound(soundTypeStone);
|
||||
this.setHardness(1f);
|
||||
this.setResistance(2000.0f);
|
||||
GameRegistry.registerBlock(this, this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(final IIconRegister iconRegister)
|
||||
{
|
||||
icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/generator_front_active");
|
||||
icon_front_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "generator_front");
|
||||
icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side");
|
||||
icon_back = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/machine_fan");
|
||||
icon_back_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_fan");
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
icon_top[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_" + i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubBlocks(final Item item, final CreativeTabs tab, final List par3list)
|
||||
{
|
||||
par3list.add(new ItemStack(item, 1, 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null;
|
||||
if (tile == null)
|
||||
{
|
||||
LogHelper.error("Missing Tile Entity (Generator)");
|
||||
return 0;
|
||||
}
|
||||
return tile.burnTimeRemaining > 0 && tile.getEnergyStored(ForgeDirection.UP) < tile.getMaxEnergyStored(ForgeDirection.UP) ? 13 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int p_149692_1_)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
|
||||
{
|
||||
TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null;
|
||||
if (tile == null)
|
||||
{
|
||||
LogHelper.error("Missing Tile Entity (Generator)");
|
||||
return null;
|
||||
}
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
IIcon back;
|
||||
IIcon front;
|
||||
|
||||
if (tile.burnTimeRemaining > 0 && tile.getEnergyStored(ForgeDirection.UP) < tile.getMaxEnergyStored(ForgeDirection.UP))
|
||||
{
|
||||
back = icon_back;
|
||||
front = icon_front;
|
||||
}
|
||||
else
|
||||
{
|
||||
back = icon_back_inactive;
|
||||
front = icon_front_inactive;
|
||||
}
|
||||
|
||||
switch (side)
|
||||
{
|
||||
case 0:
|
||||
return icon_side;
|
||||
case 1:
|
||||
return icon_top[meta];
|
||||
case 2:
|
||||
if (meta == 0)
|
||||
return front;
|
||||
else if (meta == 2)
|
||||
return back;
|
||||
else
|
||||
return icon_side;
|
||||
case 3:
|
||||
if (meta == 2)
|
||||
return front;
|
||||
else if (meta == 0)
|
||||
return back;
|
||||
else
|
||||
return icon_side;
|
||||
case 4:
|
||||
if (meta == 3)
|
||||
return front;
|
||||
else if (meta == 1)
|
||||
return back;
|
||||
else
|
||||
return icon_side;
|
||||
case 5:
|
||||
if (meta == 1)
|
||||
return front;
|
||||
else if (meta == 3)
|
||||
return back;
|
||||
else
|
||||
return icon_side;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta)
|
||||
{
|
||||
switch (side)
|
||||
{
|
||||
case 0:
|
||||
return icon_side;
|
||||
case 1:
|
||||
return icon_top[meta];
|
||||
case 2:
|
||||
if (meta == 0)
|
||||
return icon_front;
|
||||
else if (meta == 2)
|
||||
return icon_back;
|
||||
else
|
||||
return icon_side;
|
||||
case 3:
|
||||
if (meta == 2)
|
||||
return icon_front;
|
||||
else if (meta == 0)
|
||||
return icon_back;
|
||||
else
|
||||
return icon_side;
|
||||
case 4:
|
||||
if (meta == 3)
|
||||
return icon_front;
|
||||
else if (meta == 1)
|
||||
return icon_back;
|
||||
else
|
||||
return icon_side;
|
||||
case 5:
|
||||
if (meta == 1)
|
||||
return icon_front;
|
||||
else if (meta == 3)
|
||||
return icon_back;
|
||||
else
|
||||
return icon_side;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2)
|
||||
{
|
||||
return new TileGenerator();
|
||||
}
|
||||
|
||||
@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_GENERATOR, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase placer, ItemStack stack)
|
||||
{
|
||||
int l = MathHelper.floor_double((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
||||
if (l == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||
}
|
||||
|
||||
if (l == 1)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
}
|
||||
|
||||
if (l == 2)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
}
|
||||
|
||||
if (l == 3)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileGrinder)
|
||||
{
|
||||
((TileGrinder)tile).disabled = world.isBlockIndirectlyGettingPowered(x, y, z);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@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 mult = 0.05F;
|
||||
|
||||
droppedItem.motionX = (-0.5F + world.rand.nextFloat()) * mult;
|
||||
droppedItem.motionY = (4 + world.rand.nextFloat()) * mult;
|
||||
droppedItem.motionZ = (-0.5F + world.rand.nextFloat()) * mult;
|
||||
|
||||
world.spawnEntityInWorld(droppedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
|
||||
TileGenerator tile = (world.getTileEntity(x, y, z) != null && world.getTileEntity(x, y, z) instanceof TileGenerator) ? (TileGenerator) world.getTileEntity(x, y, z) : null;
|
||||
if (tile == null)
|
||||
{
|
||||
LogHelper.error("Missing Tile Entity (Generator)");
|
||||
return;
|
||||
}
|
||||
if(tile.burnTimeRemaining > 0 && tile.getEnergyStored(ForgeDirection.UP) < tile.getMaxEnergyStored(ForgeDirection.UP))
|
||||
{
|
||||
double ox = 0;
|
||||
double oz = 0;
|
||||
if (world.getBlockMetadata(x, y, z) == 0)
|
||||
oz = -0.5;
|
||||
if (world.getBlockMetadata(x, y, z) == 1)
|
||||
ox = 0.5;
|
||||
if (world.getBlockMetadata(x, y, z) == 2)
|
||||
oz = 0.5;
|
||||
if (world.getBlockMetadata(x, y, z) == 3)
|
||||
ox = -0.5;
|
||||
|
||||
world.spawnParticle("flame", ox + x + 0.5 + (Math.abs(ox)-0.5) * ((random.nextDouble() - 0.5)*1), y + 0.3 + (random.nextDouble() * 0.5), oz + z + 0.5 + (Math.abs(oz)-0.5) * ((random.nextDouble() - 0.5)*1), (ox*0.05)*random.nextDouble(), (random.nextDouble() - 0.2)*0.03, (oz*0.05)*random.nextDouble());
|
||||
world.spawnParticle("smoke", ox + x + 0.5 + (Math.abs(ox)-0.5) * ((random.nextDouble() - 0.5)*1), y + 0.3 + (random.nextDouble() * 0.5), oz + z + 0.5 + (Math.abs(oz)-0.5) * ((random.nextDouble() - 0.5)*1), (ox*0.05)*random.nextDouble(), (random.nextDouble() - 0.2)*0.03, (oz*0.05)*random.nextDouble());
|
||||
|
||||
world.playSound((double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), "fire.fire", 0.2F + (random.nextFloat()*0.1F), random.nextFloat() * 0.7F + 0.5F, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class Grinder extends BlockContainer
|
||||
IIcon back;
|
||||
IIcon front;
|
||||
|
||||
if (!tile.disabled && tile.energy >= 50)
|
||||
if (!tile.disabled && tile.getActiveBuffer().getEnergyStored() >= tile.energyPerKill)
|
||||
{
|
||||
back = icon_back;
|
||||
front = icon_front;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 23/06/2014.
|
||||
*/
|
||||
public class LRDItemBlock extends ItemBlock {
|
||||
public LRDItemBlock(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + stack.getItemDamage();
|
||||
}
|
||||
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
package com.brandon3055.draconicevolution.common.blocks;
|
||||
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.core.handler.ConfigHandler;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileLRD;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 20/07/2014.
|
||||
*/
|
||||
public class LongRangeDislocator extends DraconicEvolutionBlock {
|
||||
|
||||
IIcon blockIconTop;
|
||||
|
||||
public LongRangeDislocator() {
|
||||
this.setBlockName(Strings.longRangeDislocatorName);
|
||||
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
|
||||
this.setHardness(5f);
|
||||
this.setResistance(20.0f);
|
||||
GameRegistry.registerBlock(this, LRDItemBlock.class, this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(final IIconRegister iconRegister)
|
||||
{
|
||||
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "teteporter_front");
|
||||
blockIconTop = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(final int side, final int meta)
|
||||
{
|
||||
if (side == 0 || side == 1)
|
||||
return blockIconTop;
|
||||
else
|
||||
return blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs p_149666_2_, List list) {
|
||||
//list.add(new ItemStack(item, 1, 0));
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
}
|
||||
|
||||
@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_) {
|
||||
int meta = world.getBlockMetadata(x,y,z);
|
||||
if (meta == 0)
|
||||
return false;//return teleportPlayer(world, player, false);
|
||||
else if (meta == 1)
|
||||
return false;
|
||||
else{
|
||||
LogHelper.error("Invalid LRT Metadata");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_) {
|
||||
EntityPlayer player;
|
||||
if (world.getBlockMetadata(x, y, z) == 1 && world.isBlockIndirectlyGettingPowered(x, y, z))
|
||||
{
|
||||
player = world.getClosestPlayer(x, y, z, ConfigHandler.admin_dislocator_Detect_Range);
|
||||
if (player != null)
|
||||
{
|
||||
teleportPlayer(world, player, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean teleportPlayer(World world, EntityPlayer player, boolean admin){
|
||||
if (world.isRemote) return true;
|
||||
Random rand = new Random();
|
||||
|
||||
if (admin)
|
||||
{
|
||||
int randX = ConfigHandler.admin_dislocator_Min_Range + rand.nextInt(ConfigHandler.admin_dislocator_Max_Range - ConfigHandler.admin_dislocator_Min_Range);
|
||||
int randZ = ConfigHandler.admin_dislocator_Min_Range + rand.nextInt(ConfigHandler.admin_dislocator_Max_Range - ConfigHandler.admin_dislocator_Min_Range);
|
||||
randX = rand.nextBoolean() ? randX * -1 : randX * 1;
|
||||
randZ = rand.nextBoolean() ? randZ * -1 : randZ * 1;
|
||||
randX += (int)player.posX;
|
||||
randZ += (int)player.posZ;
|
||||
int y = 255;
|
||||
for (int i = 255; i > 1; i--)
|
||||
{
|
||||
if (world.getBlock(randX, i, randZ) != Blocks.air)
|
||||
{
|
||||
//LogHelper.info(world.getBlock(randX, i, randZ));
|
||||
y = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getBlock(randX, y, randZ).isBlockSolid(world, randX, y, randZ, 0))
|
||||
{
|
||||
world.setBlock(randX, y, randZ, world.getBlock(randX, y, randZ));
|
||||
player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F);
|
||||
player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5);
|
||||
}else{
|
||||
world.setBlock(randX, y, randZ, Blocks.stone);
|
||||
player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F);
|
||||
player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5);
|
||||
}
|
||||
|
||||
return true;
|
||||
}else{
|
||||
int randX = ConfigHandler.dislocator_Min_Range + rand.nextInt(ConfigHandler.dislocator_Max_Range - ConfigHandler.dislocator_Min_Range);
|
||||
int randZ = ConfigHandler.dislocator_Min_Range + rand.nextInt(ConfigHandler.dislocator_Max_Range - ConfigHandler.dislocator_Min_Range);
|
||||
randX = rand.nextBoolean() ? randX * -1 : randX * 1;
|
||||
randZ = rand.nextBoolean() ? randZ * -1 : randZ * 1;
|
||||
int y = 255;
|
||||
for (int i = 255; i > 1; i--)
|
||||
{
|
||||
if (world.getBlock(randX, i, randZ) != Blocks.air)
|
||||
{
|
||||
//LogHelper.info(world.getBlock(randX, i, randZ));
|
||||
y = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getBlock(randX, y, randZ).isBlockSolid(world, randX, y, randZ, 0))
|
||||
{
|
||||
world.setBlock(randX, y, randZ, world.getBlock(randX, y, randZ));
|
||||
player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F);
|
||||
player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5);
|
||||
}else{
|
||||
world.setBlock(randX, y, randZ, Blocks.stone);
|
||||
player.setLocationAndAngles(randX + 0.5, y + 1.5, randZ + 0.5, 0F, 0F);
|
||||
player.setPositionAndUpdate(randX + 0.5, y + 1.5, randZ + 0.5);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ public class ModBlocks {
|
||||
public static Block playerDetectorAdvanced;
|
||||
public static Block energyInfuser;
|
||||
public static Block customSpawner;
|
||||
public static Block longRangeDislocator;
|
||||
public static Block generator;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
@@ -34,6 +36,8 @@ public class ModBlocks {
|
||||
playerDetectorAdvanced = new PlayerDetectorAdvanced();
|
||||
energyInfuser = new EnergyInfuser();
|
||||
customSpawner = new CustomSpawner();
|
||||
generator = new Generator();
|
||||
if(ConfigHandler.disable_LRD < 2) longRangeDislocator = new LongRangeDislocator();
|
||||
|
||||
if(DraconicEvolution.debug) testBlock = new TestBlock();
|
||||
//testBlock = new TestBlock();
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -33,10 +34,17 @@ public class TestBlock extends DraconicEvolutionBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
|
||||
{
|
||||
return super.getCollisionBoundingBoxFromPool( p_149668_1_, p_149668_2_, p_149668_3_, p_149668_4_);
|
||||
//return null;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) {
|
||||
return null;
|
||||
//return super.getIcon(p_149673_1_, p_149673_2_, p_149673_3_, p_149673_4_, p_149673_5_);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return null;
|
||||
//return super.getIcon(p_149691_1_, p_149691_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,4 +118,24 @@ public class TestBlock extends DraconicEvolutionBlock {
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return super.getRenderType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(IBlockAccess world, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.brandon3055.draconicevolution.common.container;
|
||||
|
||||
import com.brandon3055.draconicevolution.client.interfaces.SlotItemValid;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.TileGenerator;
|
||||
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.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerGenerator extends Container {
|
||||
|
||||
private TileGenerator tile;
|
||||
private int cachSize = -1;
|
||||
|
||||
public ContainerGenerator(InventoryPlayer invPlayer, TileGenerator tile) {
|
||||
this.tile = tile;
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 138));
|
||||
}
|
||||
|
||||
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, 80 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true));
|
||||
}
|
||||
|
||||
@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 (TileGenerator.getItemBurnTime(stack) == 0 || !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 detectAndSendChanges() {
|
||||
ItemStack stack = tile.getStackInSlot(0);
|
||||
int size = stack == null ? 0 : stack.stackSize;
|
||||
if (cachSize != size) {
|
||||
cachSize = size;
|
||||
tile.tryRefuel();
|
||||
tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-4
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerGrinder extends Container {
|
||||
|
||||
private int cachSize = -1;
|
||||
private TileGrinder tile;
|
||||
|
||||
public ContainerGrinder(InventoryPlayer invPlayer, TileGrinder tile) {
|
||||
@@ -25,8 +26,11 @@ public class ContainerGrinder extends Container {
|
||||
addSlotToContainer(new Slot(invPlayer, x + y * 9 + 9, 8 + 18 * x, 80 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true));
|
||||
if (!tile.isExternallyPowered())
|
||||
addSlotToContainer(new SlotItemValid(tile, 0, 64, 35, true));
|
||||
else
|
||||
addSlotToContainer(new SlotItemValid(tile, 0, -10000, -10000, true));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +72,14 @@ public class ContainerGrinder extends Container {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TileGrinder getTileWC(){
|
||||
return tile;
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
ItemStack stack = tile.getStackInSlot(0);
|
||||
int size = stack == null ? 0 : stack.stackSize;
|
||||
if (cachSize != size) {
|
||||
cachSize = size;
|
||||
tile.tryRefuel();
|
||||
tile.getWorldObj().markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.brandon3055.draconicevolution.common.core.utills;
|
||||
package com.brandon3055.draconicevolution.common.core.Teleporter;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.Teleporter;
|
||||
+22
-1
@@ -1,4 +1,4 @@
|
||||
package com.brandon3055.draconicevolution.common.core.utills;
|
||||
package com.brandon3055.draconicevolution.common.core.Teleporter;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -27,4 +27,25 @@ public class Teleporter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void teleport(EntityPlayer player, double x, double y, double z)
|
||||
{
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
|
||||
|
||||
if (thePlayer.dimension == 1)
|
||||
{
|
||||
if (thePlayer.isRiding())
|
||||
thePlayer.dismountEntity(thePlayer.ridingEntity);
|
||||
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, thePlayer.dimension, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(thePlayer.dimension), x, y, z, 0, 0));
|
||||
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, thePlayer.dimension, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(thePlayer.dimension), x, y, z, 0, 0));
|
||||
} else
|
||||
{
|
||||
if (thePlayer.isRiding())
|
||||
thePlayer.dismountEntity(thePlayer.ridingEntity);
|
||||
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, thePlayer.dimension, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(thePlayer.dimension), x, y, z, 0, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-5
@@ -2,7 +2,6 @@ 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 {
|
||||
@@ -14,6 +13,12 @@ public class ConfigHandler {
|
||||
public static String[] spawnerList;
|
||||
public static boolean spawnerListType;
|
||||
public static int soulDropChance;
|
||||
public static int dislocator_Min_Range;
|
||||
public static int dislocator_Max_Range;
|
||||
public static int admin_dislocator_Min_Range;
|
||||
public static int admin_dislocator_Max_Range;
|
||||
public static int admin_dislocator_Detect_Range;
|
||||
public static int disable_LRD;
|
||||
|
||||
private static String[] defaultList = new String[] {"ExampleMob1", "ExampleMob2", "ExampleMob3 (these examples can be deleted)"};
|
||||
|
||||
@@ -24,13 +29,20 @@ public class ConfigHandler {
|
||||
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);
|
||||
disableSunDial = config.get(Configuration.CATEGORY_GENERAL, "Disable Sun Dial", 0, "Disable Sun Dial 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0);
|
||||
disableXrayBlock = config.get(Configuration.CATEGORY_GENERAL, "Disable Xray Block", 0, "Disable Distortion Flame 0:Default, 1:Disable recipe, 2:Disable completely").getInt(0);
|
||||
teleporterUsesPerPearl = config.get(Configuration.CATEGORY_GENERAL, "Teleporter Uses PerPearl", 10, "Charm of Dislocation uses per Ender pearl").getInt(10);
|
||||
bowBlockDamage = config.get(Configuration.CATEGORY_GENERAL, "Bow Block Damage", 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);
|
||||
|
||||
//dislocator_Min_Range = config.get("Long Range Dislocator", "Admin Dislocator Min Range", 1000000).getInt(1000000);
|
||||
//dislocator_Max_Range = config.get("Long Range Dislocator", "Admin Dislocator Max Range", 29000000).getInt(29000000);
|
||||
admin_dislocator_Min_Range = config.get("Long Range Dislocator", "Dislocator Min Range", 1000).getInt(1000);
|
||||
admin_dislocator_Max_Range = config.get("Long Range Dislocator", "Dislocator Max Range", 10000).getInt(10000);
|
||||
admin_dislocator_Detect_Range = config.get("Long Range Dislocator", "Admin Dislocator Detect Range", 5).getInt(5);
|
||||
disable_LRD = config.get("Long Range Dislocator", "Disable Dislocator", 0, "Disable Long Range Dislocator 0:Default, 1:Disable recipe, 2:Disable completely (Includes Admin Dislocator)").getInt(0);
|
||||
}
|
||||
catch (Exception e) {
|
||||
//DraconicEvolution.logger.error("Unable to load Config");
|
||||
|
||||
+4
-1
@@ -66,6 +66,9 @@ public class CraftingHandler {
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.rainSensor), " ", "RBR", "SPS", 'R', Items.redstone, 'B', Items.bucket, 'S', Blocks.stone_slab, 'P', Blocks.heavy_weighted_pressure_plate);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.particleGenerator), "RBR", "BCB", "RBR", 'R', Blocks.redstone_block, 'B', Items.blaze_rod, 'C', ModItems.draconicCore);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.playerDetector), "ITI", "CEC", "IDI", 'I', Items.iron_ingot, 'E', Items.ender_eye, 'T', Blocks.redstone_torch, 'C', Items.comparator, 'D', ModItems.draconicCore);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.playerDetectorAdvanced), "ISI", "EDE", "ICI", 'I', ModItems.draconiumIngot, 'E', Items.ender_eye, 'S', new ItemStack(Items.skull, 1, 1), 'C', Items.compass, 'D', ModBlocks.playerDetector);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.generator, 1, 3), "NIN", "IFI", "NCN", 'N', Items.netherbrick, 'I', Items.iron_ingot, 'F', Blocks.furnace, 'C', ModItems.draconicCore);
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.energyInfuser), "IPI", "CEC", "IDI", 'I', ModItems.draconiumIngot, 'P', ModBlocks.particleGenerator, 'C', ModItems.draconicCore, 'D', ModItems.infusedCompound, 'E', Blocks.enchanting_table);
|
||||
|
||||
if(ConfigHandler.disableSunDial == 0)
|
||||
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.sunDial), "IFI", "TDT", "GEG", 'I', ModItems.draconiumIngot, 'F', ModItems.sunFocus, 'T', ModItems.draconicCore, 'G', Blocks.glowstone, 'E', Blocks.enchanting_table, 'D', ModItems.dragonHeart);
|
||||
@@ -85,7 +88,7 @@ public class CraftingHandler {
|
||||
|
||||
}
|
||||
/*
|
||||
//turns dirt into enchanted diamond sword!
|
||||
//turns dirt into enchanted diamond sword
|
||||
ItemStack manipulation = new ItemStack(Items.diamond_sword);
|
||||
manipulation.addEnchantment(Enchantment.efficiency, 2);
|
||||
CraftingManager.getInstance().addShapelessRecipe(manipulation, Blocks.dirt);
|
||||
|
||||
@@ -3,6 +3,7 @@ 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 com.brandon3055.draconicevolution.common.tileentities.TileTestBlock;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityMobSpawnerRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -63,5 +64,8 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
render = new CustonSpawnerRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCustomSpawner.class, render);
|
||||
|
||||
render = new TestBlockRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTestBlock.class, render);
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,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.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.tileentities.*;
|
||||
import com.brandon3055.draconicevolution.common.world.DraconicWorldGenerator;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
@@ -59,6 +61,7 @@ public class CommonProxy {
|
||||
GameRegistry.registerTileEntity(TilePlayerDetectorAdvanced.class, "TilePlayerDetectorAdvanced");
|
||||
GameRegistry.registerTileEntity(TileEnergyInfuser.class, "TileEnergyInfuser");
|
||||
GameRegistry.registerTileEntity(TileCustomSpawner.class, "TileCustomSpawner");
|
||||
GameRegistry.registerTileEntity(TileGenerator.class, "TileGenerator");
|
||||
if(DraconicEvolution.debug)
|
||||
GameRegistry.registerTileEntity(TileTestBlock.class, "TileTestBlock");
|
||||
}
|
||||
@@ -95,8 +98,8 @@ public class CommonProxy {
|
||||
}
|
||||
|
||||
public void registerEntitys(){
|
||||
int dragonID = EntityRegistry.findGlobalUniqueEntityId();
|
||||
int cyan = (0 << 16) + (255 << 8) + 255;
|
||||
EntityRegistry.registerGlobalEntityID(EntityCustomDragon.class, "enderDragon", dragonID, cyan, 0);
|
||||
//int cyan = (0 << 16) + (255 << 8) + 255;
|
||||
//EntityRegistry.registerGlobalEntityID(EntityCustomDragon.class, References.RESOURCESPREFIX + "EnderDragon", EntityRegistry.findGlobalUniqueEntityId(), cyan, 0);
|
||||
EntityRegistry.registerModEntity(EntityCustomDragon.class, References.RESOURCESPREFIX + "EnderDragon", 0, DraconicEvolution.instance, 200, 3, true);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class LogHelper {
|
||||
|
||||
public static void log(Level logLevel, Object object)
|
||||
{
|
||||
FMLLog.log(logLevel, "Draconic Evolution", String.valueOf(object));
|
||||
FMLLog.log(References.MODNAME, logLevel, String.valueOf(object));
|
||||
}
|
||||
|
||||
public static void all(Object object){ log(Level.ALL, object); }
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.brandon3055.draconicevolution.common.items;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
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.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -21,6 +23,8 @@ public class DraconicCore extends DraconicEvolutionItem {
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
par3List.add(StatCollector.translateToLocal("info.draconicCore.txt"));
|
||||
par3List.add("");
|
||||
par3List.add("" + EnumChatFormatting.DARK_PURPLE + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicCore1.txt"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,9 +2,18 @@ package com.brandon3055.draconicevolution.common.items;
|
||||
|
||||
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.lib.Strings;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,6 +29,36 @@ public class MobSoul extends DraconicEvolutionItem {
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
|
||||
String name = ItemNBTHelper.getString(stack, "Name", "Pig");
|
||||
list.add(name);
|
||||
list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul1.txt"));
|
||||
list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul2.txt"));
|
||||
list.add("" + EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.mobSoul3.txt"));
|
||||
list.add("" + EnumChatFormatting.DARK_PURPLE + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float p_77648_8_, float p_77648_9_, float p_77648_10_) {
|
||||
if (!player.isSneaking()) return false;
|
||||
String name = ItemNBTHelper.getString(stack, "Name", "Pig");
|
||||
Entity entity = EntityList.createEntityByName(name, world);
|
||||
double sX = x + ForgeDirection.getOrientation(side).offsetX + 0.5;
|
||||
double sY = y + ForgeDirection.getOrientation(side).offsetY + 0.5;
|
||||
double sZ = z + ForgeDirection.getOrientation(side).offsetZ + 0.5;
|
||||
entity.setLocationAndAngles(sX, sY, sZ, player.rotationYaw, 0F);
|
||||
|
||||
if (entity instanceof EntityLivingBase && !world.isRemote) {
|
||||
((EntityLiving) entity).onSpawnWithEgg((IEntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.Teleporter;
|
||||
import com.brandon3055.draconicevolution.common.core.Teleporter.Teleporter;
|
||||
import com.brandon3055.draconicevolution.common.items.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import com.brandon3055.draconicevolution.client.interfaces.GuiHandler;
|
||||
import com.brandon3055.draconicevolution.DraconicEvolution;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.ItemNBTHelper;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.Teleporter;
|
||||
import com.brandon3055.draconicevolution.common.core.Teleporter.Teleporter;
|
||||
import com.brandon3055.draconicevolution.common.items.ModItems;
|
||||
import com.brandon3055.draconicevolution.common.lib.References;
|
||||
import com.brandon3055.draconicevolution.common.lib.Strings;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.brandon3055.draconicevolution.common.lib;
|
||||
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 VERSION = "0.9.2-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";
|
||||
|
||||
@@ -45,4 +45,6 @@ public class Strings {// public sta
|
||||
public static final String wyvernBootsName = "wyvernBoots";
|
||||
public static final String customSpawnerName = "customSpawner";
|
||||
public static final String MobSoulName = "mobSoul";
|
||||
public static final String longRangeDislocatorName = "longRangeDislocator";
|
||||
public static final String generatorName = "generator";
|
||||
}
|
||||
+282
@@ -0,0 +1,282 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.*;
|
||||
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.util.DamageSource;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraftforge.common.util.ForgeDirection.UP;
|
||||
|
||||
public class TileGenerator extends TileEntity implements ISidedInventory, IEnergyHandler {
|
||||
//########### variables #############//
|
||||
private ItemStack[] items;
|
||||
public int burnTime = 1;
|
||||
public int burnTimeRemaining = 0;
|
||||
private int burnSpeed = 6;
|
||||
/**
|
||||
* Energy per burn tick
|
||||
*/
|
||||
private int EPBT = 14;
|
||||
protected EnergyStorage storage = new EnergyStorage(100000, 0, 1000);
|
||||
|
||||
//##################################//
|
||||
|
||||
public TileGenerator() {
|
||||
items = new ItemStack[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (burnTimeRemaining > 0 && storage.getEnergyStored() < storage.getMaxEnergyStored()) {
|
||||
burnTimeRemaining -= burnSpeed;
|
||||
storage.setEnergyStored(storage.getEnergyStored() + Math.min(burnSpeed * EPBT, storage.getMaxEnergyStored() - storage.getEnergyStored()));
|
||||
} else if (burnTimeRemaining <= 0) tryRefuel();
|
||||
|
||||
if ((storage.getEnergyStored() > 0)) {
|
||||
for (int i = 0; i < 6; i++){
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + ForgeDirection.getOrientation(i).offsetX, yCoord + ForgeDirection.getOrientation(i).offsetY, zCoord + ForgeDirection.getOrientation(i).offsetZ);
|
||||
if (tile != null && tile instanceof IEnergyHandler) {
|
||||
storage.extractEnergy(((IEnergyHandler)tile).receiveEnergy(ForgeDirection.getOrientation(i).getOpposite(), storage.extractEnergy(storage.getMaxExtract(), true), false), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void tryRefuel() {
|
||||
if (burnTimeRemaining > 0 || storage.getEnergyStored() >= storage.getMaxEnergyStored()) return;
|
||||
if (items[0] != null && items[0].stackSize > 0) {
|
||||
int itemBurnTime = getItemBurnTime(items[0]);
|
||||
|
||||
if (itemBurnTime > 0) {
|
||||
decrStackSize(0, 1);
|
||||
burnTime = itemBurnTime;
|
||||
burnTimeRemaining = itemBurnTime;
|
||||
//LogHelper.info(itemBurnTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (block == Blocks.wooden_slab) {
|
||||
return 150;
|
||||
}
|
||||
|
||||
if (block.getMaterial() == Material.wood) {
|
||||
return 300;
|
||||
}
|
||||
|
||||
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() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.4) < 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
return getItemBurnTime(stack) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int var1) {
|
||||
return new int[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int var1, ItemStack var2, int var3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int var1, ItemStack var2, int var3) {
|
||||
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.setInteger("BurnTime", burnTime);
|
||||
compound.setInteger("BurnTimeRemaining", burnTimeRemaining);
|
||||
storage.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]);
|
||||
}
|
||||
|
||||
burnTime = compound.getInteger("BurnTime");
|
||||
burnTimeRemaining = compound.getInteger("BurnTimeRemaining");
|
||||
storage.readFromNBT(compound);
|
||||
|
||||
super.readFromNBT(compound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
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());
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return storage.getMaxEnergyStored();
|
||||
}
|
||||
}
|
||||
+74
-26
@@ -2,6 +2,8 @@ package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -27,23 +29,27 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
public class TileGrinder extends TileEntity implements ISidedInventory, IEnergyHandler {
|
||||
//########### variables #############//
|
||||
public int meta = -1;
|
||||
List<EntityLiving> killList;
|
||||
AxisAlignedBB killBox;
|
||||
int tick = 0;
|
||||
int updateTick = 0;
|
||||
double centreX;
|
||||
double centreY = -1;
|
||||
double centreZ;
|
||||
private ItemStack[] items;
|
||||
public int energy = 0;
|
||||
public int burnTime = 1;
|
||||
public int burnTimeRemaining = 0;
|
||||
public boolean disabled = false;
|
||||
private boolean readyNext = false;
|
||||
protected EnergyStorage internalGenBuffer = new EnergyStorage(20000, 32000, 0);
|
||||
protected EnergyStorage externalInputBuffer = new EnergyStorage(100000, 32000, 0);
|
||||
public int energyPerKill = 1000;
|
||||
private int burnSpeed = 2;
|
||||
private int EPBT = 10;
|
||||
|
||||
public void updateVariables() {
|
||||
if (meta == -1) meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
@@ -72,13 +78,6 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (burnTimeRemaining > 0) {
|
||||
burnTimeRemaining -= 2;
|
||||
energy += 2;
|
||||
if (burnTimeRemaining < 0) burnTimeRemaining = 0;
|
||||
}
|
||||
if (energy > 5000) energy = 5000;
|
||||
}
|
||||
//##################################//
|
||||
|
||||
@@ -88,22 +87,28 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if ((burnTimeRemaining == 1 || (burnTimeRemaining == 0 && updateTick == 20)) && !disabled && energy < 2500) {
|
||||
updateVariables();
|
||||
tryRefuel();
|
||||
} else updateVariables();
|
||||
updateVariables();
|
||||
|
||||
if (!worldObj.isRemote && updateTick >= 50 && readyNext && !disabled && energy >= 100) {
|
||||
if (killNextEntity()) {
|
||||
energy -= 100;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
if (burnTimeRemaining > 0 && internalGenBuffer.getEnergyStored() < internalGenBuffer.getMaxEnergyStored()) {
|
||||
burnTimeRemaining -= burnSpeed;
|
||||
internalGenBuffer.setEnergyStored(internalGenBuffer.getEnergyStored() + Math.min(burnSpeed * EPBT, internalGenBuffer.getMaxEnergyStored() - internalGenBuffer.getEnergyStored()));
|
||||
} else if (burnTimeRemaining <= 0) tryRefuel();
|
||||
|
||||
if ((internalGenBuffer.getEnergyStored() > 0)) {
|
||||
for (int i = 0; i < 6; i++){
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + ForgeDirection.getOrientation(i).offsetX, yCoord + ForgeDirection.getOrientation(i).offsetY, zCoord + ForgeDirection.getOrientation(i).offsetZ);
|
||||
if (tile != null && tile instanceof IEnergyHandler) {
|
||||
internalGenBuffer.extractEnergy(((IEnergyHandler) tile).receiveEnergy(ForgeDirection.getOrientation(i).getOpposite(), internalGenBuffer.extractEnergy(internalGenBuffer.getMaxExtract(), true), false), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (updateTick >= 50) {
|
||||
updateTick = 0;
|
||||
if (!worldObj.isRemote && readyNext && !disabled && getActiveBuffer().getEnergyStored() >= energyPerKill) {
|
||||
if (killNextEntity()) {
|
||||
getActiveBuffer().modifyEnergyStored(-energyPerKill);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
if (!disabled) updateTick += worldObj.rand.nextInt(10);
|
||||
|
||||
if (tick >= 100) {
|
||||
tick = 0;
|
||||
@@ -113,11 +118,21 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
} else tick++;
|
||||
}
|
||||
|
||||
public EnergyStorage getActiveBuffer(){
|
||||
return isExternallyPowered() ? externalInputBuffer : internalGenBuffer;
|
||||
}
|
||||
|
||||
public void checkSignal() {
|
||||
disabled = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
private void tryRefuel() {
|
||||
public boolean isExternallyPowered()
|
||||
{
|
||||
return externalInputBuffer.getEnergyStored() > energyPerKill;
|
||||
}
|
||||
|
||||
public void tryRefuel() {
|
||||
if (burnTimeRemaining > 0 || internalGenBuffer.getEnergyStored() >= internalGenBuffer.getMaxEnergyStored()) return;
|
||||
if (items[0] != null && items[0].stackSize > 0) {
|
||||
int itemBurnTime = getItemBurnTime(items[0]);
|
||||
|
||||
@@ -139,7 +154,7 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
if (mob instanceof EntityCreature) {
|
||||
if (((EntityCreature) mob).isEntityAlive()) {
|
||||
((EntityCreature) mob).attackEntityFrom(DamageSource.magic, 50000F);
|
||||
dropXP(mob);
|
||||
if (worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) dropXP(mob);
|
||||
readyNext = true;
|
||||
if (mob instanceof EntitySkeleton) {
|
||||
if (((EntitySkeleton) mob).getSkeletonType() == 1) {
|
||||
@@ -155,7 +170,7 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
} else if (mob instanceof EntityLiving) {
|
||||
if (((EntityLiving) mob).isEntityAlive()) {
|
||||
((EntityLiving) mob).attackEntityFrom(DamageSource.magic, 50000F);
|
||||
dropXP(mob);
|
||||
if (worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot")) dropXP(mob);
|
||||
readyNext = true;
|
||||
return true;
|
||||
}
|
||||
@@ -312,10 +327,11 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
compound.setTag("Item" + i, tag[i]);
|
||||
}
|
||||
|
||||
compound.setInteger("EnergyHelper", energy);
|
||||
compound.setBoolean("Disabled", disabled);
|
||||
compound.setInteger("BurnTime", burnTime);
|
||||
compound.setInteger("BurnTimeRemaining", burnTimeRemaining);
|
||||
externalInputBuffer.writeToNBT(compound, "ExternalBuffer");
|
||||
internalGenBuffer.writeToNBT(compound, "InternalBuffer");
|
||||
|
||||
super.writeToNBT(compound);
|
||||
}
|
||||
@@ -329,10 +345,11 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
items[i] = ItemStack.loadItemStackFromNBT(tag[i]);
|
||||
}
|
||||
|
||||
energy = compound.getInteger("EnergyHelper");
|
||||
disabled = compound.getBoolean("Disabled");
|
||||
burnTime = compound.getInteger("BurnTime");
|
||||
burnTimeRemaining = compound.getInteger("BurnTimeRemaining");
|
||||
externalInputBuffer.readFromNBT(compound, "ExternalBuffer");
|
||||
internalGenBuffer.readFromNBT(compound, "InternalBuffer");
|
||||
|
||||
super.readFromNBT(compound);
|
||||
}
|
||||
@@ -350,4 +367,35 @@ public class TileGrinder extends TileEntity implements ISidedInventory {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
|
||||
return externalInputBuffer.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
return externalInputBuffer.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return externalInputBuffer.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return externalInputBuffer.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
public EnergyStorage getInternalBuffer(){
|
||||
return internalGenBuffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.brandon3055.draconicevolution.common.tileentities;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* Created by Brandon on 21/07/2014.
|
||||
*/
|
||||
public class TileLRD extends TileEntity {
|
||||
}
|
||||
+11
-2
@@ -8,6 +8,7 @@ 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 com.brandon3055.draconicevolution.common.core.utills.LogHelper;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -17,12 +18,20 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
public class TileTestBlock extends TileEntity implements IEnergyHandler {
|
||||
public EnergyStorage energy = new EnergyStorage(100000000);
|
||||
public int maxInput = 100000000;
|
||||
public float modelRotation;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if (worldObj.isRemote) modelRotation += 0.5;
|
||||
|
||||
//LogHelper.info(modelRotation);
|
||||
|
||||
|
||||
|
||||
int test = 4;
|
||||
if (!worldObj.isRemote)
|
||||
System.out.println(energy.getEnergyStored());
|
||||
//if (!worldObj.isRemote)
|
||||
//System.out.println(energy.getEnergyStored());
|
||||
|
||||
if ((this.energy.getEnergyStored() > 0)) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user