From 91a193dd9c6b8a5f57c7dd15e60e664df1490366 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Fri, 2 Aug 2013 09:03:12 -0400 Subject: [PATCH] Day 2, Good Morning! --- src/resonantinduction/ResonantInduction.java | 22 ++-- src/resonantinduction/base/ItemBase.java | 2 +- .../entangler/ItemQuantumEntangler.java | 105 +++++++++--------- 3 files changed, 65 insertions(+), 64 deletions(-) diff --git a/src/resonantinduction/ResonantInduction.java b/src/resonantinduction/ResonantInduction.java index 09b6b28b..f84133dc 100644 --- a/src/resonantinduction/ResonantInduction.java +++ b/src/resonantinduction/ResonantInduction.java @@ -96,11 +96,11 @@ public class ResonantInduction { return NEXT_ITEM_ID++; } - - //Items + + // Items public static Item itemQuantumEntangler; - //Blocks + // Blocks public static Block blockTesla; @EventHandler @@ -109,21 +109,21 @@ public class ResonantInduction LOGGER.setParent(FMLLog.getLogger()); CONFIGURATION.load(); - - //config + + // config POWER_PER_COAL = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Coal Wattage", POWER_PER_COAL).getDouble(POWER_PER_COAL); - //items + // items itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID()); GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName()); - - //blocks + + // blocks blockTesla = new BlockTesla(getNextBlockID()); GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName()); - + CONFIGURATION.save(); - - //tiles + + // tiles GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName()); ResonantInduction.proxy.registerRenderers(); diff --git a/src/resonantinduction/base/ItemBase.java b/src/resonantinduction/base/ItemBase.java index 9bd69d36..774eba29 100644 --- a/src/resonantinduction/base/ItemBase.java +++ b/src/resonantinduction/base/ItemBase.java @@ -8,7 +8,7 @@ import resonantinduction.TabRI; /** * * @author AidanBrady - * + * */ public class ItemBase extends Item { diff --git a/src/resonantinduction/entangler/ItemQuantumEntangler.java b/src/resonantinduction/entangler/ItemQuantumEntangler.java index b828b6e3..75adeb59 100644 --- a/src/resonantinduction/entangler/ItemQuantumEntangler.java +++ b/src/resonantinduction/entangler/ItemQuantumEntangler.java @@ -2,8 +2,6 @@ package resonantinduction.entangler; import java.util.List; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -11,133 +9,136 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import resonantinduction.base.ItemBase; import resonantinduction.base.Vector3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; /** * * @author AidanBrady - * + * */ public class ItemQuantumEntangler extends ItemBase { public static int WILDCARD = 1337; /* :) */ - + public ItemQuantumEntangler(int id) { super("entangler", id); setMaxStackSize(1); - //TODO Handheld model, render animation, energy usage (should be easy?) + // TODO Handheld model, render animation, energy usage (should be easy?) } - + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { + { super.addInformation(itemstack, entityplayer, list, flag); - - if(hasBind(itemstack)) + + if (hasBind(itemstack)) { Vector3 vec = getBindVec(itemstack); int dimID = getDimID(itemstack); - - list.add("Bound to [" + (int)vec.x + ", " + (int)vec.y + ", " + (int)vec.z + "], dimension '" + dimID + "'"); + + list.add("Bound to [" + (int) vec.x + ", " + (int) vec.y + ", " + (int) vec.z + "], dimension '" + dimID + "'"); } - else { + else + { list.add("No block bound"); } } - + @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) - { - if(!world.isRemote) + public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) + { + if (!world.isRemote) { - if(world.isAirBlock(x, y+1, z) && world.isAirBlock(x, y+2, z)) + if (world.isAirBlock(x, y + 1, z) && world.isAirBlock(x, y + 2, z)) { int dimID = world.provider.dimensionId; - + entityplayer.addChatMessage("Bound Entangler to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'"); setBindVec(itemstack, new Vector3(x, y, z), dimID); - + return true; } - + entityplayer.addChatMessage("Error: invalid block for binding!"); } - + return false; - } - + } + @Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { - if(!world.isRemote) + if (!world.isRemote) { - if(!hasBind(itemstack)) + if (!hasBind(itemstack)) { entityplayer.addChatMessage("Error: no block bound to Entangler!"); return itemstack; } - - //TELEPORT// - + + // TELEPORT// + Vector3 vec = getBindVec(itemstack); int dimID = getDimID(itemstack); - - //travel to dimension if different dimID - if(world.provider.dimensionId != dimID) + + // travel to dimension if different dimID + if (world.provider.dimensionId != dimID) { - ((EntityPlayerMP)entityplayer).travelToDimension(dimID); + ((EntityPlayerMP) entityplayer).travelToDimension(dimID); } - - //actually teleport to new coords - ((EntityPlayerMP)entityplayer).playerNetServerHandler.setPlayerLocation(vec.x+0.5, vec.y+1, vec.z+0.5, entityplayer.rotationYaw, entityplayer.rotationPitch); - + + // actually teleport to new coords + ((EntityPlayerMP) entityplayer).playerNetServerHandler.setPlayerLocation(vec.x + 0.5, vec.y + 1, vec.z + 0.5, entityplayer.rotationYaw, entityplayer.rotationPitch); + world.playSoundAtEntity(entityplayer, "mob.endermen.portal", 1.0F, 1.0F); } - + return itemstack; } - + public boolean hasBind(ItemStack itemStack) { return getBindVec(itemStack) != null; } - + public Vector3 getBindVec(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) + if (itemStack.stackTagCompound == null) { return null; } - + int x = itemStack.stackTagCompound.getInteger("bindX"); int y = itemStack.stackTagCompound.getInteger("bindY"); int z = itemStack.stackTagCompound.getInteger("bindZ"); - + return new Vector3(x, y, z); } - + public void setBindVec(ItemStack itemStack, Vector3 vec, int dimID) { - if(itemStack.stackTagCompound == null) + if (itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); } - - itemStack.stackTagCompound.setInteger("bindX", (int)vec.x); - itemStack.stackTagCompound.setInteger("bindY", (int)vec.y); - itemStack.stackTagCompound.setInteger("bindZ", (int)vec.z); - + + itemStack.stackTagCompound.setInteger("bindX", (int) vec.x); + itemStack.stackTagCompound.setInteger("bindY", (int) vec.y); + itemStack.stackTagCompound.setInteger("bindZ", (int) vec.z); + itemStack.stackTagCompound.setInteger("dimID", dimID); } - + public int getDimID(ItemStack itemStack) { - if(itemStack.stackTagCompound == null) + if (itemStack.stackTagCompound == null) { return WILDCARD; } - + return itemStack.stackTagCompound.getInteger("dimID"); } }