本文整理匯總了Java中net.minecraft.world.WorldSettings.GameType方法的典型用法代碼示例。如果您正苦於以下問題:Java WorldSettings.GameType方法的具體用法?Java WorldSettings.GameType怎麽用?Java WorldSettings.GameType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.world.WorldSettings
的用法示例。
在下文中一共展示了WorldSettings.GameType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public void setGameType(WorldSettings.GameType type)
{
this.gameType = type;
type.configurePlayerCapabilities(this.thisPlayerMP.capabilities);
this.thisPlayerMP.sendPlayerAbilities();
this.thisPlayerMP.mcServer.getConfigurationManager().sendPacketToAllPlayers(new S38PacketPlayerListItem(S38PacketPlayerListItem.Action.UPDATE_GAME_MODE, new EntityPlayerMP[] {this.thisPlayerMP}));
}
示例2: S07PacketRespawn
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public S07PacketRespawn(int dimensionIDIn, EnumDifficulty difficultyIn, WorldType worldTypeIn, WorldSettings.GameType gameTypeIn)
{
this.dimensionID = dimensionIDIn;
this.difficulty = difficultyIn;
this.gameType = gameTypeIn;
this.worldType = worldTypeIn;
}
示例3: doMining
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
void doMining(World world, EntityPlayerMP player, int x, int y, int z) // Calling this 27 times, to blast mine a 3x3x3 area
{
Block toBeBroken = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (toBeBroken.getBlockHardness(world, x, y, z) == -1) { return; } // Unbreakable
if (toBeBroken.getHarvestLevel(meta) > 1) { return; }
if (toBeBroken.getMaterial() == Material.water) { return; }
if (toBeBroken.getMaterial() == Material.lava) { return; }
if (toBeBroken.getMaterial() == Material.air) { return; }
if (toBeBroken.getMaterial() == Material.portal) { return; }
// Need to do checks here against invalid blocks
if (toBeBroken == Blocks.water) { return; }
if (toBeBroken == Blocks.flowing_water) { return; }
if (toBeBroken == Blocks.lava) { return; }
if (toBeBroken == Blocks.flowing_lava) { return; }
if (toBeBroken == Blocks.obsidian) { return; }
if (toBeBroken == Blocks.mob_spawner) { return; }
// Crashing blocks: Redstone Lamp, Extended Piston
// They're likely trying to drop things that cannot be dropped (active states of themselves)
//WorldSettings.GameType gametype = WorldSettings.GameType.getByName("survival");
WorldSettings.GameType gametype = world.getWorldInfo().getGameType();
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, gametype, player, x, y, z);
if (event.isCanceled()) { return; } // Not allowed to do this
//toBeBroken.dropBlockAsItem(world, x, x, z, meta, 0); // The last one is Fortune
boolean removalSuccess = world.setBlockToAir(x, y, z);
if (removalSuccess) { toBeBroken.onBlockDestroyedByPlayer(world, x, y, z, meta); }
Item preBlockItem = toBeBroken.getItemDropped(meta, player.getRNG(), 0);
if (preBlockItem == null) { return; } // Item doesn't exist
ItemStack blockItem = new ItemStack(preBlockItem);
blockItem.setItemDamage(meta);
EntityItem entityItem = new EntityItem(world, x, y + 0.5d, z, blockItem);
entityItem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityItem);
}
示例4: AddPlayerData
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public AddPlayerData(GameProfile profile, int pingIn, WorldSettings.GameType gamemodeIn, IChatComponent displayNameIn)
{
this.profile = profile;
this.ping = pingIn;
this.gamemode = gamemodeIn;
this.displayName = displayNameIn;
}
示例5: processCommand
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
}
else
{
WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(worldsettings$gametype);
entityplayer.fallDistance = 0.0F;
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))
{
entityplayer.addChatMessage(new ChatComponentTranslation("gameMode.changed", new Object[0]));
}
IChatComponent ichatcomponent = new ChatComponentTranslation("gameMode." + worldsettings$gametype.getName(), new Object[0]);
if (entityplayer != sender)
{
notifyOperators(sender, this, 1, "commands.gamemode.success.other", new Object[] {entityplayer.getName(), ichatcomponent});
}
else
{
notifyOperators(sender, this, 1, "commands.gamemode.success.self", new Object[] {ichatcomponent});
}
}
}
示例6: setGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
protected void setGameType(WorldSettings.GameType p_71541_1_)
{
MinecraftServer minecraftserver = MinecraftServer.getServer();
minecraftserver.setGameType(p_71541_1_);
if (minecraftserver.getForceGamemode())
{
for (EntityPlayerMP entityplayermp : MinecraftServer.getServer().getConfigurationManager().func_181057_v())
{
entityplayermp.setGameType(p_71541_1_);
entityplayermp.fallDistance = 0.0F;
}
}
}
示例7: getCurrentGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public WorldSettings.GameType getCurrentGameType()
{
return this.currentGameType;
}
示例8: getGameMode
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public WorldSettings.GameType getGameMode()
{
return this.gamemode;
}
示例9: setGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
/**
* Sets the game type for the player.
*/
public void setGameType(WorldSettings.GameType p_78746_1_)
{
this.currentGameType = p_78746_1_;
this.currentGameType.configurePlayerCapabilities(this.mc.thePlayer.capabilities);
}
示例10: getGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public WorldSettings.GameType getGameType()
{
return this.theWorldSettings.getGameType();
}
示例11: getGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
public WorldSettings.GameType getGameType()
{
return this.gameType;
}
示例12: onImpact
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
@Override
public void onImpact(MovingObjectPosition target)
{
if (target.entityHit != null) // We hit a living thing!
{
// Damage
target.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.shootingEntity), (float)this.damage);
}
else // Hit the terrain
{
Block block = this.worldObj.getBlock(target.blockX, target.blockY, target.blockZ);
int meta = this.worldObj.getBlockMetadata(target.blockX, target.blockY, target.blockZ);
boolean breakThis = true;
// Checking here against invalid blocks
if (block == Blocks.bedrock) { breakThis = false; }
else if (block == Blocks.water) { breakThis = false; }
else if (block == Blocks.flowing_water) { breakThis = false; }
else if (block == Blocks.lava) { breakThis = false; }
else if (block == Blocks.flowing_lava) { breakThis = false; }
else if (block == Blocks.obsidian) { breakThis = false; }
else if (block == Blocks.mob_spawner) { breakThis = false; }
else if (block.getMaterial() == Material.water) { breakThis = false; }
else if (block.getMaterial() == Material.lava) { breakThis = false; }
else if (block.getMaterial() == Material.air) { breakThis = false; }
else if (block.getMaterial() == Material.portal) { breakThis = false; }
else if (block.getHarvestLevel(meta) > 0) { breakThis = false; }
else if (block.getBlockHardness(this.worldObj, target.blockX, target.blockY, target.blockZ) > 3) { breakThis = false; }
if (this.shootingEntity instanceof EntityPlayerMP)
{
WorldSettings.GameType gametype = this.worldObj.getWorldInfo().getGameType();
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(this.worldObj, gametype, (EntityPlayerMP) this.shootingEntity, target.blockX, target.blockY, target.blockZ);
if (event.isCanceled()) { breakThis = false; } // Not allowed to do this
}
if (breakThis) // Nothing preventing us from breaking this block!
{
this.worldObj.setBlockToAir(target.blockX, target.blockY, target.blockZ);
block.dropBlockAsItem(this.worldObj, target.blockX, target.blockY, target.blockZ, meta, 0);
}
}
// SFX
for (int i = 0; i < 4; ++i) { this.worldObj.spawnParticle("smoke", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); }
this.worldObj.playSoundAtEntity(this, Block.soundTypeGravel.getBreakSound(), 1.0F, 1.0F);
this.setDead(); // Hit something, so begone.
}
示例13: getGameModeFromCommand
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
/**
* Gets the Game Mode specified in the command.
*/
protected WorldSettings.GameType getGameModeFromCommand(ICommandSender p_71539_1_, String p_71539_2_) throws CommandException, NumberInvalidException
{
return !p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.SURVIVAL.getName()) && !p_71539_2_.equalsIgnoreCase("s") ? (!p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.CREATIVE.getName()) && !p_71539_2_.equalsIgnoreCase("c") ? (!p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.ADVENTURE.getName()) && !p_71539_2_.equalsIgnoreCase("a") ? (!p_71539_2_.equalsIgnoreCase(WorldSettings.GameType.SPECTATOR.getName()) && !p_71539_2_.equalsIgnoreCase("sp") ? WorldSettings.getGameTypeById(parseInt(p_71539_2_, 0, WorldSettings.GameType.values().length - 2)) : WorldSettings.GameType.SPECTATOR) : WorldSettings.GameType.ADVENTURE) : WorldSettings.GameType.CREATIVE) : WorldSettings.GameType.SURVIVAL;
}
示例14: getGameType
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
/**
* Gets the GameType.
*/
public WorldSettings.GameType getGameType()
{
return this.theWorldInfo.getGameType();
}
示例15: shareToLAN
import net.minecraft.world.WorldSettings; //導入方法依賴的package包/類
/**
* On dedicated does nothing. On integrated, sets commandsAllowedForAll, gameType and allows external connections.
*/
public abstract String shareToLAN(WorldSettings.GameType type, boolean allowCheats);