Day 2, Good Morning!
This commit is contained in:
parent
06f724de78
commit
91a193dd9c
3 changed files with 65 additions and 64 deletions
|
@ -97,10 +97,10 @@ public class ResonantInduction
|
|||
return NEXT_ITEM_ID++;
|
||||
}
|
||||
|
||||
//Items
|
||||
// Items
|
||||
public static Item itemQuantumEntangler;
|
||||
|
||||
//Blocks
|
||||
// Blocks
|
||||
public static Block blockTesla;
|
||||
|
||||
@EventHandler
|
||||
|
@ -110,20 +110,20 @@ public class ResonantInduction
|
|||
|
||||
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();
|
||||
|
|
|
@ -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,6 +9,8 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ public class ItemQuantumEntangler extends ItemBase
|
|||
{
|
||||
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
|
||||
|
@ -34,24 +34,25 @@ public class ItemQuantumEntangler extends ItemBase
|
|||
{
|
||||
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;
|
||||
|
||||
|
@ -65,32 +66,32 @@ public class ItemQuantumEntangler extends ItemBase
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ public class ItemQuantumEntangler extends ItemBase
|
|||
|
||||
public Vector3 getBindVec(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.stackTagCompound == null)
|
||||
if (itemStack.stackTagCompound == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -119,21 +120,21 @@ public class ItemQuantumEntangler extends ItemBase
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue