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

@ -97,10 +97,10 @@ 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
@ -110,20 +110,20 @@ public class ResonantInduction
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

@ -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,6 +9,8 @@ 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;
/** /**
* *
@ -25,7 +25,7 @@ public class ItemQuantumEntangler extends ItemBase
{ {
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
@ -34,24 +34,25 @@ public class ItemQuantumEntangler extends ItemBase
{ {
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;
@ -65,32 +66,32 @@ public class ItemQuantumEntangler extends ItemBase
} }
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);
} }
@ -105,7 +106,7 @@ public class ItemQuantumEntangler extends ItemBase
public Vector3 getBindVec(ItemStack itemStack) public Vector3 getBindVec(ItemStack itemStack)
{ {
if(itemStack.stackTagCompound == null) if (itemStack.stackTagCompound == null)
{ {
return null; return null;
} }
@ -119,21 +120,21 @@ public class ItemQuantumEntangler extends ItemBase
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;
} }