本文整理汇总了Java中net.minecraft.util.MovingObjectPosition类的典型用法代码示例。如果您正苦于以下问题:Java MovingObjectPosition类的具体用法?Java MovingObjectPosition怎么用?Java MovingObjectPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MovingObjectPosition类属于net.minecraft.util包,在下文中一共展示了MovingObjectPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
@Override
public void onImpact(MovingObjectPosition target) // Server-side
{
boolean griefing = true; // Allowed by default
if (this.shootingEntity instanceof EntityPlayer)
{
griefing = this.dmgTerrain; // It's up to player settings to allow/forbid this
}
else
{
griefing = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); // Are we allowed to break things?
}
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionSize, griefing); // Bewm
this.setDead(); // We've hit something, so begone with the projectile
}
示例2: sendClickBlockToController
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
private void sendClickBlockToController(boolean leftClick)
{
if (!leftClick)
{
this.leftClickCounter = 0;
}
if (this.leftClickCounter <= 0 && !this.thePlayer.isUsingItem())
{
if (leftClick && this.objectMouseOver != null && this.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = this.objectMouseOver.getBlockPos();
if (this.theWorld.getBlockState(blockpos).getBlock().getMaterial() != Material.air && this.playerController.onPlayerDamageBlock(blockpos, this.objectMouseOver.sideHit))
{
this.effectRenderer.addBlockHitEffects(blockpos, this.objectMouseOver.sideHit);
this.thePlayer.swingItem();
}
}
else
{
this.playerController.resetBlockRemoving();
}
}
}
示例3: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(MovingObjectPosition p_70184_1_)
{
if (!this.worldObj.isRemote)
{
this.worldObj.playAuxSFX(2002, new BlockPos(this), 0);
int i = 3 + this.worldObj.rand.nextInt(5) + this.worldObj.rand.nextInt(5);
while (i > 0)
{
int j = EntityXPOrb.getXPSplit(i);
i -= j;
this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
}
this.setDead();
}
}
示例4: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
/**
* Called when this EntityFireball hits a block or entity.
*/
protected void onImpact(MovingObjectPosition movingObject)
{
if (!this.worldObj.isRemote)
{
if (movingObject.entityHit != null)
{
movingObject.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 6.0F);
this.applyEnchantments(this.shootingEntity, movingObject.entityHit);
}
boolean flag = this.worldObj.getGameRules().getBoolean("mobGriefing");
this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, (float)this.explosionPower, flag, flag);
this.setDead();
}
}
示例5: getMovingObjectPositionFromPlayer
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World world, EntityPlayer player, double targetingDistance)
{
float f = 1.0F;
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
double playerX = player.prevPosX + (player.posX - player.prevPosX) * f;
double playerY = player.prevPosY + (player.posY - player.prevPosY) * f + (world.isRemote ? player.getEyeHeight() - player.getDefaultEyeHeight() : player.getEyeHeight()); // isRemote check to revert changes to ray trace position due to adding the eye height clientside and player yOffset differences
double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
Vec3 vecPlayer = Vec3.createVectorHelper(playerX, playerY, playerZ);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
double maxDistance = targetingDistance;
Vec3 vecTarget = vecPlayer.addVector(f7 * maxDistance, f6 * maxDistance, f8 * maxDistance);
return world.func_147447_a(vecPlayer, vecTarget, false, false, true); // false, true, false
}
示例6: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
@Override
public void onImpact(MovingObjectPosition movPos)
{
if (movPos.entityHit != null) // We hit a living thing!
{
if (movPos.entityHit instanceof EntityLivingBase) // We hit a LIVING living thing!
{
EntityLivingBase entitylivingbase = (EntityLivingBase) movPos.entityHit;
Helper.applyPotionEffect(entitylivingbase, pot1);
Helper.applyPotionEffect(entitylivingbase, pot2);
}
}
// else, hit the terrain
// SFX
this.worldObj.playSoundAtEntity(this, "random.fizz", 0.7F, 1.5F);
this.worldObj.spawnParticle("redstone", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
this.setDead(); // We've hit something, so begone with the projectile
}
示例7: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(MovingObjectPosition p_70184_1_)
{
if (p_70184_1_.entityHit != null)
{
int i = 0;
if (p_70184_1_.entityHit instanceof EntityBlaze)
{
i = 3;
}
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
}
for (int j = 0; j < 8; ++j)
{
this.worldObj.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
}
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
示例8: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
@Override
public void onImpact(MovingObjectPosition target)
{
if (target.entityHit != null) // We hit a living thing!
{
// Damage
target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
target.entityHit.hurtResistantTime = 0; // No immunity frames
}
this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionSize, damageTerrain); // Big baddaboom
// SFX
NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 1, (byte) 8);
this.setDead(); // No matter what, we're done here
}
示例9: onItemRightClick
import net.minecraft.util.MovingObjectPosition; //导入依赖的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;
}
示例10: getMovingObjectPositionFromPlayer
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
protected MovingObjectPosition getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids)
{
float f = playerIn.rotationPitch;
float f1 = playerIn.rotationYaw;
double d0 = playerIn.posX;
double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
double d2 = playerIn.posZ;
Vec3 vec3 = new Vec3(d0, d1, d2);
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
float f4 = -MathHelper.cos(-f * 0.017453292F);
float f5 = MathHelper.sin(-f * 0.017453292F);
float f6 = f3 * f4;
float f7 = f2 * f4;
double d3 = 5.0D;
Vec3 vec31 = vec3.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return worldIn.rayTraceBlocks(vec3, vec31, useLiquids, !useLiquids, false);
}
示例11: doReach
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
public double doReach(int button) {
if (isEnabled() && currentReach > 3 && Wrapper.theWorld() != null && Wrapper.thePlayer() != null
&& button == Wrapper.gameSettings().field_74312_F.func_151463_i() + 100) {
if (!comboMode.getValue()) if (!MathUtil.getChance(chance.getValue()))
return 3;
Object[] ent = EntityUtil.getEntity(currentReach,
expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
double reach = currentReach;
if (auto17.getValue() && auto17_maxReach.getValue() > currentReach) {
ent = EntityUtil.getEntity(auto17_maxReach.getValue(),
expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
reach = auto17_maxReach.getValue();
if (ent[0] != null) {
float yaw = Wrapper.rotationYaw((EntityLivingBase) ent[0]);
if (AngleUtil.getDistanceBetweenAngles(yaw, Wrapper.player_rotationYaw()) > 40) {
ent = EntityUtil.getEntity(currentReach,
expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
reach = currentReach;
}
} else {
ent = EntityUtil.getEntity(currentReach,
expandHitbox.getValue() ? (hitboxExpand.getValue() * 0.01f) : 0, 0);
reach = currentReach;
}
}
if (ent == null || ent[0] == null || !(ent[0] instanceof EntityLivingBase)) return 3;
if (!Wrapper.canEntityBeSeen((EntityLivingBase) ent[0])) return 3;
Wrapper.set_objectMouseOver(new MovingObjectPosition((Entity) ent[0], (Vec3) ent[1]));
Wrapper.set_pointedEntity((Entity) ent[0]);
return reach;
}
return 3;
}
示例12: getPickBlock
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
double viewDistance = 0D;
double currentDistance = player.getDistance(x + 0.5D, y + 0.5D, z + 0.5D);
boolean hasVisualAcuity = false;
boolean hasWarpVisualAcuity = false;
boolean canView = false;
if (player != null) {
hasVisualAcuity = ThaumUtils.isComplete(player, TOThaum.riVisualAcuity);
hasWarpVisualAcuity = ThaumUtils.isComplete(player, TOThaum.riWarpVisualAcuity);
if ((player.inventory.armorItemInSlot(3) != null)
&& (player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer)
&& (((IRevealer) player.inventory.armorItemInSlot(3).getItem())
.showNodes(player.inventory.armorItemInSlot(3), player))) {
canView = true;
viewDistance = hasVisualAcuity ? 32.0D : 16.0D;
} else if ((player.inventory.getCurrentItem() != null)
&& (player.inventory.getCurrentItem().getItem() instanceof ItemThaumometer)
&& (UtilsFX.isVisibleTo(0.44F, player, x, y, z))) {
canView = true;
viewDistance = hasVisualAcuity ? 16.0D : 8.0D;
}
if (hasWarpVisualAcuity) {
int warp = ThaumUtils.getWarp(player);
canView = true;
double warpViewDistance = warp * TOConfig.generalWarpVisualAcuityModifier;
if (warpViewDistance > viewDistance)
viewDistance = warpViewDistance;
}
}
if (canView && currentDistance <= viewDistance) {
return new ItemStack(this, 1, world.getBlockMetadata(x, y, z));
} else
return new ItemStack(baseBlock, 1, baseMeta);
}
示例13: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
byte b0 = 0;
if (par1MovingObjectPosition.entityHit instanceof EntityBlaze)
{
b0 = 3;
}
par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)b0);
}
for (int i = 0; i < 8; ++i)
{
this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.worldObj.isRemote)
{
this.explode();
this.setDead();
}
}
示例14: onImpact
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
@Override
public void onImpact(MovingObjectPosition target)
{
if (target.entityHit != null)
{
// Damage
target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float) this.damage);
}
else
{
// Glass breaking
Helper.tryBlockBreak(this.worldObj, this, target, 1);
if (this.shouldDrop && this.canBePickedUp) // If we can be picked up then we're dropping now
{
ItemStack nuggetStack = new ItemStack(Items.baked_potato);
EntityItem entityitem = new EntityItem(this.worldObj, target.blockX, target.blockY + 0.5d, target.blockZ, nuggetStack);
entityitem.delayBeforeCanPickup = 10;
if (captureDrops) { capturedDrops.add(entityitem); }
else { this.worldObj.spawnEntityInWorld(entityitem); }
}
}
// SFX
NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 3, (byte) 2);
this.worldObj.playSoundAtEntity(this, "random.eat", 0.6F, 0.7F);
this.setDead(); // We've hit something, so begone with the projectile
}
示例15: rayTrace
import net.minecraft.util.MovingObjectPosition; //导入依赖的package包/类
public MovingObjectPosition rayTrace(double blockReachDistance, float partialTicks)
{
Vec3 vec3 = this.getPositionEyes(partialTicks);
Vec3 vec31 = this.getLook(partialTicks);
Vec3 vec32 = vec3.addVector(vec31.xCoord * blockReachDistance, vec31.yCoord * blockReachDistance, vec31.zCoord * blockReachDistance);
return this.worldObj.rayTraceBlocks(vec3, vec32, false, false, true);
}