THE UPDATE
Merging months of dev work into master. The update is playable, but untested.
This commit is contained in:
118
StevenDimDoors/mod_pocketDim/items/BaseItemDoor.java
Normal file
118
StevenDimDoors/mod_pocketDim/items/BaseItemDoor.java
Normal file
@@ -0,0 +1,118 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
|
||||
public abstract class BaseItemDoor extends ItemDoor
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public BaseItemDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
this.setMaxStackSize(64);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@Override
|
||||
public abstract void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4);
|
||||
|
||||
@Override
|
||||
public abstract boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ);
|
||||
|
||||
public static boolean tryItemUse(Block doorBlock, ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, boolean requireLink, boolean reduceStack)
|
||||
{
|
||||
// Only place doors on top of blocks - check if we're targeting the top side
|
||||
if (side == 1 && !world.isRemote)
|
||||
{
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
if (blockID != 0)
|
||||
{
|
||||
if (!Block.blocksList[blockID].isBlockReplaceable(world, x, y, z))
|
||||
{
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
if (canPlace(world, x, y, z) && canPlace(world, x, y + 1, z) &&
|
||||
player.canPlayerEdit(x, y, z, side, stack) && player.canPlayerEdit(x, y + 1, z, side, stack) &&
|
||||
(!requireLink || PocketManager.getLink(x, y + 1, z, world) != null)&&stack.stackSize>0)
|
||||
{
|
||||
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
placeDoorBlock(world, x, y, z, orientation, doorBlock);
|
||||
|
||||
if (!player.capabilities.isCreativeMode && reduceStack)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player);
|
||||
|
||||
public boolean tryPlacingDoor(Block doorBlock, World world, EntityPlayer player, ItemStack item)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(player.worldObj, player, true);
|
||||
if (hit != null)
|
||||
{
|
||||
if (world.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
|
||||
{
|
||||
DimLink link = PocketManager.getLink(hit.blockX, hit.blockY, hit.blockZ, world.provider.dimensionId);
|
||||
if (link != null)
|
||||
{
|
||||
int x = hit.blockX;
|
||||
int y = hit.blockY;
|
||||
int z = hit.blockZ;
|
||||
|
||||
if (player.canPlayerEdit(x, y, z, hit.sideHit, item) && player.canPlayerEdit(x, y - 1, z, hit.sideHit, item))
|
||||
{
|
||||
if (canPlace(world, x, y, z) && canPlace(world, x, y - 1, z))
|
||||
{
|
||||
int orientation = MathHelper.floor_double(((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
placeDoorBlock(world, x, y - 1, z, orientation, doorBlock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canPlace(World world, int x, int y, int z)
|
||||
{
|
||||
int id = world.getBlockId(x, y, z);
|
||||
|
||||
return (id == properties.RiftBlockID || id == 0 || Block.blocksList[id].blockMaterial.isReplaceable());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemChaosDoor extends itemDimDoor
|
||||
{
|
||||
public ItemChaosDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: Leads to random destination");
|
||||
}
|
||||
|
||||
}
|
||||
48
StevenDimDoors/mod_pocketDim/items/ItemDimensionalDoor.java
Normal file
48
StevenDimDoors/mod_pocketDim/items/ItemDimensionalDoor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemDimensionalDoor extends BaseItemDoor
|
||||
{
|
||||
public ItemDimensionalDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Place on the block under a rift");
|
||||
par3List.add("to activate that rift or place");
|
||||
par3List.add("anywhere else to create a");
|
||||
par3List.add("pocket dimension.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.dimensionalDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.dimensionalDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
}
|
||||
53
StevenDimDoors/mod_pocketDim/items/ItemGoldDimDoor.java
Normal file
53
StevenDimDoors/mod_pocketDim/items/ItemGoldDimDoor.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemGoldDimDoor extends BaseItemDoor
|
||||
{
|
||||
|
||||
public ItemGoldDimDoor(int itemID, Material material) {
|
||||
super(itemID, material);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Similar to a Iron Dim Door");
|
||||
par3List.add("But if present in a pocket dim");
|
||||
par3List.add("it will keep it loaded.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.goldDimDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.goldDimDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
64
StevenDimDoors/mod_pocketDim/items/ItemGoldDoor.java
Normal file
64
StevenDimDoors/mod_pocketDim/items/ItemGoldDoor.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemGoldDoor extends ItemDoor
|
||||
{
|
||||
|
||||
public ItemGoldDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (par7 != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++par5;
|
||||
Block block = mod_pocketDim.goldDoor;
|
||||
|
||||
|
||||
|
||||
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack))
|
||||
{
|
||||
if (!block.canPlaceBlockAt(par3World, par4, par5, par6))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i1 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
placeDoorBlock(par3World, par4, par5, par6, i1, block);
|
||||
--par1ItemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -5,14 +5,11 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.EnumToolMaterial;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -21,38 +18,34 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemRiftBlade extends ItemSword
|
||||
{
|
||||
public ItemRiftBlade(int par1)
|
||||
private final DDProperties properties;
|
||||
|
||||
public ItemRiftBlade(int itemID, EnumToolMaterial material, DDProperties properties)
|
||||
{
|
||||
super(par1, EnumToolMaterial.GOLD);
|
||||
super(itemID, material);
|
||||
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
// this.itemIcon=5;
|
||||
this.setMaxDamage(500);
|
||||
this.hasSubtypes=false;
|
||||
//TODO move to proxy
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
this.hasSubtypes = false;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean isFull3D()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
|
||||
{
|
||||
if (par2Block.blockID == Block.web.blockID)
|
||||
@@ -66,25 +59,27 @@ public class ItemRiftBlade extends ItemSword
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public int getDamageVsEntity(Entity par1Entity)
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
|
||||
{
|
||||
par1ItemStack.damageItem(1, par3EntityLiving);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getDamageVsEntity(Entity par1Entity)
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
@@ -109,22 +104,19 @@ public class ItemRiftBlade extends ItemSword
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
protected boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
|
||||
private boolean teleportToEntity(ItemStack item, Entity par1Entity, EntityPlayer holder)
|
||||
{
|
||||
Vec3 var2 = holder.worldObj.getWorldVec3Pool().getVecFromPool(holder.posX - par1Entity.posX, holder.boundingBox.minY + (double)(holder.height / 2.0F) - par1Entity.posY + (double)par1Entity.getEyeHeight(), holder.posZ - par1Entity.posZ);
|
||||
|
||||
|
||||
double cooef =( var2.lengthVector()-2.5)/var2.lengthVector();
|
||||
var2.xCoord*=cooef;
|
||||
var2.yCoord*=cooef;
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = holder.posX - var2.xCoord;
|
||||
double var9 = holder.posZ - var2.zCoord;
|
||||
double var7 =holder.worldObj.getHeightValue(MathHelper.floor_double(var5), MathHelper.floor_double(var9));
|
||||
if((Math.abs((holder.posY - var2.yCoord)-var7)>2))
|
||||
{
|
||||
|
||||
var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
|
||||
|
||||
|
||||
double var7 = MathHelper.floor_double(holder.posY - var2.yCoord) ;
|
||||
|
||||
int var14 = MathHelper.floor_double(var5);
|
||||
int var15 = MathHelper.floor_double(var7);
|
||||
@@ -134,264 +126,98 @@ public class ItemRiftBlade extends ItemSword
|
||||
var15++;
|
||||
}
|
||||
var7=var15;
|
||||
}
|
||||
|
||||
|
||||
|
||||
holder.setPositionAndUpdate(var5, var7, var9);
|
||||
holder.playSound("mob.endermen.portal", 1.0F, 1.0F);
|
||||
holder.worldObj.playSoundEffect(holder.posX, holder.posY, holder.posZ, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
public ItemStack onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
public int getMaxItemUseDuration(ItemStack par1ItemStack)
|
||||
{
|
||||
return 72000;
|
||||
}
|
||||
|
||||
public EnumAction getItemUseAction(ItemStack par1ItemStack)
|
||||
{
|
||||
return properties.RiftBladeRiftCreationEnabled ? EnumAction.bow : EnumAction.block;
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
|
||||
{
|
||||
//Condition for disabling rift creation
|
||||
if (!properties.RiftBladeRiftCreationEnabled)
|
||||
return;
|
||||
|
||||
Vec3 var2 = par3EntityPlayer.getLook(1.0F);
|
||||
|
||||
double cooef = -2;
|
||||
var2.xCoord*=cooef;
|
||||
var2.yCoord*=cooef;
|
||||
var2.zCoord*=cooef;
|
||||
double var5 = par3EntityPlayer.posX - var2.xCoord;
|
||||
double var9 = par3EntityPlayer.posZ - var2.zCoord;
|
||||
double var7 = par3EntityPlayer.posY - var2.yCoord+2;
|
||||
|
||||
int x = MathHelper.floor_double(var5);
|
||||
int y = MathHelper.floor_double(var7);
|
||||
int z = MathHelper.floor_double(var9);
|
||||
|
||||
int rotation = (int) (MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw+90) * 4.0F / 360.0F) + 0.5D) & 3);
|
||||
LinkData link = new LinkData(par2World.provider.dimensionId, 0, x, y, z, x, y, z, true,rotation);
|
||||
|
||||
if(this.getMaxItemUseDuration(par1ItemStack)-par4>12&&!par2World.isRemote&&itemDimDoor.canPlace(par2World, x, y, z, rotation))
|
||||
if (!world.isRemote)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityLiving> list = (List<EntityLiving>) world.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(player.posX-8,player.posY-8, player.posZ-8, player.posX+8,player.posY+8, player.posZ+8));
|
||||
list.remove(player);
|
||||
|
||||
if(dimHelper.instance.getDimData(par2World.provider.dimensionId)!=null)
|
||||
for (EntityLiving ent : list)
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par2World.provider.dimensionId).depth==0)
|
||||
Vec3 var3 = player.getLook(1.0F).normalize();
|
||||
Vec3 var4 = player.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - player.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( player.posY + (double) player.getEyeHeight()), ent.posZ - player.posZ);
|
||||
double var5 = var4.lengthVector();
|
||||
var4 = var4.normalize();
|
||||
double var7 = var3.dotProduct(var4);
|
||||
if( (var7+.1) > 1.0D - 0.025D / var5 ? player.canEntityBeSeen(ent) : false)
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
teleportToEntity(stack, ent, player);
|
||||
stack.damageItem(3, player);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dimHelper.instance.createPocket(link,true, false);
|
||||
}
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftDoor", (float) .6, 1);
|
||||
itemDimDoor.placeDoorBlock(par2World, x, y-1, z, rotation, mod_pocketDim.transientDoor);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
Boolean didFindThing=false;
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
if (hit != null)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
int x = hit.blockX;
|
||||
int y = hit.blockY;
|
||||
int z = hit.blockZ;
|
||||
if (world.getBlockId(x, y, z) == properties.RiftBlockID)
|
||||
{
|
||||
|
||||
Block var11 = mod_pocketDim.transientDoor;
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
if (PocketManager.getLink(x, y, z, world) != null)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!itemDimDoor.canPlace(par2World, par4, par5, par6, var12)||!itemDimDoor.canPlace(par2World, par4, par5-1, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5, par6, par2World)==null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
else
|
||||
if (player.canPlayerEdit(x, y, z, hit.sideHit, stack) &&
|
||||
player.canPlayerEdit(x, y + 1, z, hit.sideHit, stack))
|
||||
{
|
||||
int orientation = MathHelper.floor_double((double)((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
itemDimDoor.placeDoorBlock(par2World, par4, par5-1, par6, var12, var11);
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftDoor", (float) .6, 1);
|
||||
|
||||
didFindThing=true;
|
||||
|
||||
|
||||
par1ItemStack.damageItem(10, par3EntityPlayer);
|
||||
|
||||
if (BaseItemDoor.canPlace(world, x, y, z) &&
|
||||
BaseItemDoor.canPlace(world, x, y - 1, z))
|
||||
{
|
||||
ItemDimensionalDoor.placeDoorBlock(world, x, y - 1, z, orientation, mod_pocketDim.transientDoor);
|
||||
player.worldObj.playSoundAtEntity(player,"mods.DimDoors.sfx.riftDoor", 0.6f, 1);
|
||||
stack.damageItem(3, player);
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.TransientDoorID)
|
||||
{
|
||||
didFindThing=true;
|
||||
}
|
||||
|
||||
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!par3EntityPlayer.worldObj.isRemote)
|
||||
{
|
||||
List<EntityLiving> list = par3EntityPlayer.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox( par3EntityPlayer.posX-8,par3EntityPlayer.posY-8, par3EntityPlayer.posZ-8, par3EntityPlayer.posX+8,par3EntityPlayer.posY+8, par3EntityPlayer.posZ+8));
|
||||
list.remove(par3EntityPlayer);
|
||||
|
||||
|
||||
for(EntityLiving ent : list)
|
||||
{
|
||||
|
||||
Vec3 var3 = par3EntityPlayer.getLook(1.0F).normalize();
|
||||
Vec3 var4 = par3EntityPlayer.worldObj.getWorldVec3Pool().getVecFromPool(ent.posX - par3EntityPlayer.posX, ent.boundingBox.minY + (double)((ent.height) / 2.0F) - ( par3EntityPlayer.posY + (double) par3EntityPlayer.getEyeHeight()), ent.posZ - par3EntityPlayer.posZ);
|
||||
double var5 = var4.lengthVector();
|
||||
var4 = var4.normalize();
|
||||
double var7 = var3.dotProduct(var4);
|
||||
if( (var7+.1) > 1.0D - 0.025D / var5 ? par3EntityPlayer.canEntityBeSeen(ent) : false)
|
||||
{
|
||||
System.out.println(list.size());
|
||||
ItemRiftBlade.class.cast(par1ItemStack.getItem()).teleportToEntity(par1ItemStack,ent, par3EntityPlayer);
|
||||
didFindThing=true;
|
||||
break;
|
||||
|
||||
//ItemRiftBlade.class.cast(item.getItem()).teleportTo(event.entityPlayer, ent.posX, ent.posY, ent.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// if(dimHelper.instance.getDimData(par2World.provider.dimensionId)!=null&&!par2World.isRemote&&!didFindThing)
|
||||
{
|
||||
|
||||
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return par1ItemStack;
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
return EnumToolMaterial.GOLD.getEnchantability();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name for this tool's material.
|
||||
*/
|
||||
public String getToolMaterialName()
|
||||
{
|
||||
return EnumToolMaterial.GOLD.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this item is repairable in an anvil.
|
||||
*/
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
return mod_pocketDim.itemStableFabric.itemID == par2ItemStack.itemID ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
/**
|
||||
* Return whether this item is repairable in an anvil.
|
||||
*/
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
if (par7 != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++par5;
|
||||
Block var11;
|
||||
|
||||
|
||||
|
||||
var11 = mod_pocketDim.transientDoor;
|
||||
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par3World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!itemDimDoor.canPlace(par3World, par4, par5, par6, var12)||dimHelper.instance.getLinkDataFromCoords(par4, par5+1, par6, par3World)==null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
itemDimDoor.placeDoorBlock(par3World, par4, par5, par6, var12, var11);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.rift", (float) .6, 1);
|
||||
|
||||
|
||||
par1ItemStack.damageItem(10, par2EntityPlayer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Don't include a call to super.getIsRepairable()!
|
||||
//That would cause this sword to accept gold as a repair material (since we set material = Gold).
|
||||
return mod_pocketDim.itemStableFabric.itemID == par2ItemStack.itemID ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Opens a temporary doors,");
|
||||
par3List.add ("special teleport attack,");
|
||||
par3List.add ("and rotates existing doors");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
par3List.add("Creates temporary doors");
|
||||
par3List.add("on rifts, rotates doors,");
|
||||
par3List.add("and has a teleport attack.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.EnumArmorMaterial;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
|
||||
public class ItemRiftGoggles extends ItemArmor
|
||||
{
|
||||
private Material doorMaterial;
|
||||
|
||||
public ItemRiftGoggles(int par1, int par2, int par3)
|
||||
{
|
||||
|
||||
245
StevenDimDoors/mod_pocketDim/items/ItemRiftSignature.java
Normal file
245
StevenDimDoors/mod_pocketDim/items/ItemRiftSignature.java
Normal file
@@ -0,0 +1,245 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.blocks.BaseDimDoor;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemRiftSignature extends Item
|
||||
{
|
||||
public ItemRiftSignature(int itemID)
|
||||
{
|
||||
super(itemID);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(0);
|
||||
this.hasSubtypes = true;
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
{
|
||||
//Make the item glow if it has one endpoint stored
|
||||
return (stack.getItemDamage() != 0);
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
//TODO- recognize doors and intelligently place rifts on them.
|
||||
// We must use onItemUseFirst() instead of onItemUse() because Minecraft checks
|
||||
// whether the user is in creative mode after calling onItemUse() and undoes any
|
||||
// damage we might set to indicate the rift sig has been activated. Otherwise,
|
||||
// we would need to rely on checking NBT tags for hasEffect() and that function
|
||||
// gets called constantly. Avoiding NBT lookups reduces our performance impact.
|
||||
|
||||
// Return false on the client side to pass this request to the server
|
||||
if (world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
y += 2; //Increase y by 2 to place the rift at head level
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
||||
Point4DOrientation source = getSource(stack);
|
||||
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
if (source != null)
|
||||
{
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL,source.getOrientation());
|
||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkTypes.NORMAL,orientation);
|
||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
//Try placing a rift at the destination point
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||
{
|
||||
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
//Try placing a rift at the source point, but check if its world is loaded first
|
||||
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
||||
if (sourceWorld != null &&
|
||||
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
||||
{
|
||||
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
clearSource(stack);
|
||||
player.sendChatToPlayer("Rift Created");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//The link signature has not been used. Store its current target as the first location.
|
||||
setSource(stack, x, adjustedY, z,orientation, PocketManager.getDimensionData(world));
|
||||
player.sendChatToPlayer("Location Stored in Rift Signature");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
Point4DOrientation source = getSource(par1ItemStack);
|
||||
if (source != null)
|
||||
{
|
||||
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores a location;");
|
||||
par3List.add("second click creates a pair of");
|
||||
par3List.add("rifts linking the two locations.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the rift placement account for replaceable blocks and doors.
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return the adjusted y coord
|
||||
*/
|
||||
public static int adjustYForSpecialBlocks(World world, int x, int y, int z)
|
||||
{
|
||||
y=y-2;//get the block the player actually clicked on
|
||||
Block block = Block.blocksList[world.getBlockId(x, y, z)];
|
||||
if(block.isBlockReplaceable(world, x, y, z))
|
||||
{
|
||||
return y+1;//move block placement down (-2+1) one so its directly over things like snow
|
||||
}
|
||||
if(block instanceof BaseDimDoor)
|
||||
{
|
||||
if(world.getBlockId(x, y-1, z)==block.blockID&&world.getBlockMetadata(x, y, z)==8)
|
||||
{
|
||||
return y;//move rift placement down two so its in the right place on the door.
|
||||
}
|
||||
return y+1;
|
||||
}
|
||||
return y+2;
|
||||
}
|
||||
public static void setSource(ItemStack itemStack, int x, int y, int z, int orientation, NewDimData dimension)
|
||||
{
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("orientation", orientation);
|
||||
tag.setInteger("linkDimID", dimension.id());
|
||||
|
||||
itemStack.setTagCompound(tag);
|
||||
itemStack.setItemDamage(1);
|
||||
}
|
||||
|
||||
public static void clearSource(ItemStack itemStack)
|
||||
{
|
||||
//Don't just set the tag to null since there may be other data there (e.g. for renamed items)
|
||||
NBTTagCompound tag = itemStack.getTagCompound();
|
||||
tag.removeTag("linkX");
|
||||
tag.removeTag("linkY");
|
||||
tag.removeTag("linkZ");
|
||||
tag.removeTag("orientation");
|
||||
tag.removeTag("linkDimID");
|
||||
itemStack.setItemDamage(0);
|
||||
}
|
||||
|
||||
public static Point4DOrientation getSource(ItemStack itemStack)
|
||||
{
|
||||
if (itemStack.getItemDamage() != 0)
|
||||
{
|
||||
if (itemStack.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = itemStack.getTagCompound();
|
||||
|
||||
Integer x = tag.getInteger("linkX");
|
||||
Integer y = tag.getInteger("linkY");
|
||||
Integer z = tag.getInteger("linkZ");
|
||||
Integer orientation = tag.getInteger("orientation");
|
||||
Integer dimID = tag.getInteger("linkDimID");
|
||||
|
||||
if (x != null && y != null && z != null && dimID != null)
|
||||
{
|
||||
return new Point4DOrientation(x, y, z,orientation, dimID);
|
||||
}
|
||||
}
|
||||
itemStack.setItemDamage(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static class Point4DOrientation
|
||||
{
|
||||
private Point4D point;
|
||||
private int orientation;
|
||||
Point4DOrientation(int x, int y, int z, int orientation, int dimID)
|
||||
{
|
||||
this.point= new Point4D(x,y,z,dimID);
|
||||
this.orientation=orientation;
|
||||
}
|
||||
|
||||
int getX()
|
||||
{
|
||||
return point.getX();
|
||||
}
|
||||
|
||||
int getY()
|
||||
{
|
||||
return point.getY();
|
||||
}
|
||||
|
||||
int getZ()
|
||||
{
|
||||
return point.getZ();
|
||||
}
|
||||
|
||||
int getDimension()
|
||||
{
|
||||
return point.getDimension();
|
||||
}
|
||||
int getOrientation()
|
||||
{
|
||||
return orientation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,201 +2,121 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.LinkTypes;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemStabilizedRiftSignature extends itemLinkSignature
|
||||
public class ItemStabilizedRiftSignature extends ItemRiftSignature
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public ItemStabilizedRiftSignature(int par)
|
||||
{
|
||||
super(par);
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setMaxDamage(0);
|
||||
this.hasSubtypes=true;
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
// adds effect if item has a link stored
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
public ItemStabilizedRiftSignature(int itemID)
|
||||
{
|
||||
super(itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
int key;
|
||||
LinkData linkData;
|
||||
int thisWorldID=par3World.provider.dimensionId;
|
||||
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
int offset = 2;
|
||||
if(par1ItemStack.getTagCompound()!=null)
|
||||
{
|
||||
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
|
||||
{
|
||||
boolean hasEnder = false;
|
||||
// checks to see if the item has a link stored, if so, it creates it
|
||||
if(par2EntityPlayer.inventory.hasItem(Item.enderPearl.itemID)||par2EntityPlayer.inventory.hasItem(properties.StableFabricItemID))
|
||||
{
|
||||
if(!par2EntityPlayer.inventory.consumeInventoryItem(properties.StableFabricItemID))
|
||||
{
|
||||
par2EntityPlayer.inventory.consumeInventoryItem(Item.enderPearl.itemID);
|
||||
}
|
||||
hasEnder=true;
|
||||
}
|
||||
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
if(hasEnder&&!par3World.isRemote)
|
||||
{
|
||||
if(dimHelper.instance.getLinkDataFromCoords(linkCoords[0], linkCoords[1], linkCoords[2], par3World)==null)
|
||||
{
|
||||
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6);
|
||||
}
|
||||
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2]);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftEnd", (float) .6, 1);
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
// Return false on the client side to pass this request to the server
|
||||
if (world.isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Created");
|
||||
}
|
||||
else if(!par3World.isRemote)
|
||||
{
|
||||
par2EntityPlayer.sendChatToPlayer("No Ender Pearls!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!par3World.isRemote)
|
||||
{
|
||||
if(par3World.getBlockId(par4, par5, par6)==Block.snow.blockID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId);
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
|
||||
// We don't check for replaceable blocks. The user can deal with that. <_<
|
||||
y += 2; //Increase y by 2 to place the rift at head level
|
||||
if (!player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Point4DOrientation source = getSource(stack);
|
||||
int adjustedY = adjustYForSpecialBlocks(world,x,y,z);
|
||||
|
||||
// Check if the Stabilized Rift Signature has been initialized
|
||||
int orientation = MathHelper.floor_double((double) ((player.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
if (source != null)
|
||||
{
|
||||
// Yes, it's initialized. Check if the player is in creative
|
||||
// or if the player can pay an Ender Pearl to create a rift.
|
||||
if (!player.capabilities.isCreativeMode && !player.inventory.hasItem(Item.enderPearl.itemID))
|
||||
{
|
||||
player.sendChatToPlayer("You don't have any Ender Pearls!");
|
||||
return true;
|
||||
}
|
||||
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
//The link was used before and already has an endpoint stored. Create links connecting the two endpoints.
|
||||
NewDimData sourceDimension = PocketManager.getDimensionData(source.getDimension());
|
||||
NewDimData destinationDimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = sourceDimension.createLink(source.getX(), source.getY(), source.getZ(), LinkTypes.NORMAL,source.getOrientation());
|
||||
DimLink reverse = destinationDimension.createLink(x, adjustedY, z, LinkTypes.NORMAL,orientation);
|
||||
destinationDimension.setDestination(link, x, adjustedY, z);
|
||||
sourceDimension.setDestination(reverse, source.getX(), source.getY(), source.getZ());
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
Integer[] coords = this.readFromNBT(par1ItemStack);
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+dimHelper.instance.getDimDepth(dimHelper.instance.getDimDepth(coords[3]))));
|
||||
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores location,");
|
||||
par3List.add ("second click creates two rifts,");
|
||||
par3List.add("that link the first location");
|
||||
par3List.add("with the second location");
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
//Try placing a rift at the destination point
|
||||
if (!mod_pocketDim.blockRift.isBlockImmune(world, x, adjustedY, z))
|
||||
{
|
||||
world.setBlock(x, adjustedY, z, mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
}
|
||||
else
|
||||
{
|
||||
tag= new NBTTagCompound();
|
||||
}
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("linkDimID", dimID);
|
||||
tag.setBoolean("isCreated", true);
|
||||
itemStack.setTagCompound(tag);
|
||||
}
|
||||
//Try placing a rift at the source point, but check if its world is loaded first
|
||||
World sourceWorld = DimensionManager.getWorld(sourceDimension.id());
|
||||
if (sourceWorld != null &&
|
||||
!mod_pocketDim.blockRift.isBlockImmune(sourceWorld, source.getX(), source.getY(), source.getZ()))
|
||||
{
|
||||
sourceWorld.setBlock(source.getX(), source.getY(), source.getZ(), mod_pocketDim.blockRift.blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the stack fields from a NBT object.
|
||||
*/
|
||||
public Integer[] readFromNBT(ItemStack itemStack)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
Integer[] linkCoords = new Integer[5];
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.inventory.consumeInventoryItem(Item.enderPearl.itemID);
|
||||
}
|
||||
player.sendChatToPlayer("Rift Created");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftEnd", 0.6f, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//The link signature has not been used. Store its current target as the first location.
|
||||
setSource(stack, x, adjustedY, z, orientation, PocketManager.getDimensionData(world));
|
||||
player.sendChatToPlayer("Location Stored in Rift Signature");
|
||||
world.playSoundAtEntity(player,"mods.DimDoors.sfx.riftStart", 0.6f, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!tag.getBoolean("isCreated"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
linkCoords[0]=tag.getInteger("linkX");
|
||||
linkCoords[1]=tag.getInteger("linkY");
|
||||
linkCoords[2]=tag.getInteger("linkZ");
|
||||
linkCoords[3]=tag.getInteger("linkDimID");
|
||||
}
|
||||
return linkCoords;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
}
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
Point4DOrientation source = getSource(par1ItemStack);
|
||||
if (source != null)
|
||||
{
|
||||
par3List.add("Leads to (" + source.getX() + ", " + source.getY() + ", " + source.getZ() + ") at dimension #" + source.getDimension());
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores a location,");
|
||||
par3List.add("second click creates two rifts");
|
||||
par3List.add("that link the locations together.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,184 +1,19 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.SchematicLoader;
|
||||
import StevenDimDoors.mod_pocketDim.Spells;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
import StevenDimDoors.mod_pocketDim.ticking.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDimClient.ClientTickHandler;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.RotationHelper;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemStableFabric extends Item
|
||||
{
|
||||
private Material doorMaterial;
|
||||
|
||||
public ItemStableFabric(int par1, int par2)
|
||||
public ItemStableFabric(int itemID, int par2)
|
||||
{
|
||||
super(par1);
|
||||
// this.setitemIcon(Item.doorWood.getIconFromDamage(0));
|
||||
super(itemID);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
|
||||
}
|
||||
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
|
||||
if(!par3World.isRemote)
|
||||
{
|
||||
System.out.println("Block metadata is "+par3World.getBlockMetadata(par4, par5, par6));
|
||||
System.out.println(par3World.getBiomeGenForCoords(par4, par6).biomeName);
|
||||
|
||||
|
||||
this.onItemRightClick(par1ItemStack, par3World, par2EntityPlayer);
|
||||
|
||||
Block block = Block.blocksList[par3World.getBlockId(par4, par5, par6)];
|
||||
|
||||
if(dimHelper.dimList.containsKey(par3World.provider.dimensionId))
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par3World.provider.dimensionId).isPocket)
|
||||
{
|
||||
if(dimHelper.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator!=null)
|
||||
{
|
||||
System.out.println("Dungeon name "+dimHelper.instance.getDimData(par3World.provider.dimensionId).dungeonGenerator.schematicPath);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
//System.out.println("Block texture data is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getBlockTexture(par3World,par4, par5, par6,par7).getIconName());
|
||||
//System.out.println("Block name is is "+Block.blocksList[par3World.getBlockId(par4, par5, par6)].getUnlocalizedName2());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 4;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (this.isSteven(par3EntityPlayer))
|
||||
{
|
||||
new Spells(par3EntityPlayer, par1ItemStack.stackSize).cast();
|
||||
//mod_pocketDim.proxy.startCasting(par3EntityPlayer, par1ItemStack.stackSize);
|
||||
}
|
||||
|
||||
Boolean didFindThing=false;
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
//if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ)==properties.RiftBlockID)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY-1;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
String cardinal= "default";
|
||||
|
||||
switch(link.linkOrientation)
|
||||
{
|
||||
case 0:
|
||||
cardinal = "East";
|
||||
break;
|
||||
case 1:
|
||||
cardinal = "South";
|
||||
break;
|
||||
case 2:
|
||||
cardinal = "West";
|
||||
break;
|
||||
case 3:
|
||||
cardinal = "North";
|
||||
break;
|
||||
}
|
||||
System.out.println("Link orientation is " + link.linkOrientation + " - " + cardinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSteven(EntityPlayer player)
|
||||
{
|
||||
return (player.username.equalsIgnoreCase("stevenrs11"));
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
45
StevenDimDoors/mod_pocketDim/items/ItemUnstableDoor.java
Normal file
45
StevenDimDoors/mod_pocketDim/items/ItemUnstableDoor.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemUnstableDoor extends BaseItemDoor
|
||||
{
|
||||
public ItemUnstableDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Caution: Leads to random destination");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.unstableDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.unstableDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
48
StevenDimDoors/mod_pocketDim/items/ItemWarpDoor.java
Normal file
48
StevenDimDoors/mod_pocketDim/items/ItemWarpDoor.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
public class ItemWarpDoor extends BaseItemDoor
|
||||
{
|
||||
public ItemWarpDoor(int itemID, Material material)
|
||||
{
|
||||
super(itemID, material);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Place on the block under");
|
||||
par3List.add("a rift to create a portal,");
|
||||
par3List.add("or place anywhere in a");
|
||||
par3List.add("pocket dimension to exit.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (tryPlacingDoor(mod_pocketDim.warpDoor, world, player, stack) &&
|
||||
!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize--;
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y,
|
||||
int z, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
return tryItemUse(mod_pocketDim.warpDoor, stack, player, world, x, y, z, par7, false, true);
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
public class itemDimDoor extends ItemDoor
|
||||
{
|
||||
private static DDProperties properties = null;
|
||||
|
||||
public itemDimDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.setMaxStackSize(64);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Place on the block under a rift");
|
||||
par3List.add("to activate that rift or place");
|
||||
par3List.add("anywhere else to create a");
|
||||
par3List.add("pocket dimension.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if (par7 != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
++par5;
|
||||
Block var11;
|
||||
|
||||
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par3World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!canPlace(par3World, par4, par5, par6, var12) || !canPlace(par3World, par4, par5+1, par6, var12))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset = 0;
|
||||
int idBlock = par3World.getBlockId(par4, par5-1, par6);
|
||||
|
||||
if(Block.blocksList.length>idBlock&&idBlock!=0)
|
||||
{
|
||||
if(Block.blocksList[idBlock].isBlockReplaceable(par3World, par4, par5-1, par6))
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
placeDoorBlock(par3World, par4, par5-offset, par6, var12, var11);
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 4;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null&&!par2World.isRemote)
|
||||
{
|
||||
if(par2World.getBlockId(hit.blockX, hit.blockY, hit.blockZ) == properties.RiftBlockID)
|
||||
{
|
||||
LinkData link = dimHelper.instance.getLinkDataFromCoords(hit.blockX, hit.blockY, hit.blockZ, par2World);
|
||||
if(link!=null)
|
||||
{
|
||||
Block var11;
|
||||
if(par1ItemStack.getItem() instanceof itemExitDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.ExitDoor;
|
||||
}
|
||||
|
||||
else if(par1ItemStack.getItem() instanceof ItemChaosDoor )
|
||||
{
|
||||
var11 = mod_pocketDim.chaosDoor;
|
||||
}
|
||||
else
|
||||
{
|
||||
var11 = mod_pocketDim.dimDoor;
|
||||
}
|
||||
|
||||
int par4 = hit.blockX;
|
||||
int par5 = hit.blockY;
|
||||
int par6 = hit.blockZ;
|
||||
int par7 = 0 ;
|
||||
|
||||
|
||||
|
||||
|
||||
if (par3EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par3EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)&&!par2World.isRemote)
|
||||
{
|
||||
int var12 = MathHelper.floor_double((double)((par3EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
if (!canPlace(par2World, par4, par5, par6, var12) || !canPlace(par2World, par4, par5-1, par6, var12) ||
|
||||
dimHelper.instance.getLinkDataFromCoords(par4, par5, par6, par2World) == null)
|
||||
{
|
||||
return par1ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
placeDoorBlock(par2World, par4, par5-1, par6, var12, var11);
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
|
||||
}
|
||||
|
||||
public static boolean canPlace(World world,int i, int j, int k, int p)
|
||||
{
|
||||
int id = world.getBlockId(i, j, k);
|
||||
|
||||
boolean flag = true;
|
||||
if (id==properties.FabricBlockID || id==properties.RiftBlockID || id==properties.PermaFabricBlockID || id == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id != 0 && !Block.blocksList[id].blockMaterial.isReplaceable())
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemDoor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class itemExitDoor extends itemDimDoor
|
||||
{
|
||||
private Material doorMaterial;
|
||||
|
||||
public itemExitDoor(int par1, Material par2Material)
|
||||
{
|
||||
super(par1, par2Material);
|
||||
this.doorMaterial = par2Material;
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
|
||||
}
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName().replace("item.", ""));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
|
||||
par3List.add("Place on the block under a rift");
|
||||
par3List.add ("in any dimension,");
|
||||
par3List.add("or place anywhere in pocket dim");
|
||||
par3List.add("to approach surface");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,274 +0,0 @@
|
||||
package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class itemLinkSignature extends Item
|
||||
{
|
||||
|
||||
public itemLinkSignature(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setMaxStackSize(1);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
|
||||
// this.itemIcon=5;
|
||||
this.setMaxDamage(0);
|
||||
this.hasSubtypes=true;
|
||||
//TODO move to proxy
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
private static DDProperties properties = null;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
// adds effect if item has a link stored
|
||||
|
||||
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
int key;
|
||||
LinkData linkData;
|
||||
int thisWorldID=par3World.provider.dimensionId;
|
||||
|
||||
|
||||
|
||||
|
||||
if(!par3World.isRemote)
|
||||
{
|
||||
|
||||
//par1ItemStack= par2EntityPlayer.getCurrentEquippedItem();
|
||||
Integer[] linkCoords =this.readFromNBT(par1ItemStack);
|
||||
|
||||
|
||||
|
||||
//System.out.println(key);
|
||||
int offset = 2;
|
||||
int idBlock = par3World.getBlockId(par4, par5, par6);
|
||||
|
||||
if(Block.blocksList.length>idBlock&&idBlock!=0)
|
||||
{
|
||||
if(Block.blocksList[idBlock].isBlockReplaceable(par3World, par4, par5, par6))
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
}
|
||||
if(par3World.getBlockId(par4, par5, par6) == properties.DimensionalDoorID && par3World.getBlockId(par4, par5 + 1, par6) == properties.DimensionalDoorID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
if(par3World.getBlockId(par4, par5, par6)==properties.WarpDoorID&&par3World.getBlockId(par4, par5+1, par6)==properties.WarpDoorID)
|
||||
{
|
||||
offset = 1;
|
||||
}
|
||||
else
|
||||
if (par3World.getBlockId(par4, par5, par6)==properties.DimensionalDoorID&&par3World.getBlockId(par4, par5-1, par6)==properties.DimensionalDoorID)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
else
|
||||
if (par3World.getBlockId(par4, par5, par6) == properties.WarpDoorID && par3World.getBlockId(par4, par5-1, par6)==properties.WarpDoorID)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int orientation = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3;
|
||||
|
||||
for(int count = 0;count<3;count++)
|
||||
{
|
||||
if(dimHelper.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World)!=null)
|
||||
{
|
||||
int id= (par3World.getBlockId(par4, par5+count, par6));
|
||||
|
||||
if(id == properties.DimensionalDoorID||id==properties.WarpDoorID||id== properties.UnstableDoorID)
|
||||
{
|
||||
orientation = dimHelper.instance.getLinkDataFromCoords(par4, par5+count, par6,par3World).linkOrientation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(par1ItemStack.getTagCompound()!=null)
|
||||
{
|
||||
if(par1ItemStack.getTagCompound().getBoolean("isCreated"))
|
||||
{
|
||||
// checks to see if the item has a link stored, if so, it creates it
|
||||
|
||||
|
||||
|
||||
dimHelper.instance.createLink(par3World.provider.dimensionId, linkCoords[3], par4, par5+offset, par6, linkCoords[0], linkCoords[1], linkCoords[2],orientation);
|
||||
dimHelper.instance.createLink(linkCoords[3], par3World.provider.dimensionId, linkCoords[0], linkCoords[1], linkCoords[2],par4, par5+offset, par6,linkCoords[4]);
|
||||
|
||||
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Created");
|
||||
par1ItemStack.stackTagCompound=null;
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftEnd", (float) .6, 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
//otherwise, it creates the first half of the link. Next click will complete it.
|
||||
key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
this.writeToNBT(par1ItemStack, par4, par5+offset, par6,par3World.provider.dimensionId,orientation);
|
||||
par2EntityPlayer.sendChatToPlayer("Rift Signature Stored");
|
||||
par2EntityPlayer.worldObj.playSoundAtEntity(par2EntityPlayer,"mods.DimDoors.sfx.riftStart", (float) .6, 1);
|
||||
}
|
||||
//dimHelper.instance.save();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
if(par1ItemStack.hasTagCompound())
|
||||
{
|
||||
if(par1ItemStack.stackTagCompound.getBoolean("isCreated"))
|
||||
{
|
||||
Integer[] coords = this.readFromNBT(par1ItemStack);
|
||||
|
||||
par3List.add(String.valueOf("Leads to dim "+coords[3] +" with depth "+(dimHelper.instance.getDimDepth(coords[3]))));
|
||||
par3List.add("at x="+coords[0]+" y="+coords[1]+" z="+coords[2]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
par3List.add("First click stores location,");
|
||||
par3List.add ("second click creates two rifts,");
|
||||
par3List.add("that link the first location");
|
||||
par3List.add("with the second location");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(ItemStack itemStack,int x, int y, int z, int dimID,int orientation)
|
||||
{
|
||||
NBTTagCompound tag;
|
||||
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tag= new NBTTagCompound();
|
||||
}
|
||||
|
||||
tag.setInteger("linkX", x);
|
||||
tag.setInteger("linkY", y);
|
||||
tag.setInteger("linkZ", z);
|
||||
tag.setInteger("linkDimID", dimID);
|
||||
tag.setBoolean("isCreated", true);
|
||||
tag.setInteger("orientation", orientation);
|
||||
|
||||
itemStack.setTagCompound(tag);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the stack fields from a NBT object.
|
||||
*/
|
||||
public Integer[] readFromNBT(ItemStack itemStack)
|
||||
{
|
||||
|
||||
NBTTagCompound tag;
|
||||
Integer[] linkCoords = new Integer[5];
|
||||
if(itemStack.hasTagCompound())
|
||||
{
|
||||
tag = itemStack.getTagCompound();
|
||||
|
||||
if(!tag.getBoolean("isCreated"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
linkCoords[0]=tag.getInteger("linkX");
|
||||
linkCoords[1]=tag.getInteger("linkY");
|
||||
linkCoords[2]=tag.getInteger("linkZ");
|
||||
linkCoords[3]=tag.getInteger("linkDimID");
|
||||
linkCoords[4]=tag.getInteger("orientation");
|
||||
|
||||
|
||||
|
||||
}
|
||||
return linkCoords;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,135 +2,135 @@ package StevenDimDoors.mod_pocketDim.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class itemRiftRemover extends Item
|
||||
{
|
||||
private Material doorMaterial;
|
||||
public itemRiftRemover(int itemID, Material par2Material)
|
||||
{
|
||||
super(itemID);
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
this.setMaxDamage(4);
|
||||
}
|
||||
|
||||
public itemRiftRemover(int par1, Material par2Material)
|
||||
{
|
||||
super(par1);
|
||||
this.setMaxStackSize(1);
|
||||
// this.setTextureFile("/PocketBlockTextures.png");
|
||||
this.setCreativeTab(mod_pocketDim.dimDoorsCreativeTab);
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
}
|
||||
|
||||
// this.itemIcon=6;
|
||||
this.setMaxDamage(5);
|
||||
this.hasSubtypes=true;
|
||||
//TODO move to proxy
|
||||
}
|
||||
|
||||
|
||||
public void registerIcons(IconRegister par1IconRegister)
|
||||
{
|
||||
this.itemIcon = par1IconRegister.registerIcon(mod_pocketDim.modid + ":" + this.getUnlocalizedName());
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
// We invoke PlayerControllerMP.onPlayerRightClick() from here so that Minecraft
|
||||
// will invoke onItemUseFirst() on the client side. We'll tell it to pass the
|
||||
// request to the server, which will make sure that rift-related changes are
|
||||
// reflected on the server.
|
||||
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack par1ItemStack)
|
||||
{
|
||||
// adds effect if item has a link stored
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MovingObjectPosition getBlockTarget(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
|
||||
{
|
||||
float var4 = 1.0F;
|
||||
float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
|
||||
float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
|
||||
double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * (double)var4;
|
||||
double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * (double)var4 + 1.62D - (double)par2EntityPlayer.yOffset;
|
||||
double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * (double)var4;
|
||||
Vec3 var13 = par1World.getWorldVec3Pool().getVecFromPool(var7, var9, var11);
|
||||
float var14 = MathHelper.cos(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var15 = MathHelper.sin(-var6 * 0.017453292F - (float)Math.PI);
|
||||
float var16 = -MathHelper.cos(-var5 * 0.017453292F);
|
||||
float var17 = MathHelper.sin(-var5 * 0.017453292F);
|
||||
float var18 = var15 * var16;
|
||||
float var20 = var14 * var16;
|
||||
double var21 = 5.0D;
|
||||
if (par2EntityPlayer instanceof EntityPlayerMP)
|
||||
{
|
||||
var21 = 6;
|
||||
}
|
||||
Vec3 var23 = var13.addVector((double)var18 * var21, (double)var17 * var21, (double)var20 * var21);
|
||||
return par1World.rayTraceBlocks_do_do(var13, var23, true, false);
|
||||
}
|
||||
if (!world.isRemote)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
{
|
||||
MovingObjectPosition hit = this.getBlockTarget(par3EntityPlayer.worldObj, par3EntityPlayer, false );
|
||||
if(hit!=null)
|
||||
{
|
||||
//System.out.println(hit.hitVec);
|
||||
if(dimHelper.instance.removeRift(par2World, hit.blockX, hit.blockY, hit.blockZ, 1, par3EntityPlayer, par1ItemStack))
|
||||
{
|
||||
par3EntityPlayer.worldObj.playSoundAtEntity(par3EntityPlayer,"mods.DimDoors.sfx.riftClose", (float) .8, 1);
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (hit != null)
|
||||
{
|
||||
int hx = hit.blockX;
|
||||
int hy = hit.blockY;
|
||||
int hz = hit.blockZ;
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(hx, hy, hz);
|
||||
if (world.getBlockId(hx, hy, hz) == mod_pocketDim.blockRift.blockID && link != null &&
|
||||
player.canPlayerEdit(hx, hy, hz, hit.sideHit, stack))
|
||||
{
|
||||
// Invoke onPlayerRightClick()
|
||||
FMLClientHandler.instance().getClient().playerController.onPlayerRightClick(
|
||||
player, world, stack, hx, hy, hz, hit.sideHit, hit.hitVec);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// dimHelper.removeRift( par3World, par4, par5, par6, range, par2EntityPlayer, par1ItemStack);
|
||||
|
||||
|
||||
}
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
|
||||
|
||||
par3List.add("Use near exposed rift");
|
||||
par3List.add ("to remove it and");
|
||||
par3List.add("any nearby rifts");
|
||||
|
||||
// We want to use onItemUseFirst() here so that this code will run on the server side,
|
||||
// so we don't need the client to send link-related updates to the server. Still,
|
||||
// check whether we have a rift in sight before passing the request over.
|
||||
|
||||
// On integrated servers, the link won't be removed immediately because of the rift
|
||||
// removal animation. That means we'll have a chance to check for the link before
|
||||
// it's deleted. Otherwise the Rift Remover's durability wouldn't drop.
|
||||
MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true);
|
||||
if (hit != null)
|
||||
{
|
||||
x = hit.blockX;
|
||||
y = hit.blockY;
|
||||
z = hit.blockZ;
|
||||
|
||||
NewDimData dimension = PocketManager.getDimensionData(world);
|
||||
DimLink link = dimension.getLink(x, y, z);
|
||||
if (world.getBlockId(x, y, z) == mod_pocketDim.blockRift.blockID && link != null &&
|
||||
player.canPlayerEdit(x, y, z, side, stack))
|
||||
{
|
||||
// Tell the rift's tile entity to do its removal animation
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
if (tileEntity != null && tileEntity instanceof TileEntityRift)
|
||||
{
|
||||
((TileEntityRift) tileEntity).shouldClose = true;
|
||||
tileEntity.onInventoryChanged();
|
||||
}
|
||||
else if (!world.isRemote)
|
||||
{
|
||||
// Only set the block to air on the server side so that we don't
|
||||
// tell the server to remove the rift block before it can use the
|
||||
// Rift Remover. Otherwise, it won't know to reduce durability.
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
if (world.isRemote)
|
||||
{
|
||||
// Tell the server about this
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.damageItem(1, player);
|
||||
}
|
||||
player.worldObj.playSoundAtEntity(player, "mods.DimDoors.sfx.riftClose", 0.8f, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if(!par2World.isRemote)
|
||||
{
|
||||
/**
|
||||
//creates the first half of the link on item creation
|
||||
int key= dimHelper.instance.createUniqueInterDimLinkKey();
|
||||
LinkData linkData= new LinkData(par2World.provider.dimensionId,MathHelper.floor_double(par3EntityPlayer.posX),MathHelper.floor_double(par3EntityPlayer.posY),MathHelper.floor_double(par3EntityPlayer.posZ));
|
||||
System.out.println(key);
|
||||
|
||||
dimHelper.instance.interDimLinkList.put(key, linkData);
|
||||
par1ItemStack.setItemDamage(key);
|
||||
**/
|
||||
}
|
||||
}
|
||||
/**
|
||||
* allows items to add custom lines of information to the mouseover description
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
par3List.add("Use near exposed rift");
|
||||
par3List.add("to remove it and");
|
||||
par3List.add("any nearby rifts.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user