Initial commit

This commit is contained in:
brandon3055 committed 2014-06-18 13:03:29 +10:00
1 parent 7bca2b681b
commit 58a892f6f5
226 files changed
+12362

No files matched your search

@@ -0,0 +1,32 @@
package draconicevolution.client.creativetab;
import draconicevolution.common.blocks.ModBlocks;
import draconicevolution.common.core.handler.ConfigHandler;
import draconicevolution.common.items.ModItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
public class TolkienTab extends CreativeTabs {
private String label;
public TolkienTab(final int id, final String modid, final String label) {
super(id, modid);
this.label = label;
}
@Override
public Item getTabIconItem()
{
if(this.label.equals("toolsAndWeapons"))
return ModItems.draconicDistructionStaff;
else if(this.label.equals("blocksAndItems"))
return ConfigHandler.disableSunDial == 2 ? Item.getItemFromBlock(ModBlocks.weatherController) : Item.getItemFromBlock(ModBlocks.sunDial);
else
return ModItems.tclogo;
}
@Override
public String getTabLabel()
{
return this.label;
}
}
@@ -0,0 +1,51 @@
package draconicevolution.client.interfaces;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.OpenGlHelper;
public class CustomGuiButton extends GuiButton
{
public CustomGuiButton(int id, int left, int top, int width, int hight, String text) {
super(id, left, top, width, hight, text);
}
public void drawButton(Minecraft minecraft, int p_146112_2_, int p_146112_3_)
{
if (this.visible)
{
FontRenderer fontrenderer = minecraft.fontRenderer;
minecraft.getTextureManager().bindTexture(buttonTextures);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.field_146123_n = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
int k = this.getHoverState(this.field_146123_n);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
this.mouseDragged(minecraft, p_146112_2_, p_146112_3_);
int l = 14737632;
if (packedFGColour != 0)
{
l = packedFGColour;
}
else if (!this.enabled)
{
l = 10526880;
}
else if (this.field_146123_n)
{
l = 16777120;
}
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
}
}
}
@@ -0,0 +1,96 @@
package draconicevolution.client.interfaces;
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.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.container.ContainerGrinder;
import draconicevolution.common.lib.References;
import draconicevolution.common.tileentities.TileGrinder;
@SideOnly(Side.CLIENT)
public class GUIGrinder extends GuiContainer {
public EntityPlayer player;
private TileGrinder tile;
private int guiUpdateTick;
public GUIGrinder(InventoryPlayer invPlayer, TileGrinder tile) {
super(new ContainerGrinder(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 = tile.energy / 5000f * -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
}
@Override
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
//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()
{
guiUpdateTick++;
if (guiUpdateTick >= 10){
initGui();
guiUpdateTick = 0;
}
super.updateScreen();
}
// ####Draw at############ read from size
//drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38);
}
@@ -0,0 +1,651 @@
package draconicevolution.client.interfaces;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.network.ParticleGenPacket;
import draconicevolution.common.lib.References;
import draconicevolution.common.tileentities.TileParticleGenerator;
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");
private int page = 1;
//Particle variables
private int red = 0;
private int green = 0;
private int blue = 0;
private int random_red = 0;
private int random_green = 0;
private int random_blue = 0;
private float motion_x = 0F;
private float motion_y = 0F;
private float motion_z = 0F;
private float random_motion_x = 0F;
private float random_motion_y = 0F;
private float random_motion_z = 0F;
private float scale = 0F;
private float random_scale = 0F;
private int life = 0;
private int random_life = 0;
private float spawn_x = 0F;
private float spawn_y = 0F;
private float spawn_z = 0F;
private float random_spawn_x = 0F;
private float random_spawn_y = 0F;
private float random_spawn_z = 0F;
private int fade = 0;
private int spawn_rate = 0;
private boolean collide = false;
private int selected_particle = 1;
private int selected_max = 3;
private float gravity = 0F;
//Buttons
//Info Page
//particle selection
private TileParticleGenerator tile;
public GUIParticleGenerator(TileParticleGenerator tile, EntityPlayer player) {
super();
this.tile = tile;
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." };
//@formatter:off
@Override
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);
}
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<String> lines = new ArrayList<String>();
lines.add("test");
//drawHoveringText(lines, x, y, fontRendererObj);
}
//@formatter:on
@Override
protected void mouseClicked(int x, int y, int button)
{
super.mouseClicked(x, y, button);
}
@SuppressWarnings("unchecked")
@Override
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
{
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"));
}
@Override
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(29) || Keyboard.isKeyDown(157)) && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)))
value = 100;
value_F = (value) / 1000F;
switch (button.id) {
case 0://Red +
red = (red + value) > 255 ? 255 : red + value;
packetValue = (short) red;
break;
case 1://Green +
green = (green + value) > 255 ? 255 : green + value;
packetValue = (short) green;
break;
case 2://Blue +
blue = (blue + value) > 255 ? 255 : blue + value;
packetValue = (short) blue;
break;
case 3://MX +
motion_x = (motion_x + value_F) > 5F ? 5F : motion_x + value_F;
packetValue = (short) (motion_x * 1000F);
break;
case 4://MY +
motion_y = (motion_y + value_F) > 5F ? 5F : motion_y + value_F;
packetValue = (short) (motion_y * 1000F);
break;
case 5://MZ +
motion_z = (motion_z + value_F) > 5F ? 5F : motion_z + value_F;
packetValue = (short) (motion_z * 1000F);
break;
case 6://Red -
red = (red - value) < 0 ? 0 : red - value;
packetValue = (short) red;
break;
case 7://Green -
green = (green - value) < 0 ? 0 : green - value;
packetValue = (short) green;
break;
case 8://Blue -
blue = (blue - value) < 0 ? 0 : blue - value;
packetValue = (short) blue;
break;
case 9://MX -
motion_x = (motion_x - value_F) < -5F ? -5F : motion_x - value_F;
packetValue = (short) (motion_x * 1000F);
break;
case 10://MY -
motion_y = (motion_y - value_F) < -5F ? -5F : motion_y - value_F;
packetValue = (short) (motion_y * 1000F);
break;
case 11://MZ -
motion_z = (motion_z - value_F) < -5F ? -5F : motion_z - value_F;
packetValue = (short) (motion_z * 1000F);
break;
case 12://RRed +
random_red = (random_red + value) > 255 ? 255 : random_red + value;
packetValue = (short) random_red;
break;
case 13://RGreen +
random_green = (random_green + value) > 255 ? 255 : random_green + value;
packetValue = (short) random_green;
break;
case 14://RBlue +
random_blue = (random_blue + value) > 255 ? 255 : random_blue + value;
packetValue = (short) random_blue;
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;
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;
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;
case 18://RRed -
random_red = (random_red - value) < 0 ? 0 : random_red - value;
packetValue = (short) random_red;
break;
case 19://RGreen -
random_green = (random_green - value) < 0 ? 0 : random_green - value;
packetValue = (short) random_green;
break;
case 20://RBlue -
random_blue = (random_blue - value) < 0 ? 0 : random_blue - value;
packetValue = (short) random_blue;
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;
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;
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;
case 24://Life +
life = (life + value) > 1000 ? 1000 : life + value;
packetValue = (short) life;
break;
case 25://Life -
life = (life - value) < 0 ? 0 : life - value;
packetValue = (short) life;
break;
case 26://RLife +
random_life = (random_life + value) > 1000 ? 1000 : random_life + value;
packetValue = (short) random_life;
break;
case 27://RLife -
random_life = (random_life - value) < 0 ? 0 : random_life - value;
packetValue = (short) random_life;
break;
case 28://Size +
scale = (scale + value_F * 10F) > 50F ? 50F : scale + value_F * 10F;
packetValue = (short) (scale * 100F);
break;
case 29://Size -
scale = (scale - value_F * 10F) < 0.01F ? 0.01F : scale - value_F * 10F;
packetValue = (short) (scale * 100F);
break;
case 30://RSize +
random_scale = (random_scale + value_F * 10F) > 50F ? 50F : random_scale + value_F * 10F;
packetValue = (short) (random_scale * 100F);
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;
case 32://Page 2
page = 2;
packetValue = (short) page;
initGui();
break;
case 33://Page 1
page = 1;
initGui();
packetValue = (short) page;
break;
case 34://SX +
spawn_x = (spawn_x + value_F * 100F) > 50F ? 50F : spawn_x + value_F * 100F;
packetValue = (short) (spawn_x * 100F);
break;
case 35://SX -
spawn_x = (spawn_x - value_F * 100F) < -50F ? -50F : spawn_x - value_F * 100F;
packetValue = (short) (spawn_x * 100F);
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;
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;
case 38://SY +
spawn_y = (spawn_y + value_F * 100F) > 50F ? 50F : spawn_y + value_F * 100F;
packetValue = (short) (spawn_y * 100F);
break;
case 39://SY -
spawn_y = (spawn_y - value_F * 100F) < -50F ? -50F : spawn_y - value_F * 100F;
packetValue = (short) (spawn_y * 100F);
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;
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;
case 42://SZ +
spawn_z = (spawn_z + value_F * 100F) > 50F ? 50F : spawn_z + value_F * 100F;
packetValue = (short) (spawn_z * 100F);
break;
case 43://SZ -
spawn_z = (spawn_z - value_F * 100F) < -50F ? -50F : spawn_z - value_F * 100F;
packetValue = (short) (spawn_z * 100F);
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;
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;
case 46://Delay +
spawn_rate = (spawn_rate + value) > 200 ? 200 : spawn_rate + value;
packetValue = (short) spawn_rate;
break;
case 47://Delay -
spawn_rate = (spawn_rate - value) < 1 ? 1 : spawn_rate - value;
packetValue = (short) spawn_rate;
break;
case 48://Fade +
fade = (fade + value) > 100 ? 100 : fade + value;
packetValue = (short) fade;
break;
case 49://Fade -
fade = (fade - value) < 0 ? 0 : fade - value;
packetValue = (short) fade;
break;
case 50://Toggle Collision
collide = !collide;
packetValue = (short) (collide ? 1 : 0);
initGui();
break;
case 51://cycle particle selection
selected_particle = selected_particle < selected_max ? selected_particle + 1 : 1;
packetValue = (short) selected_particle;
initGui();
break;
case 52://RSZ +
gravity = (gravity + value_F) > 5F ? 5F : gravity + value_F;
packetValue = (short) (gravity * 1000F);
break;
case 53://RSZ -
gravity = (gravity - value_F) < -5F ? -5F : gravity - value_F;
packetValue = (short) (gravity * 1000F);
break;
case 54://Info Page
page = 3;
initGui();
packetValue = (short) page;
break;
case 55://Back Page
page = 1;
initGui();
packetValue = (short) page;
break;
case 56://Info Next Page
if (page < 7)
page++;
else
initGui();
break;
case 57://Info Previous Page
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 == '')
{
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
}
}
@Override
public void updateScreen()
{
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
private void syncWithServer()
{
red = tile.red;
green = tile.green;
blue = tile.blue;
random_red = tile.random_red;
random_green = tile.random_green;
random_blue = tile.random_blue;
motion_x = tile.motion_x;
motion_y = tile.motion_y;
motion_z = tile.motion_z;
random_motion_x = tile.random_motion_x;
random_motion_y = tile.random_motion_y;
random_motion_z = tile.random_motion_z;
scale = tile.scale;
random_scale = tile.random_scale;
life = tile.life;
random_life = tile.random_life;
spawn_x = tile.spawn_x;
spawn_y = tile.spawn_y;
spawn_z = tile.spawn_z;
random_spawn_x = tile.random_spawn_x;
random_spawn_y = tile.random_spawn_y;
random_spawn_z = tile.random_spawn_z;
page = tile.page;
spawn_rate = tile.spawn_rate;
collide = tile.collide;
fade = tile.fade;
selected_particle = tile.selected_particle;
gravity = tile.gravity;
}
//@formatter:off
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);
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(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);
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);
}
@SuppressWarnings("unchecked")
private void page1Buttons()
{
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
int DX1 = 5;
int DX2 = DX1 + 71;
int DX3 = DX2 + 40;
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(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"));
}
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);
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);
}
@SuppressWarnings("unchecked")
private void page2Buttons()
{
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
int DX1 = 5;
int DX2 = DX1 + 71;
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));
}
//@formatter:on
}
@@ -0,0 +1,311 @@
package draconicevolution.client.interfaces;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.container.ContainerPlayerDetector;
import draconicevolution.common.core.network.PlayerDetectorButtonPacket;
import draconicevolution.common.core.network.PlayerDetectorStringPacket;
import draconicevolution.common.lib.References;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
@SideOnly(Side.CLIENT)
public class GUIPlayerDetector extends GuiContainer
{
public EntityPlayer player;
private TilePlayerDetectorAdvanced detector;
private int guiUpdateTick;
public boolean showCamoSlot = false;
public boolean showInvSlots = true;
private boolean editMode = false;
private int range = 0;
private int maxRange = 20;
private boolean whitelist = false;
private boolean initScedualed = false;
private int initTick = 0;
private String[] names = new String[42];
private GuiTextField selectedNameText;
private int selected = -1;
public GUIPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced detector) {
super(detector.getGuiContainer(invPlayer));
this.inventorySlots = new ContainerPlayerDetector(invPlayer, detector, this);
for (int i = 0; i < names.length; i++)
names[i] = "";
xSize = 176;
ySize = 198;
this.detector = detector;
this.player = invPlayer.player;
syncWithServer();
}
private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/PlayerDetector.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);
if (editMode)
{
drawTexturedModalRect(guiLeft + 3, guiTop + ySize / 2, 3, 3, xSize - 6, (ySize / 2) - 3);
drawNameChart(x, y);
}
drawCamoTab(x, y);
}
@Override
protected void drawGuiContainerForegroundLayer(int x, int y)
{
drawGuiText(x, y);
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
super.initGui();
buttonList.clear();
if (!editMode)
{
String wt = whitelist ? "White List" : "Black List";
int centre = width / 2;
buttonList.add(new GuiButton(0, centre - 20 - 20, guiTop + 20, 20, 20, "+"));
buttonList.add(new GuiButton(1, centre + 20, guiTop + 20, 20, 20, "-"));
buttonList.add(new GuiButton(3, centre - 40, guiTop + 60, 60, 20, wt));
buttonList.add(new GuiButton(4, centre + 20, guiTop + 60, 20, 20, "!"));
} else
{
buttonList.add(new GuiButton(5, guiLeft - 40, guiTop + ySize - 20, 40, 20, "Back"));
}
selectedNameText = new GuiTextField(fontRendererObj, 4, -12, 168, 12);
selectedNameText.setTextColor(-1);
selectedNameText.setDisabledTextColour(-1);
selectedNameText.setEnableBackgroundDrawing(true);
selectedNameText.setMaxStringLength(40);
selectedNameText.setVisible(editMode);
//ID
//buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, "sgASGgs"));
syncWithServer();
}
@Override
protected void actionPerformed(GuiButton button)
{
switch (button.id) {
case 0: //Range +
range = (range < maxRange) ? range + 1 : maxRange;
DraconicEvolution.channelHandler.sendToServer(new PlayerDetectorButtonPacket((byte)0, (byte)range));
break;
case 1: //Range -
range = (range > 1) ? range - 1 : 1;
DraconicEvolution.channelHandler.sendToServer(new PlayerDetectorButtonPacket((byte)0, (byte)range));
break;
case 3: //White List -
initScedualed = true;
editMode = true;
showInvSlots = false;
((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots();
break;
case 4: //Toggle White List -
whitelist = !whitelist;
initScedualed = true;
byte val = (byte) (whitelist ? 1 : 0);
DraconicEvolution.channelHandler.sendToServer(new PlayerDetectorButtonPacket((byte)1, val));
break;
case 5: //Back -
editMode = false;
showInvSlots = true;
((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots();
initScedualed = true;
break;
}
//DraconicEvolution.channelHandler.sendToServer(new ButtonPacket((byte) 0, true));
}
@Override
protected void keyTyped(char par1, int par2)
{
if(this.selectedNameText.textboxKeyTyped(par1, par2))
return;
else if (par2 == 28)
{
if (selectedNameText.isFocused())
{
names[selected] = selectedNameText.getText();
selectedNameText.setText("");
selectedNameText.setFocused(false);
DraconicEvolution.channelHandler.sendToServer(new PlayerDetectorStringPacket((byte)selected, names[selected]));
selected = -1;
}
}else
super.keyTyped(par1, par2);
}
@Override
public void updateScreen()
{
if (initScedualed)
initTick++;
if (initTick > 1)
{
initTick = 0;
initScedualed = false;
initGui();
}
super.updateScreen();
}
private void drawCamoTab(int x, int y)
{
boolean hovering = false;
if ((x - guiLeft > xSize && x - guiLeft < xSize + 20) && (y - guiTop > 0 && y - guiTop < 19))
hovering = true;
if (showCamoSlot)
{
if (hovering)
drawTexturedModalRect(guiLeft + xSize, guiTop, xSize, 85, 23, 41);
else
drawTexturedModalRect(guiLeft + xSize, guiTop, xSize, 44, 23, 41);
} else
{
if (hovering)
drawTexturedModalRect(guiLeft + xSize, guiTop, xSize, 22, 23, 22);
else
drawTexturedModalRect(guiLeft + xSize, guiTop, xSize, 0, 23, 22);
}
ArrayList<String> lines = new ArrayList<String>();
lines.add("Camouflage");
if ((x - guiLeft > xSize && x - guiLeft < xSize + 20) && (y - guiTop > 0 && y - guiTop < 19))
drawHoveringText(lines, x, y, fontRendererObj);
}
@Override
protected void mouseClicked(int x, int y, int par3)
{
super.mouseClicked(x, y, par3);
//Check if the camo slot was clicked
if ((x - guiLeft > xSize && x - guiLeft < xSize + 20) && (y - guiTop > 0 && y - guiTop < 19))
{
showCamoSlot = !showCamoSlot;
((ContainerPlayerDetector) this.inventorySlots).updateContainerSlots();
}
if (editMode)
selectName(x - guiLeft, y - guiTop);
//this.selectedNameText.mouseClicked(x - guiLeft, y - guiTop, par3);
}
private void drawGuiText(int rawX, int rawY)
{
if (!editMode)
{
drawCenteredString(fontRendererObj, "Advanced Player Detector", xSize/2, 5, 0x00FFFF);
fontRendererObj.drawString("Range:", 73, 21, 0x000000, false);
if (range < 10)
fontRendererObj.drawString("" + range, 85, 31, 0x000000, false);
else
fontRendererObj.drawString("" + range, 82, 31, 0x000000, false);
} else
{
if (selected != -1)
drawCenteredString(fontRendererObj, "Press Enter to save", xSize/2, -22, 0xFF0000);
for (int i = 0; i < 21; i++)
{
for (int j = 0; j < 2; j++)
{
if (i + j * 21 != selected)
{
String s = names[i + j * 21];
if (s.length() > 13)
s = s.substring(0, 13) + "...";
fontRendererObj.drawString(s, 5 + j * 84, 6 + i * 9, 0x980000);
}
}
}
}
selectedNameText.drawTextBox();
}
private void drawNameChart(int rawX, int rawY)
{
int x = rawX - guiLeft;
int y = rawY - guiTop;
for (int i = 0; i < 21; i++)
{
drawTexturedModalRect(guiLeft + 4, guiTop + 4 + i * 9, 0, ySize, 186, 10);
}
for (int i = 0; i < 21; i++)
{
for (int j = 0; j < 2; j++)
{
if ((x > 4 + j * 84 && x < (xSize / 2) - 1 + j * 82) && (y > 4 + i * 9 && y < 13 + i * 9) || i + j * 21 == selected)
drawTexturedModalRect(guiLeft + 5 + j * 84, guiTop + 5 + i * 9, 0, ySize + 10, 82, 8);
}
}
}
public void selectName(int x, int y)
{
if (initScedualed)
return;
for (int i = 0; i < 21; i++)
{
for (int j = 0; j < 2; j++)
{
if ((x > 4 + j * 84 && x < (xSize / 2) - 1 + j * 82) && (y > 4 + i * 9 && y < 13 + i * 9))
{
selected = i + j * 21;
selectedNameText.setText(names[i + j * 21]);
selectedNameText.setFocused(true);
}
}
}
}
private void syncWithServer()
{
this.whitelist = detector.whiteList;
for (int i = 0; i < detector.names.length; i++)
{
if (detector.names[i] != null)
names[i] = detector.names[i];
}
range = detector.range;
}
}
@@ -0,0 +1,33 @@
package draconicevolution.client.interfaces;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.container.ContainerReader;
import draconicevolution.common.core.utills.InventoryReader;
@SideOnly(Side.CLIENT)
public class GUIReader extends GuiContainer {
private static final ResourceLocation TEXTURE = new ResourceLocation("books", "textures/gui/binder.png");
protected final InventoryReader storage;
public GUIReader(IInventory inventoryPlayer, InventoryReader itemInventory) {
super(new ContainerReader(inventoryPlayer, itemInventory));
this.storage = itemInventory;
this.ySize += 10;
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(TEXTURE);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}
@@ -0,0 +1,84 @@
package draconicevolution.client.interfaces;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.container.ContainerSunDial;
import draconicevolution.common.core.network.TeleporterPacket;
import draconicevolution.common.lib.References;
import draconicevolution.common.tileentities.TileSunDial;
@SideOnly(Side.CLIENT)
public class GUISunDial extends GuiContainer {
private int guiUpdateTick;
public GUISunDial(InventoryPlayer invPlayer, TileSunDial te1) {
super(new ContainerSunDial(invPlayer, te1));
xSize = 176;
ySize = 90;
}
private static final ResourceLocation texture = new ResourceLocation(References.MODID, "textures/gui/SunDial.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);
}
@Override
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
//fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000);
//drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000);
//drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0);
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
super.initGui();
//ID
buttonList.add(new GuiButton(0, guiLeft +10, guiTop + 10, 85, 20, ""));
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.id == 0){
DraconicEvolution.channelHandler.sendToServer(new TeleporterPacket());
}
}
@Override
public void updateScreen()
{
guiUpdateTick++;
if (guiUpdateTick >= 10){
initGui();
guiUpdateTick = 0;
}
super.updateScreen();
}
}
@@ -0,0 +1,333 @@
package draconicevolution.client.interfaces;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.WorldProvider;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.handler.ConfigHandler;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.core.network.TeleporterPacket;
import draconicevolution.common.core.network.TeleporterStringPacket;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
@SideOnly(Side.CLIENT)
public class GUITeleporter extends GuiScreen
{
private final int xSize = 160;
private final int ySize = 138;
private ResourceLocation guiTexture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/TeleporterMKII.png");
private ItemStack teleporterItem;
private double[] dPosX = { 0, 0, 0, 0, 0 };
private double[] dPosY = { 0, 0, 0, 0, 0 };
private double[] dPosZ = { 0, 0, 0, 0, 0 };
private int[] dPosD = { 0, 0, 0, 0, 0 };
private float[] dYaw = { 0, 0, 0, 0, 0 };
private float[] dPitch = { 0, 0, 0, 0, 0 };
private boolean[] dSet = { false, false, false, false, false };
private int selected = 0;
private int fuel = 0;
private boolean editing = false;
private EntityPlayer player;
public GUITeleporter(EntityPlayer player) {
super();
this.player = player;
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)))
{
this.teleporterItem = player.getCurrentEquippedItem();
updatePositions(teleporterItem);
updateNames(teleporterItem);
}
}
String[] destText = { "", "", "", "", "" };
String[] destValue = { "[Unset]", "[Unset]", "[Unset]", "[Unset]", "[Unset]" };
@Override
public void drawScreen(int x, int y, float f)
{
drawDefaultBackground();
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);
drawTexturedModalRect(posX + 3, posY + 3 + selected * 23, 0, ySize, 67, 10);
//Light Cursor Position
for (int i = 0; i < 5; i++)
{
if ((x > posX + 2 && x < posX + 70) && (y > posY + 2 + i * 23 && y < posY + 14 + i * 23))
{
if (!editing)
drawTexturedModalRect(posX + 3, posY + 3 + i * 23, 0, ySize, 67, 10);
if (i == selected && !editing)
{
drawTexturedModalRect(posX, posY - 10, 0, ySize + 10, 30, 10);
drawTexturedModalRect(posX + 15, posY - 10, 40, ySize + 10, 30, 10);
fontRendererObj.drawString("Rename", posX + 3, posY - 9, 0xffffff, false);
}else if (!editing
)
{
drawTexturedModalRect(posX, posY - 10, 0, ySize + 10, 30, 10);
drawTexturedModalRect(posX + 10, posY - 10, 40, ySize + 10, 30, 10);
fontRendererObj.drawString("Select", posX + 3, posY - 9, 0xffffff, false);
}
}
}
if (editing)
{
drawTexturedModalRect(posX, posY - 10, 0, ySize + 10, 60, 10);
drawTexturedModalRect(posX + 60, posY - 10, 18, ySize + 10, 60, 10);
fontRendererObj.drawString("Press Enter to save", posX + 3, posY - 9, 0xffffff, false);
}
//Draw Destination data
for (int i = 0; i < 5; i++)
{
if (dSet[i])
{
destValue[i] = "X:" + (int) dPosX[0] + " Y:" + (int) dPosY[0] + " Z:" + (int) dPosZ[0];// + " Dimension:" + world.provider.getProviderForDimension(dPosD[i]).getDimensionName() + "";
}
if (editing && i == selected)
fontRendererObj.drawString(EnumChatFormatting.UNDERLINE + destText[i], posX + 5, posY + 5 + (i * 23), 0xff0000);
else
fontRendererObj.drawString(destText[i], posX + 5, posY + 5 + (i * 23), 0x000000);
fontRendererObj.drawString((dSet[i] ? (EnumChatFormatting.DARK_BLUE + WorldProvider.getProviderForDimension(dPosD[i]).getDimensionName()) : EnumChatFormatting.DARK_RED + "[Unset]"), posX + 73, posY + 5 + (i * 23), 0x000000);
fontRendererObj.drawString("X:" + String.valueOf((int) dPosX[i]), posX + 4, posY + 16 + (i * 23), 0x00b000);
fontRendererObj.drawString("Y:" + String.valueOf((int) dPosY[i]), posX + 50, posY + 16 + (i * 23), 0x00b000);
fontRendererObj.drawString("Z:" + String.valueOf((int) dPosZ[i]), posX + 96, posY + 16 + (i * 23), 0x00b000);
}
fontRendererObj.drawString("Charges: " + fuel, posX + 5, posY + 120, 0x000000);
super.drawScreen(x, y, f);
//initGui();
if (player.getCurrentEquippedItem() == null || !player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)) || player.isDead)
{
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
}
}
@Override
protected void mouseClicked(int x, int y, int button)
{
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
for (int i = 0; i < 5; i++)
{
if ((x > posX + 2 && x < posX + 70) && (y > posY + 2 + i * 23 && y < posY + 14 + i * 23))
{
if (selected != i && !editing)
{
selected = i;
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)))
ItemNBTHelper.setShort(this.player.getCurrentEquippedItem(), "Selection", (short) selected);
DraconicEvolution.channelHandler.sendToServer(new TeleporterPacket((byte) 0, selected));
initGui();
}else if (!editing)
{
editing = true;
}
}
}
super.mouseClicked(x, y, button);
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
buttonList.clear();
int posX = (this.width - xSize) / 2;
int posY = (this.height - ySize) / 2;
updateTeleporter();
buttonList.add(new GuiButton(selected, posX - 25, posY + 3 + selected * 23, 25, 20, "Set"));
buttonList.add(new GuiButton(5, posX + 109, posY + 117, 50, 20, "Add Fuel"));
}
@Override
protected void actionPerformed(GuiButton button)
{
super.actionPerformed(button);
for (int i = 0; i < 5; i++)
{
if (i == button.id)
{
double playerX = player.posX;
double playerY = player.posY - 1.61;
double playerZ = player.posZ;
float yaw = player.rotationYaw;
float pitch = player.rotationPitch;
int dim = player.dimension;
dPosX[i] = playerX;
dPosY[i] = playerY;
dPosZ[i] = playerZ;
dPosD[i] = dim;
dSet[i] = true;
DraconicEvolution.channelHandler.sendToServer(new TeleporterPacket((byte) 1, i, dim, playerX, playerY, playerZ, yaw, pitch));
}
}
if (button.id == 5)
{
if (player.inventory.hasItem(Items.ender_pearl))
{
if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54)))
{
DraconicEvolution.channelHandler.sendToServer(new TeleporterPacket((byte) 6, 1));
this.fuel += ConfigHandler.teleporterUsesPerPearl;
}else if (hasPearls(16))
{
DraconicEvolution.channelHandler.sendToServer(new TeleporterPacket((byte) 6, 16));
this.fuel += ConfigHandler.teleporterUsesPerPearl * 16;
}else
player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfPearls.txt"));
}
else
player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfPearls.txt"));
}
}
public boolean hasPearls(int number)
{
int found = 0;
ItemStack stack;
for (int i = 0; i < player.inventory.getSizeInventory(); i++)
{
stack = player.inventory.getStackInSlot(i);
if (stack != null && stack.isItemEqual(new ItemStack(Items.ender_pearl)))
found += stack.stackSize;
if (found >= number)
return true;
}
return false;
}
@Override
public void keyTyped(char key, int keyN)
{
if ((key == 'e' && !editing) || key == '')
{
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
}
if (editing)
{
String text = destText[selected];
if (keyN == 14)
if (text.length() > 0)
destText[selected] = text.substring(0, text.length() - 1);
else
return;
else if (keyN == 28)
{
editing = false;
DraconicEvolution.channelHandler.sendToServer(new TeleporterStringPacket(selected, destText[selected]));
}
else if (keyN == 42)
return;
else if (destText[selected].length() < 13)
destText[selected] += key;
initGui();
}
}
@Override
public void updateScreen()
{
}
@Override
public boolean doesGuiPauseGame()
{
return false;
}
private void updatePositions(ItemStack teleporter)
{
for (int i = 0; i < 5; i++)
{
this.dPosX[i] = ItemNBTHelper.getDouble(teleporter, "X_" + i, -1);
}
for (int i = 0; i < 5; i++)
{
this.dPosY[i] = ItemNBTHelper.getDouble(teleporter, "Y_" + i, -1);
}
for (int i = 0; i < 5; i++)
{
this.dPosZ[i] = ItemNBTHelper.getDouble(teleporter, "Z_" + i, -1);
}
for (int i = 0; i < 5; i++)
{
this.dPosD[i] = ItemNBTHelper.getIntager(teleporter, "Dimension_" + i, 0);
}
for (int i = 0; i < 5; i++)
{
this.dYaw[i] = ItemNBTHelper.getFloat(teleporter, "Yaw_" + i, 0);
}
for (int i = 0; i < 5; i++)
{
this.dPitch[i] = ItemNBTHelper.getFloat(teleporter, "Pitch_" + i, 0);
}
for (int i = 0; i < 5; i++)
{
this.dSet[i] = ItemNBTHelper.getBoolean(teleporter, "IsSet_" + i, false);
}
this.selected = ItemNBTHelper.getShort(teleporter, "Selection", (short) 0);
this.fuel = ItemNBTHelper.getIntager(teleporter, "Fuel", 0);
}
public void updateNames(ItemStack teleporter)
{
for (int i = 0; i < 5; i++)
{
this.destText[i] = ItemNBTHelper.getString(teleporter, "Dest_" + i, "Destination " + i);
}
}
public void updateTeleporter()
{
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)))
{
this.teleporterItem = player.getCurrentEquippedItem();
updatePositions(teleporterItem);
}
}
}
@@ -0,0 +1,112 @@
package draconicevolution.client.interfaces;
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.ResourceLocation;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.container.ContainerWeatherController;
import draconicevolution.common.core.network.ButtonPacket;
import draconicevolution.common.lib.References;
import draconicevolution.common.tileentities.TileWeatherController;
@SideOnly(Side.CLIENT)
public class GUIWeatherController extends GuiContainer {
public EntityPlayer player;
private TileWeatherController tileWC;
private int charges;
private int guiUpdateTick;
public GUIWeatherController(InventoryPlayer invPlayer, TileWeatherController tileWC) {
super(new ContainerWeatherController(invPlayer, tileWC));
xSize = 176;
ySize = 143;
this.tileWC = tileWC;
this.charges = tileWC.charges;
this.player = invPlayer.player;
}
private static final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/gui/WeatherController.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);
if(charges > 0)
drawTexturedModalRect(guiLeft + 37, guiTop + 4, 0, 143, 37, 38);
}
@Override
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
{
fontRendererObj.drawString("Charges: " + charges, 90, 25, 0x000000);
//drawCenteredString(fontRendererObj, "Charges: " + charges, 117, 25, 0x000000);
drawCenteredString(fontRendererObj, "Weather Controller", xSize/2, -15, 0x2a4ed0);
}
public static final String RAIN_ON_TEXT = "Turn rain on";
public static final String RAIN_OFF_TEXT = "Turn rain off";
public static final String STORM_TEXT = "Thunder Storm";
public static String text;
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
super.initGui();
buttonList.clear();
if (tileWC.mode == 0)
text = RAIN_OFF_TEXT;
else if (tileWC.mode == 1)
text = RAIN_ON_TEXT;
else
text = STORM_TEXT;
//ID
buttonList.add(new GuiButton(0, guiLeft + 85, guiTop , 85, 20, text));
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.id == 0){
DraconicEvolution.channelHandler.sendToServer(new ButtonPacket((byte) 0, true));
if (button.displayString.equals(STORM_TEXT))
button.displayString = RAIN_OFF_TEXT;
else if (button.displayString.equals(RAIN_OFF_TEXT))
button.displayString = RAIN_ON_TEXT;
else
button.displayString = STORM_TEXT;
}
}
@Override
public void updateScreen()
{
guiUpdateTick++;
if (guiUpdateTick >= 10){
initGui();
guiUpdateTick = 0;
}
super.updateScreen();
this.charges = tileWC.charges;
}
}
@@ -0,0 +1,108 @@
package draconicevolution.client.interfaces;
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 draconicevolution.common.container.ContainerGrinder;
import draconicevolution.common.container.ContainerPlayerDetector;
import draconicevolution.common.container.ContainerReader;
import draconicevolution.common.container.ContainerSunDial;
import draconicevolution.common.container.ContainerWeatherController;
import draconicevolution.common.core.utills.InventoryReader;
import draconicevolution.common.tileentities.TileGrinder;
import draconicevolution.common.tileentities.TileParticleGenerator;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
import draconicevolution.common.tileentities.TileSunDial;
import draconicevolution.common.tileentities.TileWeatherController;
public class GuiHandler implements IGuiHandler {
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;
public static final int GUIID_READER = 4;
public static final int GUIID_PARTICLEGEN = 5;
public static final int GUIID_PLAYERDETECTOR = 6;
public GuiHandler() {
NetworkRegistry.INSTANCE.registerGuiHandler(draconicevolution.common.DraconicEvolution.instance, this);
}
@Override
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;
}
return null;
}
@Override
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);
}
}
return null;
}
}
@@ -0,0 +1,94 @@
package draconicevolution.client.interfaces;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
import cpw.mods.fml.common.registry.GameRegistry;
public class SlotItemValid extends Slot {
private Item item;
private boolean fuel = false;
public SlotItemValid(IInventory inventory, int id, int x, int y, Item validItem) {
super(inventory, id, x, y);
this.item = validItem;
}
public SlotItemValid(IInventory inventory, int id, int x, int y, boolean fuel) {
super(inventory, id, x, y);
this.fuel = fuel;
}
@Override
public boolean isItemValid(ItemStack stack)
{
if (fuel)
return getItemBurnTime(stack) > 0;
else
return stack.isItemEqual(new ItemStack(item));
}
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 IIcon getBackgroundIconIndex()
{
IIcon icon = Items.coal.getIconIndex(new ItemStack(Items.coal));
if (false)
return icon;
else
return super.getBackgroundIconIndex();
}*/
}
@@ -0,0 +1,34 @@
package draconicevolution.client.interfaces;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotOpaqueBlock extends Slot {
public SlotOpaqueBlock(IInventory inventory, int id, int x, int y) {
super(inventory, id, x, y);
}
@Override
public boolean isItemValid(ItemStack stack)
{
if (super.isItemValid(stack))
{
Block block = Block.getBlockFromItem(stack.getItem());
return block.isOpaqueCube() && block.renderAsNormalBlock();
}
return false;
}
@Override
public int getSlotStackLimit()
{
return 1;
}
}
@@ -0,0 +1,140 @@
package draconicevolution.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class BowRenderer implements IItemRenderer {
//private RenderManager renderManager;
private Minecraft mc;
//private TextureManager texturemanager;
public BowRenderer() {
//this.renderManager = RenderManager.instance;
this.mc = Minecraft.getMinecraft();
//this.texturemanager = this.mc.getTextureManager();
}
@Override
//HandleRenderType lets forge know if it will render the item in the requested view.
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
//You can remove everything after "EQUIPPED" if you only want this class to render the third person item.
return type == ItemRenderType.EQUIPPED;// || type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
//RenderHelpers I don't fully understand, I'd assume they are modifiers, but I've never looked into it.
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return false;
}
@Override
//This function decides what to do in rendering an item, whether it's first or third person.
//Credit to SanAndreasP on minecraftforge forums for this code.
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
EntityClientPlayerMP entity = (EntityClientPlayerMP) data[1];
//ItemRenderer irInstance = this.mc.entityRenderer.itemRenderer;
GL11.glPopMatrix(); // 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);
GL11.glScalef(f2, f2, f2);
GL11.glTranslatef(-0.25F, -0.1875F, 0.1875F);
// render the item as 'real' bow
//This is pulled from RenderBiped
float f3 = 0.625F;
GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
GL11.glScalef(f3, -f3, f3);
GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
this.renderItem(entity, item, 0);
GL11.glPopMatrix();
}
GL11.glPushMatrix(); // 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)
{
{
//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) {
GL11.glPopMatrix();
return;
}
TextureManager texturemanager = this.mc.getTextureManager();
texturemanager.getTexture(texturemanager.getResourceLocation(par2ItemStack.getItemSpriteNumber()));
Tessellator tessellator = Tessellator.instance;
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
float f4 = 0.0F;
float f5 = 0.3F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslatef(-f4, -f5, 0.0F);
float f6 = 1.5F;
GL11.glScalef(f6, f6, f6);
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)) {
GL11.glDepthFunc(GL11.GL_EQUAL);
GL11.glDisable(GL11.GL_LIGHTING);
texturemanager.bindTexture(new ResourceLocation("textures/misc/enchanted_item_glint.png"));
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
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;
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;
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);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDepthFunc(GL11.GL_LEQUAL);
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
}
}
@@ -0,0 +1,101 @@
package draconicevolution.client.render;
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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.lib.References;
public class CustomParticle extends EntityFX
{
public int red = 0;
public int green = 0;
public int blue = 0;
public int maxAge = 0;
public int fadeTime = 0;
public int fadeLength = 0;
public float gravity = 0F;
public CustomParticle(World world, double spawnX, double spawnY, double spawnZ, float spawnMotionX, float spawnMotionY, float spawnMotionZ, float scale, boolean canCollide, int index) {
super(world, spawnX, spawnY, spawnZ, 0.0D, 0.0D, 0.0D);
this.motionX = spawnMotionX;//initial motion value X
this.motionY = spawnMotionY;//initial motion value Y
this.motionZ = spawnMotionZ;//initial motion value Z
this.particleTextureIndexX = index - 1; //
this.particleTextureIndexY = 0;
this.particleScale = scale;
this.noClip = !canCollide;
}
@Override
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.maxAge)
{
this.particleAlpha = (float) ((float) fadeTime) / ((float) fadeLength);
if (fadeTime <= 0)
this.setDead();
fadeTime--;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);// also important if you want your particle to move
//this.motionX = motionX * (1 - (worldObj.rand.nextFloat() / 10F));
this.motionY = motionY - (gravity / 100F);
//this.motionZ = motionZ * (1 - (worldObj.rand.nextFloat() / 10F));
}
@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 = (float)this.particleTextureIndexX / 8.0F;
float maxU = minU + 0.124F;
float minV = (float)this.particleTextureIndexY / 8.0F;
float maxV = 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(red, green, blue, (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();
}
}
@@ -0,0 +1,109 @@
package draconicevolution.client.render;
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;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.lib.References;
public class DistortionParticle extends EntityFX
{
double originalX;
double originalZ;
public DistortionParticle(World par1World, double par2, double par4, double par6, float par8, float par9, float par10, float scale) {
this(par1World, par2, par4, par6, 1.0F, par8, par9, par10, scale);
}
public DistortionParticle(World world, double par2, double par4, double par6, float par8, float par9, float par10, float par11, float scale) {
super(world, par2, par4, par6, 0.0D, 0.0D, 0.0D);
this.motionX = par9;//initial motion value X
this.motionY = par10;//initial motion value Y
this.motionZ = par11;//initial motion value Z
this.originalX = par9;
this.originalZ = par11;
if (par9 == 0.0F)
{
par9 = 1.0F;
}
//float var12 = (float) Math.random() * 0.4F + 0.6F;
this.particleTextureIndexX = 0; //
this.particleTextureIndexY = 0;
this.particleRed = 0.7F;//RGB of your particle
this.particleGreen = 0.8F;
this.particleBlue = 1.0F;
//this.particleScale *= 0.05f + world.rand.nextFloat()*0.005;
//this.particleScale *= par8;
this.particleScale = scale;
this.particleMaxAge = 40 + world.rand.nextInt(40);//how soon the particle dies. You can use randomizer for this
this.noClip = true;//does your particle collide with blocks?
}
@Override
public void onUpdate()
{
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if (this.particleAge++ >= this.particleMaxAge)
{
this.setDead();//make sure to have this
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);// also important if you want your particle to move
this.motionX = motionX * (1 - (worldObj.rand.nextFloat() / 10F));
this.motionY = motionY * (1 - (worldObj.rand.nextFloat() / 10F));
this.motionZ = motionZ * (1 - (worldObj.rand.nextFloat() / 10F));
this.particleAlpha = (1F - ((float)this.particleAge / (float)this.particleMaxAge)) * 0.5F;
}
@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();
}
}
@@ -0,0 +1,47 @@
package draconicevolution.client.render;
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 ItemParticleGenRenderer implements IItemRenderer
{
TileEntitySpecialRenderer render;
private TileEntity dummytile;
public ItemParticleGenRenderer(TileEntitySpecialRenderer render, TileEntity 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 == IItemRenderer.ItemRenderType.ENTITY)
GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
this.dummytile.xCoord = 0;
this.dummytile.yCoord = 0;
this.dummytile.zCoord = 0;
this.dummytile.setWorldObj(Minecraft.getMinecraft().theWorld);
this.render.renderTileEntityAt(this.dummytile, 0.0D, 0.0D, 0.0D, 0.0F);
}
}
@@ -0,0 +1,248 @@
package draconicevolution.client.render;
import net.minecraft.block.Block;
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.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import draconicevolution.common.lib.References;
import draconicevolution.common.tileentities.TileParticleGenerator;
public class ParticleGenRenderer extends TileEntitySpecialRenderer
{
private final ResourceLocation texture = new ResourceLocation(References.MODID.toLowerCase(), "textures/models/ParticleGenTextureSheet.png");
private float pxl = 1F / 64;
@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
TileParticleGenerator tileEntityGen = (TileParticleGenerator) tileEntity;
renderBlock(tileEntityGen, 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(TileParticleGenerator tl, World world, int x, int y, int z, Block block)
{
Tessellator tessellator = Tessellator.instance;
bindTexture(texture);
boolean inverted = tl.inverted;
tessellator.startDrawingQuads();
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);
//tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1F);
{//Draw Corners
float f = 0.4F;
drawCornerCube(tessellator, f, f, f, 1F - f, inverted);
drawCornerCube(tessellator, f, -f, f, 1F - f, inverted);
drawCornerCube(tessellator, -f, f, -f, 1F - f, inverted);
drawCornerCube(tessellator, -f, -f, -f, 1F - f, inverted);
drawCornerCube(tessellator, -f, f, f, 1F - f, inverted);
drawCornerCube(tessellator, f, f, -f, 1F - f, inverted);
drawCornerCube(tessellator, f, -f, -f, 1F - f, inverted);
drawCornerCube(tessellator, -f, -f, f, 1F - f, inverted);
}
{//Draw Beams
float f = 0.45F;
float f2 = 0.4F;
drawBeamX(tessellator, 0, f2, f2, 1F - f);
drawBeamX(tessellator, 0, -f2, f2, 1F - f);
drawBeamX(tessellator, 0, f2, -f2, 1F - f);
drawBeamX(tessellator, 0, -f2, -f2, 1F - f);
drawBeamY(tessellator, f2, 0, f2, 1F - f);
drawBeamY(tessellator, -f2, 0, f2, 1F - f);
drawBeamY(tessellator, f2, 0, -f2, 1F - f);
drawBeamY(tessellator, -f2, 0, -f2, 1F - f);
drawBeamZ(tessellator, f2, f2, 0, 1F - f);
drawBeamZ(tessellator, -f2, f2, 0, 1F - f);
drawBeamZ(tessellator, f2, -f2, 0, 1F - f);
drawBeamZ(tessellator, -f2, -f2, 0, 1F - f);
}
tessellator.draw();
}
private void drawCornerCube(Tessellator tess, float x, float y, float z, float FP, boolean inverted)
{
float srcXMin = inverted ? 38F * pxl: 32F * pxl;
float srcYMin = 0F;
float srcXMax = inverted ? 44F * pxl : 38F * pxl;
float srcYMax = 6 * pxl;
//float FP = 0.6F; //Scale
float FN = 1F - FP;
//X+
tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMin, srcYMax);
//X-
tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMax, srcYMax);
tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMax);
//Y+
tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMin, srcYMax);
//Y-
tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMax);
//Z+
tess.addVertexWithUV(FP + x, FN + y, FP + z, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(FN + x, FN + y, FP + z, srcXMin, srcYMax);
//Z-
tess.addVertexWithUV(FN + x, FN + y, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, FN + z, srcXMax, srcYMax);
tess.addVertexWithUV(FP + x, FN + y, FN + z, srcXMin, srcYMax);
}
private void drawBeamX(Tessellator tess, float x, float y, float z, float FP)
{
float srcXMin = 0;
float srcYMin = 0F;
float srcXMax = 32F * pxl;
float srcYMax = 4 * pxl;
float FN = 1F - FP;
float XX = 0.9F;
float XM = 0.1F;
//Y+
tess.addVertexWithUV(XM, FP + y, FN + z, srcXMin, srcYMax);
tess.addVertexWithUV(XM, FP + y, FP + z, srcXMin, srcYMin);
tess.addVertexWithUV(XX, FP + y, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(XX, FP + y, FN + z, srcXMax, srcYMax);
//Y-
tess.addVertexWithUV(XM, FN + y, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(XX, FN + y, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(XX, FN + y, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(XM, FN + y, FP + z, srcXMin, srcYMax);
//Z+
tess.addVertexWithUV(XX, FN + y, FP + z, srcXMin, srcYMax);
tess.addVertexWithUV(XX, FP + y, FP + z, srcXMin, srcYMin);
tess.addVertexWithUV(XM, FP + y, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(XM, FN + y, FP + z, srcXMax, srcYMax);
//Z-
tess.addVertexWithUV(XM, FN + y, FN + z, srcXMin, srcYMax);
tess.addVertexWithUV(XM, FP + y, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(XX, FP + y, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(XX, FN + y, FN + z, srcXMax, srcYMax);
}
private void drawBeamY(Tessellator tess, float x, float y, float z, float FP)
{
float srcXMin = 0;
float srcYMin = 0F;
float srcXMax = 32F * pxl;
float srcYMax = 4 * pxl;
float FN = 1F - FP;
float XX = 0.9F;
float XM = 0.1F;
//X+
tess.addVertexWithUV(FP + x, XM, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, XX, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, XX, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(FP + x, XM, FP + z, srcXMin, srcYMax);
//X-
tess.addVertexWithUV(FN + x, XM, FP + z, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, XX, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(FN + x, XX, FN + z, srcXMax, srcYMax);
tess.addVertexWithUV(FN + x, XM, FN + z, srcXMin, srcYMax);
//Z+
tess.addVertexWithUV(FP + x, XM, FP + z, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, XX, FP + z, srcXMax, srcYMin);
tess.addVertexWithUV(FN + x, XX, FP + z, srcXMax, srcYMax);
tess.addVertexWithUV(FN + x, XM, FP + z, srcXMin, srcYMax);
//Z-
tess.addVertexWithUV(FN + x, XM, FN + z, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, XX, FN + z, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, XX, FN + z, srcXMax, srcYMax);
tess.addVertexWithUV(FP + x, XM, FN + z, srcXMin, srcYMax);
}
private void drawBeamZ(Tessellator tess, float x, float y, float z, float FP)
{
float srcXMin = 0;
float srcYMin = 0F;
float srcXMax = 32F * pxl;
float srcYMax = 4 * pxl;
float FN = 1F - FP;
float XX = 0.9F;
float XM = 0.1F;
//X+
tess.addVertexWithUV(FP + x, FN + y, XM, srcXMin, srcYMax);
tess.addVertexWithUV(FP + x, FP + y, XM, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, XX, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, FN + y, XX, srcXMax, srcYMax);
//X-
tess.addVertexWithUV(FN + x, FN + y, XX, srcXMin, srcYMax);
tess.addVertexWithUV(FN + x, FP + y, XX, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, XM, srcXMax, srcYMin);
tess.addVertexWithUV(FN + x, FN + y, XM, srcXMax, srcYMax);
//Y+
tess.addVertexWithUV(FN + x, FP + y, XM, srcXMin, srcYMin);
tess.addVertexWithUV(FN + x, FP + y, XX, srcXMax, srcYMin);
tess.addVertexWithUV(FP + x, FP + y, XX, srcXMax, srcYMax);
tess.addVertexWithUV(FP + x, FP + y, XM, srcXMin, srcYMax);
//Y-
tess.addVertexWithUV(FN + x, FN + y, XM, srcXMin, srcYMax);
tess.addVertexWithUV(FP + x, FN + y, XM, srcXMin, srcYMin);
tess.addVertexWithUV(FP + x, FN + y, XX, srcXMax, srcYMin);
tess.addVertexWithUV(FN + x, FN + y, XX, srcXMax, srcYMax);
}
}
@@ -0,0 +1,79 @@
package draconicevolution.common;
import java.util.Arrays;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraft.creativetab.CreativeTabs;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.FMLEventChannel;
import draconicevolution.client.creativetab.TolkienTab;
import draconicevolution.common.core.network.ChannelHandler;
import draconicevolution.common.core.proxy.CommonProxy;
import draconicevolution.common.lib.References;
@Mod(modid = References.MODID, name = References.MODNAME, version = References.VERSION)
public class DraconicEvolution {
@Instance
public static DraconicEvolution instance;
@SidedProxy(clientSide = References.CLIENTPROXYLOCATION, serverSide = References.COMMONPROXYLOCATION)
public static CommonProxy proxy;
private static CreativeTabs tolkienTabToolsWeapons = new TolkienTab(CreativeTabs.getNextID(), References.MODID, "toolsAndWeapons");
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 boolean debug = false;
public static final Logger logger = LogManager.getLogger("DraconicEvolution");
public DraconicEvolution()
{
//logger.info("This is Draconic Evolution");
}
@Mod.EventHandler
public static void preInit(final FMLPreInitializationEvent event)
{if(debug)
System.out.println("preInit()" + event.getModMetadata().name);
event.getModMetadata().autogenerated = false;
event.getModMetadata().credits = "Many Online tutorials";
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";
proxy.preInit(event);
}
@Mod.EventHandler
public void init(final FMLInitializationEvent event)
{if(debug)
System.out.println("init()");
proxy.init(event);
}
@Mod.EventHandler
public void postInit(final FMLPostInitializationEvent event)
{if(debug)
System.out.println("postInit()");
proxy.postInit(event);
}
public static CreativeTabs getCreativeTab(int tab)
{
return tab == 1 ? tolkienTabToolsWeapons : tolkienTabBlocksItems;
}
}
@@ -0,0 +1,95 @@
package draconicevolution.common.blocks;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TileSunDial;
public class BlockSunDial extends TolkienBlock {
//@SideOnly(Side.CLIENT)
public IIcon icon_front;
public IIcon icon_front_active;
public IIcon icon_side;
public boolean blockState = true;
public BlockSunDial() {
this.setBlockName(Strings.blockSunDialName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setStepSound(soundTypeStone);
this.setHardness(1f);
this.setResistance(200.0f);
ModBlocks.register(this);
}
@Override
public boolean hasTileEntity(final int meta)
{
return true;
}
@Override
public TileEntity createTileEntity(final World world, final int meta)
{
return new TileSunDial();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister iconRegister)
{
icon_front = iconRegister.registerIcon(References.RESOURCESPREFIX + "sun_dial_front");
icon_front_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/sun_dial_front_active");
icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(final int side, final int meta)
{
if (side == 0 || side == 1 || side == 4 || side == 5)
return icon_side;
else
return icon_front;
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
TileEntity tile = world.getTileEntity(x, y, z);
IIcon front = null;
if (tile != null && tile instanceof TileSunDial)
front = ((TileSunDial)tile).running == true ? icon_front_active : icon_front;
if (side == 0 || side == 1 || side == 4 || side == 5)
return icon_side;
else
return front;
}
@Override
public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block)
{
//if (!world.isRemote) {
//world.setBlock(x, y, z, ModBlocks.sunDial, 0, 2);
//}
}
@Override
public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int par1, final float par2, final float par3, final float par4)
{
if (!world.isRemote) {
//FMLNetworkHandler.openGui(entityPlayer, DraconicEvolution.instance, 1, world, x, y, z);
}
return true;
}
}
@@ -0,0 +1,204 @@
package draconicevolution.common.blocks;
import java.util.List;
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.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.world.IBlockAccess;
import net.minecraft.world.World;
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 draconicevolution.client.interfaces.GuiHandler;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TileWeatherController;
public class BlockWeatherController extends BlockContainer {
public boolean blockState = true;
public IIcon icon_top;
public IIcon icon_bottom;
public IIcon icon_side_rain_off;
public IIcon icon_side_rain_on;
public IIcon icon_side_thunder_off;
public IIcon icon_side_thunder_on;
public IIcon icon_side_sun_on;
public IIcon icon_side_sun_off;
public BlockWeatherController() {
super(Material.rock);
this.setBlockName(Strings.blockWeatherControllerName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setStepSound(soundTypeStone);
this.setHardness(1f);
this.setResistance(200.0f);
GameRegistry.registerBlock(this, this.getUnlocalizedName());
}
@Override
public boolean hasTileEntity(final int meta)
{
return true;
}
@Override
public String getUnlocalizedName()
{
return String.format("tile.%s", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
public String getUnwrappedUnlocalizedName(final String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister iconRegister)
{
icon_top = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weather_controller_top");
icon_bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side");
icon_side_rain_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weather_controller_rain");
icon_side_rain_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_rain_active");
icon_side_thunder_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_thunderstorm");
icon_side_thunder_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_thunderstorm_active");
icon_side_sun_off = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_sun");
icon_side_sun_on = iconRegister.registerIcon(References.RESOURCESPREFIX + "weather_controller/weatherController_sun_active");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
IIcon icon_side = null;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileWeatherController)
{
if (((TileWeatherController)tile).charges > 0)
{
if (((TileWeatherController)tile).mode == 0)
icon_side = icon_side_sun_on;
else if (((TileWeatherController)tile).mode == 1)
icon_side = icon_side_rain_on;
else
icon_side = icon_side_thunder_on;
}else{
if (((TileWeatherController)tile).mode == 0)
icon_side = icon_side_sun_off;
else if (((TileWeatherController)tile).mode == 1)
icon_side = icon_side_rain_off;
else
icon_side = icon_side_thunder_off;
}
}
if (side > 1)
return icon_side;
else if (side == 0)
return icon_bottom;
else
return icon_top;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if (side > 1)
return icon_side_sun_on;
else if (side == 0)
return icon_bottom;
else
return icon_top;
}
@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, 0));
}
@Override
public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer entityPlayer, final int par1, final float par2, final float par3, final float par4)
{
if (!world.isRemote) {
FMLNetworkHandler.openGui(entityPlayer, DraconicEvolution.instance, GuiHandler.GUIID_WEATHER_CONTROLLER, world, x, y, z);
}
return true;
}
public String getUnlocalizedWeatherControllerName()
{
return String.format("tile.%s%s", References.RESOURCESPREFIX, "weatherController/weatherController");
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
return new TileWeatherController();
}
@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 onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
TileWeatherController tile = (TileWeatherController) world.getTileEntity(x, y, z);
if (tile != null){
if(!tile.lastTickInput){
if (world.isBlockIndirectlyGettingPowered(x, y, z)){
tile.activate();
}
}
tile.lastTickInput = world.isBlockIndirectlyGettingPowered(x, y, z);
}
}
}
@@ -0,0 +1,78 @@
package draconicevolution.common.blocks;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.util.IIcon;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconiumOre extends TolkienBlock {
public IIcon icon;
public IIcon iconEnd;
public IIcon iconNether;
protected DraconiumOre() {
super(Material.rock);
this.setBlockName(Strings.draconiumOreName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setHardness(5f);
this.setResistance(20.0f);
GameRegistry.registerBlock(this, this.getUnlocalizedName());
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister iconRegister)
{
icon = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore");
iconEnd = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_end");
iconNether = iconRegister.registerIcon(References.RESOURCESPREFIX + "animated/draconium_ore_nether");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
int dim = Minecraft.getMinecraft().theWorld.provider.dimensionId;
if (dim == -1)
return iconNether;
else if (dim == 0)
return icon;
else
return iconEnd;
}
@Override
public int quantityDropped(final Random random)
{
return 1 + random.nextInt(2);
}
@Override
public int quantityDroppedWithBonus(final int number, final Random random)
{
return this.quantityDropped(random) + random.nextInt(number + 1);
}
@Override
protected boolean canSilkHarvest()
{
return true;
}
@Override
public Item getItemDropped(final int p_149650_1_, final Random p_149650_2_, final int p_149650_3_)
{
return ModItems.draconiumDust;
}
}
@@ -0,0 +1,264 @@
package draconicevolution.common.blocks;
import java.util.List;
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 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 draconicevolution.client.interfaces.GuiHandler;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TileGrinder;
public class Grinder 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 Grinder() {
super(Material.rock);
this.setBlockName(Strings.grinderName);
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/grinder_front_active");
icon_front_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "grinder_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 damageDropped(int p_149692_1_)
{
return 3;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
TileGrinder tile = (TileGrinder) world.getTileEntity(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
IIcon back;
IIcon front;
if (!tile.disabled && tile.energy >= 50)
{
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 TileGrinder();
}
@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_GRINDER, 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);
}
}
@@ -0,0 +1,43 @@
package draconicevolution.common.blocks;
import net.minecraft.block.Block;
import cpw.mods.fml.common.registry.GameRegistry;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.handler.ConfigHandler;
public class ModBlocks {
public static Block xRayBlock;
public static Block weatherController;
public static Block sunDial;
public static Block draconiumOre;
public static Block testBlock;
public static Block grinder;
public static Block potentiometer;
public static Block rainSensor;
public static Block particleGenerator;
public static Block playerDetector;
public static Block playerDetectorAdvanced;
public static void init()
{
if(ConfigHandler.disableXrayBlock < 2) xRayBlock = new XRayBlock();
weatherController = new BlockWeatherController();
if(ConfigHandler.disableSunDial < 2) sunDial = new BlockSunDial();
draconiumOre = new DraconiumOre();
grinder = new Grinder();
potentiometer = new Potentiometer();
rainSensor = new RainSensor();
particleGenerator = new ParticleGenerator();
playerDetector = new PlayerDetector();
playerDetectorAdvanced = new PlayerDetectorAdvanced();
if(DraconicEvolution.debug) testBlock = new TestBlock();
//testBlock = new TestBlock();
}
public static void register(final TolkienBlock block)
{
GameRegistry.registerBlock(block, block.getUnwrappedUnlocalizedName(block.getUnlocalizedName()));
}
}
@@ -0,0 +1,151 @@
package draconicevolution.common.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
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 draconicevolution.client.interfaces.GuiHandler;
import draconicevolution.client.render.CustomParticle;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.handler.ParticleHandler;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TileParticleGenerator;
public class ParticleGenerator extends Block
{
public static Block instance;
public ParticleGenerator() {
super(Material.rock);
this.setBlockName(Strings.particleGeneratorName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setStepSound(soundTypeStone);
this.setHardness(1f);
this.setResistance(200.0f);
this.setLightOpacity(0);
GameRegistry.registerBlock(this, this.getUnlocalizedName());
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
if (player.isSneaking())
{
TileEntity tile = world.getTileEntity(x, y, z);
TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null;
if (gen != null)
{
gen.toggleInverted();
}
} else
FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_PARTICLEGEN, world, x, y, z);
return true;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block block)
{
TileEntity tile = world.getTileEntity(x, y, z);
TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator) tile : null;
if (gen != null)
{
gen.signal = world.isBlockIndirectlyGettingPowered(x, y, z);
world.markBlockForUpdate(x, y, z);
}
}
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return true;
}
@SideOnly(Side.CLIENT)
@Override
public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int meta)
{
if (world.isRemote)
{
Random rand = world.rand;
float modifier = 0.1F;
float SCALE = 1;
double spawnX = x + 0.5D;
double spawnY = y + 0.5D;
double spawnZ = z + 0.5D;
for (int i = 0; i < 100; i++)
{
float MX = modifier - ((2f*modifier) * rand.nextFloat());
float MY = modifier - ((2f*modifier) * rand.nextFloat());
float MZ = modifier - ((2f*modifier) * rand.nextFloat());
{
CustomParticle particle = new CustomParticle(world, spawnX, spawnY, spawnZ, MX, MY, MZ, SCALE, false, 1);
particle.red = rand.nextInt(255);
particle.green = rand.nextInt(255);
particle.blue = rand.nextInt(255);
particle.maxAge = rand.nextInt(10);
particle.fadeTime = 20;
particle.fadeLength = 20;
particle.gravity = 0F;
ParticleHandler.spawnCustomParticle(particle);
}
}
}
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean hasTileEntity(int meta)
{
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata)
{
return new TileParticleGenerator();
}
}
@@ -0,0 +1,144 @@
package draconicevolution.common.blocks;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TilePlayerDetector;
public class PlayerDetector extends TolkienBlock
{
IIcon side_inactive;
IIcon side_active;
IIcon top;
IIcon bottom;
protected PlayerDetector() {
this.setBlockName(Strings.playerDetectorName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setStepSound(soundTypeStone);
this.setHardness(1f);
this.setResistance(200.0f);
ModBlocks.register(this);
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
side_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "player_detector_side_inactive");
side_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "player_detector_side_active");
top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0");
bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side");
}
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
IIcon side_icon;
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TilePlayerDetector && ((TilePlayerDetector)tile).output)
side_icon = side_active;
else
side_icon = side_inactive;
if (side == 0)
return bottom;
else if (side == 1)
return top;
else
return side_icon;
}
@Override
public IIcon getIcon(int side, int meta)
{
if (side == 0)
return bottom;
else if (side == 1)
return top;
else
return side_active;
}
@Override
public boolean hasTileEntity(int meta)
{
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata)
{
return new TilePlayerDetector();
}
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta)
{
TileEntity te = world.getTileEntity(x, y, z);
TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null;
if(detector != null)
return detector.output ? 15 : 0;
else
return 0;
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta)
{
TileEntity te = world.getTileEntity(x, y, z);
TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null;
if(detector != null)
return detector.output ? 15 : 0;
else
return 0;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
TileEntity te = world.getTileEntity(x, y, z);
TilePlayerDetector detector = (te != null && te instanceof TilePlayerDetector) ? (TilePlayerDetector) te : null;
if(detector != null)
{
int range = detector.getRange();
if(player.isSneaking())
{
range--;
}else
{
range++;
}
if (range > 10)
range = 1;
if (range < 1)
range = 10;
detector.setRange(range);
if (world.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.range.txt").appendSibling(new ChatComponentText(" " + range)));
}
return true;
}
}
@@ -0,0 +1,140 @@
package draconicevolution.common.blocks;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import draconicevolution.client.interfaces.GuiHandler;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TilePlayerDetector;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
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.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class PlayerDetectorAdvanced extends BlockContainer
{
IIcon side_inactive;
IIcon side_active;
IIcon top;
IIcon bottom;
protected PlayerDetectorAdvanced() {
super(Material.iron);
this.setBlockName(Strings.playerDetectorAdvancedName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setStepSound(soundTypeStone);
this.setHardness(1f);
this.setResistance(200.0f);
GameRegistry.registerBlock(this, this.getUnlocalizedName());
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
side_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "advanced_player_detector_side_inactive");
side_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "advanced_player_detector_side_active");
top = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_top_0");
bottom = iconRegister.registerIcon(References.RESOURCESPREFIX + "machine_side");
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
{
IIcon side_icon;
TileEntity tile = world.getTileEntity(x, y, z);
TilePlayerDetectorAdvanced detector = (tile != null && tile instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced)tile : null;
if (detector != null && detector.getStackInSlot(0) != null)
{
ItemStack stack = detector.getStackInSlot(0);
Block block = Block.getBlockFromItem(stack.getItem());
if (block != null && block.renderAsNormalBlock())
return block.getIcon(side, stack.getItemDamage());
}else
{
if (detector != null && detector.output)
side_icon = side_active;
else
side_icon = side_inactive;
if (side == 0)
return bottom;
else if (side == 1)
return top;
else
return side_icon;
}
return null;
}
@Override
public IIcon getIcon(int side, int meta)
{
if (side == 0)
return bottom;
else if (side == 1)
return top;
else
return side_active;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
return new TilePlayerDetectorAdvanced();
}
@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_)
{
if (!world.isRemote) {
FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_PLAYERDETECTOR, world, x, y, z);
}
return true;
}
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta)
{
TileEntity te = world.getTileEntity(x, y, z);
TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null;
if(detector != null)
return detector.output ? 15 : 0;
else
return 0;
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int meta)
{
TileEntity te = world.getTileEntity(x, y, z);
TilePlayerDetectorAdvanced detector = (te != null && te instanceof TilePlayerDetectorAdvanced) ? (TilePlayerDetectorAdvanced) te : null;
if(detector != null)
return detector.output ? 15 : 0;
else
return 0;
}
}
@@ -0,0 +1,355 @@
package draconicevolution.common.blocks;
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 net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
import draconicevolution.common.tileentities.TilePotentiometer;
public class Potentiometer extends TolkienBlock
{
IIcon icons[] = new IIcon[16];
protected Potentiometer() {
super(Material.circuits);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setHardness(0.3f);
this.setResistance(0.1f);
this.setLightLevel(0.3F);
this.setBlockName(Strings.potentiometerName);
ModBlocks.register(this);
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
return null;
}
@Override
public boolean hasTileEntity(int metadata)
{
return true;
}
@Override
public TileEntity createTileEntity(World world, int metadata)
{
return new TilePotentiometer();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister iconRegister)
{
for (int i = 0; i < 16; i++)
{
icons[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + "potentiometer/potentiometer_" + i);
}
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int meta)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TilePotentiometer)
return icons[((TilePotentiometer)tile).power];
else return null;
}
@Override
public IIcon getIcon(int side, int meta)
{
return icons[0];
}
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z)
{
return (world.isSideSolid(x, y + 1, z, UP)) || (world.isSideSolid(x, y - 1, z, DOWN)) || (world.isSideSolid(x - 1, y, z, EAST)) || (world.isSideSolid(x + 1, y, z, WEST)) || (world.isSideSolid(x, y, z - 1, SOUTH)) || (world.isSideSolid(x, y, z + 1, NORTH));
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
{
int l = world.getBlockMetadata(x, y, z);
this.setBounds(l);
}
private void setBounds(int meta)
{
int j = meta;
float f = 0.206F;
float f1 = 0.796F;
float f2 = 0.296F;
float f3 = 0.125F;
if (j == 6)
{
this.setBlockBounds(0.5F - f2, 0.0F, 0.5F - f2, 0.5F + f2, f3, 0.5F + f2);
}
if (j == 1)
{
this.setBlockBounds(0.0F, f, 0.5F - f2, f3, f1, 0.5F + f2);
} else if (j == 2)
{
this.setBlockBounds(1.0F - f3, f, 0.5F - f2, 1.0F, f1, 0.5F + f2);
} else if (j == 3)
{
this.setBlockBounds(0.5F - f2, f, 0.0F, 0.5F + f2, f1, f3);
} else if (j == 4)
{
this.setBlockBounds(0.5F - f2, f, 1.0F - f3, 0.5F + f2, f1, 1.0F);
}
if (j == 5)
{
this.setBlockBounds(0.5F - f2, 1.0F - f3, 0.5F - f2, 0.5F + f2, 1.0F, 0.5F + f2);
}
}
@Override
public void setBlockBoundsForItemRender()
{
float f = 0.206F;
float f1 = 0.796F;
float f2 = 0.296F;
float f3 = 0.125F;
this.setBlockBounds(0.5F - f2, f, 0.3F, 0.5F + f2, f1, f3 + 0.3F);
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
int j1 = world.getBlockMetadata(x, y, z);
int k1 = j1 & 8;
j1 &= 7;
ForgeDirection dir = ForgeDirection.getOrientation(side);
if (dir == NORTH && world.isSideSolid(x, y, z + 1, NORTH))
{
j1 = 4;
} else if (dir == SOUTH && world.isSideSolid(x, y, z - 1, SOUTH))
{
j1 = 3;
} else if (dir == WEST && world.isSideSolid(x + 1, y, z, WEST))
{
j1 = 2;
} else if (dir == EAST && world.isSideSolid(x - 1, y, z, EAST))
{
j1 = 1;
} else if (dir == UP && world.isSideSolid(x, y - 1, z, UP))
{
j1 = 6;
} else if (dir == DOWN && world.isSideSolid(x, y + 1, z, DOWN))
{
j1 = 5;
} else
{
j1 = this.fundSolidSide(world, x, y, z);
}
return j1 + k1;
}
private int fundSolidSide(World world, int x, int y, int z)
{
if (world.isSideSolid(x, y - 1, z, UP))
return 6;
if (world.isSideSolid(x - 1, y, z, EAST))
return 1;
if (world.isSideSolid(x + 1, y, z, WEST))
return 2;
if (world.isSideSolid(x, y, z - 1, SOUTH))
return 3;
if (world.isSideSolid(x, y, z + 1, NORTH))
return 4;
if (world.isSideSolid(x, y + 1, z, UP))
return 5;
return 1;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
if (this.isLocationStillValid(world, x, y, z))
{
int l = world.getBlockMetadata(x, y, z) & 7;
boolean flag = false;
if (!world.isSideSolid(x, y - 1, z, UP) && l == 6)
{
flag = true;
}
if (!world.isSideSolid(x - 1, y, z, EAST) && l == 1)
{
flag = true;
}
if (!world.isSideSolid(x + 1, y, z, WEST) && l == 2)
{
flag = true;
}
if (!world.isSideSolid(x, y, z - 1, SOUTH) && l == 3)
{
flag = true;
}
if (!world.isSideSolid(x, y, z + 1, NORTH) && l == 4)
{
flag = true;
}
if (!world.isSideSolid(x, y + 1, z, DOWN) && l == 5)
{
flag = true;
}
if (flag)
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
}
}
}
private boolean isLocationStillValid(World world, int x, int y, int z)
{
if (!this.canPlaceBlockAt(world, x, y, z))
{
this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
world.setBlockToAir(x, y, z);
return false;
} else
{
return true;
}
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta)
{
if (meta > 0)
{
int i1 = meta;
this.updateBlocks(world, x, y, z, i1);
}
super.breakBlock(world, x, y, z, block, meta);
}
private void updateBlocks(World world, int x, int y, int z, int meta)
{
world.notifyBlocksOfNeighborChange(x, y, z, this);
if (meta == 1)
{
world.notifyBlocksOfNeighborChange(x - 1, y, z, this);
}
else if (meta == 2)
{
world.notifyBlocksOfNeighborChange(x + 1, y, z, this);
}
else if (meta == 3)
{
world.notifyBlocksOfNeighborChange(x, y, z - 1, this);
}
else if (meta == 4)
{
world.notifyBlocksOfNeighborChange(x, y, z + 1, this);
}
else if (meta == 5)
{
world.notifyBlocksOfNeighborChange(x, y + 1, z, this);
}
else if (meta == 6)
{
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
}
else
{
world.notifyBlocksOfNeighborChange(x, y - 1, z, this);
}
}
//#################################LOGIC##################################//
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{
TilePotentiometer tile = (TilePotentiometer) world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TilePotentiometer)
{
if (!player.isSneaking())
((TilePotentiometer)tile).increasePower();
else
((TilePotentiometer)tile).decreasePower();
if (world.isRemote)
player.addChatMessage(new ChatComponentText(String.valueOf(((TilePotentiometer)tile).power)));
world.markBlockRangeForRenderUpdate(x, y, z, x, y, z);
}
else
System.out.println("Invalid tile");
return true;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TilePotentiometer)
return ((TilePotentiometer) tile).power;
else
return 0;
}
@Override
public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side)
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TilePotentiometer)
return ((TilePotentiometer) tile).power;
else
return 0;
}
}
@@ -0,0 +1,132 @@
package draconicevolution.common.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class RainSensor extends TolkienBlock
{
IIcon icon_inactive;
IIcon icon_active;
IIcon icon_side;
protected RainSensor() {
super(Material.iron);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setBlockBounds(0, 0, 0, 1, 0.125F, 1);
this.setHardness(5f);
this.setResistance(10f);
this.setTickRandomly(true);
this.setBlockName(Strings.rainSensorName);
ModBlocks.register(this);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister)
{
icon_inactive = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_inactive");
icon_active = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_active");
icon_side = iconRegister.registerIcon(References.RESOURCESPREFIX + "rain_sensor_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int face, int meta)
{
IIcon iconstate = (meta == 0 ? icon_inactive : icon_active);
return face == 1 ? iconstate : icon_side;
}
@Override
public boolean canProvidePower()
{
return true;
}
@Override
public int tickRate(World world)
{
return 100;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
if (world.canBlockSeeTheSky(x, y, z))
world.setBlockMetadataWithNotify(x, y, z, world.getWorldInfo().isRaining() ? 1 : 0, 2);
else
world.setBlockMetadataWithNotify(x, y, z, 0, 2);
world.scheduleBlockUpdate(x, y, z, this, 100);
world.notifyBlocksOfNeighborChange(x, y, z, this);
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int meta)
{
return world.getBlockMetadata(x, y, z) == 1 ? 15 : 0;
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block p_149695_5_)
{
world.scheduleBlockUpdate(x, y, z, this, 100);
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
world.scheduleBlockUpdate(x, y, z, this, 10);
return super.onBlockPlaced(world, x, y, z, p_149660_5_, p_149660_6_, p_149660_7_, p_149660_8_, p_149660_9_);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random)
{
int l = world.getBlockMetadata(x, y, z);
int rand = random.nextInt(3);
if (l == 1)
{
if (rand == 0)
world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 1 - 0.155, 0.5, 0.4, 1);
if (rand == 1)
world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 1 - 0.155, 1, 0.2, 0.2);
if (rand == 1)
world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 0.155, 0.5, 0.4, 1);
if (rand == 2)
world.spawnParticle("reddust", x + 1 - 0.155, y + 0.12, z + 0.155, 1, 0.2, 0.2);
if (rand == 2)
world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 1 - 0.155, 0.5, 0.4, 1);
if (rand == 3)
world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 1 - 0.155, 1, 0.2, 0.2);
if (rand == 3)
world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 0.155, 0.5, 0.4, 1);
if (rand == 0)
world.spawnParticle("reddust", x + 0.155, y + 0.12, z + 0.155, 1, 0.2, 0.2);
}
}
}
@@ -0,0 +1,87 @@
package draconicevolution.common.blocks;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.handler.ParticleHandler;
import draconicevolution.common.core.network.ExamplePacket;
public class TestBlock extends TolkienBlock {
protected TestBlock() {
super(Material.rock);
this.setBlockName("testBlock");
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setHardness(5f);
this.setResistance(200.0f);
//this.setBlockBounds(0.4f, 0f, 0.4f, 0.6f, 1f, 0.6f);
ModBlocks.register(this);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_)
{
return null;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float px, float py, float pz)
{
if (!world.isRemote && !player.isSneaking())
{
System.out.println("Sending from server");
DraconicEvolution.channelHandler.sendToAll(new ExamplePacket());
}
if (world.isRemote && player.isSneaking())
{
System.out.println("Sending from client");
DraconicEvolution.channelHandler.sendToServer(new ExamplePacket());
}
return true;
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
{
// TODO Auto-generated method stub
return Item.getItemFromBlock(Blocks.cobblestone);
}
@Override
public void randomDisplayTick(World world, int x, int y, int z, Random rand)
{
float mX1 = (rand.nextFloat() - 0.5F) * 0.005F;
float mY1 = rand.nextFloat() * 0.01F;
float mZ1 = (rand.nextFloat() - 0.5F) * 0.005F;
ParticleHandler.spawnParticle("testParticle", x + 0.5, y + 1.5, z + 0.5, mX1, mY1, mZ1, 1);
for (int i = 0; i < 3; i++)
{
float mX = (rand.nextFloat() - 0.5F) * 0.005F;
float mY = 0.01F + rand.nextFloat() * 0.005F;
float mZ = (rand.nextFloat() - 0.5F) * 0.005F;
float scale = 0.2F + (rand.nextFloat() * 0.2F);
ParticleHandler.spawnParticle("testParticle", x + 0.5, y + 1.5, z + 0.5, mX, mY, mZ, scale);
}
}
}
@@ -0,0 +1,41 @@
package draconicevolution.common.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.lib.References;
public class TolkienBlock extends Block {
public TolkienBlock(final Material material) {
super(material);
}
public TolkienBlock() {
super(Material.rock);
}
@Override
public String getUnlocalizedName()
{
return String.format("tile.%s", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
public String getUnwrappedUnlocalizedName(final String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(final IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
}
@@ -0,0 +1,122 @@
package draconicevolution.common.blocks;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.handler.ParticleHandler;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.Strings;
public class XRayBlock extends TolkienBlock {
protected XRayBlock() {
super(Material.rock);
this.setBlockName(Strings.xrayBlockName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
this.setBlockBounds(0.4F, 0.4F, 0.4F, 0.6F, 0.6F, 0.6F);
this.setHardness(7f);
this.setHarvestLevel("pickaxe", 4);
this.setResistance(200.0f);
ModBlocks.register(this);
}
@Override
public int getRenderType()
{
return -1;
}
@Override
public boolean isReplaceable(IBlockAccess world, int x, int y, int z)
{
// TODO Auto-generated method stub
return super.isReplaceable(world, x, y, z);
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(final World p_149668_1_, final int p_149668_2_, final int p_149668_3_, final int p_149668_4_)
{
return null;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(final World world, final int x, final int y, final int z, final Random rand)
{
final double d0 = x + 0.5F;
final double d1 = y + 0.48F;
final double d2 = z + 0.5F;
float mX1 = (rand.nextFloat() - 0.5F) * 0.005F;
float mY1 = rand.nextFloat() * 0.01F;
float mZ1 = (rand.nextFloat() - 0.5F) * 0.005F;
ParticleHandler.spawnParticle("distortionParticle", d0, d1, d2, mX1, mY1, mZ1, 1);
for (int i = 0; i < 3; i++)
{
float mX = (rand.nextFloat() - 0.5F) * 0.005F;
float mY = 0.01F + rand.nextFloat() * 0.005F;
float mZ = (rand.nextFloat() - 0.5F) * 0.005F;
float scale = 0.2F + (rand.nextFloat() * 0.2F);
ParticleHandler.spawnParticle("distortionParticle", d0, d1, d2, mX, mY, mZ, scale);
}
}
@Override
public int quantityDropped(final Random p_149745_1_)
{
return 0;
}
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player)
{
ItemStack tool = player.getCurrentEquippedItem();
if (tool != null && (player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.draconicDistructionStaff)) || player.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.draconicPickaxe))))
{
EntityItem item = new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Item.getItemFromBlock(ModBlocks.xRayBlock)));
world.setBlockToAir(x, y, z);
if (!world.isRemote)
world.spawnEntityInWorld(item);
}
super.onBlockClicked(world, x, y, z, player);
}
@Override
protected boolean canSilkHarvest()
{
return false;
}
@Override
public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entity)
{
//if(entity != EntityItem)
//System.out.println();
//entity.attackEntityFrom(DamageSource.magic, 10F);
}
@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_)
{
//world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z));
return false;
}
}
@@ -0,0 +1,47 @@
package draconicevolution.common.container;
import draconicevolution.client.interfaces.SlotItemValid;
import 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.Slot;
import net.minecraft.item.ItemStack;
public class ContainerGrinder extends Container {
private TileGrinder tile;
public ContainerGrinder(InventoryPlayer invPlayer, TileGrinder 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 par1EntityPlayer, int par2)
{
return null;
}
public TileGrinder getTileWC(){
return tile;
}
}
@@ -0,0 +1,139 @@
package draconicevolution.common.container;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import draconicevolution.client.interfaces.GUIPlayerDetector;
import draconicevolution.client.interfaces.SlotItemValid;
import draconicevolution.client.interfaces.SlotOpaqueBlock;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
public class ContainerPlayerDetector extends Container {
private TilePlayerDetectorAdvanced tileDetector;
private GUIPlayerDetector gui = null;
public ContainerPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced tileDetector) {
this.tileDetector = tileDetector;
bindPlayerInventory(invPlayer);
addContainerSlots(tileDetector);
updateContainerSlots();
}
public ContainerPlayerDetector(InventoryPlayer invPlayer, TilePlayerDetectorAdvanced tileDetector, GUIPlayerDetector gui) {
this.tileDetector = tileDetector;
this.gui = gui;
bindPlayerInventory(invPlayer);
addContainerSlots(tileDetector);
updateContainerSlots();
}
private void bindPlayerInventory(InventoryPlayer invPlayer)
{
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 174));
}
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, 116 + y * 18));
}
}
}
public void addContainerSlots(TilePlayerDetectorAdvanced tileDetector)
{
addSlotToContainer(new SlotOpaqueBlock(tileDetector, 0, 47, 15));
}
@SuppressWarnings("unchecked")
public void updateContainerSlots()
{
if (gui == null)
{
return;
}
Iterator<Slot> i1 = inventorySlots.iterator();
while (i1.hasNext())
{
Slot sl = i1.next();
if (sl instanceof SlotOpaqueBlock)
{
if (gui.showCamoSlot)
{
sl.xDisplayPosition = 178;
sl.yDisplayPosition = 20;
}else
{
sl.xDisplayPosition = -1000;
sl.yDisplayPosition = -1000;
}
}else
{
if (gui.showInvSlots)
{
if (sl.slotNumber < 9)
{
sl.xDisplayPosition = 8 + 18 * sl.slotNumber;
sl.yDisplayPosition = 174;
}
else if (sl.slotNumber < 18)
{
sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 8);
sl.yDisplayPosition = 116 + 0 * 18;
}
else if (sl.slotNumber < 26)
{
sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 17);
sl.yDisplayPosition = 116 + 1 * 18;
}
else if (sl.slotNumber < 34)
{
sl.xDisplayPosition = 8 + 18 * (sl.slotNumber - 26);
sl.yDisplayPosition = 116 + 2 * 18;
}
}else
{
sl.xDisplayPosition = -1000;
sl.yDisplayPosition = -1000;
}
}
}
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tileDetector.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
return null;
}
public TilePlayerDetectorAdvanced getTileDetector(){
return tileDetector;
}
@Override
public ItemStack slotClick(int slot, int button, int par3, EntityPlayer par4EntityPlayer)
{
if (par3 == 4)
return super.slotClick(slot, button, 0, par4EntityPlayer);
else
return super.slotClick(slot, button, par3, par4EntityPlayer);
}
}
@@ -0,0 +1,90 @@
package draconicevolution.common.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import draconicevolution.common.core.utills.InventoryReader;
import draconicevolution.common.items.tools.Reader;
public class ContainerReader extends Container
{
protected final InventoryReader itemInventory;
public ContainerReader(IInventory inventoryPlayer, InventoryReader itemInventory) {
this.itemInventory = itemInventory;
for (int i = 0; i < 7; i++) {
this.addSlotToContainer(new CustomSlot(itemInventory, i, 17 + (i * 21), 11));
}
for (int i = 0; i < 7; i++) {
this.addSlotToContainer(new CustomSlot(itemInventory, i + 7, 17 + (i * 21), 36));
}
for (int i = 0; i < 7; i++) {
this.addSlotToContainer(new CustomSlot(itemInventory, i + 14, 17 + (i * 21), 61));
}
bindPlayerInventory(inventoryPlayer, 10);
}
private void bindPlayerInventory(IInventory inventory, int yOffset) {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, (84 + i * 18) + yOffset));
}
}
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142 + yOffset));
}
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return this.itemInventory.isUseableByPlayer(player);
}
@SuppressWarnings("static-access")
@Override
public ItemStack slotClick(int slotID, int button, int par3, EntityPlayer player) {
Slot slot = (slotID < 0 || slotID > this.inventorySlots.size()) ? null : (Slot) this.inventorySlots.get(slotID);
if (slot != null && player.getCurrentEquippedItem() != null && slot.getHasStack() && slot.getStack().areItemStacksEqual(slot.getStack(), player.getCurrentEquippedItem())) return null;
return super.slotClick(slotID, button, par3, player);
}
public static boolean isBook(ItemStack stack) {
String name = Item.itemRegistry.getNameForObject(stack.getItem());
if(name != null) {
/*
for (String check : Config.prefixes) {
if (name.contains(check))
return true;
}*/
return true;
}
return stack.getItem() instanceof Reader;
}
public static class CustomSlot extends Slot {
public CustomSlot(IInventory inventoryPlayer, int id, int x, int y) {
super(inventoryPlayer, id, x, y);
}
@Override
public boolean isItemValid(ItemStack stack) {
return true;
}
@Override
public int getSlotStackLimit() {
return 1;
}
}
}
@@ -0,0 +1,35 @@
package draconicevolution.common.container;
import draconicevolution.common.tileentities.TileSunDial;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
public class ContainerSunDial extends Container {
private TileSunDial tile;
public ContainerSunDial(InventoryPlayer invPlayer, TileSunDial tile) {
this.tile = tile;
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tile.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
return null;
}
public TileSunDial getTile(){
return tile;
}
}
@@ -0,0 +1,49 @@
package draconicevolution.common.container;
import draconicevolution.client.interfaces.SlotItemValid;
import draconicevolution.common.tileentities.TileWeatherController;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerWeatherController extends Container {
private TileWeatherController tileWC;
public ContainerWeatherController(InventoryPlayer invPlayer, TileWeatherController tileWC) {
this.tileWC = tileWC;
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(invPlayer, x, 8 + 18 * x, 119));
}
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, 61 + y * 18));
}
}
addSlotToContainer(new SlotItemValid(tileWC, 0, 47, 15, Items.emerald));
}
@Override
public boolean canInteractWith(EntityPlayer player)
{
return tileWC.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
return null;
}
public TileWeatherController getTileWC(){
return tileWC;
}
}
@@ -0,0 +1,26 @@
package draconicevolution.common.core.handler;
import java.io.File;
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);
config.save();
}
public static int disableSunDial;
public static int teleporterUsesPerPearl;
public static int disableXrayBlock;
}
@@ -0,0 +1,92 @@
package draconicevolution.common.core.handler;
import draconicevolution.common.blocks.ModBlocks;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.items.tools.DraconicAxe;
import draconicevolution.common.items.tools.DraconicDistructionStaff;
import draconicevolution.common.items.tools.DraconicHoe;
import draconicevolution.common.items.tools.DraconicPickaxe;
import draconicevolution.common.items.tools.DraconicShovel;
import draconicevolution.common.items.tools.TeleporterMKI;
import draconicevolution.common.items.tools.TeleporterMKII;
import draconicevolution.common.items.tools.WyvernPickaxe;
import draconicevolution.common.items.tools.WyvernShovel;
import draconicevolution.common.items.weapons.DraconicBow;
import draconicevolution.common.items.weapons.DraconicSword;
import draconicevolution.common.items.weapons.WyvernBow;
import draconicevolution.common.items.weapons.WyvernSword;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.FurnaceRecipes;
public class CraftingHandler {
public static void init()
{
registerShapedRecipes();
registerSmeltingRecipes();
registerShapelessRecipes();
registerToolRecipes();
}
private static void registerToolRecipes()
{
DraconicPickaxe.registerRecipe();
DraconicAxe.registerRecipe();
DraconicDistructionStaff.registerRecipe();
DraconicShovel.registerRecipe();
DraconicHoe.registerRecipe();
DraconicSword.registerRecipe();
DraconicBow.registerRecipe();
WyvernPickaxe.registerRecipe();
WyvernShovel.registerRecipe();
WyvernSword.registerRecipe();
WyvernBow.registerRecipe();
TeleporterMKI.registerRecipe();
TeleporterMKII.registerRecipe();
}
public static void registerShapedRecipes()
{
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicCore), "GIG", "ISI", "GIG", 'S', Items.diamond, 'G', Items.gold_ingot, 'I', ModItems.draconiumIngot);
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.sunFocus), "RIR", "ISI", "RIR", 'S', Items.nether_star, 'R', Items.blaze_rod, 'I', ModItems.draconiumIngot);
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.infusedCompound, 2), "IDI", "DSD", "IDI", 'S', Items.nether_star, 'D', Items.diamond, 'I', ModItems.draconiumIngot);
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.dragonHeart), " C ", "CIC", " C ", 'C', ModItems.infusedCompound, 'I', ModItems.draconiumIngot);
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconiumBlend), " D ", "DID", " D ", 'I', Items.iron_ingot, 'D', ModItems.draconiumDust);
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicCompound), " C ", "CHC", " C ", 'C', ModItems.infusedCompound, 'H', ModItems.dragonHeart);
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.grinder, 1, 3), "IXI", "DCD", "IFI", 'I', Items.iron_ingot, 'X', ModItems.draconiumIngot, 'D', Items.diamond_sword, 'C', ModItems.draconicCore, 'F', Blocks.furnace);
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.weatherController), "RSR", "TPT", "IEI", 'R', Items.blaze_rod, 'S', ModItems.sunFocus, 'T', Blocks.tnt, 'P', ModItems.draconicCore, 'I', Items.iron_ingot, 'E', Blocks.enchanting_table);
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.potentiometer), "ITI", "QCQ", "IRI", 'I', Items.iron_ingot, 'T', Blocks.redstone_torch, 'Q', Items.quartz, 'C', Items.comparator, 'R', Blocks.redstone_block);
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);
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);
if(ConfigHandler.disableXrayBlock == 0)
CraftingManager.getInstance().addRecipe(new ItemStack(ModBlocks.xRayBlock, 4), "SGS", "GDG", "SGS", 'S', Items.nether_star, 'G', Blocks.glass, 'D', Items.diamond);
}
public static void registerSmeltingRecipes()
{
FurnaceRecipes.smelting().func_151396_a(ModItems.draconiumBlend, new ItemStack(ModItems.draconiumIngot, 2), 1.0f);
}
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);
}
}
/*
//turns dirt into enchanted diamond sword!
ItemStack manipulation = new ItemStack(Items.diamond_sword);
manipulation.addEnchantment(Enchantment.efficiency, 2);
CraftingManager.getInstance().addShapelessRecipe(manipulation, Blocks.dirt);
ItemStack manipulation2 = new ItemStack(Items.diamond_sword);
manipulation2.damageItem(10, null);
CraftingManager.getInstance().addShapelessRecipe(manipulation2, Blocks.end_portal_frame); */
@@ -0,0 +1,5 @@
package draconicevolution.common.core.handler;
public class FMLEventHandler {
}
@@ -0,0 +1,68 @@
package 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
}*/
}
@@ -0,0 +1,75 @@
package draconicevolution.common.core.handler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.world.World;
import draconicevolution.client.render.DistortionParticle;
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)
{
int var14 = mc.gameSettings.particleSetting;
if (var14 == 1 && theWorld.rand.nextInt(3) == 0)
{
var14 = 2;
}
double var15 = mc.renderViewEntity.posX - x;
double var17 = mc.renderViewEntity.posY - y;
double var19 = mc.renderViewEntity.posZ - z;
EntityFX var21 = null;
double var22 = 16.0D;
if (var15 * var15 + var17 * var17 + var19 * var19 > var22 * var22)
{
return null;
} else if (var14 > 1)
{
return null;
} else
{
if (particleName.equals("distortionParticle"))
{
var21 = new DistortionParticle(theWorld, x, y, z, (float) motionX, (float) motionY, (float) motionZ, scale);
}
mc.effectRenderer.addEffect(var21);
return var21;
}
}
return null;
}
public static EntityFX spawnCustomParticle(EntityFX particle)
{
if (mc != null && mc.renderViewEntity != null && mc.effectRenderer != null)
{
int var14 = mc.gameSettings.particleSetting;
if (var14 == 1 && theWorld.rand.nextInt(3) == 0)
{
//var14 = 2;
}
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)
{
return null;
} else if (var14 > 1)
{
return null;
} else
{
mc.effectRenderer.addEffect(particle);
return particle;
}
}
return null;
}
}
@@ -0,0 +1,93 @@
package draconicevolution.common.core.helper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public final class ItemNBTHelper {
// SETTERS ///////////////////////////////////////////////////////////////////
public static NBTTagCompound getCompound(ItemStack stack){
if (stack.getTagCompound() == null)
return new NBTTagCompound();
else
return stack.getTagCompound();
}
public static void setBoolean(ItemStack stack, String tag, boolean b)
{
NBTTagCompound compound = getCompound(stack);
compound.setBoolean(tag, b);
stack.setTagCompound(compound);
}
public static void setShort(ItemStack stack, String tag, short s)
{
NBTTagCompound compound = getCompound(stack);
compound.setShort(tag, s);
stack.setTagCompound(compound);
}
public static void setIntager(ItemStack stack, String tag, int i)
{
NBTTagCompound compound = getCompound(stack);
compound.setInteger(tag, i);
stack.setTagCompound(compound);
}
public static void setFloat(ItemStack stack, String tag, float f)
{
NBTTagCompound compound = getCompound(stack);
compound.setFloat(tag, f);
stack.setTagCompound(compound);
}
public static void setDouble(ItemStack stack, String tag, double d)
{
NBTTagCompound compound = getCompound(stack);
compound.setDouble(tag, d);
stack.setTagCompound(compound);
}
public static void setString(ItemStack stack, String tag, String s) {
NBTTagCompound compound = getCompound(stack);
compound.setString(tag, s);
stack.setTagCompound(compound);
}
// GETTERS ///////////////////////////////////////////////////////////////////
public static boolean verifyExistance(ItemStack stack, String tag) {
NBTTagCompound compound = stack.getTagCompound();
if (compound == null)
return false;
else
return stack.getTagCompound().hasKey(tag);
}
public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) {
return verifyExistance(stack, tag) ? stack.getTagCompound().getBoolean(tag) : defaultExpected;
}
public static short getShort(ItemStack stack, String tag, short defaultExpected) {
return verifyExistance(stack, tag) ? stack.getTagCompound().getShort(tag) : defaultExpected;
}
public static int getIntager(ItemStack stack, String tag, int defaultExpected) {
return verifyExistance(stack, tag) ? stack.getTagCompound().getInteger(tag) : defaultExpected;
}
public static float getFloat(ItemStack stack, String tag, float defaultExpected) {
return verifyExistance(stack, tag) ? stack.getTagCompound().getFloat(tag) : defaultExpected;
}
public static double getDouble(ItemStack stack, String tag, double defaultExpected) {
return verifyExistance(stack, tag) ? stack.getTagCompound().getDouble(tag) : defaultExpected;
}
public static String getString(ItemStack stack, String tag, String defaultExpected) {
return verifyExistance(stack, tag) ? stack.getTagCompound().getString(tag) : defaultExpected;
}
}
@@ -0,0 +1,63 @@
package draconicevolution.common.core.network;
import draconicevolution.common.container.ContainerWeatherController;
import draconicevolution.common.tileentities.TileWeatherController;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.inventory.Container;
import net.minecraft.network.NetHandlerPlayServer;
public class ButtonPacket implements IPacket
{
byte buttonId = 0;
boolean state = false;
public ButtonPacket() {}
public ButtonPacket(byte buttonId, boolean state) {
this.buttonId = buttonId;
this.state = state;
}
@Override
public void readBytes(ByteBuf bytes)
{
this.buttonId = bytes.readByte();
this.state = bytes.readBoolean();
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeByte(buttonId);
bytes.writeBoolean(state);
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
System.out.println("a client");
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
switch (this.buttonId) {
case 0:
{
Container container = player.playerEntity.openContainer;
if (container != null && container instanceof ContainerWeatherController){
TileWeatherController tileWC = ((ContainerWeatherController) container).getTileWC();
tileWC.reciveButtonEvent(buttonId);
}
break;
}
case 1:
break;
default:
break;
}
}
}
@@ -0,0 +1,204 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.LinkedList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.INetHandler;
import net.minecraft.network.NetHandlerPlayServer;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
import cpw.mods.fml.common.network.FMLOutboundHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ChannelHandler extends FMLIndexedMessageToMessageCodec<IPacket>
{
public EnumMap<Side, FMLEmbeddedChannel> channels;
private LinkedList<Class<? extends IPacket>> packets = new LinkedList<Class<? extends IPacket>>();
private boolean isPostInitialised = false;
private final String logger;
private final String channelName;
public ChannelHandler(String logName, String modChannel) {
this.logger = logName;
this.channelName = modChannel;
}
public boolean registerPacket(Class<? extends IPacket> clazz)
{
if (this.packets.size() > 256)
{
FMLLog.log(this.logger, Level.ERROR, "Cannot register more than 256 packets! Packet %s not registered!", clazz.getName());
return false;
}
if (this.packets.contains(clazz))
{
FMLLog.log(this.logger, Level.ERROR, "Packet %s already registered!", clazz.getName());
return false;
}
if (this.isPostInitialised)
{
FMLLog.log(this.logger, Level.ERROR, "Packet %s cannot be registered during / after Post-Initialization!", clazz.getName());
return false;
}
this.addDiscriminator(this.packets.size(), clazz);
this.packets.add(clazz);
return true;
}
@Override
public void encodeInto(ChannelHandlerContext ctx, IPacket msg, ByteBuf target) throws Exception
{
msg.writeBytes(target);
}
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, IPacket msg)
{
msg.readBytes(source);
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
if (netHandler instanceof NetHandlerPlayServer)
{
msg.handleServerSide((NetHandlerPlayServer) netHandler);
} else if (netHandler instanceof NetHandlerPlayClient)
{
msg.handleClientSide((NetHandlerPlayClient) netHandler);
}
}
public void initialise()
{
this.channels = NetworkRegistry.INSTANCE.newChannel(this.channelName, this);
}
public void postInitialise()
{
if (this.isPostInitialised)
{
return;
}
this.isPostInitialised = true;
Collections.sort(this.packets, new Comparator<Class<? extends IPacket>>() {
@Override
public int compare(Class<? extends IPacket> clazz1, Class<? extends IPacket> clazz2)
{
int com = String.CASE_INSENSITIVE_ORDER.compare(clazz1.getCanonicalName(), clazz2.getCanonicalName());
if (com == 0)
{
com = clazz1.getCanonicalName().compareTo(clazz2.getCanonicalName());
}
return com;
}
});
}
@SideOnly(Side.CLIENT)
private EntityPlayer getClientPlayer()
{
return Minecraft.getMinecraft().thePlayer;
}
/**
* Send this message to everyone.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
*/
public void sendToAll(IPacket message)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
/**
* Send this message to the specified player.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
* @param player
* The player to send it to
*/
public void sendTo(IPacket message, EntityPlayerMP player)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
/**
* Send this message to everyone within a certain range of a point.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
* @param point
* The {@link cpw.mods.fml.common.network.NetworkRegistry.TargetPoint}
* around which to send
*/
public void sendToAllAround(IPacket message, NetworkRegistry.TargetPoint point)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
/**
* Send this message to everyone within the supplied dimension.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
* @param dimensionId
* The dimension id to target
*/
public void sendToDimension(IPacket message, int dimensionId)
{
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.DIMENSION);
this.channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
this.channels.get(Side.SERVER).writeAndFlush(message);
}
/**
* Send this message to the server.
* <p/>
* Adapted from CPW's code in
* cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper
*
* @param message
* The message to send
*/
public void sendToServer(IPacket message)
{
this.channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);
this.channels.get(Side.CLIENT).writeAndFlush(message);
}
}
@@ -0,0 +1,49 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetHandlerPlayServer;
import cpw.mods.fml.common.network.ByteBufUtils;
public class ExamplePacket implements IPacket
{
@Override
public void readBytes(ByteBuf bytes)
{
System.out.println(bytes.readBoolean());
System.out.println(bytes.readDouble());
System.out.println(bytes.readInt());
System.out.println(bytes.readChar());
System.out.println(ByteBufUtils.readUTF8String(bytes));
System.out.println(ByteBufUtils.readItemStack(bytes));
System.out.println(ByteBufUtils.readTag(bytes));
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeBoolean(true);
bytes.writeDouble(3.141592653589D);
bytes.writeInt(65536);
bytes.writeChar("c".charAt(0));
ByteBufUtils.writeUTF8String(bytes, "A string");
ByteBufUtils.writeItemStack(bytes, new ItemStack(Items.boat));
ByteBufUtils.writeTag(bytes, new NBTTagCompound());
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
System.out.println("a client");
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
System.out.println("a server");
}
}
@@ -0,0 +1,14 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.NetHandlerPlayServer;
public interface IPacket
{
public void readBytes(ByteBuf bytes);
public void writeBytes(ByteBuf bytes);
public void handleClientSide(NetHandlerPlayClient nhClient);
public void handleServerSide(NetHandlerPlayServer nhServer);
}
@@ -0,0 +1,234 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity;
import draconicevolution.common.tileentities.TileParticleGenerator;
public class ParticleGenPacket implements IPacket
{
byte buttonId = 0;
short value = 0;
int tileX = 0;
int tileY = 0;
int tileZ = 0;
public ParticleGenPacket() {}
public ParticleGenPacket(byte buttonId, short value, int x, int y, int z) {
this.buttonId = buttonId;
this.value = value;
this.tileX = x;
this.tileY = y;
this.tileZ = z;
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeByte(buttonId);
bytes.writeShort(value);
bytes.writeInt(tileX);
bytes.writeInt(tileY);
bytes.writeInt(tileZ);
}
@Override
public void readBytes(ByteBuf bytes)
{
this.buttonId = bytes.readByte();
this.value = bytes.readShort();
this.tileX = bytes.readInt();
this.tileY = bytes.readInt();
this.tileZ = bytes.readInt();
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
TileEntity tile = player.playerEntity.worldObj.getTileEntity(tileX, tileY, tileZ);
TileParticleGenerator gen = (tile != null && tile instanceof TileParticleGenerator) ? (TileParticleGenerator)tile : null;
if (gen != null)
{
//System.out.println(buttonId + " " + value);
switch (buttonId) {
case 0://red
gen.red = (int) value;
break;
case 1://green
gen.green = (int) value;
break;
case 2://blue
gen.blue = (int) value;
break;
case 3://mx
gen.motion_x = (float) value / 1000F;
break;
case 4://my
gen.motion_y = (float) value / 1000F;
break;
case 5://mz
gen.motion_z = (float) value / 1000F;
break;
case 6://ged
gen.red = (int) value;
break;
case 7://green
gen.green = (int) value;
break;
case 8://blue
gen.blue = (int) value;
break;
case 9://mx
gen.motion_x = (float) value / 1000F;
break;
case 10://my
gen.motion_y = (float) value / 1000F;
break;
case 11://mz
gen.motion_z = (float) value / 1000F;
break;
case 12://red
gen.random_red = (int) value;
break;
case 13://green
gen.random_green = (int) value;
break;
case 14://blue
gen.random_blue = (int) value;
break;
case 15://mx
gen.random_motion_x = (float) value / 1000F;
break;
case 16://my
gen.random_motion_y = (float) value / 1000F;
break;
case 17://mz
gen.random_motion_z = (float) value / 1000F;
break;
case 18://ged
gen.random_red = (int) value;
break;
case 19://green
gen.random_green = (int) value;
break;
case 20://blue
gen.random_blue = (int) value;
break;
case 21://mx
gen.random_motion_x = (float) value / 1000F;
break;
case 22://my
gen.random_motion_y = (float) value / 1000F;
break;
case 23://mz
gen.random_motion_z = (float) value / 1000F;
break;
case 24://Life +
gen.life = (int) value;
break;
case 25://Life -
gen.life = (int) value;
break;
case 26://RLife +
gen.random_life = (int) value;
break;
case 27://RLife -
gen.random_life = (int) value;
break;
case 28://Size +
gen.scale = (float) value / 100F;
break;
case 29://Size -
gen.scale = (float) value / 100F;
break;
case 30://RSize +
gen.random_scale = (float) value / 100F;
break;
case 31://RSize -
gen.random_scale = (float) value / 100F;
break;
case 32://SX +
gen.page = (int) value;
break;
case 33://SX -
gen.page = (int) value;
break;
case 34://SX +
gen.spawn_x = (float) value / 100F;
break;
case 35://SX -
gen.spawn_x = (float) value / 100F;
break;
case 36://RSX +
gen.random_spawn_x = (float) value / 100F;
break;
case 37://RSX -
gen.random_spawn_x = (float) value / 100F;
break;
case 38://SY +
gen.spawn_y = (float) value / 100F;
break;
case 39://SY -
gen.spawn_y = (float) value / 100F;
break;
case 40://RSY +
gen.random_spawn_y = (float) value / 100F;
break;
case 41://RSY -
gen.random_spawn_y = (float) value / 100F;
break;
case 42://SZ +
gen.spawn_z = (float) value / 100F;
break;
case 43://SZ -
gen.spawn_z = (float) value / 100F;
break;
case 44://RSZ +
gen.random_spawn_z = (float) value / 100F;
break;
case 45://RSZ -
gen.random_spawn_z = (float) value / 100F;
break;
case 46://Delay -
gen.spawn_rate = (int) value;
break;
case 47://Delay -
gen.spawn_rate = (int) value;
break;
case 48://Fade -
gen.fade = (int) value;
break;
case 49://Fade -
gen.fade = (int) value;
break;
case 50://Collision -
gen.collide = value == 0 ? false : true;
break;
case 51://Particle Selected -
gen.selected_particle = (int) value;
break;
case 52://Gravity +
gen.gravity = (float) value / 1000F;
break;
case 53://Gravity -
gen.gravity = (float) value / 1000F;
break;
case 54://Info Page (3)
gen.page = (int) value;
break;
case 55://Back
gen.page = (int) value;
break;
}
player.playerEntity.worldObj.markBlockForUpdate(tileX, tileY, tileZ);
}
}
}
@@ -0,0 +1,63 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.NetHandlerPlayServer;
import cpw.mods.fml.common.network.ByteBufUtils;
import draconicevolution.common.container.ContainerPlayerDetector;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
public class PlayerDetectorButtonPacket implements IPacket
{
private short index = 0;
private short value = 0;
public PlayerDetectorButtonPacket() {}
public PlayerDetectorButtonPacket(byte index, short value) {
this.index = index;
this.value = value;
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeByte(index);
bytes.writeByte(value);
}
@Override
public void readBytes(ByteBuf bytes)
{
index = bytes.readByte();
value = bytes.readByte();
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
ContainerPlayerDetector container = (player.playerEntity.openContainer instanceof ContainerPlayerDetector) ? (ContainerPlayerDetector)player.playerEntity.openContainer : null;
TilePlayerDetectorAdvanced tile = (container != null) ? ((ContainerPlayerDetector)container).getTileDetector() : null;
if (tile != null)
{
switch (index)
{
case 0:
tile.range = value;
break;
case 1:
tile.whiteList = value == 1 ? true : false;
break;
}
player.playerEntity.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
}
}
}
@@ -0,0 +1,55 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.NetHandlerPlayServer;
import cpw.mods.fml.common.network.ByteBufUtils;
import draconicevolution.common.container.ContainerPlayerDetector;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
public class PlayerDetectorStringPacket implements IPacket
{
private int index = 0;
private String name = "";
public PlayerDetectorStringPacket() {}
public PlayerDetectorStringPacket(byte index, String name) {
this.index = index;
this.name = name;
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeByte(index);
ByteBufUtils.writeUTF8String(bytes, name);
}
@Override
public void readBytes(ByteBuf bytes)
{
index = bytes.readByte();
name = ByteBufUtils.readUTF8String(bytes);
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
ContainerPlayerDetector container = (player.playerEntity.openContainer instanceof ContainerPlayerDetector) ? (ContainerPlayerDetector)player.playerEntity.openContainer : null;
TilePlayerDetectorAdvanced tile = (container != null) ? ((ContainerPlayerDetector)container).getTileDetector() : null;
if (tile != null)
{
tile.names[index] = name;
player.playerEntity.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
}
}
}
@@ -0,0 +1,115 @@
package draconicevolution.common.core.network;
import draconicevolution.common.core.handler.ConfigHandler;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
public class TeleporterPacket implements IPacket
{
byte buttonId = 0;
int dim = 0;
int selection = 0;
double playerX = 0;
double playerY = 0;
double playerZ = 0;
float yaw = 0;
float pitch = 0;
public TeleporterPacket() {
}
public TeleporterPacket(byte buttonId, int data) {
this.buttonId = buttonId;
this.selection = data;
}
public TeleporterPacket(byte buttonId, int data, int dim, double x, double y, double z, float yaw, float pitch) {
this.buttonId = buttonId;
this.dim = dim;
this.selection = data;
this.playerX = x;
this.playerY = y;
this.playerZ = z;
this.yaw = yaw;
this.pitch = pitch;
}
@Override
public void readBytes(ByteBuf bytes)
{
this.buttonId = bytes.readByte();
this.dim = bytes.readInt();
this.selection = bytes.readInt();
this.playerX = bytes.readDouble();
this.playerY = bytes.readDouble();
this.playerZ = bytes.readDouble();
this.yaw = bytes.readFloat();
this.pitch = bytes.readFloat();
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeByte(buttonId);
bytes.writeInt(dim);
bytes.writeInt(selection);
bytes.writeDouble(playerX );
bytes.writeDouble(playerY);
bytes.writeDouble(playerZ);
bytes.writeFloat(yaw);
bytes.writeFloat(pitch);
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
System.out.println("a client");
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
switch (this.buttonId) {
case 0: //Teleporter mode set
if (player.playerEntity.getCurrentEquippedItem() != null && player.playerEntity.getCurrentEquippedItem().isItemEqual(new ItemStack(ModItems.teleporterMKII)))
ItemNBTHelper.setShort(player.playerEntity.getCurrentEquippedItem(), "Selection", (short) this.selection);
break; //Set waypoint
case 1:
ItemStack stack = player.playerEntity.getCurrentEquippedItem();
if (stack != null && stack.isItemEqual(new ItemStack(ModItems.teleporterMKII)))
{
ItemNBTHelper.setDouble(stack, "X_" + selection, playerX);
ItemNBTHelper.setDouble(stack, "Y_" + selection, playerY);
ItemNBTHelper.setDouble(stack, "Z_" + selection, playerZ);
ItemNBTHelper.setFloat(stack, "Yaw_" + selection, yaw);
ItemNBTHelper.setFloat(stack, "Pitch_" + selection, pitch);
ItemNBTHelper.setIntager(stack, "Dimension_" + selection, dim);
ItemNBTHelper.setBoolean(stack, "IsSet_" + selection, true);
}
break;
case 6:
ItemStack stack2 = player.playerEntity.getCurrentEquippedItem();
if (stack2 != null && stack2.isItemEqual(new ItemStack(ModItems.teleporterMKII)))
{
int fuel = ItemNBTHelper.getIntager(stack2, "Fuel", 0);
if (player.playerEntity.inventory.hasItem(Items.ender_pearl))
{
for (int i = 0; i < selection; i++)
{
player.playerEntity.inventory.consumeInventoryItem(Items.ender_pearl);
}
ItemNBTHelper.setIntager(stack2, "Fuel", fuel + (ConfigHandler.teleporterUsesPerPearl * selection));
}
}
break;
}
}
}
@@ -0,0 +1,54 @@
package draconicevolution.common.core.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
import cpw.mods.fml.common.network.ByteBufUtils;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
public class TeleporterStringPacket implements IPacket
{
int index = 0;
String name = "Destination";
public TeleporterStringPacket() {}
public TeleporterStringPacket(int index, String name) {
this.index = index;
this.name = name;
}
@Override
public void readBytes(ByteBuf bytes)
{
this.index = bytes.readInt();
name = ByteBufUtils.readUTF8String(bytes);
}
@Override
public void writeBytes(ByteBuf bytes)
{
bytes.writeInt(index);
ByteBufUtils.writeUTF8String(bytes, name);
}
@Override
public void handleClientSide(NetHandlerPlayClient player)
{
}
@Override
public void handleServerSide(NetHandlerPlayServer player)
{
ItemStack stack = player.playerEntity.getCurrentEquippedItem();
if (stack != null && stack.isItemEqual(new ItemStack(ModItems.teleporterMKII)))
{
ItemNBTHelper.setString(stack, "Dest_" + index, name);
}
}
}
@@ -0,0 +1,59 @@
package draconicevolution.common.core.proxy;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
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 draconicevolution.client.render.BowRenderer;
import draconicevolution.client.render.ItemParticleGenRenderer;
import draconicevolution.client.render.ParticleGenRenderer;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.blocks.ModBlocks;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.tileentities.TileParticleGenerator;
public class ClientProxy extends CommonProxy {
private final static boolean debug = DraconicEvolution.debug;
@Override
public void preInit(FMLPreInitializationEvent event)
{if(debug)
System.out.println("on Client side");
super.preInit(event);
//Client Only
registerRendering();
}
@Override
public void init(FMLInitializationEvent event)
{if(debug)
System.out.println("on Client side");
super.init(event);
//Client Only
}
@Override
public void postInit(FMLPostInitializationEvent event)
{if(debug)
System.out.println("on Client side");
super.postInit(event);
//Client Only
}
public void registerRendering()
{
MinecraftForgeClient.registerItemRenderer(ModItems.wyvernBow, new BowRenderer());
MinecraftForgeClient.registerItemRenderer(ModItems.draconicBow, new BowRenderer());
TileEntitySpecialRenderer render = new ParticleGenRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileParticleGenerator.class, render);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.particleGenerator), new ItemParticleGenRenderer(render, new TileParticleGenerator()));
}
}
@@ -0,0 +1,101 @@
package draconicevolution.common.core.proxy;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import draconicevolution.client.interfaces.GuiHandler;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.blocks.ModBlocks;
import draconicevolution.common.core.handler.ConfigHandler;
import draconicevolution.common.core.handler.CraftingHandler;
import draconicevolution.common.core.handler.FMLEventHandler;
import draconicevolution.common.core.handler.ModEventHandler;
import draconicevolution.common.core.network.ButtonPacket;
import draconicevolution.common.core.network.ExamplePacket;
import draconicevolution.common.core.network.ParticleGenPacket;
import draconicevolution.common.core.network.PlayerDetectorButtonPacket;
import draconicevolution.common.core.network.PlayerDetectorStringPacket;
import draconicevolution.common.core.network.TeleporterPacket;
import draconicevolution.common.core.network.TeleporterStringPacket;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.tileentities.TileGrinder;
import draconicevolution.common.tileentities.TileParticleGenerator;
import draconicevolution.common.tileentities.TilePlayerDetector;
import draconicevolution.common.tileentities.TilePlayerDetectorAdvanced;
import draconicevolution.common.tileentities.TilePotentiometer;
import draconicevolution.common.tileentities.TileSunDial;
import draconicevolution.common.tileentities.TileWeatherController;
import draconicevolution.common.world.TolkienWorldGenerator;
public class CommonProxy {
private final static boolean debug = DraconicEvolution.debug;
public void preInit(FMLPreInitializationEvent event)
{
ConfigHandler.init(event.getSuggestedConfigurationFile());
ModBlocks.init();
ModItems.init();
GameRegistry.registerWorldGenerator(new TolkienWorldGenerator(), 1);
registerTileEntities();
}
public void init(FMLInitializationEvent event)
{
CraftingHandler.init();
registerEventListeners();
registerGuiHandeler();
registerWorldGen();
DraconicEvolution.channelHandler.initialise();
registerPackets();
}
public void postInit(FMLPostInitializationEvent event)
{
DraconicEvolution.channelHandler.postInitialise();
}
public void registerTileEntities()
{
GameRegistry.registerTileEntity(TileWeatherController.class, "TileWeatherController");
GameRegistry.registerTileEntity(TileSunDial.class, "TileSunDial");
GameRegistry.registerTileEntity(TileGrinder.class, "TileGrinder");
GameRegistry.registerTileEntity(TilePotentiometer.class, "TilePotentiometer");
GameRegistry.registerTileEntity(TileParticleGenerator.class, "TileParticleGenerator");
GameRegistry.registerTileEntity(TilePlayerDetector.class, "TilePlayerDetector");
GameRegistry.registerTileEntity(TilePlayerDetectorAdvanced.class, "TilePlayerDetectorAdvanced");
}
public void registerEventListeners()
{
MinecraftForge.EVENT_BUS.register(new ModEventHandler());
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
}
public void registerPackets()
{
if(debug){
System.out.println("[DEBUG]CommonProxy: registerPackets");
DraconicEvolution.channelHandler.registerPacket(ExamplePacket.class);
}
DraconicEvolution.channelHandler.registerPacket(ButtonPacket.class);
DraconicEvolution.channelHandler.registerPacket(TeleporterPacket.class);
DraconicEvolution.channelHandler.registerPacket(TeleporterStringPacket.class);
DraconicEvolution.channelHandler.registerPacket(ParticleGenPacket.class);
DraconicEvolution.channelHandler.registerPacket(PlayerDetectorStringPacket.class);
DraconicEvolution.channelHandler.registerPacket(PlayerDetectorButtonPacket.class);
}
public void registerGuiHandeler()
{
new GuiHandler();
}
public void registerWorldGen()
{
GameRegistry.registerWorldGenerator(new TolkienWorldGenerator(), 1);
}
}
@@ -0,0 +1,41 @@
package draconicevolution.common.core.utills;
import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;
public class CustomTeleporter extends Teleporter
{
private double tX;
private double tY;
private double tZ;
private float yaw;
private float pitch;
public CustomTeleporter(WorldServer worldServer, double tX, double tY, double tZ, float yaw, float pitch) {
super(worldServer);
this.tX = tX;
this.tY = tY;
this.tZ = tZ;
this.yaw = yaw;
this.pitch = pitch;
}
@Override
public void placeInPortal(Entity entity, double x, double y, double z, float r)
{
entity.setLocationAndAngles(this.tX, this.tY, this.tZ, this.yaw, this.pitch);
}
@Override
public void removeStalePortalLocations(long par1)
{
}
@Override
public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
{
return false;
}
}
@@ -0,0 +1,184 @@
package draconicevolution.common.core.utills;
import draconicevolution.common.items.tools.Reader;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
public class InventoryReader implements IInventory
{
private World world;
private EntityPlayer player;
private ItemStack reader;
private ItemStack[] inventory;
public InventoryReader(EntityPlayer player) {
this.player = player;
this.world = player.worldObj;
this.reader = player.getCurrentEquippedItem();
if(this.inventory == null) {
this.inventory = loadItemInventory(21);
}
}
public InventoryReader(World world, ItemStack stack) {
this.world = world;
this.reader = stack;
if(this.inventory == null) {
this.inventory = loadItemInventory(21);
}
}
@Override
public int getSizeInventory() {
return inventory.length;
}
@Override
public ItemStack getStackInSlot(int i) {
return inventory[i];
}
@Override
public ItemStack decrStackSize(int i, int j)
{
if (inventory[i] != null) {
if (inventory[i].stackSize <= j) {
ItemStack itemstack = inventory[i];
inventory[i] = null;
markDirty();
return itemstack;
}
ItemStack itemstack1 = inventory[i].splitStack(j);
if (inventory[i].stackSize == 0) {
inventory[i] = null;
}
markDirty();
return itemstack1;
} else {
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
return getStackInSlot(var1);
}
@Override
public void setInventorySlotContents(int i, ItemStack stack)
{
inventory[i] = stack;
if (stack != null && stack.stackSize > getInventoryStackLimit()) {
stack.stackSize = getInventoryStackLimit();
}
markDirty();
}
@Override
public String getInventoryName()
{
return null;
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public void markDirty()
{
saveItemInventory();
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
{
return true;
}
@Override
public void openInventory()
{
}
@Override
public void closeInventory()
{
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2)
{
return false;
}
public ItemStack[] loadItemInventory(int size) {
inventory = new ItemStack[size];
if(!world.isRemote) {
ItemStack reader = player != null? player.getCurrentEquippedItem(): this.reader;
if(reader != null && reader.getItem() instanceof Reader) {
NBTTagCompound inventoryTagCompound = reader.hasTagCompound() ? reader.stackTagCompound: new NBTTagCompound();
NBTTagList inventoryTagList = inventoryTagCompound.getTagList("Inventory", 10);
if (inventoryTagList != null) {
ItemStack[] inventory = new ItemStack[size];
for (int i = 0; i < inventoryTagList.tagCount(); i++) {
NBTTagCompound itemTagCompound = inventoryTagList.getCompoundTagAt(i);
byte byte0 = itemTagCompound.getByte("Slot");
if (byte0 >= 0 && byte0 < inventory.length) {
inventory[byte0] = ItemStack.loadItemStackFromNBT(itemTagCompound);
}
}
return inventory;
}
return new ItemStack[size];
}
}
return new ItemStack[size];
}
public void saveItemInventory(){
if (!world.isRemote) {
ItemStack reader = player != null? player.getCurrentEquippedItem(): this.reader;
if(reader != null && reader.getItem() instanceof Reader) {
try {
NBTTagList inventoryTagList = new NBTTagList();
for (int i = 0; i < inventory.length; i++) {
if (inventory[i] != null) {
NBTTagCompound itemTagCompound = new NBTTagCompound();
itemTagCompound.setByte("Slot", (byte) i);
inventory[i].writeToNBT(itemTagCompound);
inventoryTagList.appendTag(itemTagCompound);
}
}
if (!reader.hasTagCompound()) {
reader.setTagCompound(new NBTTagCompound());
}
reader.stackTagCompound.setTag("Inventory", inventoryTagList);
} catch (Exception e) {
}
}
}
}
}
@@ -0,0 +1,30 @@
package draconicevolution.common.core.utills;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
public class Teleporter
{
public static void teleport(EntityPlayer player, double x, double y, double z, float yaw, float pitch, int dim)
{
if (player instanceof EntityPlayerMP)
{
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
if (thePlayer.dimension == dim)
{
player.setLocationAndAngles(x, y, z, yaw, pitch);
player.setPositionAndUpdate(x, y, z);
} else if (thePlayer.dimension == 1)
{
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z, yaw, pitch));
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z, yaw, pitch));
} else
{
if (thePlayer.isRiding())
thePlayer.dismountEntity(thePlayer.ridingEntity);
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, dim, new CustomTeleporter(thePlayer.mcServer.worldServerForDimension(dim), x, y, z, yaw, pitch));
}
}
}
}
@@ -0,0 +1,538 @@
package draconicevolution.common.entity;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class EntityDraconicArrow extends EntityArrow implements IProjectile {
private int field_145791_d = -1;
private int field_145792_e = -1;
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
private boolean inGround;
private int ticksInGround;
private int ticksInAir;
private double damage = 2.0D;
/** The amount of knockback an arrow applies when it hits a mob. */
private int knockbackStrength;
public boolean ignorSpeed = false;
public boolean explosive = false;
private World world;
public EntityDraconicArrow(ItemStack stack, World par1World, EntityLivingBase par2EntityLivingBase, float par3) {
super(par1World);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = par2EntityLivingBase;
world = par1World;
//if (par2EntityLivingBase instanceof EntityPlayer) {
// if (!(EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0))
// this.canBePickedUp = 2;
//}
this.setSize(0.5F, 0.5F);
this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch);
this.posX -= MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.posY -= 0.10000000149011612D;
this.posZ -= MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = -MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
this.motionZ = MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI);
this.motionY = (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI));
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
}
@Override
protected void entityInit()
{
super.entityInit();
//this.dataWatcher.addObject(16, Byte.valueOf((byte) 0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z
* direction.
*/
@Override
public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8)
{
float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
par1 /= f2;
par3 /= f2;
par5 /= f2;
par1 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8;
par3 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8;
par5 += this.rand.nextGaussian() * (this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * par8;
par1 *= par7;
par3 *= par7;
par5 *= par7;
this.motionX = par1;
this.motionY = par3;
this.motionZ = par5;
float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f3) * 180.0D / Math.PI);
this.ticksInGround = 0;
}
/**
* Sets the position and rotation. Only difference from the other one is no
* bounding on the rotation. Args: posX,
* posY, posZ, yaw, pitch
*/
@Override
@SideOnly(Side.CLIENT)
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
{
this.setPosition(par1, par3, par5);
this.setRotation(par7, par8);
}
/**
* Sets the velocity to the args. Args: x, y, z
*/
@Override
@SideOnly(Side.CLIENT)
public void setVelocity(double par1, double par3, double par5)
{
this.motionX = par1;
this.motionY = par3;
this.motionZ = par5;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(par3, f) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
this.ticksInGround = 0;
}
}
/**
* Called to update the entity's position/logic.
*/
@SuppressWarnings("rawtypes")
@Override
public void onUpdate()
{
//super.onUpdate();
super.onEntityUpdate();
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
this.prevRotationPitch = this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
}
Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block.getMaterial() != Material.air) {
if (explosive) {
world.createExplosion(this.shootingEntity, this.field_145791_d, this.field_145792_e, this.field_145789_f, 10, true);
this.setDead();
}
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))) {
this.inGround = true;
}
}
if (this.arrowShake > 0) {
--this.arrowShake;
}
if (this.inGround) {
int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
if (block == this.field_145790_g && j == this.inData) {
++this.ticksInGround;
if (this.ticksInGround == 1200) {
this.setDead();
}
} else {
this.inGround = false;
this.motionX *= this.rand.nextFloat() * 0.2F;
this.motionY *= this.rand.nextFloat() * 0.2F;
this.motionZ *= this.rand.nextFloat() * 0.2F;
this.ticksInGround = 0;
this.ticksInAir = 0;
}
} 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);
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);
if (movingobjectposition != null) {
vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double d0 = 0.0D;
int i;
float f1;
for (i = 0; i < list.size(); ++i) {
Entity entity1 = (Entity) list.get(i);
if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
f1 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f1, f1, f1);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
if (movingobjectposition1 != null) {
double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;
if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
movingobjectposition = null;
}
}
float f2;
float f4;
if (movingobjectposition != null) {
if (movingobjectposition.entityHit != null) {
if (explosive) {
world.createExplosion(this.shootingEntity, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 15, false);
movingobjectposition.entityHit.hurtResistantTime = 0;
world.createExplosion(this.shootingEntity, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 4, true);
this.setDead();
}
int k;
if (!ignorSpeed) {
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
k = MathHelper.ceiling_double_int(f2 * this.damage);
if (this.getIsCritical()) {
k += this.rand.nextInt(k / 2 + 2);
}
} else {
k = (int) this.damage;
if (this.getIsCritical()) {
k += this.rand.nextInt(k / 2 + 2);
}
}
DamageSource damagesource = null;
if (this.shootingEntity == null) {
damagesource = DamageSource.causeArrowDamage(this, this);
} else {
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
if (movingobjectposition.entityHit instanceof EntityEnderman)
damagesource = DamageSource.magic;
if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
movingobjectposition.entityHit.setFire(5);
}
movingobjectposition.entityHit.hurtResistantTime = 0;
if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k)) {
if (movingobjectposition.entityHit instanceof EntityLivingBase) {
EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit;
if (!this.worldObj.isRemote) {
entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
}
if (this.knockbackStrength > 0) {
f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f4 > 0.0F) {
movingobjectposition.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6000000238418579D / f4, 0.1D, this.motionZ * this.knockbackStrength * 0.6000000238418579D / f4);
}
}
if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase) {
EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
EnchantmentHelper.func_151385_b((EntityLivingBase) this.shootingEntity, entitylivingbase);
}
if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) {
((EntityPlayerMP) this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
}
}
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
// if (!(movingobjectposition.entityHit instanceof EntityEnderman))
//{
this.setDead();
//}
} else {
this.motionX *= -0.10000000149011612D;
this.motionY *= -0.10000000149011612D;
this.motionZ *= -0.10000000149011612D;
this.rotationYaw += 180.0F;
this.prevRotationYaw += 180.0F;
this.ticksInAir = 0;
}
} else {
this.field_145791_d = movingobjectposition.blockX;
this.field_145792_e = movingobjectposition.blockY;
this.field_145789_f = movingobjectposition.blockZ;
this.field_145790_g = block;
this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
this.motionX = ((float) (movingobjectposition.hitVec.xCoord - this.posX));
this.motionY = ((float) (movingobjectposition.hitVec.yCoord - this.posY));
this.motionZ = ((float) (movingobjectposition.hitVec.zCoord - this.posZ));
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
this.posX -= this.motionX / f2 * 0.05000000074505806D;
this.posY -= this.motionY / f2 * 0.05000000074505806D;
this.posZ -= this.motionZ / f2 * 0.05000000074505806D;
this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
this.inGround = true;
this.arrowShake = 7;
this.setIsCritical(false);
if (this.field_145790_g.getMaterial() != Material.air) {
this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
}
}
}
if (this.getIsCritical()) {
for (i = 0; i < 4; ++i) {
this.worldObj.spawnParticle("crit", this.posX + this.motionX * i / 4.0D, this.posY + this.motionY * i / 4.0D, this.posZ + this.motionZ * i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotationPitch = (float) (Math.atan2(this.motionY, f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f3 = 0.99F;
f1 = 0.05F;
if (this.isInWater()) {
for (int l = 0; l < 4; ++l) {
f4 = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * f4, this.posY - this.motionY * f4, this.posZ - this.motionZ * f4, this.motionX, this.motionY, this.motionZ);
}
f3 = 0.8F;
}
if (this.isWet()) {
this.extinguish();
}
this.motionX *= f3;
this.motionY *= f3;
this.motionZ *= f3;
this.motionY -= f1;
this.setPosition(this.posX, this.posY, this.posZ);
this.func_145775_I();
}
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short) this.field_145791_d);
par1NBTTagCompound.setShort("yTile", (short) this.field_145792_e);
par1NBTTagCompound.setShort("zTile", (short) this.field_145789_f);
par1NBTTagCompound.setShort("life", (short) this.ticksInGround);
par1NBTTagCompound.setByte("inTile", (byte) Block.getIdFromBlock(this.field_145790_g));
par1NBTTagCompound.setByte("inData", (byte) this.inData);
par1NBTTagCompound.setByte("shake", (byte) this.arrowShake);
par1NBTTagCompound.setByte("inGround", (byte) (this.inGround ? 1 : 0));
par1NBTTagCompound.setByte("pickup", (byte) this.canBePickedUp);
par1NBTTagCompound.setDouble("damage", this.damage);
//par1NBTTagCompound.setString("shooter", getShooter() instanceof EntityPlayer ? ((EntityPlayer) getShooter()).getCommandSenderName() : "");
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
this.field_145791_d = par1NBTTagCompound.getShort("xTile");
this.field_145792_e = par1NBTTagCompound.getShort("yTile");
this.field_145789_f = par1NBTTagCompound.getShort("zTile");
this.ticksInGround = par1NBTTagCompound.getShort("life");
this.field_145790_g = Block.getBlockById(par1NBTTagCompound.getByte("inTile") & 255);
this.inData = par1NBTTagCompound.getByte("inData") & 255;
this.arrowShake = par1NBTTagCompound.getByte("shake") & 255;
this.inGround = par1NBTTagCompound.getByte("inGround") == 1;
//dataWatcher.updateObject(SHOOTER_DATAWATCHER_INDEX, par1NBTTagCompound.hasKey("shooter") ? par1NBTTagCompound.getString("shooter") : "");
if (par1NBTTagCompound.hasKey("damage", 99)) {
this.damage = par1NBTTagCompound.getDouble("damage");
}
if (par1NBTTagCompound.hasKey("pickup", 99)) {
this.canBePickedUp = par1NBTTagCompound.getByte("pickup");
} else if (par1NBTTagCompound.hasKey("player", 99)) {
this.canBePickedUp = par1NBTTagCompound.getBoolean("player") ? 1 : 0;
}
}
/**
* Called by a player entity when they collide with an entity
*/
@Override
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) {
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && par1EntityPlayer.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1))) {
flag = false;
}
if (flag) {
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
this.setDead();
}
}
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they
* walk on. used for spiders and wolves to
* prevent them from trampling crops
*/
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
@Override
public void setDamage(double par1)
{
this.damage = par1;
}
@Override
public double getDamage()
{
return this.damage;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
@Override
public void setKnockbackStrength(int par1)
{
this.knockbackStrength = par1;
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
@Override
public boolean canAttackWithItem()
{
return false;
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
@Override
public void setIsCritical(boolean par1)
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
if (par1) {
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 1)));
} else {
this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -2)));
}
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
@Override
public boolean getIsCritical()
{
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
return (b0 & 1) != 0;
}
}
@@ -0,0 +1,24 @@
package draconicevolution.common.items;
import java.util.List;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class DraconicCompound extends TolkienItem {
public DraconicCompound() {
this.setUnlocalizedName(Strings.draconicCompoundName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation)
{
list.add("Imbued with the power of the dragon heart");
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class DraconicCore extends TolkienItem {
public DraconicCore() {
this.setUnlocalizedName(Strings.draconicCoreName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class DraconiumBlend extends TolkienItem {
public DraconiumBlend() {
this.setUnlocalizedName(Strings.draconiumBlendName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class DraconiumDust extends TolkienItem {
public DraconiumDust() {
this.setUnlocalizedName(Strings.draconiumDustName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class DraconiumIngot extends TolkienItem {
public DraconiumIngot() {
this.setUnlocalizedName(Strings.draconiumIngotName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class DragonHeart extends TolkienItem {
public DragonHeart() {
this.setUnlocalizedName(Strings.dragonHeartName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class InfusedCompound extends TolkienItem {
public InfusedCompound() {
this.setUnlocalizedName(Strings.infusedCompoundName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,99 @@
package draconicevolution.common.items;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.util.EnumHelper;
import cpw.mods.fml.common.registry.GameRegistry;
import draconicevolution.common.items.tools.DraconicAxe;
import draconicevolution.common.items.tools.DraconicDistructionStaff;
import draconicevolution.common.items.tools.DraconicHoe;
import draconicevolution.common.items.tools.DraconicPickaxe;
import draconicevolution.common.items.tools.DraconicShovel;
import draconicevolution.common.items.tools.TeleporterMKI;
import draconicevolution.common.items.tools.TeleporterMKII;
import draconicevolution.common.items.tools.WyvernPickaxe;
import draconicevolution.common.items.tools.WyvernShovel;
import draconicevolution.common.items.weapons.DraconicBow;
import draconicevolution.common.items.weapons.DraconicSword;
import draconicevolution.common.items.weapons.WyvernBow;
import 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 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);
public static Item draconicPickaxe;
public static Item draconicShovel;
public static Item draconicHoe;
public static Item draconicAxe;
public static Item draconicSword;
public static Item draconicBow;
public static Item wyvernPickaxe;
public static Item wyvernShovel;
public static Item wyvernSword;
public static Item wyvernBow;
public static Item wyvernChestPlate;
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;
public static Item dragonHeart;
public static Item draconicDistructionStaff;
public static Item draconicCompound;
public static Item tclogo;
public static Item draconicCore;
public static Item sunFocus;
public static Item teleporterMKI;
public static Item teleporterMKII;
public static Item reader;
public static Item testPick;
public static void init()
{
draconicDistructionStaff = new DraconicDistructionStaff();
draconicPickaxe = new DraconicPickaxe();
draconicAxe = new DraconicAxe();
draconicShovel = new DraconicShovel();
draconicHoe = new DraconicHoe();
draconicSword = new DraconicSword();
draconicBow = new DraconicBow();
wyvernPickaxe = new WyvernPickaxe();
wyvernShovel = new WyvernShovel();
wyvernSword = new WyvernSword();
wyvernBow = new WyvernBow();
//wyvernChestPlate = new WyvernChestPlate();
infusedCompound = new InfusedCompound();
draconiumDust = new DraconiumDust();
draconiumIngot = new DraconiumIngot();
draconiumBlend = new DraconiumBlend();
dragonHeart = new DragonHeart();
draconicCompound = new DraconicCompound();
teleporterMKI = new TeleporterMKI();
teleporterMKII = new TeleporterMKII();
tclogo = new Tclogo();
draconicCore = new DraconicCore();
sunFocus = new SunFocus();
//reader = new Reader();
//testPick = new TestPick();
}
public static void register(final TolkienItem item)
{
GameRegistry.registerItem(item, item.getUnwrappedUnlocalizedName(item.getUnlocalizedName()));
}
}
@@ -0,0 +1,13 @@
package draconicevolution.common.items;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.Strings;
public class SunFocus extends TolkienItem {
public SunFocus() {
this.setUnlocalizedName(Strings.sunFocusName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(2));
ModItems.register(this);
}
}
@@ -0,0 +1,153 @@
package draconicevolution.common.items;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.core.handler.ParticleHandler;
import draconicevolution.common.lib.Strings;
public class Tclogo extends TolkienItem {
public Tclogo() {
this.setUnlocalizedName(Strings.tclogoName);
//this.setCreativeTab(draconicevolution.getCreativeTab());
ModItems.register(this);
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 100;
}
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
{
//if (entity.isCollidedHorizontally)// && !world.isRemote)
//entity.setLocationAndAngles(entity.posX+30D, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);;
/*
//System.out.println("Update Tick");
int X = (int)entity.posX;
int Y = (int)entity.posY;
int Z = (int)entity.posZ;
entity.worldObj.spawnParticle("flame", 613, 5, -822, 0, 0, 0);
if (((EntityPlayer)entity).getHeldItem() != null && ((EntityPlayer)entity).getHeldItem().isItemEqual(new ItemStack(ModItems.tclogo)))
{
for(int x = X - 5; x <= X + 5; x++)
{
for(int y = Y; y <= Y; y++)
{
for(int z = Z - 5; z <= Z + 5; z++)
{
entity.worldObj.spawnParticle("flame", x - 0.5, y - 0.5, z - 0.5, 0, 0, 0);
entity.worldObj.scheduleBlockUpdate(x, y, z, entity.worldObj.getBlock(x, y, z), 1);
System.out.println("Update Tick " +X+ " " +Y+ " " +Z);
}
}
}
}*/
}
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.block;
}
@Override
public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return par1ItemStack;
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (world.isRemote)
ParticleHandler.spawnParticle("testParticle", player.posX, player.posY, player.posZ, 0, 0, 0, 1);
return stack;
}
@Override
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 = raytraceFromEntity(player.worldObj, player, true, 4.5D);
System.out.println(mop.sideHit);
return false;
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
{
System.out.println("Use Tick");
super.onUsingTick(stack, player, count);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation)
{
list.add(EnumChatFormatting.AQUA + "AQUA");
list.add(EnumChatFormatting.BLACK + "BLACK");
list.add(EnumChatFormatting.BLUE + "BLUE");
list.add(EnumChatFormatting.DARK_AQUA + "DARK_AQUA");
list.add(EnumChatFormatting.DARK_BLUE + "DARK_BLUE");
list.add(EnumChatFormatting.DARK_GRAY + "DARK_GRAY");
list.add(EnumChatFormatting.DARK_GREEN + "DARK_GREEN");
list.add(EnumChatFormatting.DARK_PURPLE + "DARK_PURPLE");
list.add(EnumChatFormatting.DARK_RED + "DARK_RED");
list.add(EnumChatFormatting.GOLD + "GOLD");
list.add(EnumChatFormatting.GRAY + "GRAY");
list.add(EnumChatFormatting.GREEN + "GREEN");
list.add(EnumChatFormatting.LIGHT_PURPLE + "LIGHT_PURPLE");
list.add(EnumChatFormatting.RED + "RED");
list.add(EnumChatFormatting.WHITE + "WHITE");
list.add(EnumChatFormatting.YELLOW + "YELLOW");
list.add(EnumChatFormatting.BOLD + "BOLD");
list.add(EnumChatFormatting.ITALIC + "ITALIC");
list.add(EnumChatFormatting.OBFUSCATED + "OBFUSCATED");
list.add(EnumChatFormatting.UNDERLINE + "UNDERLINE");
list.add(EnumChatFormatting.STRIKETHROUGH + "STRIKETHROUGH");
}
public static MovingObjectPosition raytraceFromEntity (World world, Entity player, boolean par3, double range)
{
float f = 1.0F;
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f;
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);
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);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = range;
if (player instanceof EntityPlayerMP)
{
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
}
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
}
}
@@ -0,0 +1,35 @@
package draconicevolution.common.items;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.lib.References;
public class TolkienItem extends Item {
public String getUnwrappedUnlocalizedName(final String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
@Override
public String getUnlocalizedName()
{
return String.format("item.%s", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
@Override
public String getUnlocalizedName(final ItemStack itemStack)
{
return String.format("item.%s", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
}
@@ -0,0 +1,79 @@
package 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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import 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);
}
}
@@ -0,0 +1,185 @@
package draconicevolution.common.items.tools;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconicAxe extends ItemAxe
{
public DraconicAxe() {
super(ModItems.DRACONIUM_T1);
this.setUnlocalizedName(Strings.draconicAxeName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.draconicAxeName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_axe");
}
@Override
public boolean onBlockStartBreak(ItemStack stack, int X, int Y, int Z, EntityPlayer player)
{
World world = player.worldObj;
boolean tree = isTree(world, X, Y, Z);
if (!tree)
{
return false;
}
if (player.isSneaking())
{
return false;
}
if (!world.isRemote)
world.playAuxSFX(2001, X, Y, Z, Block.getIdFromBlock(world.getBlock(X, Y, Z)));
trimLeavs(X, Y, Z, player, world, stack);
chopTree(X, Y, Z, player, world, stack);
return true;
}
private boolean isTree(World world, int X, int Y, int Z)
{
final Block wood = world.getBlock(X, Y, Z);
if (wood == null || !wood.isWood(world, X, Y, Z))
{
return false;
}
else
{
int top = Y;
for (int y = Y; y <= Y + 50; y++)
{
if (!world.getBlock(X, y, Z).isWood(world, X, y, Z) && !world.getBlock(X, y, Z).isLeaves(world, X, y, Z))
{
top += y;
break;
}
}
int leaves = 0;
for (int xPos = X - 1; xPos <= X + 1; xPos++)
{
for (int yPos = Y; yPos <= top; yPos++)
{
for (int zPos = Z - 1; zPos <= Z + 1; zPos++)
{
if (world.getBlock(xPos, yPos, zPos).isLeaves(world, xPos, yPos, zPos))
leaves++;
}
}
}
if (leaves >= 3)
return true;
}
return false;
}
void chopTree(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack)
{
for (int xPos = X - 1; xPos <= X + 1; xPos++)
{
for (int yPos = Y; yPos <= Y + 1; yPos++)
{
for (int zPos = Z - 1; zPos <= Z + 1; zPos++)
{
Block block = world.getBlock(xPos, yPos, zPos);
int meta = world.getBlockMetadata(xPos, yPos, zPos);
if(block.isWood(world, xPos, yPos, zPos))
{
world.setBlockToAir(xPos, yPos, zPos);
if (!player.capabilities.isCreativeMode)
{
if (block.removedByPlayer(world, player, xPos, yPos, zPos))
{
block.onBlockDestroyedByPlayer(world, xPos, yPos, zPos, meta);
}
block.harvestBlock(world, player, xPos, yPos, zPos, meta);
block.onBlockHarvested(world, xPos, yPos, zPos, meta, player);
onBlockDestroyed(stack, world, block, xPos, yPos, zPos, player);
}
chopTree(xPos, yPos, zPos, player, world, stack);
}//else
//trimLeavs(xPos, yPos, zPos, player, world, stack);
}
}
}
}
void trimLeavs(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack)
{
scedualUpdates(X, Y, Z, player, world, stack);
}
void scedualUpdates(int X, int Y, int Z, EntityPlayer player, World world, ItemStack stack)
{
for (int xPos = X - 15; xPos <= X + 15; xPos++)
{
for (int yPos = Y; yPos <= Y + 50; yPos++)
{
for (int zPos = Z - 15; zPos <= Z + 15; zPos++)
{
Block block = world.getBlock(xPos, yPos, zPos);
if(block.isLeaves(world, xPos, yPos, zPos))
{
world.scheduleBlockUpdate(xPos, yPos, zPos, block, 2 + world.rand.nextInt(10));
}
}
}
}
}
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int x, int y, int z, int side, float par8, float par9, float par10)
{
//System.out.println(x + " " + y + " " + z);
return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, x, y, z, side, par8, par9, par10);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation)
{
list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.draconicAxe1.txt"));
list.add("");
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicLaw1.txt"));
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicLaw2.txt"));
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.rare;
}
public static void registerRecipe()
{
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);
}
}
@@ -0,0 +1,187 @@
package draconicevolution.common.items.tools;
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.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import com.google.common.collect.Multimap;
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;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconicDistructionStaff extends ItemTool {
public IIcon itemIcon0;
public IIcon itemIcon1;
public IIcon itemIcon2;
private static Set<Block> minableBlocks = Sets.newHashSet();
private static final Set<Block> 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<Block> 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<Block> field_150917_c = Sets.newHashSet(new Block[] { Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.pumpkin, Blocks.lit_pumpkin });
static {
for (Block block : field_150915_c) {
minableBlocks.add(block);
}
for (Block block : field_150916_c) {
minableBlocks.add(block);
}
for (Block block : field_150917_c) {
minableBlocks.add(block);
}
}
public DraconicDistructionStaff() {
super(0F, ModItems.DRACONIUM_T3, minableBlocks);
this.setUnlocalizedName(Strings.draconicDStaffName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
this.setHarvestLevel("pickaxe", 4);
this.setHarvestLevel("spade", 4);
this.setHarvestLevel("axe", 4);
GameRegistry.registerItem(this, Strings.draconicDStaffName);
}
@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);
}
@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;
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon0 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_staff");
this.itemIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_staff_active");
this.itemIcon2 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_staff_obliterate");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
public boolean onBlockStartBreak(final ItemStack stack, final int x, final int y, final int z, final EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
Material mat = block.getMaterial();
if (!ToolHandler.isRightMaterial(mat, ToolHandler.materialsDStaff)) {
return false;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
ToolHandler.disSquare(x, y, z, player, world, silk, fortune, ToolHandler.materialsDStaff, stack);
return false;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
return ToolHandler.changeMode(stack, player, true, 4);
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
ToolHandler.AOEAttack(player, entity, stack, 25, ItemNBTHelper.getShort(stack, "size", (short)0) * 2);
ToolHandler.demageEntytyBasedOnHealth(entity, player, 0.5F);
return true;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Multimap getItemAttributeModifiers()
{
Multimap multimap = super.getItemAttributeModifiers();
multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double) 4.0F + ModItems.DRACONIUM_T2.getDamageVsEntity(), 0));
return multimap;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
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)))
list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information");
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"));
list.add(EnumChatFormatting.GREEN + "Right-click to toggle Obliteration mode");
list.add(EnumChatFormatting.GREEN + "Obliteration mode destroys low value blocks");
list.add("");
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "After great pains you have managed");
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + "to master the Draconic powers!");
}
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.epic;
}
public static void registerRecipe()
{
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);
}
}
@@ -0,0 +1,145 @@
package draconicevolution.common.items.tools;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IIconRegister;
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.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconicHoe extends ItemHoe
{
public DraconicHoe() {
super(ModItems.DRACONIUM_T1);
this.setUnlocalizedName(Strings.draconicHoeName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.draconicHoeName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_hoe");
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
Block clicked = world.getBlock(x, y, z);
if(!player.isSneaking() && player.canPlayerEdit(x, y, z, par7, stack) && (clicked == Blocks.dirt || clicked == Blocks.grass || clicked == Blocks.farmland) && par7 == 1)
{
int size = 4;
for (int x1 = -size; x1 <= size; x1++)
{
for (int z1 = -size; z1 <= size; z1++)
{
if (world.getBlock(x + x1, y + 1, z + z1) == Blocks.tallgrass || world.getBlock(x + x1, y + 1, z + z1) == Blocks.snow_layer || world.getBlock(x + x1, y + 1, z + z1) == Blocks.double_plant)
{
world.setBlockToAir(x + x1, y + 1, z + z1);
}
if (world.getBlock(x + x1, y, z + z1) == Blocks.tallgrass || world.getBlock(x + x1, y, z + z1) == Blocks.snow_layer || world.getBlock(x + x1, y, z + z1) == Blocks.double_plant)
{
world.setBlockToAir(x + x1, y, z + z1);
}
if (world.getBlock(x + x1, y, z + z1) == Blocks.air){
if(player.inventory.hasItem(Item.getItemFromBlock(Blocks.dirt)) || player.capabilities.isCreativeMode)
{
world.setBlock(x + x1, y, z + z1, Blocks.dirt);
player.inventory.consumeInventoryItem(Item.getItemFromBlock(Blocks.dirt));
}
}
if ((world.getBlock(x + x1, y + 1, z + z1) == Blocks.dirt || world.getBlock(x + x1, y + 1, z + z1) == Blocks.grass || world.getBlock(x + x1, y + 1, z + z1) == Blocks.farmland) && world.getBlock(x + x1, y + 2, z + z1) == Blocks.air)
{
if (!world.isRemote)
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Item.getItemFromBlock(Blocks.dirt))));
world.setBlock(x + x1, y + 1, z + z1, Blocks.air);
}
hoe(stack, player, world, x + x1, y, z + z1, par7);
}
}
}
else
hoe(stack, player, world, x, y, z, par7);
return false;
}
private boolean hoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7){
if (!player.canPlayerEdit(x, y, z, par7, stack))
{
return false;
} else
{
UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
stack.damageItem(1, player);
return true;
}
Block block = world.getBlock(x, y, z);
if (par7 != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt))
{
Block block1 = Blocks.farmland;
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);
if (world.isRemote)
{
return true;
} else
{
world.setBlock(x, y, z, block1);
stack.damageItem(1, player);
return true;
}
} else
{
return false;
}
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation)
{
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicLaw1.txt"));
list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("info.draconicLaw2.txt"));
}
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);
}
}
@@ -0,0 +1,131 @@
package draconicevolution.common.items.tools;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconicPickaxe extends ItemPickaxe {
public IIcon itemIcon0;
public IIcon itemIcon1;
public IIcon itemIcon2;
public DraconicPickaxe() {
super(ModItems.DRACONIUM_T2);
this.setUnlocalizedName(Strings.draconicPickaxeName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.draconicPickaxeName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon0 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_pick");
this.itemIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_pick_active");
this.itemIcon2 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_pick_obliterate");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
public boolean onBlockStartBreak(final ItemStack stack, final int x, final int y, final int z, final EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
Material mat = block.getMaterial();
if (!ToolHandler.isRightMaterial(mat, ToolHandler.materialsPick)) {
return false;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
ToolHandler.disSquare(x, y, z, player, world, silk, fortune, ToolHandler.materialsPick, stack);
return false;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
return ToolHandler.changeMode(stack, player, true, 3);
}
public static int getMode(final ItemStack tool)
{
return tool.getItemDamage();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
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)))
list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information");
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"));
list.add(EnumChatFormatting.GREEN + "Right-click to toggle Obliteration mode");
list.add(EnumChatFormatting.GREEN + "Obliteration mode destroys low value blocks");
list.add("");
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");
}
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.rare;
}
public static void registerRecipe()
{
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);
}
}
@@ -0,0 +1,131 @@
package draconicevolution.common.items.tools;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconicShovel extends ItemSpade {
public IIcon itemIcon0;
public IIcon itemIcon1;
public IIcon itemIcon2;
public DraconicShovel() {
super(ModItems.DRACONIUM_T2);
this.setUnlocalizedName(Strings.draconicShovelName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.draconicShovelName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon0 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_shovel");
this.itemIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_shovel_active");
this.itemIcon2 = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_shovel_obliterate");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0 && ItemNBTHelper.getBoolean(stack, "obliterate", false))
return itemIcon2;
else if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
public boolean onBlockStartBreak(final ItemStack stack, final int x, final int y, final int z, final EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
Material mat = block.getMaterial();
if (!ToolHandler.isRightMaterial(mat, ToolHandler.materialsShovel)) {
return false;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
ToolHandler.disSquare(x, y, z, player, world, silk, fortune, ToolHandler.materialsShovel, stack);
return false;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
return ToolHandler.changeMode(stack, player, true, 3);
}
public static int getMode(final ItemStack tool)
{
return tool.getItemDamage();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
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)))
list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information");
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"));
list.add(EnumChatFormatting.GREEN + "Right-click to toggle Obliteration mode");
list.add(EnumChatFormatting.GREEN + "Obliteration mode destroys low value blocks");
list.add("");
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");
}
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.rare;
}
public static void registerRecipe()
{
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);
}
}
@@ -0,0 +1,94 @@
package draconicevolution.common.items.tools;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class Reader extends Item
{
public Reader() {
this.setUnlocalizedName(Strings.readerName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
this.setMaxStackSize(1);
GameRegistry.registerItem(this, Strings.readerName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.readerName);
}
@Override
public IIcon getIcon(ItemStack stack, int pass)
{
return itemIcon;//(new ItemStack(Items.apple)).getIconIndex();
}
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
ItemStack selectedItem = getSelectedItem(player.worldObj, player, 1);
if (selectedItem != null)
return selectedItem.getIconIndex();
else
return itemIcon;
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
player.displayGUIBook(new ItemStack(Items.writable_book));
if (!world.isRemote && player.isSneaking())
{
//FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_READER, world, (int) player.posX, (int) player.posY, (int) player.posZ);
}else if (!player.isSneaking()){
//System.out.println((getSelectedItem(world, player, 1).useItemRightClick(world, player)));
}
/*
ItemStack book = new ItemStack(ModItems.teleporterMKII);
book.useItemRightClick(par2World, par3EntityPlayer);
*/
return super.onItemRightClick(stack, world, player);
}
public ItemStack getSelectedItem(World world, EntityPlayer player, int item) {
ItemStack reader = player != null? player.getCurrentEquippedItem(): null;
ItemStack selectedItem = null;
if(reader != null && reader.getItem() instanceof Reader) {
NBTTagCompound inventoryTagCompound = reader.hasTagCompound() ? reader.stackTagCompound: new NBTTagCompound();
NBTTagList inventoryTagList = inventoryTagCompound.getTagList("Inventory", 10);
if (inventoryTagList != null) {
for (int i = 0; i < inventoryTagList.tagCount(); i++) {
NBTTagCompound itemTagCompound = inventoryTagList.getCompoundTagAt(i);
byte byte0 = itemTagCompound.getByte("Slot");
if (byte0 == item) {
selectedItem = ItemStack.loadItemStackFromNBT(itemTagCompound);
}
}
return selectedItem;
}
}
return selectedItem;
}
}
@@ -0,0 +1,185 @@
package draconicevolution.common.items.tools;
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.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.core.utills.Teleporter;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class TeleporterMKI extends Item
{
public TeleporterMKI() {
this.setUnlocalizedName(Strings.teleporterMKIName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
this.setMaxDamage(19);
this.setMaxStackSize(1);
GameRegistry.registerItem(this, Strings.teleporterMKIName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.teleporterMKIName);
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
boolean isSet = ItemNBTHelper.getBoolean(stack, "IsSet", false);
double x = ItemNBTHelper.getDouble(stack, "X", 0);
double y = ItemNBTHelper.getDouble(stack, "Y", 0);
double z = ItemNBTHelper.getDouble(stack, "Z", 0);
int dim = ItemNBTHelper.getIntager(stack, "Dimension", 0);
if (!(entity instanceof EntityPlayer))
{
if (entity.dimension == dim)
{
if (isSet)
{
if (player.getHealth() > 2 || player.capabilities.isCreativeMode)
{
stack.damageItem(1, player);
if (!player.capabilities.isCreativeMode)
player.setHealth(player.getHealth() - 2);
travelEffect(player.worldObj, entity);
entity.setPosition(x, y, z);
travelEffect(player.worldObj, entity);
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterSentMob.txt").getFormattedText() + "x:" + (int) x + " y:" + (int) y + " z:" + (int) z));
} else if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterLowHealth.txt"));
} else if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt"));
} else if (player.worldObj.isRemote)
{
player.addChatMessage(new ChatComponentTranslation("msg.teleporterEntityDimensional.txt"));
}
}
return true;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
boolean isSet = ItemNBTHelper.getBoolean(stack, "IsSet", false);
double x = ItemNBTHelper.getDouble(stack, "X", 0);
double y = ItemNBTHelper.getDouble(stack, "Y", 0);
double z = ItemNBTHelper.getDouble(stack, "Z", 0);
float yaw = ItemNBTHelper.getFloat(stack, "Yaw", 0);
float pitch = ItemNBTHelper.getFloat(stack, "Pitch", 0);
int dim = ItemNBTHelper.getIntager(stack, "Dimension", 0);
if (player.isSneaking())
{
if (!isSet)
{
ItemNBTHelper.setDouble(stack, "X", player.posX);
ItemNBTHelper.setDouble(stack, "Y", player.posY);
ItemNBTHelper.setDouble(stack, "Z", player.posZ);
ItemNBTHelper.setFloat(stack, "Yaw", player.rotationYaw);
ItemNBTHelper.setFloat(stack, "Pitch", player.rotationPitch);
ItemNBTHelper.setIntager(stack, "Dimension", player.dimension);
ItemNBTHelper.setBoolean(stack, "IsSet", true);
if (world.isRemote)
player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterBound.txt").getFormattedText() + "{X:" + (int) player.posX + " Y:" + (int) player.posY + " Z:" + (int) player.posZ + " Dim:" + player.worldObj.provider.getDimensionName() + "}"));
} else if (world.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterAlreadySet.txt"));
} else
{
if (isSet)
{
if ((player.getHealth() > 2 || player.capabilities.isCreativeMode) && !player.isRiding())
{
stack.damageItem(1, player);
if (!player.capabilities.isCreativeMode)
player.setHealth(player.getHealth() - 2);
travelEffect(world, player);
Teleporter.teleport(player, x, y, z, yaw, pitch, dim);
travelEffect(world, player);
} else if (world.isRemote && player.getHealth() <= 2 && !player.capabilities.isCreativeMode)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterLowHealth.txt"));
} else if (world.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt"));
}
return stack;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation)
{
if (!ItemNBTHelper.getBoolean(stack, "IsSet", false))
{
list.add(EnumChatFormatting.RED + StatCollector.translateToLocal("info.teleporterInfUnset1.txt"));
list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset2.txt"));
list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset3.txt"));
list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset4.txt"));
list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfUnset5.txt"));
} else
{
list.add(EnumChatFormatting.GREEN + StatCollector.translateToLocal("info.teleporterInfSet1.txt"));
list.add(EnumChatFormatting.WHITE + "{x:" + (int) ItemNBTHelper.getDouble(stack, "X", 0) + " y:" + (int) ItemNBTHelper.getDouble(stack, "Y", 0) + " z:" + (int) ItemNBTHelper.getDouble(stack, "Z", 0) + " Dim:" + WorldProvider.getProviderForDimension(ItemNBTHelper.getIntager(stack, "Dimension", 0)).getDimensionName() + "}");
list.add(EnumChatFormatting.BLUE + String.valueOf(stack.getMaxDamage() - stack.getItemDamage() + 1) + " " + StatCollector.translateToLocal("info.teleporterInfSet2.txt"));
}
}
public void travelEffect(World world, Entity entity)
{
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "portal.travel", 1F, entity.worldObj.rand.nextFloat() * 0.1F + 0.9F);
/*
for (int i = 0; i < 100; i++)
{
if (entity instanceof EntityPlayer)
{
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY - 1 + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
} else
{
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY + 1 + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
}
}
*/
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.uncommon;
}
public static void registerRecipe()
{
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.teleporterMKI), "BDB", "DED", "BDB", 'D', ModItems.draconiumDust, 'E', Items.ender_eye, 'B', Items.blaze_powder);
}
}
@@ -0,0 +1,189 @@
package draconicevolution.common.items.tools;
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.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
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 draconicevolution.client.interfaces.GuiHandler;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.core.utills.Teleporter;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class TeleporterMKII extends Item
{
public TeleporterMKII() {
this.setUnlocalizedName(Strings.teleporterMKIIName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
this.setMaxStackSize(1);
GameRegistry.registerItem(this, Strings.teleporterMKIIName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + Strings.teleporterMKIIName);
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
short selection = ItemNBTHelper.getShort(stack, "Selection", (short) 0);
double x = ItemNBTHelper.getDouble(stack, "X_" + selection, 0);
double y = ItemNBTHelper.getDouble(stack, "Y_" + selection, 0);
double z = ItemNBTHelper.getDouble(stack, "Z_" + selection, 0);
boolean isSet = ItemNBTHelper.getBoolean(stack, "IsSet_" + selection, false);
int dim = ItemNBTHelper.getIntager(stack, "Dimension_" + selection, 0);
int fuel = ItemNBTHelper.getIntager(stack, "Fuel", 0);
if (entity instanceof EntityPlayer)
{
return true;
}
if (entity.dimension != dim)
{
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterEntityDimensional.txt"));
return true;
}
if (!isSet)
{
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt"));
return true;
}
if (!player.capabilities.isCreativeMode && fuel <= 0)
{
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt"));
return true;
}
if (!player.capabilities.isCreativeMode && fuel > 0)
ItemNBTHelper.setIntager(stack, "Fuel", fuel - 1);
travelEffect(player.worldObj, entity);
entity.setPosition(x, y, z);
travelEffect(player.worldObj, entity);
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentText(new ChatComponentTranslation("msg.teleporterSentMob.txt").getFormattedText() + "x:" + (int) x + " y:" + (int) y + " z:" + (int) z));
return true;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
short selection = ItemNBTHelper.getShort(stack, "Selection", (short) 0);
double x = ItemNBTHelper.getDouble(stack, "X_" + selection, 0);
double y = ItemNBTHelper.getDouble(stack, "Y_" + selection, 0);
double z = ItemNBTHelper.getDouble(stack, "Z_" + selection, 0);
boolean isSet = ItemNBTHelper.getBoolean(stack, "IsSet_" + selection, false);
float yaw = ItemNBTHelper.getFloat(stack, "Yaw_" + selection, 0);
float pitch = ItemNBTHelper.getFloat(stack, "Pitch_" + selection, 0);
int dim = ItemNBTHelper.getIntager(stack, "Dimension_" + selection, 0);
int fuel = ItemNBTHelper.getIntager(stack, "Fuel", 0);
if (player.isSneaking())
{
if (world.isRemote)
{
FMLNetworkHandler.openGui(player, DraconicEvolution.instance, GuiHandler.GUIID_TELEPORTER, world, (int) player.posX, (int) player.posY, (int) player.posZ);
}
} else
{
if (player.isRiding())
{
return stack;
}
if (!isSet)
{
if (world.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterUnSet.txt"));
return stack;
}
if (!player.capabilities.isCreativeMode && fuel <= 0)
{
if (world.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.teleporterOutOfFuel.txt"));
return stack;
}
if (!player.capabilities.isCreativeMode && fuel > 0)
ItemNBTHelper.setIntager(stack, "Fuel", fuel - 1);
travelEffect(world, player);
Teleporter.teleport(player, x, y, z, yaw, pitch, dim);
player.fallDistance = 0;
player.setVelocity(0, 0, 0);
travelEffect(world, player);
}
return stack;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(final ItemStack stack, final EntityPlayer player, final List list, final boolean extraInformation)
{
int selected = ItemNBTHelper.getShort(stack, "Selection", (short) 0);
list.add(EnumChatFormatting.WHITE + ItemNBTHelper.getString(stack, "Dest_" + selected, "Destination " + selected));
list.add(EnumChatFormatting.WHITE + StatCollector.translateToLocal("info.teleporterInfFuel.txt") + " " + ItemNBTHelper.getIntager(stack, "Fuel", 0));
}
public void travelEffect(World world, Entity entity)
{
entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "portal.travel", 1F, entity.worldObj.rand.nextFloat() * 0.1F + 0.9F);
/*
for (int i = 0; i < 100; i++)
{
if (entity instanceof EntityPlayer)
{
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY - 1 + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
} else
{
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
world.spawnParticle("portal", entity.posX + (world.rand.nextFloat() - 0.5), entity.posY + 1 + (world.rand.nextFloat() - 0.5), entity.posZ + (world.rand.nextFloat() - 0.5), 0D, 0D, 0D);
}
}
*/
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.uncommon;
}
public static void registerRecipe()
{
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.teleporterMKII), "BIB", "DED", "BIB", 'D', ModItems.draconicCore, 'E', ModItems.teleporterMKI, 'B', ModItems.draconiumIngot, 'I', ModItems.infusedCompound);
}
}
@@ -0,0 +1,122 @@
package 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<Block> 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<ItemStack> 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;
}
}
@@ -0,0 +1,194 @@
package draconicevolution.common.items.tools;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import draconicevolution.common.core.helper.ItemNBTHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
public class ToolHandler {
public static Material[] materialsPick = { Material.anvil, Material.circuits, Material.coral, Material.glass, Material.ice, Material.iron, Material.rock };
public static Material[] materialsShovel = { Material.clay, Material.ground, Material.grass, Material.sand, Material.snow, Material.craftedSnow };
public static Material[] materialsAxe = { Material.cactus, Material.leaves, Material.wood, Material.plants };
public static Material[] materialsDStaff = { Material.anvil, Material.circuits, Material.coral, Material.glass, Material.ice, Material.iron, Material.rock, Material.clay, Material.ground, Material.grass, Material.sand, Material.snow, Material.craftedSnow, Material.cactus, Material.leaves, Material.wood, Material.plants };
public static Block[] destroyList = { Blocks.cobblestone, Blocks.stone, Blocks.dirt, Blocks.gravel, Blocks.sand, Blocks.grass, Blocks.netherrack };
public static boolean isRightMaterial(final Material material, final Material[] materialsListing)
{
for (final Material mat : materialsListing) {
if (material == mat) {
return true;
}
}
return false;
}
public static boolean checkDestroyList(Block curBlock)
{
for (Block block : destroyList) {
if (curBlock == block) {
return true;
}
}
return false;
}
public static void disSquare(int x, int y, int z, final EntityPlayer player, final World world, final boolean silk, final int fortune, Material[] materialsListing, ItemStack stack)
{
int size = ItemNBTHelper.getShort(stack, "size", (short)0);
int dyrection = getBlockFace(player, x, y, z);
int sizeX = size;
int sizeY = size;
int sizeZ = size;
int yOff = (size * -1);
if (size > 0)
yOff++;
if (ItemNBTHelper.getShort(stack, "size", (short)0) == 0)
return;
switch (dyrection) {
case 1:
sizeX = 0;
break;
case 2:
sizeY = 0;
yOff = 0;
break;
case 3:
sizeZ = 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++) {
if ((x1 != x) || (y1 != y) || (z1 != z))
mineBlock(x1, y1, z1, player, world, silk, fortune, materialsListing, stack);
}
}
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void mineBlock(final int x, final int y, final int z, final EntityPlayer player, final World world, final boolean silk, final int fortune, Material[] materialsListing, 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<ItemStack> items = new ArrayList();
if ((!block.canHarvestBlock(player, meta)) || (!isRightMaterial(mat, materialsListing))) {
return;
}
if (checkDestroyList(block) && (ItemNBTHelper.getBoolean(stack, "obliterate", false))) {
world.setBlockToAir(x, y, z);
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, (int)player.posX, (int)player.posY, (int)player.posZ, block.getExpDrop(world, meta, fortune));
int xp = block.getExpDrop(world, meta, fortune);
player.addExperience(xp);
}
world.setBlockToAir(x, y, z);
if (!world.isRemote && !(((EntityPlayerMP) player).theItemInWorldManager.getGameType() == GameType.CREATIVE)) {
for (final ItemStack item : items) {
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, item));
}
}
}
}
public static int getBlockFace(EntityPlayer player, int blockX, int blockY, int blockZ)
{
double playerX = player.posX;
double playerY = player.posY;
if (!player.worldObj.isRemote)
playerY += 1.62D;
if (player.isSneaking())
playerY += -1.62;
double playerZ = player.posZ;
double xx = Math.abs(playerX - (blockX + 0.5));
double yy = Math.abs(playerY - (blockY + 0.5));
double zz = Math.abs(playerZ - (blockZ + 0.5));
if ((xx > yy) && (xx > zz))
return 1;
else if ((yy > xx) && (yy > zz))
return 2;
else
return 3;
}
public static ItemStack changeMode(ItemStack stack, EntityPlayer player, boolean hasOblit, int maxSize)
{
if (player.isSneaking()) {
if (ItemNBTHelper.getShort(stack, "size", (short)0) < maxSize)
ItemNBTHelper.setShort(stack, "size", (short) (ItemNBTHelper.getShort(stack, "size", (short) 0) + 1));
else
ItemNBTHelper.setShort(stack, "size", (short) 0);
if (!player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.size" + ItemNBTHelper.getShort(stack, "size", (short)0) + ".txt"));
} else {
if (hasOblit) {
ItemNBTHelper.setBoolean(stack, "obliterate", !ItemNBTHelper.getBoolean(stack, "obliterate", false));
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.oblit" + ItemNBTHelper.getBoolean(stack, "obliterate", false) + ".txt"));
}
}
return stack;
}
public static void demageEntytyBasedOnHealth(Entity entity, EntityPlayer player, float dmg)
{
World world = player.worldObj;
if (entity.getEyeHeight() > 0) {
float entHealth = ((EntityLivingBase) entity).getHealth();
if (!world.isRemote) {
if (entHealth > 20) {
entity.attackEntityFrom(DamageSource.causePlayerDamage(player), (entHealth) * dmg);
}
}
}
}
@SuppressWarnings({ "rawtypes", "unused" })
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);
List list = world.getEntitiesWithinAABBExcludingEntity(player, box);
for (Object o : list) {
if (((Entity) o) instanceof EntityLivingBase)
((Entity) o).attackEntityFrom(DamageSource.causePlayerDamage(player), dmg + sharp);
}
}
}
@@ -0,0 +1,124 @@
package draconicevolution.common.items.tools;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class WyvernPickaxe extends ItemPickaxe {
public IIcon itemIcon0;
public IIcon itemIcon1;
public WyvernPickaxe() {
super(ModItems.DRACONIUM_T1);
this.setUnlocalizedName(Strings.wyvernPickaxeName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.wyvernPickaxeName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon0 = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_pick");
this.itemIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_pick_active");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
public boolean onBlockStartBreak(final ItemStack stack, final int x, final int y, final int z, final EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
Material mat = block.getMaterial();
if (!ToolHandler.isRightMaterial(mat, ToolHandler.materialsPick)) {
return false;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
ToolHandler.disSquare(x, y, z, player, world, silk, fortune, ToolHandler.materialsPick, stack);
return false;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
return ToolHandler.changeMode(stack, player, false, 1);
}
public static int getMode(final ItemStack tool)
{
return tool.getItemDamage();
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
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;
if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54)))
list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information");
else {
list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size);
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);
}
}
@@ -0,0 +1,122 @@
package draconicevolution.common.items.tools;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class WyvernShovel extends ItemSpade {
public IIcon itemIcon0;
public IIcon itemIcon1;
public WyvernShovel() {
super(ModItems.DRACONIUM_T1);
this.setUnlocalizedName(Strings.wyvernShovelName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.wyvernShovelName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon0 = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_shovel");
this.itemIcon1 = iconRegister.registerIcon(References.RESOURCESPREFIX + "wyvern_shovel_active");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconIndex(ItemStack stack)
{
if (ItemNBTHelper.getShort(stack, "size", (short)0) > 0)
return itemIcon1;
else
return itemIcon0;
}
@Override
public boolean onBlockStartBreak(final ItemStack stack, final int x, final int y, final int z, final EntityPlayer player)
{
World world = player.worldObj;
Block block = world.getBlock(x, y, z);
Material mat = block.getMaterial();
if (!ToolHandler.isRightMaterial(mat, ToolHandler.materialsShovel)) {
return false;
}
int fortune = EnchantmentHelper.getFortuneModifier(player);
boolean silk = EnchantmentHelper.getSilkTouchModifier(player);
ToolHandler.disSquare(x, y, z, player, world, silk, fortune, ToolHandler.materialsShovel, stack);
return false;
}
@Override
public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer player)
{
return ToolHandler.changeMode(stack, player, false, 1);
}
public static int getMode(final ItemStack tool)
{
return tool.getItemDamage();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
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;
if ((!Keyboard.isKeyDown(42)) && (!Keyboard.isKeyDown(54)))
list.add(EnumChatFormatting.DARK_GREEN + "Hold shift for information");
else {
list.add(EnumChatFormatting.GREEN + "Mining Mode: " + EnumChatFormatting.BLUE + size + "x" + size);
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.wyvernShovel), " C ", "CDC", " C ", 'C', ModItems.infusedCompound, 'D', Items.diamond_shovel);
}
}
@@ -0,0 +1,97 @@
package draconicevolution.common.items.weapons;
import java.util.Random;
import draconicevolution.common.entity.EntityDraconicArrow;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
public class BowHandler {
public static void standerdShot(ItemStack stack, World world, EntityPlayer player, int count, Random itemRand, float pullSpeedModifier, float speedModifier, boolean ignorSpeedWhenCalculatingDamage, double ignorSpeedCompensation, float soundPitchModifier, boolean isExplosive, int minRelease)
{
int j = 72000 - count;
ArrowLooseEvent event = new ArrowLooseEvent(player, stack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
return;
}
j = event.charge;
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;
if (flag || player.inventory.hasItem(Items.arrow)) {
float f = j / pullSpeedModifier;
f = (f * f + f * 2.0F) / 3.0F;
if ((j < minRelease) || f < 0.1D)
return;
if (f > 1.0F)
f = 1.0F;
f *= speedModifier;
EntityDraconicArrow entityarrow = new EntityDraconicArrow(stack, world, player, f * 2.0F);//.setShooter(player);
if (f >= 1.0F)
entityarrow.setIsCritical(true);
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
if (k > 0) //
entityarrow.setDamage(entityarrow.getDamage() + k + 0.5D);
int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
if (l > 0)
entityarrow.setKnockbackStrength(l * 2);
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
entityarrow.setFire(200);
if (ignorSpeedWhenCalculatingDamage) {
entityarrow.ignorSpeed = true;
entityarrow.setDamage(entityarrow.getDamage() + ignorSpeedCompensation);
}
if (isExplosive) {
if ((player.inventory.hasItemStack(new ItemStack(Items.gunpowder, 4)) || player.capabilities.isCreativeMode)) {
entityarrow.explosive = isExplosive;
for (int i = 0; i < 4; ++i)
player.inventory.consumeInventoryItem(Items.gunpowder);
} else {
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.bowoutofgunpowder.txt"));
}
}
stack.damageItem(1, player); //
world.playSoundAtEntity(player, "random.bow", 1.0F, soundPitchModifier * (1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.3F));
if (flag)
entityarrow.canBePickedUp = 2;
else {
entityarrow.canBePickedUp = 1;
player.inventory.consumeInventoryItem(Items.arrow);
}
if (!world.isRemote)
world.spawnEntityInWorld(entityarrow);
}
}
public static void rapidFire(EntityPlayer player, int count, int speed)
{
int ticks = 72000 - count;
if (ticks > speed) {
//if (!player.isSneaking())
player.stopUsingItem();
}
}
}
@@ -0,0 +1,214 @@
package draconicevolution.common.items.weapons;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import 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;
public DraconicBow() {
this.maxStackSize = 1;
this.setMaxDamage(-1);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
this.setUnlocalizedName(Strings.draconicBowName);
GameRegistry.registerItem(this, Strings.draconicBowName);
}
/* ======================================== CUSTOMEBOW START =====================================*/
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (!player.isSneaking())
{
ArrowNockEvent event = new ArrowNockEvent(player, stack);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return event.result;
}
if (player.capabilities.isCreativeMode || player.inventory.hasItem(Items.arrow))
{
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
}
} else
changeMode(stack, player);
return stack;
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
if (currentMode.equals("rapidfire"))
BowHandler.rapidFire(player, count, 4);
else if (currentMode.equals("sharpshooter"))
player.addPotionEffect(new PotionEffect(2, 2, 10, true));
else if (currentMode.equals("devistation"))
BowHandler.rapidFire(player, count, 2);
}
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
if (currentMode.equals("rapidfire"))
BowHandler.standerdShot(stack, world, player, count, itemRand, 5F, 1.5F, true, 9D, 1F, false, 0);
else if (currentMode.equals("sharpshooter"))
BowHandler.standerdShot(stack, world, player, count, itemRand, 21F, 5F, true, 30D, 0.7F, false, 20);
else if (currentMode.equals("explosive"))
BowHandler.standerdShot(stack, world, player, count, itemRand, 5F, 0.8F, true, 0D, 1F, true, 40);
else if (currentMode.equals("devistation"))
BowHandler.standerdShot(stack, world, player, count, itemRand, 2F, 1.5F, true, 0D, 1F, true, 0);
}
public void changeMode(ItemStack stack, EntityPlayer player)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
if (currentMode.equals("rapidfire"))
ItemNBTHelper.setString(stack, "mode", "sharpshooter");
else if (currentMode.equals("sharpshooter"))
ItemNBTHelper.setString(stack, "mode", "explosive");
else if (currentMode.equals("explosive") && player.capabilities.isCreativeMode)
ItemNBTHelper.setString(stack, "mode", "devistation");
else
ItemNBTHelper.setString(stack, "mode", "rapidfire");
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.bowmode" + ItemNBTHelper.getString(stack, "mode", "rapidfire") + ".txt"));
}
/* ======================================== TEXTURE START =====================================*/
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(getUnwrappedUnlocalizedName(getUnlocalizedName()) + "_standby");
this.iconArray = new IIcon[bowPullIconNameArray.length];
for (int i = 0; i < this.iconArray.length; ++i)
{
this.iconArray[i] = iconRegister.registerIcon(getUnwrappedUnlocalizedName(getUnlocalizedName()) + "_" + bowPullIconNameArray[i]);
}
}
@Override
public String getUnlocalizedName()
{
return String.format("item.%s%s", References.RESOURCESPREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
public String getUnwrappedUnlocalizedName(final String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
int j = stack.getMaxItemUseDuration() - useRemaining;
if (usingItem == null)
return this.itemIcon;
if (currentMode.equals("rapidfire"))
{
if (j >= 4)
return getItemIconForUseDuration(2);
else if (j > 2)
return getItemIconForUseDuration(1);
else if (j > 0)
return getItemIconForUseDuration(0);
} else if (currentMode.equals("devistation"))
{
if (j >= 2)
return getItemIconForUseDuration(2);
else if (j > 1)
return getItemIconForUseDuration(1);
else if (j > 0)
return getItemIconForUseDuration(0);
} else if (currentMode.equals("sharpshooter"))
{
if (j >= 20)
return getItemIconForUseDuration(2);
else if (j > 10)
return getItemIconForUseDuration(1);
else if (j > 0)
return getItemIconForUseDuration(0);
} else
{
if (j >= 40)
return getItemIconForUseDuration(2);
else if (j > 20)
return getItemIconForUseDuration(1);
else if (j > 0)
return getItemIconForUseDuration(0);
}
return this.itemIcon;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getItemIconForUseDuration(int par1)
{
return this.iconArray[par1];
}
/* ======================================== TEXTURE END =====================================*/
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
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");
}
}
public static void registerRecipe()
{
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.draconicBow), "ISI", "DBD", "ICI", 'B', ModItems.wyvernBow, 'D', ModItems.draconicCompound, 'S', ModItems.sunFocus, 'C', ModItems.draconicCore, 'I', ModItems.draconiumIngot);
}
}
@@ -0,0 +1,65 @@
package draconicevolution.common.items.weapons;
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.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.items.tools.ToolHandler;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class DraconicSword extends ItemSword {
public DraconicSword() {
super(ModItems.DRACONIUM_T2);
this.setUnlocalizedName(Strings.draconicSwordName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.draconicSwordName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "draconic_sword");
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
ToolHandler.AOEAttack(player, entity, stack, 15, 3);
ToolHandler.demageEntytyBasedOnHealth(entity, player, 0.3F);
return true;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
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("");
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");
}
@Override
public EnumRarity getRarity(ItemStack stack)
{
return EnumRarity.rare;
}
public static void registerRecipe()
{
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);
}
}
@@ -0,0 +1,179 @@
package draconicevolution.common.items.weapons;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.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 draconicevolution.common.DraconicEvolution;
import draconicevolution.common.core.helper.ItemNBTHelper;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class WyvernBow extends ItemBow {
public static final String[] bowPullIconNameArray = new String[] { "pulling_0", "pulling_1", "pulling_2" };
@SideOnly(Side.CLIENT)
private IIcon[] iconArray;
public WyvernBow() {
this.maxStackSize = 1;
this.setMaxDamage(-1);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
this.setUnlocalizedName(Strings.wyvernBowName);
GameRegistry.registerItem(this, Strings.wyvernBowName);
}
/* ======================================== CUSTOMEBOW START =====================================*/
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (!player.isSneaking()) {
ArrowNockEvent event = new ArrowNockEvent(player, stack);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled()) {
return event.result;
}
if (player.capabilities.isCreativeMode || player.inventory.hasItem(Items.arrow)) {
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
}
} else
changeMode(stack, player);
return stack;
}
@Override
public void onUsingTick(ItemStack stack, EntityPlayer player, int count)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
if (currentMode.equals("rapidfire"))
BowHandler.rapidFire(player, count, 18);
else if (currentMode.equals("sharpshooter"))
player.addPotionEffect(new PotionEffect(2, 2, 10, true));
}
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int count)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
if (currentMode.equals("rapidfire"))
BowHandler.standerdShot(stack, world, player, count, itemRand, 19F, 1F, false, 0D, 1F, false, 0);
else if (currentMode.equals("sharpshooter"))
BowHandler.standerdShot(stack, world, player, count, itemRand, 30F, 5F, true, 20D, 0.7F, false, 30);
}
public void changeMode(ItemStack stack, EntityPlayer player)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
System.out.println("curent mode:" + currentMode);
if (currentMode.equals("rapidfire"))
ItemNBTHelper.setString(stack, "mode", "sharpshooter");
else
ItemNBTHelper.setString(stack, "mode", "rapidfire");
if (player.worldObj.isRemote)
player.addChatMessage(new ChatComponentTranslation("msg.bowmode" + ItemNBTHelper.getString(stack, "mode", "rapidfire") + ".txt"));
}
/* ======================================== TEXTURE START =====================================*/
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(getUnlocalizedName()) + "_standby");
this.iconArray = new IIcon[bowPullIconNameArray.length];
for (int i = 0; i < this.iconArray.length; ++i) {
this.iconArray[i] = iconRegister.registerIcon(References.RESOURCESPREFIX + getUnwrappedUnlocalizedName(getUnlocalizedName()) + "_" + bowPullIconNameArray[i]);
}
}
@Override
public String getUnlocalizedName()
{
return String.format("item.%s", getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
}
public String getUnwrappedUnlocalizedName(final String unlocalizedName)
{
return unlocalizedName.substring(unlocalizedName.indexOf(".") + 1);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
String currentMode = ItemNBTHelper.getString(stack, "mode", "rapidfire");
int j = stack.getMaxItemUseDuration() - useRemaining;
if (usingItem == null) {
return this.itemIcon;
}
if (currentMode.equals("rapidfire")) {
if (j >= 13)
return getItemIconForUseDuration(2);
else if (j > 7)
return getItemIconForUseDuration(1);
else if (j > 0)
return getItemIconForUseDuration(0);
} else if (currentMode.equals("sharpshooter")) {
if (j >= 30)
return getItemIconForUseDuration(2);
else if (j > 15)
return getItemIconForUseDuration(1);
else if (j > 0)
return getItemIconForUseDuration(0);
}
return this.itemIcon;
}
//@Override
@Override
@SideOnly(Side.CLIENT)
public IIcon getItemIconForUseDuration(int par1)
{
return this.iconArray[par1];
}
/* ======================================== TEXTURE END =====================================*/
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "unchecked", "rawtypes" })
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");
}
}
public static void registerRecipe()
{
CraftingManager.getInstance().addRecipe(new ItemStack(ModItems.wyvernBow), " I ", "CBC", " I ", 'C', ModItems.infusedCompound, 'B', Items.bow, 'I', ModItems.draconiumIngot);
}
}
@@ -0,0 +1,75 @@
package draconicevolution.common.items.weapons;
import java.util.List;
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.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.EnumChatFormatting;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import draconicevolution.common.DraconicEvolution;
import draconicevolution.common.items.ModItems;
import draconicevolution.common.items.tools.ToolHandler;
import draconicevolution.common.lib.References;
import draconicevolution.common.lib.Strings;
public class WyvernSword extends ItemSword {
public WyvernSword() {
super(ModItems.DRACONIUM_T1);
this.setUnlocalizedName(Strings.wyvernSwordName);
this.setCreativeTab(DraconicEvolution.getCreativeTab(1));
GameRegistry.registerItem(this, Strings.wyvernSwordName);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(final IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon(References.RESOURCESPREFIX + "sword_wyvern");
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
ToolHandler.AOEAttack(player, entity, stack, 8, 1);
ToolHandler.demageEntytyBasedOnHealth(entity, player, 0.2F);
return true;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
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("");
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.wyvernSword), " C ", "CSC", " C ", 'C', ModItems.infusedCompound, 'S', Items.diamond_sword);
}
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
{
System.out.println(par2EntityLivingBase.isEntityAlive());
System.out.println(par3EntityLivingBase.isEntityAlive());
return super.hitEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase);
}
}
@@ -0,0 +1,10 @@
package 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-Pre1";
public static final String CLIENTPROXYLOCATION = "draconicevolution.common.core.proxy.ClientProxy";
public static final String COMMONPROXYLOCATION = "draconicevolution.common.core.proxy.CommonProxy";
public static final String RESOURCESPREFIX = MODID + ":";
}
@@ -0,0 +1,45 @@
package draconicevolution.common.lib;
public class Strings {// public static Block name
public static final String blockWeatherControllerName = "weatherController";
public static final String tclogoName = "tclogo";
public static final String xrayBlockName = "xRayBlock";
public static final String blockSunDialName = "sunDial";
public static final String sunFocusName = "sunFocus";
public static final String draconicCoreName = "draconicCore";
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";
public static final String dragonHeartName = "dragonHeart";
public static final String draconicShovelName = "draconicShovel";
public static final String wyvernShovelName = "wyvernShovel";
public static final String wyvernPickaxeName = "wyvernPickaxe";
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";
public static final String draconicAxeName = "draconicAxe";
public static final String teleporterMKIIName = "teleporterMKII";
public static final String grinderName = "grinder";
public static final String potentiometerName = "potentiometer";
public static final String rainSensorName = "rainSensor";
public static final String readerName = "reader";
public static final String particleGeneratorName = "particleGenerator";
public static final String playerDetectorName = "playerDetector";
public static final String playerDetectorAdvancedName = "playerDetectorAdvanced";
}
@@ -0,0 +1,417 @@
package draconicevolution.common.tileentities;
import java.util.List;
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.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.item.ItemTool;
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 cpw.mods.fml.common.registry.GameRegistry;
public class TileGrinder extends TileEntity implements ISidedInventory
{
//########### 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;
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 (burnTimeRemaining > 0)
{
burnTimeRemaining-=2;
energy += 2;
if (burnTimeRemaining < 0) burnTimeRemaining = 0;
}
if (energy > 5000) energy = 5000;
}
//##################################//
public TileGrinder()
{
items = new ItemStack[1];
}
@Override
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())
{
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++;
}
public void checkSignal()
{
disabled = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
}
private void tryRefuel()
{
if (items[0] != null && items[0].stackSize > 0)
{
int itemBurnTime = getItemBurnTime(items[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);
killList = worldObj.getEntitiesWithinAABB(EntityLiving.class, killBox);
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);
dropXP(mob);
readyNext = true;
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);
}
}
return true;
}
readyNext = true;
return false;
}else if (mob instanceof EntityLiving)
{
if (((EntityLiving)mob).isEntityAlive())
{
((EntityLiving)mob).attackEntityFrom(DamageSource.magic, 50000F);
dropXP(mob);
readyNext = true;
return true;
}
readyNext = true;
return false;
}
}
readyNext = false;
return false;
}
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));
}
}
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("Energy", energy);
compound.setBoolean("Disabled", disabled);
compound.setInteger("BurnTime", burnTime);
compound.setInteger("BurnTimeRemaining", burnTimeRemaining);
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]);
}
energy = compound.getInteger("Energy");
disabled = compound.getBoolean("Disabled");
burnTime = compound.getInteger("BurnTime");
burnTimeRemaining = compound.getInteger("BurnTimeRemaining");
super.readFromNBT(compound);
}
@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());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,187 @@
package draconicevolution.common.tileentities;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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 draconicevolution.client.render.CustomParticle;
import draconicevolution.common.core.handler.ParticleHandler;
public class TileParticleGenerator extends TileEntity
{
public int red = 0;
public int green = 0;
public int blue = 0;
public int random_red = 0;
public int random_green = 0;
public int random_blue = 0;
public float motion_x = 0.0F;
public float motion_y = 0.0F;
public float motion_z = 0.0F;
public float random_motion_x = 0.0F;
public float random_motion_y = 0.0F;
public float random_motion_z = 0.0F;
public float scale = 1F;
public float random_scale = 0F;
public int life = 100;
public int random_life = 0;
public float spawn_x = 0;
public float spawn_y = 0;
public float spawn_z = 0;
public float random_spawn_x = 0;
public float random_spawn_y = 0;
public float random_spawn_z = 0;
public int page = 1;
public int fade = 0;
public int spawn_rate = 1;
public boolean collide = false;
public int selected_particle = 1;
public float gravity = 0F;
public boolean active = true;
public boolean signal = false;
public boolean inverted = false;
private int tick = 0;
@SideOnly(Side.CLIENT)
@Override
public void updateEntity()
{
if (signal && !inverted)
active = true;
else if (!signal && inverted)
active = true;
else
active = false;
if (tick >= spawn_rate && active)
{
tick = 0;
if (worldObj.isRemote)
{
Random rand = worldObj.rand;
float MX = motion_x + (random_motion_x * rand.nextFloat());
float MY = motion_y + (random_motion_y * rand.nextFloat());
float MZ = motion_z + (random_motion_z * rand.nextFloat());
float SCALE = scale + (random_scale * rand.nextFloat());
double spawnX = xCoord + spawn_x + (random_spawn_x * rand.nextFloat());
double spawnY = yCoord + spawn_y + (random_spawn_y * rand.nextFloat());
double spawnZ = zCoord + spawn_z + (random_spawn_z * rand.nextFloat());
CustomParticle particle = new CustomParticle(worldObj, spawnX + 0.5, spawnY + 0.5, spawnZ + 0.5, MX, MY, MZ, SCALE, collide, this.selected_particle);
particle.red = this.red + rand.nextInt(random_red + 1);
particle.green = this.green + rand.nextInt(random_green + 1);
particle.blue = this.blue + rand.nextInt(random_blue + 1);
particle.maxAge = this.life + rand.nextInt(random_life + 1);
particle.fadeTime = this.fade;
particle.fadeLength = this.fade;
particle.gravity = this.gravity;
ParticleHandler.spawnCustomParticle(particle);
}
}
else
tick++;
}
public void toggleInverted(){
inverted = !inverted;
}
@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());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void writeToNBT(NBTTagCompound compound)
{
compound.setInteger("Red", red);
compound.setInteger("Green", green);
compound.setInteger("Blue", blue);
compound.setInteger("RandomRed", random_red);
compound.setInteger("RandomGreen", random_green);
compound.setInteger("RandomBlue", random_blue);
compound.setFloat("MotionX", motion_x);
compound.setFloat("MotionY", motion_y);
compound.setFloat("MotionZ", motion_z);
compound.setFloat("RandomMotionX", random_motion_x);
compound.setFloat("RandomMotionY", random_motion_y);
compound.setFloat("RandomMotionZ", random_motion_z);
compound.setFloat("Scale", scale);
compound.setFloat("RandomScale", random_scale);
compound.setInteger("Life", life);
compound.setInteger("RandomLife", random_life);
compound.setFloat("SpawnX", spawn_x);
compound.setFloat("SpawnY", spawn_y);
compound.setFloat("SpawnZ", spawn_z);
compound.setFloat("RandomSpawnX", random_spawn_x);
compound.setFloat("RandomSpawnY", random_spawn_y);
compound.setFloat("RandomSpawnZ", random_spawn_z);
compound.setInteger("Page", page);
compound.setInteger("SpawnRate", spawn_rate);
compound.setBoolean("CanCollide", collide);
compound.setInteger("Fade", fade);
compound.setInteger("SelectedParticle", selected_particle);
compound.setFloat("Gravity", gravity);
compound.setBoolean("Active", active);
compound.setBoolean("Signal", signal);
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound)
{
red = compound.getInteger("Red");
green = compound.getInteger("Green");
blue = compound.getInteger("Blue");
random_red = compound.getInteger("RandomRed");
random_green = compound.getInteger("RandomGreen");
random_blue = compound.getInteger("RandomBlue");
motion_x = compound.getFloat("MotionX");
motion_y = compound.getFloat("MotionY");
motion_z = compound.getFloat("MotionZ");
random_motion_x = compound.getFloat("RandomMotionX");
random_motion_y = compound.getFloat("RandomMotionY");
random_motion_z = compound.getFloat("RandomMotionZ");
scale = compound.getFloat("Scale");
random_scale = compound.getFloat("RandomScale");
life = compound.getInteger("Life");
random_life = compound.getInteger("RandomLife");
spawn_x = compound.getFloat("SpawnX");
spawn_y = compound.getFloat("SpawnY");
spawn_z = compound.getFloat("SpawnZ");
random_spawn_x = compound.getFloat("RandomSpawnX");
random_spawn_y = compound.getFloat("RandomSpawnY");
random_spawn_z = compound.getFloat("RandomSpawnZ");
page = compound.getInteger("Page");
spawn_rate = compound.getInteger("SpawnRate");
collide = compound.getBoolean("CanCollide");
fade = compound.getInteger("Fade");
selected_particle = compound.getInteger("SelectedParticle");
gravity = compound.getFloat("Gravity");
active = compound.getBoolean("Active");
signal = compound.getBoolean("Signal");
super.readFromNBT(compound);
}
}
@@ -0,0 +1,97 @@
package draconicevolution.common.tileentities;
import net.minecraft.entity.player.EntityPlayer;
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;
public class TilePlayerDetector extends TileEntity
{
private int tick = 0;
public boolean output = false;
private int scanRate = 5;
private int range = 1;
@Override
public void updateEntity()
{
if (worldObj.isRemote)
return;
if (tick >= scanRate)
{
tick = 0;
EntityPlayer player = worldObj.getClosestPlayer(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, range + 0.5D);
if (player != null)
{
if (!output)
setOutput(true);
}
else{
if (output)
setOutput(false);
}
}else
tick++;
}
private void setOutput(boolean out)
{
output = out;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
updateBlocks();
}
public void setRange(int value)
{
this.range = value;
}
public int getRange()
{
return range;
}
public void updateBlocks()
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType);
}
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());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void writeToNBT(NBTTagCompound compound)
{
compound.setBoolean("OutPut", output);
compound.setInteger("Range", range);
super.writeToNBT(compound);
}
@Override
public void readFromNBT(NBTTagCompound compound)
{
output = compound.getBoolean("OutPut");
range = compound.getInteger("Range");
super.readFromNBT(compound);
}
}
@@ -0,0 +1,307 @@
package draconicevolution.common.tileentities;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.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 draconicevolution.common.container.ContainerPlayerDetector;
public class TilePlayerDetectorAdvanced extends TileEntity implements IInventory
{
public String[] names = new String[42];
private ItemStack[] items;
public boolean whiteList = false;
public int range = 10;
private int tick = 0;
private int scanRate = 5;
public boolean output = false;
List<EntityLiving> EntityList;
AxisAlignedBB ScanBox;
public TilePlayerDetectorAdvanced()
{
for (int i = 0; i < names.length; i++)
if (names[i] == null)
names[i] = "";
items = new ItemStack[1];
}
@Override
public void updateEntity()
{
if (worldObj.isRemote)
return;
if (tick >= scanRate)
{
tick = 0;
if (shouldEmit())
{
if (!output)
setOutput(true);
}
else{
if (output)
setOutput(false);
}
}else
tick++;
}
public boolean shouldEmit()
{
findEntitys();
boolean b = false;
Iterator<EntityLiving> i = EntityList.iterator();
while (i.hasNext())
{
Entity ent = i.next();
if (!(ent instanceof EntityPlayer))
return false;
String name = ((EntityPlayer)ent).getCommandSenderName();
if(whiteList)
{
if (isPlayerListed(name))
return true;
}else
{
if (!isPlayerListed(name))
return true;
}
}
return b;
}
@SuppressWarnings({ "unchecked" })
private void findEntitys()
{
double x1 = xCoord + 0.5 - range;
double y1 = yCoord + 0.5 - range;
double z1 = zCoord + 0.5 - range;
double x2 = xCoord + 0.5 + range;
double y2 = yCoord + 0.5 + range;
double z2 = zCoord + 0.5 + range;
//System.out.println(x1 + " " + y1 + " " + z1 + " " + x2 + " " + y2 + " " + z2);
//ScanBox = AxisAlignedBB.getBoundingBox(x1, y1, z1, x2, y2, z2);
//ScanBox = AxisAlignedBB.getAABBPool().getAABB(xCoord + 0.5 - range, yCoord + 0.5 - range, zCoord + 0.5 - range, xCoord + 0.5 + range, yCoord + 0.5 + range, zCoord + 0.5 + range);
EntityList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x1, y1, z1, x2, y2, z2));
//System.out.println(EntityList);
}
private void setOutput(boolean out)
{
output = out;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
updateBlocks();
}
public void updateBlocks()
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, blockType);
}
public boolean isPlayerListed(String name)
{
if (name == null)
return false;
for (int i = 0; i < names.length; i++)
{
if (names[i].equals(name))
return true;
}
return false;
}
//###################INVENTORY###########################
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();
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@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 itemstack)
{
return false;
}
//######################################################
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());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
public Container getGuiContainer (InventoryPlayer inventoryplayer)
{
return new ContainerPlayerDetector(inventoryplayer, this);
}
@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]);
}
for (int i = 0; i < names.length; i++)
{
String name = (names[i] != null) ? names[i] : "";
compound.setString("Name_"+i, name);
}
compound.setBoolean("WhiteList", whiteList);
compound.setBoolean("Output", output);
compound.setInteger("Range", range);
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]);
}
for (int i = 0; i < names.length; i++)
names[i] = compound.getString("Name_" + i);
whiteList = compound.getBoolean("WhiteList");
range = compound.getInteger("Range");
output = compound.getBoolean("Output");
super.readFromNBT(compound);
}
}
@@ -0,0 +1,98 @@
package draconicevolution.common.tileentities;
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;
public class TilePotentiometer extends TileEntity
{
public int power = 0;
public void increasePower()
{
if (power < 15)
{
power++;
worldObj.playSound(xCoord, yCoord, zCoord, "random.click", 1, 0.5F + ((float)power / 15F), false);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
updateBlocks();
}
public void decreasePower()
{
if (power > 0)
{
power--;
worldObj.playSound(xCoord, yCoord, zCoord, "random.click", 1, 0.5F + ((float)power / 15F), false);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
updateBlocks();
}
public void updateBlocks()
{
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
if (meta == 1)
{
worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
else if (meta == 2)
{
worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
else if (meta == 3)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, worldObj.getBlock(xCoord, yCoord, zCoord));
}
else if (meta == 4)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, worldObj.getBlock(xCoord, yCoord, zCoord));
}
else if (meta == 5)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
else if (meta == 6)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
else
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
}
}
@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());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
power = compound.getInteger("Power");
}
@Override
public void writeToNBT(NBTTagCompound compound)
{
compound.setInteger("Power", power);
super.writeToNBT(compound);
}
}
@@ -0,0 +1,222 @@
package draconicevolution.common.tileentities;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public class TileSunDial extends TileEntity implements IInventory {
int tick;
int tick2;
public boolean running = false;
@Override
public void updateEntity()
{
CheckPower();
if (running) {
tick++;
tick2++;
Runn();
}
}
private void CheckPower()
{
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
running = true;
else {
if (running) {
tick = 0;
tick2 = 0;
running = false;
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:discharge", 5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
}
}
private void Runn()
{
if (tick == 1) {
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:charge", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
if (tick < 74) {
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0.1, zCoord, 0D, 0D, -0.01D);
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0.1, zCoord + 1, 0D, 0D, 0.01D);
worldObj.spawnParticle("explode", xCoord + 0, yCoord + 0.1, zCoord + 0.5, -0.01D, 0D, 0D);
worldObj.spawnParticle("explode", xCoord + 1, yCoord + 0.1, zCoord + 0.5, 0.01D, 0D, 0D);
}
if (tick > 74 && tick2 == 1) {
worldObj.spawnParticle("flame", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord, 0D, 0D, -0.01D);
worldObj.spawnParticle("flame", xCoord + worldObj.rand.nextFloat(), yCoord + worldObj.rand.nextFloat(), zCoord + 1, 0D, 0D, 0.01D);
worldObj.spawnParticle("flame", xCoord + 0, yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), -0.01D, 0D, 0D);
worldObj.spawnParticle("flame", xCoord + 1, yCoord + worldObj.rand.nextFloat(), zCoord + worldObj.rand.nextFloat(), 0.01D, 0D, 0D);
}
if (tick > 74)
Track(getTime());
if (tick > 74)
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:beam", 5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
if (tick > 74)
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 20F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
if (tick2 == 5)
tick2 = 0;
}
private void Track(final double t)
{
double time = t;
if ((time >= 0 && time <= 5) || (time >= 19.3 && time <= 20)) {
if (time > 5) {
Beam(1, (time - 19.33) / 3);
} else {
final double x = 5 - time;
final double y = 1 * time + 1.2;
final double x1 = map(x, 0, 5, 0, 1);
final double y1 = map(y, 0, 5, 0, 1);
Beam(x1, y1);
}
} else if (time >= 5 && time <= 10.63) {
final double x = (time - 5) * -1;
final double y = 6.2 - (time - 5);
final double x1 = map(x, 0, 5, 0, 1);
final double y1 = map(y, 0, 5, 0, 1);
if (time > 10)
Beam(x1, y1 - ((time - 10) / 4.5));
else
Beam(x1, y1);
} else if (time > 10.63 && time < 15) {
final double comp = time - 10.63;
time = (time - 10) - (0.63 - (comp / 7.936));
final double x = time - 5;
final double y = 0 - time;
final double x1 = map(x, 0, 5, 0, 1);
final double y1 = map(y, 0, 5, 0, 1);
Beam(x1, y1);
} else if (time > 15 && time < 19.3) {
final double comp = time - 15;
time = time + comp / 6;
final double x = 0 + (time - 15);
final double y = -5 + (time - 15);
final double x1 = map(x, 0, 5, 0, 1);
final double y1 = map(y, 0, 5, 0, 1);
Beam(x1, y1);
}
}
private void Beam(final double x, final double y)
{
long worldTime = worldObj.getWorldTime();
worldTime = worldTime + 30;
worldObj.setWorldTime(worldTime);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 2, y * 2, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 3, y * 3, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 4, y * 4, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 5, y * 5, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 6, y * 6, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 7, y * 7, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 8, y * 8, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 9, y * 9, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 10, y * 10, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.3, y * 19.3, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.5, y * 19.5, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 19.7, y * 19.7, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, x * 20, y * 20, 0D);
worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, 0D, 0D);
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, 0D, 0D);
}
private double getTime()
{
final double days = worldObj.getWorldTime() / 24000;
final double time = worldObj.getWorldTime() - days * 24000;
final double time2 = time / 1.2;
final double time3 = Math.round(time2 / 10);
final double time4 = time3 / 100;
return time4;
}
private double map(final double x, final double in_min, final double in_max, final double out_min, final double out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
//###################################Inventory#####################################################//
@Override
public int getSizeInventory()
{
return 0;
}
@Override
public ItemStack getStackInSlot(int i)
{
return null;
}
@Override
public ItemStack decrStackSize(int i, int count)
{
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
return null;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
}
@Override
public String getInventoryName()
{
return "";
}
@Override
public boolean hasCustomInventoryName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 0;
}
@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 itemstack)
{
return false;
}
}
@@ -0,0 +1,322 @@
package draconicevolution.common.tileentities;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
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.storage.WorldInfo;
import draconicevolution.common.DraconicEvolution;
public class TileWeatherController extends TileEntity implements IInventory
{
int tick = 0;
boolean running = false;
public boolean lastTickInput = false;
public int mode = 0;
private final static boolean debug = DraconicEvolution.debug;
private ItemStack[] items;
public int charges;
public TileWeatherController() {
items = new ItemStack[1];
}
@Override
public void updateEntity()
{
if (charges == 0 && !worldObj.isRemote)
reload();
WorldInfo worldinfo = worldObj.getWorldInfo();
toggleDownfall(worldinfo);
}
public void activate()
{
WorldInfo worldinfo = worldObj.getWorldInfo();
if (!running && charges > 0)
{
if (mode == 0 && worldinfo.isRaining())
running = true;
else if (mode == 1 && !worldinfo.isRaining())
running = true;
else if (mode == 2 && !worldinfo.isRaining())
running = true;
}
}
private void reload()
{
ItemStack fuel = getStackInSlot(0);
if (charges == 0 && fuel != null)
{
if (fuel.stackSize > 0 && fuel.isItemEqual(new ItemStack(Items.emerald)))
{
addCharge(10);
}
}
}
private void toggleDownfall(final WorldInfo worldinfo)
{
if (running)
{
if (tick == 1 && !worldObj.isRemote)
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
if (tick < 70 && worldObj.isRemote)
{
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0D, 3D, 0D);
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 1.5, zCoord + 0.5, 0D, 5D, 0D);
worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 1D, 0D);
worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 2D, 0D);
worldObj.spawnParticle("flame", xCoord + 0.5, yCoord + 1, zCoord + 0.5, 0D, 1D, 0D);
worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D);
worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D);
worldObj.spawnParticle("largesmoke", xCoord + 0.5, yCoord + 1.2, zCoord + 0.5, 0D, -0.3D, 0D);
worldObj.spawnParticle("flame", xCoord + 0.2, yCoord + 1, zCoord + 0.8, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5);
worldObj.spawnParticle("flame", xCoord + 0.8, yCoord + 1, zCoord + 0.8, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5);
worldObj.spawnParticle("flame", xCoord + 0.2, yCoord + 1, zCoord + 0.2, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5);
worldObj.spawnParticle("flame", xCoord + 0.8, yCoord + 1, zCoord + 0.2, (worldObj.rand.nextFloat() - 0.5) * 1.5, 1.7D, (worldObj.rand.nextFloat() - 0.5) * 1.5);
worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "mob.ghast.fireball", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false);
}
if (tick > 80 && tick < 90)
{
if (!worldObj.isRemote)
{
if (mode == 0)
worldinfo.setRaining(false);
else if (mode == 1)
worldinfo.setRaining(true);
else if (mode == 2)
{
worldinfo.setRaining(true);
worldinfo.setThundering(true);
}
}
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "draconicevolution:boom", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (tick > 110 && worldObj.isRemote)
{
worldObj.playSound(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.fizz", 10F, worldObj.rand.nextFloat() * 0.1F + 0.9F, false);
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0, zCoord + 0, 0D, 0D, 0D);
worldObj.spawnParticle("explode", xCoord + 0.5, yCoord + 0, zCoord + 1, 0D, 0D, 0D);
worldObj.spawnParticle("explode", xCoord + 0, yCoord + 0, zCoord + 0.5, 0D, 0D, 0D);
worldObj.spawnParticle("explode", xCoord + 1, yCoord + 0, zCoord + 0.5, 0D, 0D, 0D);
}
if (tick > 130)
{
tick = 0;
running = false;
if (!worldObj.isRemote)
useCharge();
}
tick++;
}
}
private void addCharge(int count)
{
if (!worldObj.isRemote)
{
charges = 10;
decrStackSize(0, 1);
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
private void useCharge()
{
if (!worldObj.isRemote)
charges--;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public Packet getDescriptionPacket()
{
if (debug)
System.out.println("[DEBUG]TileWeatherController: 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)
{
if (debug)
System.out.println("[DEBUG]TileWeatherController: onDataPacket");
readFromNBT(pkt.func_148857_g());
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
//==============================================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();
}
}
@Override
public String getInventoryName()
{
return "InventoryWeatherController";
}
@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 itemstack)
{
return itemstack.isItemEqual(new ItemStack(Items.emerald));
}
//############################################################################################################//
@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("Tick", tick);
compound.setShort("Charges", (short) charges);
compound.setBoolean("Running", running);
compound.setShort("Mode", (short) mode);
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]);
}
tick = compound.getInteger("Tick");
charges = compound.getShort("Charges");
running = compound.getBoolean("Running");
mode = compound.getShort("Mode");
super.readFromNBT(compound);
}
public void reciveButtonEvent(byte buttonId)
{
if (buttonId == 0)
{
if (mode < 2)
mode++;
else
mode = 0;
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
@@ -0,0 +1,78 @@
package draconicevolution.common.world;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;
import draconicevolution.common.blocks.ModBlocks;
public class TolkienWorldGenerator implements IWorldGenerator {
@Override
public void generate(final Random random, final int chunkX, final int chunkZ, final World world, final IChunkProvider chunkGenerator, final IChunkProvider chunkProvider)
{
switch (world.provider.dimensionId) {
case 0:
generateSurface(random, chunkX * 16, chunkZ * 16, world);
break;
case 1:
generateEnd(random, chunkX * 16, chunkZ * 16, world);
break;
case -1:
generateNether(random, chunkX * 16, chunkZ * 16, world);
break;
default:
;
}
}
public void generateSurface(final Random random, final int chunkX, final int chunkZ, final World world)
{// minVainSise, maxVainSize, spawnChance(Def2), minY, maxY
//addOreSpawn(ModBlocks.MySidedBlock, world, random, chunkX, chunkZ, 10, 50, 10, 4, 100);
}
public void generateEnd(final Random random, final int chunkX, final int chunkZ, final World world)
{
addEndOreSpawn(ModBlocks.draconiumOre, world, random, chunkX, chunkZ, 4, 4, 10, 1, 70);
}
public void generateNether(final Random random, final int chunkX, final int chunkZ, final World world)
{
addNetherOreSpawn(ModBlocks.draconiumOre, world, random, chunkX, chunkZ, 3, 4, 5, 1, 125);
}
public void addEndOreSpawn(final Block block, final World world, final Random random, final int blockXPos, final int blockZPos, final int minVainSize, final int maxVainSize, final int chancesToSpawn, final int minY, final int maxY)
{
for (int i = 0; i < chancesToSpawn; i++) {
final int posX = blockXPos + random.nextInt(16);
final int posY = minY + random.nextInt(maxY - minY);
final int posZ = blockZPos + random.nextInt(16);
new WorldGenMinable(block, 3, Blocks.end_stone).generate(world, random, posX, posY, posZ);
}
}
public void addOverworldOreSpawn(final Block block, final World world, final Random random, final int blockXPos, final int blockZPos, final int minVainSize, final int maxVainSize, final int chancesToSpawn, final int minY, final int maxY)
{
for (int i = 0; i < chancesToSpawn; i++) {
final int posX = blockXPos + random.nextInt(16);
final int posY = minY + random.nextInt(maxY - minY);
final int posZ = blockZPos + random.nextInt(16);
new WorldGenMinable(block, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.stone).generate(world, random, posX, posY, posZ);
}
}
public void addNetherOreSpawn(final Block block, final World world, final Random random, final int blockXPos, final int blockZPos, final int minVainSize, final int maxVainSize, final int chancesToSpawn, final int minY, final int maxY)
{
for (int i = 0; i < chancesToSpawn; i++) {
final int posX = blockXPos + random.nextInt(16);
final int posY = minY + random.nextInt(maxY - minY);
final int posZ = blockZPos + random.nextInt(16);
new WorldGenMinable(block, (minVainSize + random.nextInt(maxVainSize - minVainSize)), Blocks.netherrack).generate(world, random, posX, posY, posZ);
}
}
}