use of net.minecraft.util.MovingObjectPosition in project ArsMagica2 by Mithion.
the class Rune method beginStackStage.
@Override
public SpellCastResult beginStackStage(ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean consumeMBR, int useCount) {
int procs = SpellUtils.instance.getModifiedInt_Add(1, stack, caster, target, world, 0, SpellModifiers.PROCS);
boolean targetWater = SpellUtils.instance.modifierIsPresent(SpellModifiers.TARGET_NONSOLID_BLOCKS, stack, 0);
MovingObjectPosition mop = item.getMovingObjectPosition(caster, world, 8.0f, true, targetWater);
if (mop == null || mop.typeOfHit == MovingObjectType.ENTITY)
return SpellCastResult.EFFECT_FAILED;
if (!BlocksCommonProxy.spellRune.placeAt(world, mop.blockX, mop.blockY + 1, mop.blockZ, SpellUtils.instance.mainAffinityFor(stack).ordinal())) {
return SpellCastResult.EFFECT_FAILED;
}
if (!world.isRemote) {
world.setTileEntity(mop.blockX, mop.blockY + 1, mop.blockZ, BlocksCommonProxy.spellRune.createTileEntity(world, 0));
BlocksCommonProxy.spellRune.setSpellStack(world, mop.blockX, mop.blockY + 1, mop.blockZ, SpellUtils.instance.popStackStage(stack));
BlocksCommonProxy.spellRune.setPlacedBy(world, mop.blockX, mop.blockY + 1, mop.blockZ, caster);
int meta = world.getBlockMetadata(mop.blockX, mop.blockY + 1, mop.blockZ);
BlocksCommonProxy.spellRune.setNumTriggers(world, mop.blockX, mop.blockY + 1, mop.blockZ, meta, procs);
}
return SpellCastResult.SUCCESS;
}
use of net.minecraft.util.MovingObjectPosition in project ArsMagica2 by Mithion.
the class ItemWakebloom method onItemRightClick.
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
if (movingobjectposition == null) {
return par1ItemStack;
} else {
if (movingobjectposition.typeOfHit == MovingObjectType.BLOCK) {
int i = movingobjectposition.blockX;
int j = movingobjectposition.blockY;
int k = movingobjectposition.blockZ;
if (!par2World.canMineBlock(par3EntityPlayer, i, j, k)) {
return par1ItemStack;
}
if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack)) {
return par1ItemStack;
}
if (par2World.getBlock(i, j, k).getMaterial() == Material.water && par2World.getBlockMetadata(i, j, k) == 0 && par2World.isAirBlock(i, j + 1, k)) {
par2World.setBlock(i, j + 1, k, BlocksCommonProxy.wakebloom);
if (!par3EntityPlayer.capabilities.isCreativeMode) {
--par1ItemStack.stackSize;
}
}
}
return par1ItemStack;
}
}
use of net.minecraft.util.MovingObjectPosition in project Engine by VoltzEngine-Project.
the class TestAbstractLocation method testInit.
/**
* Tests constructors
*/
public void testInit() {
List<TLocation> locations = new ArrayList();
//Test main method
locations.add(new TLocation(world, 10, 11, 12));
//Test entity method
Entity entity = new EntitySheep(world);
entity.setPosition(10, 11, 12);
locations.add(new TLocation(entity));
//Test tile
TileEntity tile = new TileEntity();
tile.setWorldObj(world);
tile.xCoord = 10;
tile.yCoord = 11;
tile.zCoord = 12;
locations.add(new TLocation(tile));
//Test NBT method
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("dimension", world.provider.dimensionId);
tag.setDouble("x", 10);
tag.setDouble("y", 11);
tag.setDouble("z", 12);
locations.add(new TLocation(tag));
//Test byte buf method
ByteBuf buf = Unpooled.buffer();
buf.writeInt(world.provider.dimensionId);
buf.writeDouble(10);
buf.writeDouble(11);
buf.writeDouble(12);
locations.add(new TLocation(buf));
//Test IWorldPosition
locations.add(new TLocation(new IWorldPosition() {
@Override
public World world() {
return world;
}
@Override
public double x() {
return 10;
}
@Override
public double y() {
return 11;
}
@Override
public double z() {
return 12;
}
}));
//Test world, IPos3D
locations.add(new TLocation(world, new IPos3D() {
@Override
public double x() {
return 10;
}
@Override
public double y() {
return 11;
}
@Override
public double z() {
return 12;
}
}));
//Test world, vec3
locations.add(new TLocation(world, Vec3.createVectorHelper(10, 11, 12)));
//Test world, moving object
locations.add(new TLocation(world, new MovingObjectPosition(10, 11, 12, 0, Vec3.createVectorHelper(10, 11, 12))));
for (int i = 0; i < locations.size(); i++) {
TLocation location = locations.get(i);
assertTrue("" + i, location.world == world);
assertTrue("" + i, location.xi() == 10);
assertTrue("" + i, location.yi() == 11);
assertTrue("" + i, location.zi() == 12);
}
}
use of net.minecraft.util.MovingObjectPosition in project Engine by VoltzEngine-Project.
the class AbstractTileTest method testGetpickBlock.
@Test
public void testGetpickBlock() {
FakeWorld world = FakeWorld.newWorld("TestGetpickBlock");
world.setBlock(0, 0, 0, block);
Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
for (int i = 0; i < 256; i++) {
tile.getPickBlock(new MovingObjectPosition(0, 0, 0, dir.ordinal(), getNextClick(dir, i).toVec3(), true));
}
}
}
use of net.minecraft.util.MovingObjectPosition in project ICBM-Classic by BuiltBrokenModding.
the class ItemRadarGun method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (world.isRemote) {
MovingObjectPosition objectMouseOver = player.rayTrace(200, 1);
TileEntity tileEntity = world.getTileEntity(objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ);
if (!(tileEntity instanceof ILauncherController)) {
Engine.instance.packetHandler.sendToServer(new PacketPlayerItem(player, objectMouseOver.blockX, objectMouseOver.blockY, objectMouseOver.blockZ));
}
}
return stack;
}
Aggregations