Day 2, Good Morning!

This commit is contained in:
Calclavia 2013-08-02 09:03:12 -04:00
parent 06f724de78
commit 91a193dd9c
3 changed files with 65 additions and 64 deletions

View file

@ -96,11 +96,11 @@ public class ResonantInduction
{ {
return NEXT_ITEM_ID++; return NEXT_ITEM_ID++;
} }
//Items // Items
public static Item itemQuantumEntangler; public static Item itemQuantumEntangler;
//Blocks // Blocks
public static Block blockTesla; public static Block blockTesla;
@EventHandler @EventHandler
@ -109,21 +109,21 @@ public class ResonantInduction
LOGGER.setParent(FMLLog.getLogger()); LOGGER.setParent(FMLLog.getLogger());
CONFIGURATION.load(); CONFIGURATION.load();
//config // config
POWER_PER_COAL = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Coal Wattage", POWER_PER_COAL).getDouble(POWER_PER_COAL); POWER_PER_COAL = (float) CONFIGURATION.get(Configuration.CATEGORY_GENERAL, "Coal Wattage", POWER_PER_COAL).getDouble(POWER_PER_COAL);
//items // items
itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID()); itemQuantumEntangler = new ItemQuantumEntangler(getNextItemID());
GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName()); GameRegistry.registerItem(itemQuantumEntangler, itemQuantumEntangler.getUnlocalizedName());
//blocks // blocks
blockTesla = new BlockTesla(getNextBlockID()); blockTesla = new BlockTesla(getNextBlockID());
GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName()); GameRegistry.registerBlock(blockTesla, blockTesla.getUnlocalizedName());
CONFIGURATION.save(); CONFIGURATION.save();
//tiles // tiles
GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName()); GameRegistry.registerTileEntity(TileEntityTesla.class, blockTesla.getUnlocalizedName());
ResonantInduction.proxy.registerRenderers(); ResonantInduction.proxy.registerRenderers();

View file

@ -8,7 +8,7 @@ import resonantinduction.TabRI;
/** /**
* *
* @author AidanBrady * @author AidanBrady
* *
*/ */
public class ItemBase extends Item public class ItemBase extends Item
{ {

View file

@ -2,8 +2,6 @@ package resonantinduction.entangler;
import java.util.List; 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.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -11,133 +9,136 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World; import net.minecraft.world.World;
import resonantinduction.base.ItemBase; import resonantinduction.base.ItemBase;
import resonantinduction.base.Vector3; import resonantinduction.base.Vector3;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** /**
* *
* @author AidanBrady * @author AidanBrady
* *
*/ */
public class ItemQuantumEntangler extends ItemBase public class ItemQuantumEntangler extends ItemBase
{ {
public static int WILDCARD = 1337; /* :) */ public static int WILDCARD = 1337; /* :) */
public ItemQuantumEntangler(int id) public ItemQuantumEntangler(int id)
{ {
super("entangler", id); super("entangler", id);
setMaxStackSize(1); setMaxStackSize(1);
//TODO Handheld model, render animation, energy usage (should be easy?) // TODO Handheld model, render animation, energy usage (should be easy?)
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{ {
super.addInformation(itemstack, entityplayer, list, flag); super.addInformation(itemstack, entityplayer, list, flag);
if(hasBind(itemstack)) if (hasBind(itemstack))
{ {
Vector3 vec = getBindVec(itemstack); Vector3 vec = getBindVec(itemstack);
int dimID = getDimID(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"); list.add("No block bound");
} }
} }
@Override @Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) 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.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; int dimID = world.provider.dimensionId;
entityplayer.addChatMessage("Bound Entangler to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'"); entityplayer.addChatMessage("Bound Entangler to block [" + x + ", " + y + ", " + z + "], dimension '" + dimID + "'");
setBindVec(itemstack, new Vector3(x, y, z), dimID); setBindVec(itemstack, new Vector3(x, y, z), dimID);
return true; return true;
} }
entityplayer.addChatMessage("Error: invalid block for binding!"); entityplayer.addChatMessage("Error: invalid block for binding!");
} }
return false; return false;
} }
@Override @Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) 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!"); entityplayer.addChatMessage("Error: no block bound to Entangler!");
return itemstack; return itemstack;
} }
//TELEPORT// // TELEPORT//
Vector3 vec = getBindVec(itemstack); Vector3 vec = getBindVec(itemstack);
int dimID = getDimID(itemstack); int dimID = getDimID(itemstack);
//travel to dimension if different dimID // travel to dimension if different dimID
if(world.provider.dimensionId != dimID) if (world.provider.dimensionId != dimID)
{ {
((EntityPlayerMP)entityplayer).travelToDimension(dimID); ((EntityPlayerMP) entityplayer).travelToDimension(dimID);
} }
//actually teleport to new coords // actually teleport to new coords
((EntityPlayerMP)entityplayer).playerNetServerHandler.setPlayerLocation(vec.x+0.5, vec.y+1, vec.z+0.5, entityplayer.rotationYaw, entityplayer.rotationPitch); ((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); world.playSoundAtEntity(entityplayer, "mob.endermen.portal", 1.0F, 1.0F);
} }
return itemstack; return itemstack;
} }
public boolean hasBind(ItemStack itemStack) public boolean hasBind(ItemStack itemStack)
{ {
return getBindVec(itemStack) != null; return getBindVec(itemStack) != null;
} }
public Vector3 getBindVec(ItemStack itemStack) public Vector3 getBindVec(ItemStack itemStack)
{ {
if(itemStack.stackTagCompound == null) if (itemStack.stackTagCompound == null)
{ {
return null; return null;
} }
int x = itemStack.stackTagCompound.getInteger("bindX"); int x = itemStack.stackTagCompound.getInteger("bindX");
int y = itemStack.stackTagCompound.getInteger("bindY"); int y = itemStack.stackTagCompound.getInteger("bindY");
int z = itemStack.stackTagCompound.getInteger("bindZ"); int z = itemStack.stackTagCompound.getInteger("bindZ");
return new Vector3(x, y, z); return new Vector3(x, y, z);
} }
public void setBindVec(ItemStack itemStack, Vector3 vec, int dimID) public void setBindVec(ItemStack itemStack, Vector3 vec, int dimID)
{ {
if(itemStack.stackTagCompound == null) if (itemStack.stackTagCompound == null)
{ {
itemStack.setTagCompound(new NBTTagCompound()); itemStack.setTagCompound(new NBTTagCompound());
} }
itemStack.stackTagCompound.setInteger("bindX", (int)vec.x); itemStack.stackTagCompound.setInteger("bindX", (int) vec.x);
itemStack.stackTagCompound.setInteger("bindY", (int)vec.y); itemStack.stackTagCompound.setInteger("bindY", (int) vec.y);
itemStack.stackTagCompound.setInteger("bindZ", (int)vec.z); itemStack.stackTagCompound.setInteger("bindZ", (int) vec.z);
itemStack.stackTagCompound.setInteger("dimID", dimID); itemStack.stackTagCompound.setInteger("dimID", dimID);
} }
public int getDimID(ItemStack itemStack) public int getDimID(ItemStack itemStack)
{ {
if(itemStack.stackTagCompound == null) if (itemStack.stackTagCompound == null)
{ {
return WILDCARD; return WILDCARD;
} }
return itemStack.stackTagCompound.getInteger("dimID"); return itemStack.stackTagCompound.getInteger("dimID");
} }
} }