Java 类net.minecraft.world.WorldSettings.GameType 实例源码

项目:Proyecto-DASI    文件:ServerStateMachine.java   
private void resetPlayerGameTypes()
{
    // Go through and set all the players to their correct game type:
    for (Map.Entry<String, String> entry : this.usernameToAgentnameMap.entrySet())
    {
        AgentSection as = getAgentSectionFromAgentName(entry.getValue());
        EntityPlayerMP player = getPlayerFromUsername(entry.getKey());
        if (as != null && player != null)
        {
            player.setGameType(GameType.getByName(as.getMode().name().toLowerCase()));
            // Also make sure we haven't accidentally left the player flying:
            player.capabilities.isFlying = false;
            player.sendPlayerAbilities();
        }
    }
}
项目:Proyecto-DASI    文件:ServerStateMachine.java   
private void resetPlayerGameTypes()
{
    // Go through and set all the players to their correct game type:
    for (Map.Entry<String, String> entry : this.usernameToAgentnameMap.entrySet())
    {
        AgentSection as = getAgentSectionFromAgentName(entry.getValue());
        EntityPlayerMP player = getPlayerFromUsername(entry.getKey());
        if (as != null && player != null)
        {
            player.setGameType(GameType.getByName(as.getMode().name().toLowerCase()));
            // Also make sure we haven't accidentally left the player flying:
            player.capabilities.isFlying = false;
            player.sendPlayerAbilities();
        }
    }
}
项目:Cauldron    文件:WorldProvider.java   
public ChunkCoordinates getRandomizedSpawnPoint()
{
    ChunkCoordinates chunkcoordinates = new ChunkCoordinates(this.worldObj.getSpawnPoint());

    boolean isAdventure = worldObj.getWorldInfo().getGameType() == GameType.ADVENTURE;
    int spawnFuzz = terrainType.getSpawnFuzz();
    int spawnFuzzHalf = spawnFuzz / 2;

    if (!hasNoSky && !isAdventure)
    {
        chunkcoordinates.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
        chunkcoordinates.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
        chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ);
    }

    return chunkcoordinates;
}
项目:Cauldron    文件:WorldProvider.java   
public ChunkCoordinates getRandomizedSpawnPoint()
{
    ChunkCoordinates chunkcoordinates = new ChunkCoordinates(this.worldObj.getSpawnPoint());

    boolean isAdventure = worldObj.getWorldInfo().getGameType() == GameType.ADVENTURE;
    int spawnFuzz = terrainType.getSpawnFuzz();
    int spawnFuzzHalf = spawnFuzz / 2;

    if (!hasNoSky && !isAdventure)
    {
        chunkcoordinates.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
        chunkcoordinates.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
        chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ);
    }

    return chunkcoordinates;
}
项目:TheStuffMod    文件:PotionHandler.java   
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event) {
    if(event.entityLiving.isPotionActive(ModPotions.bleeding)) {
        if(event.entityLiving.worldObj.rand.nextInt(40) == 0) {
            event.entityLiving.attackEntityFrom(new DamageSource("allthethings:bleeding"), 1);
            event.entityLiving.worldObj.spawnParticle("splash", event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, 1.0D, 1.0D, 1.0D);
        }
    } else if(event.entityLiving.isPotionActive(ModPotions.leadPoison)) {
        if(event.entityLiving.worldObj.rand.nextInt(40) == 0) {
            event.entityLiving.attackEntityFrom(new DamageSource("allthethings:leadPoison"), 2);
            if (event.entityLiving instanceof EntityPlayer) {
                ((EntityPlayer)event.entityLiving).addExhaustion(20.0F);
            }
            event.entityLiving.worldObj.spawnParticle("splash", (event.entityLiving.posX+0.5F)-0.27000001072883606D, (event.entityLiving.posY+0.7F)+0.2199999988079071D, (event.entityLiving.posZ+0.5F), 0.0D, 0.0D, 0.0D);
        }
    } else if(event.entityLiving.isPotionActive(ModPotions.lessening)) {
        if(event.entityLiving instanceof EntityPlayerMP && ((EntityPlayerMP) event.entityLiving).theItemInWorldManager.getGameType() == GameType.CREATIVE) return;
        else if(event.entityLiving.getHealth() <= 1 || event.entityLiving.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue() <= 2.0) {
            event.entityLiving.attackEntityFrom(new DamageSource("allthethings:lessening"), 9001);
        }
    }
}
项目:Proyecto-DASI    文件:ServerStateMachine.java   
private void initialisePlayer(String username, String agentname)
{
    AgentSection as = getAgentSectionFromAgentName(agentname);
    EntityPlayerMP player = getPlayerFromUsername(username);

    if (player != null && as != null)
    {
        if ((player.getHealth() <= 0 || player.isDead || !player.isEntityAlive()))
        {
            player.markPlayerActive();
            player = MinecraftServer.getServer().getConfigurationManager().recreatePlayerEntity(player, player.dimension, false);
            player.playerNetServerHandler.playerEntity = player;
        }

        // Reset their food and health:
        player.setHealth(player.getMaxHealth());
        player.getFoodStats().addStats(20, 40);
        player.maxHurtResistantTime = 1; // Set this to a low value so that lava will kill the player straight away.
        disablePlayerGracePeriod(player);   // Otherwise player will be invulnerable for the first 60 ticks.
        player.extinguish();    // In case the player was left burning.

        // Set their initial position and speed:
        PosAndDirection pos = as.getAgentStart().getPlacement();
        if (pos != null) {
            player.rotationYaw = pos.getYaw().floatValue();
            player.rotationPitch = pos.getPitch().floatValue();
            player.setPositionAndUpdate(pos.getX().doubleValue(),pos.getY().doubleValue(),pos.getZ().doubleValue());
            player.onUpdate();  // Needed to force scene to redraw
        }
        player.setVelocity(0, 0, 0);    // Minimise chance of drift!

        // Set their inventory:
        if (as.getAgentStart().getInventory() != null)
            initialiseInventory(player, as.getAgentStart().getInventory());

        // Set their game mode to spectator for now, to protect them while we wait for the rest of the cast to assemble:
        player.setGameType(GameType.SPECTATOR);
    }
}
项目:Proyecto-DASI    文件:DefaultWorldGeneratorImplementation.java   
@Override
public boolean createWorld(MissionInit missionInit)
{
    long seed = getWorldSeedFromString(this.dwparams.getSeed());
    WorldType.worldTypes[0].onGUICreateWorldPress();
    WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.worldTypes[0]);
    worldsettings.setWorldName("");
    worldsettings.enableCommands();
    // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
    // will be created, it will simply load the old one.
    return MapFileHelper.createAndLaunchWorld(worldsettings, this.dwparams.isDestroyAfterUse());
}
项目:Proyecto-DASI    文件:FlatWorldGeneratorImplementation.java   
@Override
public boolean createWorld(MissionInit missionInit)
{
    long seed = DefaultWorldGeneratorImplementation.getWorldSeedFromString(this.fwparams.getSeed());
    WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, false, false, WorldType.FLAT);
    // This call to setWorldName allows us to specify the layers of our world, and also the features that will be created.
    // This website provides a handy way to generate these strings: http://chunkbase.com/apps/superflat-generator
    worldsettings.setWorldName(this.fwparams.getGeneratorString());
    worldsettings.enableCommands(); // Enables cheat commands.
    // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
    // will be created, it will simply load the old one.
    return MapFileHelper.createAndLaunchWorld(worldsettings, this.fwparams.isDestroyAfterUse());
}
项目:Proyecto-DASI    文件:ServerStateMachine.java   
private void initialisePlayer(String username, String agentname)
{
    AgentSection as = getAgentSectionFromAgentName(agentname);
    EntityPlayerMP player = getPlayerFromUsername(username);

    if (player != null && as != null)
    {
        if ((player.getHealth() <= 0 || player.isDead || !player.isEntityAlive()))
        {
            player.markPlayerActive();
            player = MinecraftServer.getServer().getConfigurationManager().recreatePlayerEntity(player, player.dimension, false);
            player.playerNetServerHandler.playerEntity = player;
        }

        // Reset their food and health:
        player.setHealth(player.getMaxHealth());
        player.getFoodStats().addStats(20, 40);
        player.maxHurtResistantTime = 1; // Set this to a low value so that lava will kill the player straight away.
        disablePlayerGracePeriod(player);   // Otherwise player will be invulnerable for the first 60 ticks.
        player.extinguish();    // In case the player was left burning.

        // Set their initial position and speed:
        PosAndDirection pos = as.getAgentStart().getPlacement();
        if (pos != null) {
            player.rotationYaw = pos.getYaw().floatValue();
            player.rotationPitch = pos.getPitch().floatValue();
            player.setPositionAndUpdate(pos.getX().doubleValue(),pos.getY().doubleValue(),pos.getZ().doubleValue());
            player.onUpdate();  // Needed to force scene to redraw
        }
        player.setVelocity(0, 0, 0);    // Minimise chance of drift!

        // Set their inventory:
        if (as.getAgentStart().getInventory() != null)
            initialiseInventory(player, as.getAgentStart().getInventory());

        // Set their game mode to spectator for now, to protect them while we wait for the rest of the cast to assemble:
        player.setGameType(GameType.SPECTATOR);
    }
}
项目:Proyecto-DASI    文件:DefaultWorldGeneratorImplementation.java   
@Override
public boolean createWorld(MissionInit missionInit)
{
    long seed = getWorldSeedFromString(this.dwparams.getSeed());
    WorldType.worldTypes[0].onGUICreateWorldPress();
    WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.worldTypes[0]);
    worldsettings.setWorldName("");
    worldsettings.enableCommands();
    // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
    // will be created, it will simply load the old one.
    return MapFileHelper.createAndLaunchWorld(worldsettings, this.dwparams.isDestroyAfterUse());
}
项目:Proyecto-DASI    文件:FlatWorldGeneratorImplementation.java   
@Override
public boolean createWorld(MissionInit missionInit)
{
    long seed = DefaultWorldGeneratorImplementation.getWorldSeedFromString(this.fwparams.getSeed());
    WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, false, false, WorldType.FLAT);
    // This call to setWorldName allows us to specify the layers of our world, and also the features that will be created.
    // This website provides a handy way to generate these strings: http://chunkbase.com/apps/superflat-generator
    worldsettings.setWorldName(this.fwparams.getGeneratorString());
    worldsettings.enableCommands(); // Enables cheat commands.
    // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world
    // will be created, it will simply load the old one.
    return MapFileHelper.createAndLaunchWorld(worldsettings, this.fwparams.isDestroyAfterUse());
}
项目:4Space-5    文件:NEIServerUtils.java   
public static GameType getGameType(int mode) {
    switch (mode) {
        case 0:
            return GameType.SURVIVAL;
        case 1:
        case 2:
            return GameType.CREATIVE;
        case 3:
            return GameType.ADVENTURE;
    }
    return null;
}
项目:BIGB    文件:NEIServerUtils.java   
public static GameType getGameType(int mode) {
    switch (mode) {
        case 0:
            return GameType.SURVIVAL;
        case 1:
        case 2:
            return GameType.CREATIVE;
        case 3:
            return GameType.ADVENTURE;
    }
    return null;
}
项目:BuildcentricTweeks    文件:TileAdventureMode.java   
public void changeMode()
{
    if (whatPlayerIsNearADVENTURE() != null && whatPlayerIsNearADVENTURE().capabilities.allowEdit == true)
    {
        whatPlayerIsNearADVENTURE().setGameType(GameType.ADVENTURE);
    }
    else if (whatPlayerIsNearSURVIVAL() != null  && whatPlayerIsNearSURVIVAL().capabilities.allowEdit == false)
    {
        if(whatPlayerIsNearSURVIVAL() != whatPlayerIsNearADVENTURE())
            whatPlayerIsNearSURVIVAL().setGameType(GameType.SURVIVAL);
    }
}
项目:BuildcentricTweeks    文件:RespawnEvent.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onRespawnEvent(PlayerRespawnEvent event) 
{
    if (event.isCancelable())
        return;

    if(!event.player.capabilities.allowEdit)
    {
        event.player.setGameType(GameType.SURVIVAL);
    }
}
项目:Adventure-Backport    文件:CanPlaceOnHandler.java   
@SubscribeEvent
public void onPlace(PlaceEvent event) {
    if(PlayerLogic.getGameType(event.player) != GameType.ADVENTURE)
        return;

    if(!PlayerLogic.canPlaceOn(event.player, event.itemInHand, event.placedAgainst))
        event.setCanceled(true);
}
项目:Adventure-Backport    文件:CanPlaceOnHandler.java   
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
    if(event.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
            || PlayerLogic.getGameType(event.entityPlayer) != GameType.ADVENTURE)
        return;

    if(Config.affectInteraction 
            && !PlayerLogic.canRightClickOn(event.entityPlayer, event.entityPlayer.getHeldItem(), event.x, event.y, event.z))
        event.setCanceled(true);
}
项目:NightfallMod    文件:CreativeAmulet.java   
@Override
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
       ((EntityPlayer)player).setGameType(GameType.SURVIVAL);
       for(ItemStack bau: PlayerHandler.getPlayerBaubles((EntityPlayer) player).stackList)
        if(bau != null && bau.getItem() == NFMain.flyBelt)
            ((EntityPlayer)player).capabilities.isFlying = true;
}
项目:NausicaaMod    文件:NausicaaDebugWindow.java   
@Override
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    // if clik exit end program
    if ("end".equals(command)) {
        Minecraft.getMinecraft().shutdown();
        Main.debugWrite("Shutting down....");
    } else if ("abort".equals(command)) {
        Main.debugWrite("ABORTING: I REALLY HOPE YOU MENT TO PRESS THIS");
        System.exit(0);
    } else if (command.equals("survival")) {
        Main.debugWrite("GameMode set to survival");
        nSetGameMode(0);
    } else if (command.equals("creative")) {
        Main.debugWrite("GameMode set to creative");
        nSetGameMode(1);
    } else if (command.equals("day")) {
        for (int j = 0; j < MinecraftServer.getServer().worldServers.length; ++j)
            MinecraftServer.getServer().worldServers[j].setWorldTime(0);
        Main.debugWrite("Time set to day.");
    } else if (command.equals("night")) {
        for (int j = 0; j < MinecraftServer.getServer().worldServers.length; ++j)
            MinecraftServer.getServer().worldServers[j].setWorldTime(13000);
        Main.debugWrite("Time set to night.");

    } else if (command.equals("heal")) {
        Minecraft.getMinecraft().thePlayer.heal(30);

    } else if (command.equals("newWorld")) {
        Minecraft.getMinecraft().launchIntegratedServer("TESTING", "TESTING", new WorldSettings(12341234, GameType.CREATIVE, true, false, WorldType.FLAT));

    }

}
项目:NausicaaMod    文件:NausicaaDebugWindow.java   
/**
 * Changes all players gamemodes <br>
 * HOLY SH*T THIS TOOK A LONG TIME AND IT SETS EVERYONES GAME TYPE *crys*
 * 
 * @param modeType
 */
static void nSetGameMode(int modeType) {
    try {
        Minecraft.getMinecraft().thePlayer.setGameType(modeType == 0 ? GameType.SURVIVAL : GameType.CREATIVE);
        for (int j = 0; j < MinecraftServer.getServer().worldServers.length; ++j)
            for (int i = 0; i < MinecraftServer.getServer().worldServers[i].playerEntities.size(); ++i)
                ((EntityPlayerMP) (MinecraftServer.getServer().worldServers[j].playerEntities.get(i))).setGameType(modeType == 0 ? GameType.SURVIVAL : GameType.CREATIVE);
    } catch (Exception e) {
        System.err.println("Error occured when trying to change gamemode");
        Main.debugWrite("Error occured when trying to change gamemode");
        System.err.println(e.getLocalizedMessage());
    }
}
项目:SamsPowerups    文件:SpellGhost.java   
private void setPlayerGhostMode(EntityPlayer player, World par2World)
{
    if(par2World.isRemote == false)  //false means serverside
    { 
        player.setGameType(GameType.SPECTATOR);

        ModSpells.incrementPlayerIntegerNBT(player, KEY_TIMER, GHOST_SECONDS * 20);
        player.getEntityData().setBoolean(KEY_BOOLEAN,true);
        player.getEntityData().setString(KEY_EATLOC, ModSpells.posToStringCSV(player.getPosition()));
        player.getEntityData().setInteger(KEY_EATDIM, player.dimension);
    }
}
项目:SamsPowerups    文件:SpellGhost.java   
public static void onPlayerUpdate(LivingUpdateEvent event) 
{
    if(event.entityLiving instanceof EntityPlayer == false){return;}//just in case

    EntityPlayer player = (EntityPlayer)event.entityLiving;

    if(player.getEntityData().getBoolean(KEY_BOOLEAN))//if in_ghostmode == true
    { 
        int playerGhost = player.getEntityData().getInteger(KEY_TIMER);

        if(playerGhost > 0)
        {
            ModSpells.incrementPlayerIntegerNBT(player, KEY_TIMER,-1);
        }
        else  
        {
            if(player.getEntityData().getInteger(KEY_EATDIM) != player.dimension)
            {
                //if the player changed dimension while a ghost, thats not allowed

                player.setGameType(GameType.SURVIVAL);
                player.attackEntityFrom(DamageSource.magic, 50); 
            }
            else
            {
                // : teleport back to source
                String posCSV = player.getEntityData().getString(KEY_EATLOC); 
                String[] p = posCSV.split(",");  

                player.fallDistance = 0.0F;
                player.setPositionAndUpdate(Double.parseDouble(p[0]),Double.parseDouble(p[1]),Double.parseDouble(p[2]));
                player.setGameType(GameType.SURVIVAL);
            } 

            player.getEntityData().setBoolean(KEY_BOOLEAN, false);//then we are done
        }  
    }
}
项目:NBTEdit    文件:EntityNBTPacket.java   
@Override
public void handleServerSide(EntityPlayerMP player) {
    Entity e = player.worldObj.getEntityByID(entityID);
    if (e != null) {
        try {
            GameType preGameType = player.theItemInWorldManager.getGameType();
            e.readFromNBT(tag);
            NBTEdit.log(Level.FINE, player.getCommandSenderName() + " edited a tag -- Entity ID #" + entityID);
            NBTEdit.logTag(tag);
            if (e == player) { //Update player info
                player.sendContainerToPlayer(player.inventoryContainer);
                GameType type = player.theItemInWorldManager.getGameType();
                if (preGameType != type)
                    player.setGameType(type);
                player.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
                player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel));
                player.sendPlayerAbilities();
            }
            sendMessageToPlayer(player, "Your changes have been saved");
        } 
        catch(Throwable t) {
            sendMessageToPlayer(player, SECTION_SIGN + "cSave Failed - Invalid NBT format for Entity");
            NBTEdit.log(Level.WARNING, player.getCommandSenderName() + " edited a tag and caused an exception");
            NBTEdit.logTag(tag);
            NBTEdit.throwing("EntityNBTPacket", "handleServerSide", t);
        }
    }
}
项目:TheStuffMod    文件:PotionLessening.java   
@Override
public void applyAttributesModifiersToEntity(EntityLivingBase entity, BaseAttributeMap map, int p_111185_3_) {
    if(entity instanceof EntityPlayerMP && ((EntityPlayerMP) entity).theItemInWorldManager.getGameType() == GameType.CREATIVE) return;
    AttributeModifier modifier = new AttributeModifier("lessen", -0.1D*this.getEffectiveness(), 0);
    entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(modifier);
    modifiers.add(modifier);
    if(new Random().nextInt(20) <= 2) entity.worldObj.playSoundAtEntity(entity, "minecraft:mob.zombiepig.zpigdeath", 1.0F, 0.7F);
    if(entity.getHealth() > entity.getMaxHealth()) entity.setHealth(entity.getMaxHealth());
    super.applyAttributesModifiersToEntity(entity, map, p_111185_3_);
}
项目:TRHS_Club_Mod_2016    文件:EnumHelperClient.java   
public static GameType addGameType(String name, int id, String displayName)
{
    return addEnum(GameType.class, name, id, displayName);
}
项目:TRHS_Club_Mod_2016    文件:ForgeHooks.java   
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{
    // Logic from tryHarvestBlock for pre-canceling the event
    boolean preCancelEvent = false;
    if (gameType.func_82752_c() && !entityPlayer.func_82246_f(x, y, z))
    {
        preCancelEvent = true;
    }
    else if (gameType.func_77145_d() && entityPlayer.func_70694_bm() != null && entityPlayer.func_70694_bm().func_77973_b() instanceof ItemSword)
    {
        preCancelEvent = true;
    }

    // Tell client the block is gone immediately then process events
    if (world.func_147438_o(x, y, z) == null)
    {
        S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
        packet.field_148883_d = Blocks.field_150350_a;
        packet.field_148884_e = 0;
        entityPlayer.field_71135_a.func_147359_a(packet);
    }

    // Post the block break event
    Block block = world.func_147439_a(x, y, z);
    int blockMetadata = world.func_72805_g(x, y, z);
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
    event.setCanceled(preCancelEvent);
    MinecraftForge.EVENT_BUS.post(event);

    // Handle if the event is canceled
    if (event.isCanceled())
    {
        // Let the client know the block still exists
        entityPlayer.field_71135_a.func_147359_a(new S23PacketBlockChange(x, y, z, world));

        // Update any tile entity data for this block
        TileEntity tileentity = world.func_147438_o(x, y, z);
        if (tileentity != null)
        {
            Packet pkt = tileentity.func_145844_m();
            if (pkt != null)
            {
                entityPlayer.field_71135_a.func_147359_a(pkt);
            }
        }
    }
    return event;
}
项目:LookingGlass    文件:ProxyWorld.java   
public ProxyWorld(int dimensionID) {
    super(Minecraft.getMinecraft().getNetHandler(), new WorldSettings(0L, GameType.SURVIVAL, true, false, WorldType.DEFAULT), dimensionID, Minecraft.getMinecraft().gameSettings.difficulty, Minecraft.getMinecraft().theWorld.theProfiler);
}
项目:CauldronGit    文件:EnumHelperClient.java   
public static GameType addGameType(String name, int id, String displayName)
{
    return addEnum(GameType.class, name, id, displayName);
}
项目:CauldronGit    文件:ForgeHooks.java   
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{
    // Logic from tryHarvestBlock for pre-canceling the event
    boolean preCancelEvent = false;
    if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
    {
        preCancelEvent = true;
    }
    else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        preCancelEvent = true;
    }

    // Tell client the block is gone immediately then process events
    if (world.getTileEntity(x, y, z) == null)
    {
        S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
        packet.field_148883_d = Blocks.air;
        packet.field_148884_e = 0;
        entityPlayer.playerNetServerHandler.sendPacket(packet);
    }

    // Post the block break event
    Block block = world.getBlock(x, y, z);
    int blockMetadata = world.getBlockMetadata(x, y, z);
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
    event.setCanceled(preCancelEvent);
    MinecraftForge.EVENT_BUS.post(event);

    // Handle if the event is canceled
    if (event.isCanceled())
    {
        // Let the client know the block still exists
        entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));

        // Update any tile entity data for this block
        TileEntity tileentity = world.getTileEntity(x, y, z);
        if (tileentity != null)
        {
            Packet pkt = tileentity.getDescriptionPacket();
            if (pkt != null)
            {
                entityPlayer.playerNetServerHandler.sendPacket(pkt);
            }
        }
    }
    return event;
}
项目:Framez    文件:FakeWorldClient.java   
private FakeWorldClient() {

        super(new NetHandlerPlayClient(Minecraft.getMinecraft(), null, new NetworkManager(true)), new WorldSettings(0, GameType.NOT_SET,
                false, false, WorldType.DEFAULT), 0, EnumDifficulty.PEACEFUL, Minecraft.getMinecraft().theWorld.theProfiler);
    }
项目:Cauldron    文件:EnumHelperClient.java   
public static GameType addGameType(String name, int id, String displayName)
{
    return addEnum(GameType.class, name, id, displayName);
}
项目:Cauldron    文件:ForgeHooks.java   
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{
    // Logic from tryHarvestBlock for pre-canceling the event
    boolean preCancelEvent = false;
    if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
    {
        preCancelEvent = true;
    }
    else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        preCancelEvent = true;
    }

    // Tell client the block is gone immediately then process events
    if (world.getTileEntity(x, y, z) == null)
    {
        S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
        packet.field_148883_d = Blocks.air;
        packet.field_148884_e = 0;
        entityPlayer.playerNetServerHandler.sendPacket(packet);
    }

    // Post the block break event
    Block block = world.getBlock(x, y, z);
    int blockMetadata = world.getBlockMetadata(x, y, z);
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
    event.setCanceled(preCancelEvent);
    MinecraftForge.EVENT_BUS.post(event);

    // Handle if the event is canceled
    if (event.isCanceled())
    {
        // Let the client know the block still exists
        entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));

        // Update any tile entity data for this block
        TileEntity tileentity = world.getTileEntity(x, y, z);
        if (tileentity != null)
        {
            Packet pkt = tileentity.getDescriptionPacket();
            if (pkt != null)
            {
                entityPlayer.playerNetServerHandler.sendPacket(pkt);
            }
        }
    }
    return event;
}
项目:Cauldron    文件:EnumHelperClient.java   
public static GameType addGameType(String name, int id, String displayName)
{
    return addEnum(GameType.class, name, id, displayName);
}
项目:Cauldron    文件:ForgeHooks.java   
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{
    // Cauldron - pre-cancel handled in BreakEvent
    /*
    // Logic from tryHarvestBlock for pre-canceling the event
    boolean preCancelEvent = false;
    if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
    {
        preCancelEvent = true;
    }
    else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        preCancelEvent = true;
    }
    */
    // Tell client the block is gone immediately then process events
    if (world.getTileEntity(x, y, z) == null && !(entityPlayer instanceof FakePlayer)) // Cauldron - don't send packets to fakeplayers
    {
        S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
        packet.field_148883_d = Blocks.air;
        packet.field_148884_e = 0;
        entityPlayer.playerNetServerHandler.sendPacket(packet);
    }

    // Post the block break event
    Block block = world.getBlock(x, y, z);
    int blockMetadata = world.getBlockMetadata(x, y, z);
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
    //event.setCanceled(preCancelEvent); // Cauldron
    MinecraftForge.EVENT_BUS.post(event);

    // Handle if the event is canceled
    if (event.isCanceled() && !(entityPlayer instanceof FakePlayer)) // Cauldron - don't send packets to fakeplayers
    {
        // Let the client know the block still exists
        entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));

        // Update any tile entity data for this block
        TileEntity tileentity = world.getTileEntity(x, y, z);
        if (tileentity != null)
        {
            Packet pkt = tileentity.getDescriptionPacket();
            if (pkt != null)
            {
                entityPlayer.playerNetServerHandler.sendPacket(pkt);
            }
        }
    }
    return event;
}
项目:Cauldron    文件:EnumHelperClient.java   
public static GameType addGameType(String name, int id, String displayName)
{
    return addEnum(GameType.class, name, id, displayName);
}
项目:Cauldron    文件:ForgeHooks.java   
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
{
    // Logic from tryHarvestBlock for pre-canceling the event
    boolean preCancelEvent = false;
    if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
    {
        preCancelEvent = true;
    }
    else if (gameType.isCreative() && entityPlayer.getHeldItem() != null && entityPlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        preCancelEvent = true;
    }

    // Tell client the block is gone immediately then process events
    if (world.getTileEntity(x, y, z) == null)
    {
        S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
        packet.field_148883_d = Blocks.air;
        packet.field_148884_e = 0;
        entityPlayer.playerNetServerHandler.sendPacket(packet);
    }

    // Post the block break event
    Block block = world.getBlock(x, y, z);
    int blockMetadata = world.getBlockMetadata(x, y, z);
    BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
    event.setCanceled(preCancelEvent);
    MinecraftForge.EVENT_BUS.post(event);

    // Handle if the event is canceled
    if (event.isCanceled())
    {
        // Let the client know the block still exists
        entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));

        // Update any tile entity data for this block
        TileEntity tileentity = world.getTileEntity(x, y, z);
        if (tileentity != null)
        {
            Packet pkt = tileentity.getDescriptionPacket();
            if (pkt != null)
            {
                entityPlayer.playerNetServerHandler.sendPacket(pkt);
            }
        }
    }
    return event;
}
项目:MinecraftScripting    文件:ScriptPlayer.java   
public void setGameType(int id) {
    player.setGameType(GameType.getByID(id));
}
项目:MinecraftScripting    文件:ScriptPlayer.java   
public void setGameType(String name) {
    player.setGameType(GameType.getByName(name.toLowerCase()));
}
项目:NightfallMod    文件:CreativeAmulet.java   
@Override
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
        MLib.printToPlayer("Creative Amulet Active");
        MLib.printToPlayer("Effects are perminat unless removed");

        ((EntityPlayer)player).setGameType(GameType.CREATIVE);


}