當前位置: 首頁>>代碼示例>>Java>>正文


Java MovingObjectType類代碼示例

本文整理匯總了Java中net.minecraft.util.MovingObjectPosition.MovingObjectType的典型用法代碼示例。如果您正苦於以下問題:Java MovingObjectType類的具體用法?Java MovingObjectType怎麽用?Java MovingObjectType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MovingObjectType類屬於net.minecraft.util.MovingObjectPosition包,在下文中一共展示了MovingObjectType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onItemRightClick

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);

    if (mop == null)
        return is;

    if (mop.typeOfHit == MovingObjectType.BLOCK)
    {
        int x = mop.blockX;
        int y = mop.blockY;
        int z = mop.blockZ;

        if (!world.canMineBlock(player, x, y, z))
            return is;

        return new ItemStack(TFCItems.woodenBucketEmpty);
    }

    return is;
}
 
開發者ID:Wahazar,項目名稱:TFCPrimitiveTech,代碼行數:23,代碼來源:WoodenBucket_BasePotashLiquor.java

示例2: impactWasting

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
private void impactWasting(MovingObjectPosition mop, boolean enhanced) {
   Entity livingEntity = mop.entityHit;
   double x;
   double y;
   double z;
   if(mop.typeOfHit == MovingObjectType.ENTITY) {
      x = livingEntity.posX;
      y = livingEntity.posY;
      z = livingEntity.posZ;
   } else {
      x = (double)mop.blockX;
      y = (double)mop.blockY;
      z = (double)mop.blockZ;
   }

   explodeWasting(super.worldObj, x, y, z, livingEntity, super.boundingBox, enhanced);
}
 
開發者ID:lerion13,項目名稱:witchery,代碼行數:18,代碼來源:EntityWitchProjectile.java

示例3: rayTraceCuboids

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
public void rayTraceCuboids(Vector3 start, Vector3 end, List<IndexedCuboid6> cuboids, BlockCoord pos, Block block, List<ExtendedMOP> hitList)
{
    for(IndexedCuboid6 cuboid : cuboids)
    {
        MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
        if(mop != null)
        {
            ExtendedMOP emop = new ExtendedMOP(mop, cuboid.data, s_dist);
            emop.typeOfHit = MovingObjectType.BLOCK;
            emop.blockX = pos.x;
            emop.blockY = pos.y;
            emop.blockZ = pos.z;
            hitList.add(emop);
        }
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:17,代碼來源:RayTracer.java

示例4: renderOverlay

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
public static void renderOverlay() {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.currentScreen == null &&
            mc.theWorld != null &&
            !mc.gameSettings.keyBindPlayerList.getIsKeyPressed() &&
            NEIClientConfig.getBooleanSetting("world.highlight_tips") &&
            mc.objectMouseOver != null &&
            mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
        World world = mc.theWorld;
        ArrayList<ItemStack> items = ItemInfo.getIdentifierItems(world, mc.thePlayer, mc.objectMouseOver);
        if (items.isEmpty())
            return;

        int minDamage = Integer.MAX_VALUE;
        ItemStack stack = null;
        for(ItemStack astack : items) {
            if(astack.getItem() != null && astack.getItemDamage() < minDamage) {
                stack = astack;
                minDamage = stack.getItemDamage();
            }
        }

        renderOverlay(stack, ItemInfo.getText(stack, world, mc.thePlayer, mc.objectMouseOver), getPositioning());
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:26,代碼來源:HUDRenderer.java

示例5: renderOverlay

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
public static void renderOverlay() {
    Minecraft mc = Minecraft.getMinecraft();
    if (mc.currentScreen == null &&
            mc.theWorld != null &&
            !mc.gameSettings.keyBindPlayerList.isKeyDown() &&
            NEIClientConfig.getBooleanSetting("world.highlight_tips") &&
            mc.objectMouseOver != null &&
            mc.objectMouseOver.typeOfHit == MovingObjectType.BLOCK) {
        World world = mc.theWorld;
        ArrayList<ItemStack> items = ItemInfo.getIdentifierItems(world, mc.thePlayer, mc.objectMouseOver);
        if (items.isEmpty())
            return;

        int minDamage = Integer.MAX_VALUE;
        ItemStack stack = null;
        for(ItemStack astack : items) {
            if(astack.getItem() != null && astack.getItemDamage() < minDamage) {
                stack = astack;
                minDamage = stack.getItemDamage();
            }
        }

        renderOverlay(stack, ItemInfo.getText(stack, world, mc.thePlayer, mc.objectMouseOver), getPositioning());
    }
}
 
開發者ID:SneakyTactician,項目名稱:BIGB,代碼行數:26,代碼來源:HUDRenderer.java

示例6: clickItem

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
boolean clickItem(EntityPlayer player, ItemStack is, MovingObjectPosition mop) {
    try {
        if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
            return mcClick(player, mop, is);
        } else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) {
            if (player.interactWith(mop.entityHit)) {
                return true;
            }
        }
    } catch (Throwable t) {
        CrashReport err = new CrashReport("clicking item", t);
        CrashReportCategory cat = err.makeCategory("clicked item");
        cat.addCrashSection("Item", is);
        cat.addCrashSection("Mop", mop);
        throw new ReportedException(err);
    }
    return false;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:19,代碼來源:SocketRobotHand.java

示例7: degooArea

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
private boolean degooArea(EntityPlayer player, GooData data, ItemStack gooItem, MovingObjectPosition mop, int radius) {
    if (player.worldObj.isRemote) return false;
    if (data == null) return false;
    if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return false;
    int d = radius;
    boolean any = false;
    BlockPos pos = mop.getBlockPos();
    for (int dx = -d; dx <= d; dx++) {
        for (int dy = -d; dy <= d; dy++) {
            for (int dz = -d; dz <= d; dz++) {
                any |= deselectCoord(gooItem, data, player.worldObj, pos.add(dx, dy, dz), false);
            }
        }
    }
    if (any) {
        data.markDirty();
    }
    return false;
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:20,代碼來源:ItemGoo.java

示例8: processCommand

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
public void processCommand(ICommandSender sender, String[] args) {
    String msg = Joiner.on(" ").join(args);
    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayer player = mc.thePlayer;
    MovingObjectPosition mop = getMouseOver(player, 64);
    if (mop == null || mop.typeOfHit == MovingObjectType.MISS) {
        sender.addChatMessage(new ChatComponentTranslation("notify.point.toofar"));
        return;
    }
    try {
        switch (mop.typeOfHit) {
        default: return;
        case BLOCK:
            PointNetworkHandler.INSTANCE.pointAtCoord(Coord.fromMop(player.worldObj, mop), msg);
            break;
        case ENTITY:
            PointNetworkHandler.INSTANCE.pointAtEntity(mop.entityHit, msg);
            break;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:25,代碼來源:PointCommand.java

示例9: onItemRightClick

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);

    if (mop == null)
        return is;

    if (mop.typeOfHit == MovingObjectType.BLOCK) {
        int x = mop.blockX;
        int y = mop.blockY;
        int z = mop.blockZ;

        if (!world.canMineBlock(player, x, y, z))
            return is;

        return new ItemStack(this);
    }
    return is;

}
 
開發者ID:AnodeCathode,項目名稱:TechNodefirmacraftMod,代碼行數:21,代碼來源:ModItemBottle.java

示例10: onItemRightClick

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player)
{
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);

    if (mop == null)
        return is;

    if (mop.typeOfHit == MovingObjectType.BLOCK)
    {
        int x = mop.blockX;
        int y = mop.blockY;
        int z = mop.blockZ;

        if (!world.canMineBlock(player, x, y, z))
            return is;

        return new ItemStack(TFCItems.woodenBucketEmpty);
    }

    return is;
}
 
開發者ID:Aleksey-Terzi,項目名稱:DecorationsTFC,代碼行數:26,代碼來源:ItemPlaster.java

示例11: onImpact

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
protected void onImpact(MovingObjectPosition mop)
{

	if(mop.typeOfHit == MovingObjectType.BLOCK)
	{
		this.worldObj.newExplosion(this, mop.blockX, mop.blockY, mop.blockZ, 2.0F, true, true);
	}
	if (mop.entityHit != null)
       {
           this.worldObj.newExplosion(this, mop.blockX, mop.blockY, mop.blockZ, 2.0F, true, true);         
       }
	if (!this.worldObj.isRemote)
	{
		this.setDead();
	}
}
 
開發者ID:RamiLego4Game,項目名稱:GalacticraftPixelGalaxy,代碼行數:18,代碼來源:EntitySeedFrezz.java

示例12: onUse

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
public void onUse(World world, EntityPlayer player, IPlayerSession session, ItemStack stack, int boost, int cost) {
    if (session.hasEnoughMana(cost())) {
        MovingObjectPosition mop = SimpleUtil.rayTrace(player, world, 43);
        if (mop != null) {
            if (mop.typeOfHit == MovingObjectType.BLOCK) {
                int blockX = mop.blockX;
                int blockY = mop.blockY;
                int blockZ = mop.blockZ;
                Block block = world.getBlock(blockX, blockY, blockZ);
                if (block != null && !world.isAirBlock(blockX, blockY, blockZ)) {
                    EntityLightningBolt light = new EntityLightningBolt(world, blockX, blockY, blockZ);
                    world.spawnEntityInWorld(light);
                    session.adjustMana(-cost(), false);
                }
            }
        }
    }
}
 
開發者ID:Lomeli12,項目名稱:MagicalRings,代碼行數:20,代碼來源:HeavenStrike.java

示例13: onImpact

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
protected void onImpact(MovingObjectPosition pos) {
	if (pos.entityHit instanceof EntityEnderman) return;
	if (pos.typeOfHit == MovingObjectType.BLOCK) {
		if (worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ).getMaterial().isReplaceable()) return;
	}
	setDead();
	if (!worldObj.isRemote) {
		if (pos.entityHit != null && pos.entityHit instanceof EntityLivingBase) {
			float min = (float)FarragoMod.config.getDouble("blunderbuss.damage.min");
			float max = (float)FarragoMod.config.getDouble("blunderbuss.damage.max");
			((EntityLivingBase)pos.entityHit).attackEntityFrom(new EntityDamageSourceIndirect("blunderbuss", this, getThrower()), (rand.nextFloat()*(max-min))+min);
			((EntityLivingBase)pos.entityHit).hurtResistantTime = 1;
		}
		if (worldObj instanceof WorldServer) {
			((WorldServer)worldObj).func_147487_a("smoke", pos.hitVec.xCoord, pos.hitVec.yCoord, pos.hitVec.zCoord, 1, 0.2f, 0.2f, 0.2f, 0f);
			((WorldServer)worldObj).playSoundAtEntity(this, "step.stone", 0.5f, 0.3f);
		}
	}
}
 
開發者ID:unascribed,項目名稱:Farrago,代碼行數:21,代碼來源:EntityBlunderbussProjectile.java

示例14: onImpact

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
@Override
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
	if(!worldObj.isRemote)
		if(par1MovingObjectPosition.typeOfHit == MovingObjectType.ENTITY)
		{
			if(par1MovingObjectPosition.entityHit instanceof EntityPlayer)
				if(((EntityPlayer)par1MovingObjectPosition.entityHit).capabilities.isCreativeMode || (EntityLivingBase)par1MovingObjectPosition.entityHit == getThrower())
					return;

			if(par1MovingObjectPosition.entityHit instanceof EntityLivingBase)
			{
				((EntityLivingBase) par1MovingObjectPosition.entityHit).attackEntityFrom(DamageSource.generic, 1F);
				((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.weakness.id, 500, 2));
				((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.confusion.id, 500, 2));
				((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 500, 2));
				setDead();
			}
		}
}
 
開發者ID:Geforce132,項目名稱:SecurityCraft,代碼行數:21,代碼來源:EntityTaserBullet.java

示例15: getBlockInFront

import net.minecraft.util.MovingObjectPosition.MovingObjectType; //導入依賴的package包/類
private int[] getBlockInFront(World par1World, EntityPlayer par2EntityPlayer, double reach){
	int[] blockInfo = {0, 0, 0, 0, -1, 0};
	
	MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par1World, par2EntityPlayer, true, reach);
	
	if(movingobjectposition != null){
		if(movingobjectposition.typeOfHit == MovingObjectType.BLOCK){
			blockInfo[1] = movingobjectposition.blockX;
			blockInfo[2] = movingobjectposition.blockY;
			blockInfo[3] = movingobjectposition.blockZ;
			blockInfo[4] = movingobjectposition.sideHit;
			blockInfo[5] = par1World.getBlockMetadata(blockInfo[1], blockInfo[2], blockInfo[3]);
			blockInfo[0] = Block.getIdFromBlock(par1World.getBlock(blockInfo[1], blockInfo[2], blockInfo[3]));

		}
	}
	
	return blockInfo;
}
 
開發者ID:Geforce132,項目名稱:SecurityCraft,代碼行數:20,代碼來源:PacketCheckRetinalScanner.java


注:本文中的net.minecraft.util.MovingObjectPosition.MovingObjectType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。