use of net.minecraftforge.common.util.FakePlayer in project ForestryMC by ForestryMC.
the class ProxyNetwork method sendToPlayer.
public void sendToPlayer(ForestryPacket packet, EntityPlayer entityplayer) {
if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer)) {
return;
}
EntityPlayerMP player = (EntityPlayerMP) entityplayer;
Forestry.packetHandler.sendPacket(packet.getPacket(), player);
}
use of net.minecraftforge.common.util.FakePlayer in project BloodMagic by WayofTime.
the class CreativeDagger method onItemRightClick.
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;
}
findAndFillAltar(world, player, Integer.MAX_VALUE);
return stack;
}
use of net.minecraftforge.common.util.FakePlayer in project Wizardry by TeamWizardry.
the class BlockUtils method breakBlock.
/**
* Tries breaking a block safely and fires an event for it.
*
* @return Whether the block was successfully broken
*/
public static boolean breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nullable IBlockState oldState, @Nonnull EntityPlayerMP player) {
if (!world.isBlockLoaded(pos))
return false;
if (!(player instanceof FakePlayer) && !hasEditPermission(pos, player))
return false;
if (oldState == null)
oldState = world.getBlockState(pos);
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, oldState, player);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
return false;
TileEntity tile = world.getTileEntity(pos);
Block block = oldState.getBlock();
if (block.removedByPlayer(oldState, world, pos, player, true)) {
block.onPlayerDestroy(world, pos, oldState);
block.harvestBlock(world, player, pos, oldState, tile, player.getHeldItemMainhand());
world.notifyBlockUpdate(pos, oldState, Blocks.AIR.getDefaultState(), 3);
} else
return false;
return true;
}
use of net.minecraftforge.common.util.FakePlayer in project Overloaded by CJ-MC-Mods.
the class TileItemManipulator method update.
@Override
public void update() {
ItemStack currentItem = itemStack.getStackInSlot(0);
if (currentItem.isEmpty())
return;
FakePlayer player = getPlayer();
BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(this.getPos());
for (int i = 0; i < player.interactionManager.getBlockReachDistance(); i++) {
if (!this.getWorld().isAirBlock(blockPos.move(this.facing))) {
EnumActionResult result = currentItem.getItem().onItemUse(player, getWorld(), blockPos, EnumHand.MAIN_HAND, facing.getOpposite(), 0.5f, 0.5f, 0.5f);
// blockPos,this.facing.getOpposite(),0.5f,0.5f,0.5f);
break;
}
}
}
use of net.minecraftforge.common.util.FakePlayer in project Overloaded by CJ-MC-Mods.
the class TileItemManipulator method getPlayer.
private FakePlayer getPlayer() {
if (this.player == null || this.player.get() == null) {
FakePlayer fakePlayer = FakePlayerFactory.get((WorldServer) this.getWorld(), FAKEPLAYER);
this.player = new WeakReference<>(fakePlayer);
fakePlayer.setLocationAndAngles(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 0f, 0f);
fakePlayer.inventory.clear();
}
return this.player.get();
}
Aggregations