use of net.minecraftforge.common.util.FakePlayer in project BloodMagic by WayofTime.
the class ItemDiabloKey method onItemRightClick.
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
World world = par3EntityPlayer.worldObj;
if (!EnergyItems.checkAndSetItemOwner(par1ItemStack, par3EntityPlayer) || par3EntityPlayer instanceof FakePlayer || par3EntityPlayer instanceof EntityPlayerMP) {
return par1ItemStack;
}
if (world != null) {
double posX = par3EntityPlayer.posX;
double posY = par3EntityPlayer.posY;
double posZ = par3EntityPlayer.posZ;
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.dimensionId, 4, posX, posY, posZ);
}
if (!par3EntityPlayer.worldObj.isRemote && !(par3EntityPlayer.getClass().equals(EntityPlayerMP.class))) {
return par1ItemStack;
}
if (par3EntityPlayer.isSneaking()) {
return par1ItemStack;
}
NBTTagCompound itemTag = par1ItemStack.getTagCompound();
if (itemTag == null || itemTag.getString("ownerName").equals("")) {
return par1ItemStack;
}
String ownerName = itemTag.getString("ownerName");
ItemStack[] inv = par3EntityPlayer.inventory.mainInventory;
for (ItemStack itemStack : inv) {
if (itemStack == null) {
continue;
}
Item item = itemStack.getItem();
if (item instanceof ItemDiabloKey) {
continue;
}
if (item instanceof IBindable) {
EnergyItems.checkAndSetItemOwner(itemStack, ownerName);
}
}
return par1ItemStack;
}
use of net.minecraftforge.common.util.FakePlayer in project BloodMagic by WayofTime.
the class SacrificialDagger method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (this.canUseForSacrifice(stack)) {
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
return stack;
}
if (!player.capabilities.isCreativeMode) {
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2);
if (MinecraftForge.EVENT_BUS.post(evt)) {
return stack;
}
if (evt.shouldDrainHealth) {
player.setHealth(player.getHealth() - 2);
}
if (!evt.shouldFillAltar) {
return stack;
}
}
if (player instanceof FakePlayer) {
return stack;
}
double posX = player.posX;
double posY = player.posY;
double posZ = player.posZ;
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
float f = 1.0F;
float f1 = f * 0.6F + 0.4F;
float f2 = f * f * 0.7F - 0.5F;
float f3 = f * f * 0.6F - 0.7F;
for (int l = 0; l < 8; ++l) {
world.spawnParticle("reddust", posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
}
if (!world.isRemote && SpellHelper.isFakePlayer(world, player)) {
return stack;
}
if (player.isPotionActive(AlchemicalWizardry.customPotionSoulFray)) {
findAndFillAltar(world, player, 20);
} else {
findAndFillAltar(world, player, 200);
}
if (player.getHealth() <= 0.001f) {
player.onDeath(DamageSource.generic);
}
return stack;
}
use of net.minecraftforge.common.util.FakePlayer in project Wizardry by TeamWizardry.
the class BlockUtils method placeBlock.
public static boolean placeBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, @Nonnull ItemStack stack) {
if (!world.isBlockLoaded(pos))
return false;
FakePlayer player = FakePlayerFactory.get((WorldServer) world, PLACER);
player.moveToBlockPosAndAngles(pos, 0, -90);
player.setHeldItem(EnumHand.MAIN_HAND, stack);
player.setSneaking(true);
if (!hasEditPermission(pos, player))
return false;
EnumActionResult result = player.interactionManager.processRightClickBlock(player, world, stack, EnumHand.MAIN_HAND, pos, facing, 0, 0, 0);
return result != EnumActionResult.FAIL;
}
Aggregations