use of net.minecraftforge.common.util.FakePlayer in project OpenModularTurrets by OpenModularTurretsTeam.
the class OMTEventHandler method entityHurtEvent.
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
EntityLivingBase entity = event.getEntityLiving();
int fakeDrops = OMTUtil.getFakeDropsLevel(entity);
if (fakeDrops >= 0) {
FakePlayer player = OMTFakePlayer.getFakePlayer((WorldServer) event.getEntityLiving().getEntityWorld());
player.setHeldItem(EnumHand.MAIN_HAND, OMTFakePlayer.getSword(fakeDrops));
entity.setLastAttackedEntity(player);
}
}
use of net.minecraftforge.common.util.FakePlayer in project Random-Things by lumien231.
the class RTEventHandler method livingDeath.
@SubscribeEvent
public void livingDeath(LivingDeathEvent event) {
if (!event.getEntityLiving().world.isRemote) {
if (event.getEntityLiving() instanceof EntityDragon) {
RTWorldInformation rtInfo = RTWorldInformation.getInstance();
if (rtInfo != null) {
rtInfo.setEnderDragonDefeated(true);
}
}
if (event.getSource().getTrueSource() != null && !(event.getSource().getTrueSource() instanceof FakePlayer) && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getEntity() instanceof EntitySpirit)) {
double chance = Numbers.SPIRIT_CHANCE_NORMAL;
RTWorldInformation rtInfo = RTWorldInformation.getInstance();
if (rtInfo != null) {
if (rtInfo.isDragonDefeated()) {
chance += Numbers.SPIRIT_CHANCE_END_INCREASE;
}
}
if (event.getEntityLiving().world.canBlockSeeSky(event.getEntityLiving().getPosition()) && !event.getEntityLiving().world.isDaytime()) {
chance += event.getEntityLiving().world.getCurrentMoonPhaseFactor() / 100f * Numbers.SPIRIT_CHANCE_MOON_MULT;
}
if (Math.random() < chance) {
event.getEntityLiving().world.spawnEntity(new EntitySpirit(event.getEntityLiving().world, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ));
}
}
if (event.getEntityLiving() instanceof EntityPlayer) {
if (!(event.getEntityLiving() instanceof FakePlayer)) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (!event.isCanceled()) {
player.world.spawnEntity(new EntitySoul(player.world, player.posX, player.posY, player.posZ, player.getGameProfile().getName()));
}
}
}
}
}
use of net.minecraftforge.common.util.FakePlayer in project Bookshelf by Darkhax-Minecraft.
the class PlayerUtils method getFakePlayer.
/**
* Gets a fake player using their game profile. If there are no matching fake players a new
* one will be created using the provided factory.
*
* @param world A world instance used to load the fake player. This will be passed to the
* factory if no matching fake players were found.
* @param profile The profile of the fake player to find. This will be passed to the
* factory if there are no matching fake players.
* @param factory A factory used to create the fake player if a match could not be found.
* @return The fake player that was found or created.
*/
public static FakePlayer getFakePlayer(ServerWorld world, GameProfile profile, BiFunction<ServerWorld, GameProfile, FakePlayer> factory) {
final Map<GameProfile, FakePlayer> fakePlayers = getCurrentFakePlayers();
FakePlayer fakePlayer = fakePlayers.get(profile);
if (fakePlayer == null) {
fakePlayer = factory.apply(world, profile);
fakePlayers.put(profile, fakePlayer);
}
return fakePlayer;
}
use of net.minecraftforge.common.util.FakePlayer in project Pearcel-Mod by MiningMark48.
the class EventOnPlayerAttack method onPlayerAttack.
@SubscribeEvent
public void onPlayerAttack(LivingHurtEvent e) {
if (e.getEntityLiving() instanceof FakePlayer) {
return;
}
if (e.getSource().getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) e.getSource().getEntity();
if (!player.isCreative()) {
if (e.getEntityLiving().getHealth() - e.getAmount() <= 0) {
if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == ModItems.pearcel_blood_dagger) {
ItemStack stack = player.getHeldItemMainhand();
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setInteger("level", 1);
} else {
if (stack.getTagCompound().getInteger("level") <= 8) {
stack.getTagCompound().setInteger("level", stack.getTagCompound().getInteger("level") + 1);
} else {
stack.getTagCompound().setInteger("level", 0);
EntityItem item = new EntityItem(player.getEntityWorld(), player.posX, player.posY + 0.5, player.posZ);
item.setEntityItemStack(new ItemStack(ModItems.blood_drop));
Random rand = new Random();
int num = rand.nextInt(2) + 1;
for (int i = 0; i <= num; i++) {
player.getEntityWorld().spawnEntity(item);
}
}
}
}
}
}
}
}
use of net.minecraftforge.common.util.FakePlayer in project Armourers-Workshop by RiskyKen.
the class EquipmentWardrobeHandler method onRender.
@SubscribeEvent
public void onRender(RenderPlayerEvent.Post event) {
EntityPlayer player = event.entityPlayer;
if (player instanceof MannequinFakePlayer) {
return;
}
if (player.getGameProfile() == null) {
return;
}
if (player instanceof FakePlayer) {
return;
}
// Restore the head overlay.
PlayerPointer playerPointer = new PlayerPointer(player);
RenderPlayer renderer = event.renderer;
if (equipmentWardrobeMap.containsKey(playerPointer)) {
renderer.modelBipedMain.bipedHeadwear.isHidden = false;
}
}
Aggregations