本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerSleepInBedEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerSleepInBedEvent类的具体用法?Java PlayerSleepInBedEvent怎么用?Java PlayerSleepInBedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerSleepInBedEvent类属于net.minecraftforge.event.entity.player包,在下文中一共展示了PlayerSleepInBedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerSleepInBed
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerSleepInBed(PlayerSleepInBedEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack itemStack = inv.getStackInSlot(inv.currentItem);
World world = event.entityLiving.worldObj;
if(player.dimension == 0 && !world.isDaytime() && itemRand.nextInt(100)<=mod_Rediscovered.DreamChance && (itemStack == null || itemStack.getItem() != mod_Rediscovered.DreamPillow) && player instanceof EntityPlayerMP)
{
ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) event.entity);
props.setRespawn(event.pos.getX(), event.pos.getY(), event.pos.getZ());
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, mod_Rediscovered.DimID, new SkyDimensionTeleporter(thePlayer.mcServer.worldServerForDimension(mod_Rediscovered.DimID)));
}
}
示例2: onPlayerSleep
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerSleep(PlayerSleepInBedEvent event)
{
EntityPlayer player = (EntityPlayer)event.entityPlayer;
EnumStatus stats = EnumStatus.OTHER_PROBLEM;
if(Morph.config.getSessionInt("canSleepMorphed") == 0)
{
if(FMLCommonHandler.instance().getEffectiveSide().isServer() && Morph.proxy.tickHandlerServer.getPlayerMorphInfo(player) != null)
{
event.result = stats;
player.addChatMessage(new ChatComponentTranslation("morph.denySleep"));
}
else if(FMLCommonHandler.instance().getEffectiveSide().isClient() && Morph.proxy.tickHandlerClient.playerMorphInfo.containsKey(player.getCommandSenderName()))
{
event.result = stats;
}
}
}
示例3: onSleep
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onSleep(PlayerSleepInBedEvent event)
{
ServerPlayerBaseMagic pm;
pm = Main.getPlayerServer(event.entityPlayer);
if (pm != null)
{
if (pm.getPlayer().worldObj.rand.nextInt(2) == 0);
// pm.travelToDimension(Main.DIM_ID, pm.getPlayer().dimension);
}
}
示例4: canPlayerSleep
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
/**
* hack in the vanilla sleep test, or at least something similar
*
* @param player
* @param world
* @return
*/
private SleepResult canPlayerSleep(EntityPlayer player, World world) {
if (player.isEntityAlive() == false) {
return EntityPlayer.SleepResult.OTHER_PROBLEM;
}
if (world.isDaytime()) {
return EntityPlayer.SleepResult.NOT_POSSIBLE_NOW;
}
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, player.getPosition());
MinecraftForge.EVENT_BUS.post(event);
if (event.getResultStatus() != null) {
return event.getResultStatus();
}
return EntityPlayer.SleepResult.OK;
}
示例5: handleSleepInBed
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void handleSleepInBed(PlayerSleepInBedEvent event) {
EntityPlayer p = event.getEntityPlayer();
final IPlayerExtendedProperties sleep = p.getCapability(ModCyclic.CAPABILITYSTORAGE, null);
if (sleep != null && sleep.isSleeping()) {
event.setResult(EntityPlayer.SleepResult.OK);
}
}
示例6: sleepEvent
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void sleepEvent(PlayerSleepInBedEvent event) {
if(event.entity.worldObj.provider instanceof WorldProviderPlanet &&
AtmosphereHandler.hasAtmosphereHandler(event.entity.worldObj.provider.dimensionId) && !AtmosphereHandler.getOxygenHandler(event.entity.worldObj.provider.dimensionId).getAtmosphereType(event.x, event.y, event.z).isBreathable()) {
event.result = EnumStatus.OTHER_PROBLEM;
}
}
示例7: sleepEvent
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public static void sleepEvent(PlayerSleepInBedEvent event)
{
if (nosleep || D3Core.isAprilFools())
{
event.setResult(EntityPlayer.SleepResult.OTHER_PROBLEM);
}
}
示例8: onPlayerSleepEvent
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerSleepEvent(PlayerSleepInBedEvent event)
{
if (Settings.checkAtBed && NearbyMobLocator.areConditionsMet(event.entityPlayer, event.x, event.y, event.z))
{
ServerTickHandler.playerRequesting = event.entityPlayer;
ServerTickHandler.nearbyMobList = NearbyMobLocator.findNearbyMobs(event.entityPlayer, event.x, event.y, event.z);
}
}
示例9: onPlayerSleepInBed
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@ForgeSubscribe
public void onPlayerSleepInBed(PlayerSleepInBedEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack itemStack = inv.getStackInSlot(inv.currentItem);
World world = event.entityLiving.worldObj;
if(!mod_Rediscovered.DreamBedEnabled && player.dimension == 0 && !world.isDaytime() && itemRand.nextInt(100)<=mod_Rediscovered.DreamChance && (itemStack == null || itemStack.getItem() != mod_Rediscovered.DreamPillow) && player instanceof EntityPlayerMP)
{
ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) event.entity);
props.setRespawn(event.x, event.y, event.z);
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, mod_Rediscovered.DimID, new SkyDimensionTeleporter(thePlayer.mcServer.worldServerForDimension(mod_Rediscovered.DimID)));
}
}
示例10: playerSleepInBedEvent
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerSleepInBedEvent(PlayerSleepInBedEvent event)
{
if (event.entityPlayer.isPotionActive(ModPotion.PotionCaffeine))
{
event.result = EntityPlayer.EnumStatus.OTHER_PROBLEM;
event.entityPlayer.addChatMessage(new ChatComponentTranslation("msg." + Reference.MOD_ID.toLowerCase() + ":sleep.txt"));
}
}
示例11: onPlayerSleepInBed
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerSleepInBed(PlayerSleepInBedEvent event)
{
EntityPlayer player = event.entityPlayer;
InventoryPlayer inv = player.inventory;
ItemStack itemStack = inv.getStackInSlot(inv.currentItem);
World world = event.entityLiving.worldObj;
if(player.dimension == 0 && !world.isDaytime() && itemRand.nextInt(100)<=mod_Rediscovered.DreamChance && (itemStack == null || itemStack.getItem() != mod_Rediscovered.DreamPillow) && player instanceof EntityPlayerMP)
{
ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) event.entity);
props.setRespawn(event.x, event.y, event.z);
EntityPlayerMP thePlayer = (EntityPlayerMP) player;
thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, mod_Rediscovered.DimID, new SkyDimensionTeleporter(thePlayer.mcServer.worldServerForDimension(mod_Rediscovered.DimID)));
}
}
示例12: sleep
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void sleep(PlayerSleepInBedEvent event) {
BedPlacements bedPlacements = getBedPlacements(event.getEntity().worldObj);
if (bedPlacements.canSleep(event.getEntity(), event.getPos()))
return;
event.getEntityPlayer()
.addChatComponentMessage(new TextComponentTranslation("tile.bed.recentlyPlaced"));
event.setResult(EntityPlayer.EnumStatus.OTHER_PROBLEM);
}
示例13: playerSleep
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
@SubscribeEvent
public void playerSleep(PlayerSleepInBedEvent event) {
if (event.getEntityPlayer().getEntityData().getInteger("genera.sacrifices_made") > 0)
event.getEntityPlayer().getEntityData().setInteger("genera.sacrifices_made", 0);
}
示例14: onPlayerSleepInBed
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
public static SleepResult onPlayerSleepInBed(EntityPlayer player, BlockPos pos)
{
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(player, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.getResultStatus();
}
示例15: sleepInBedAt
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; //导入依赖的package包/类
public EnumStatus sleepInBedAt(int p_71018_1_, int p_71018_2_, int p_71018_3_)
{
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(this, p_71018_1_, p_71018_2_, p_71018_3_);
MinecraftForge.EVENT_BUS.post(event);
if (event.result != null) {
return event.result;
}
if (!this.worldObj.isRemote)
{
if ((isPlayerSleeping()) || (!isEntityAlive())) {
return EnumStatus.OTHER_PROBLEM;
}
if (!this.worldObj.provider.isSurfaceWorld()) {
return EnumStatus.NOT_POSSIBLE_HERE;
}
if (this.worldObj.isDaytime()) {
return EnumStatus.NOT_POSSIBLE_NOW;
}
if ((Math.abs(this.posX - p_71018_1_) > 3.0D) || (Math.abs(this.posY - p_71018_2_) > 2.0D) || (Math.abs(this.posZ - p_71018_3_) > 3.0D)) {
return EnumStatus.TOO_FAR_AWAY;
}
double d0 = 8.0D;
double d1 = 5.0D;
List list = this.worldObj.getEntitiesWithinAABB(EntityMob.class, AxisAlignedBB.getBoundingBox(p_71018_1_ - d0, p_71018_2_ - d1, p_71018_3_ - d0, p_71018_1_ + d0, p_71018_2_ + d1, p_71018_3_ + d0));
if (!list.isEmpty()) {
return EnumStatus.NOT_SAFE;
}
}
if (isRiding()) {
mountEntity((Entity)null);
}
setSize(0.2F, 0.2F);
this.yOffset = 0.2F;
if (this.worldObj.blockExists(p_71018_1_, p_71018_2_, p_71018_3_))
{
int l = this.worldObj.getBlock(p_71018_1_, p_71018_2_, p_71018_3_).getBedDirection(this.worldObj, p_71018_1_, p_71018_2_, p_71018_3_);
float f1 = 0.5F;
float f = 0.5F;
switch (l)
{
case 0:
f = 0.9F;
break;
case 1:
f1 = 0.1F;
break;
case 2:
f = 0.1F;
break;
case 3:
f1 = 0.9F;
}
func_71013_b(l);
setPosition(p_71018_1_ + f1, p_71018_2_ + 0.9375F, p_71018_3_ + f);
}
else
{
setPosition(p_71018_1_ + 0.5F, p_71018_2_ + 0.9375F, p_71018_3_ + 0.5F);
}
this.sleeping = true;
this.sleepTimer = 0;
this.playerLocation = new ChunkCoordinates(p_71018_1_, p_71018_2_, p_71018_3_);
this.motionX = (this.motionZ = this.motionY = 0.0D);
if (!this.worldObj.isRemote) {
this.worldObj.updateAllPlayersSleepingFlag();
}
return EnumStatus.OK;
}