本文整理汇总了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;
}
示例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);
}
示例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);
}
}
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
示例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();
}
}
}
示例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;
}