本文整理汇总了Java中net.minecraft.network.play.server.SPacketChangeGameState类的典型用法代码示例。如果您正苦于以下问题:Java SPacketChangeGameState类的具体用法?Java SPacketChangeGameState怎么用?Java SPacketChangeGameState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SPacketChangeGameState类属于net.minecraft.network.play.server包,在下文中一共展示了SPacketChangeGameState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeDimension
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
@Override
public Entity changeDimension(int dimensionIn) {
if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, dimensionIn)) {
return this;
}
ObfuscationReflectionHelper.setPrivateValue(EntityPlayerMP.class, this, true, "invulnerableDimensionChange", "field_184851_cj");
if (dimension == 1 && dimensionIn == 1) {
world.removeEntity(this);
if (!queuedEndExit) {
queuedEndExit = true;
connection.sendPacket(new SPacketChangeGameState(4, 0.0F));
}
return this;
}
else {
if (dimension == 0 && dimensionIn == 1) {
dimensionIn = 1;
}
mcServer.getPlayerList().changePlayerDimension(this, dimensionIn);
return this;
}
}
示例2: onPacketIncoming
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
@SubscribeEvent
public void onPacketIncoming(PacketEvent.Incoming.Pre event) {
if(event.getPacket() instanceof SPacketChangeGameState) {
int state = ((SPacketChangeGameState) event.getPacket()).getGameState();
float strength = ((SPacketChangeGameState) event.getPacket()).getValue();
boolean isRainState = false;
switch (state) {
case 1:
isRainState = true;
setState(true, 0.f, 0.f);
break;
case 2:
isRainState = true;
setState(false, 1.f, 1.f);
break;
case 7:
isRainState = true;
setState(strength, strength);
break;
}
if(isRainState) {
disableRain();
event.setCanceled(true);
}
}
}
示例3: setGameType
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
/**
* Sets the player's game mode and sends it to them.
*/
public void setGameType(GameType gameType)
{
this.interactionManager.setGameType(gameType);
this.connection.sendPacket(new SPacketChangeGameState(3, (float)gameType.getID()));
if (gameType == GameType.SPECTATOR)
{
this.dismountRidingEntity();
}
else
{
this.setSpectatingEntity(this);
}
this.sendPlayerAbilities();
this.markPotionsDirty();
}
示例4: updateTimeAndWeatherForPlayer
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
/**
* Updates the time and weather for the given player to those of the given world
*/
public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn)
{
WorldBorder worldborder = this.mcServer.worldServers[0].getWorldBorder();
playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE));
playerIn.connection.sendPacket(new SPacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));
BlockPos blockpos = worldIn.getSpawnPoint();
playerIn.connection.sendPacket(new SPacketSpawnPosition(blockpos));
if (worldIn.isRaining())
{
playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F));
playerIn.connection.sendPacket(new SPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
playerIn.connection.sendPacket(new SPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
}
}
示例5: onImpact
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
@Override
protected void onImpact(RayTraceResult result)
{
if (result.typeOfHit == Type.ENTITY && result.entityHit != this.getThrower())
{
result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.getThrower()), 5);
result.entityHit.addVelocity(this.motionX, 0.6D, this.motionZ);
if (this.getThrower() != null && result.entityHit != this.getThrower() && result.entityHit instanceof EntityPlayer && this.getThrower() instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.getThrower()).connection.sendPacket(new SPacketChangeGameState(6, 0.0F));
}
}
for(int j = 0; j < 8; j++)
{
this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
this.worldObj.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
this.setDead();
}
示例6: onImpact
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
@Override
protected void onImpact(RayTraceResult result) {
if (result.typeOfHit == RayTraceResult.Type.ENTITY) {
EntityLivingBase thrower = getThrower();
// prevent damaging thrower
if (result.entityHit == thrower)
return;
Entity entity = result.entityHit;
DamageSource ds = createDamageSource(null == thrower ? this : thrower);
if (isBurning() && !(entity instanceof EntityEnderman))
entity.setFire(5);
if (entity.attackEntityFrom(ds, getDamage())) {
if (entity instanceof EntityLivingBase) {
EntityLivingBase base = (EntityLivingBase) entity;
if (knockbackStrength > 0) {
float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
if (f1 > 0f) {
base.addVelocity(motionX * knockbackStrength * 0.6000000238418579D / f1,
0.1D, motionZ * knockbackStrength * 0.6000000238418579D / f1);
}
}
if (null != thrower) {
EnchantmentHelper.applyThornEnchantments(base, thrower);
EnchantmentHelper.applyArthropodEnchantments(thrower, base);
if (base != thrower && base instanceof EntityPlayer && thrower instanceof EntityPlayerMP)
{
((EntityPlayerMP)thrower).connection.sendPacket(new SPacketChangeGameState(6, 0.0F));
}
}
}
}
}
if (!worldObj.isRemote)
setDead();
}
示例7: updateWeather
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
/**
* Updates all weather states.
*/
protected void updateWeather()
{
boolean flag = this.isRaining();
super.updateWeather();
if (this.prevRainingStrength != this.rainingStrength)
{
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(7, this.rainingStrength), this.provider.getDimensionType().getId());
}
if (this.prevThunderingStrength != this.thunderingStrength)
{
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(8, this.thunderingStrength), this.provider.getDimensionType().getId());
}
if (flag != this.isRaining())
{
if (flag)
{
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(2, 0.0F));
}
else
{
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(1, 0.0F));
}
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(7, this.rainingStrength));
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(8, this.thunderingStrength));
}
}
示例8: updateAITasks
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
protected void updateAITasks()
{
super.updateAITasks();
int i = 1200;
if ((this.ticksExisted + this.getEntityId()) % 1200 == 0)
{
Potion potion = MobEffects.MINING_FATIGUE;
List<EntityPlayerMP> list = this.world.<EntityPlayerMP>getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>()
{
public boolean apply(@Nullable EntityPlayerMP p_apply_1_)
{
return EntityElderGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure();
}
});
int j = 2;
int k = 6000;
int l = 1200;
for (EntityPlayerMP entityplayermp : list)
{
if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200)
{
entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F));
entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2));
}
}
}
if (!this.hasHome())
{
this.setHomePosAndDistance(new BlockPos(this), 16);
}
}
示例9: fixWorldWeather
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
private void fixWorldWeather()
{
if (this.worldInfo.isRaining() || this.worldInfo.isThundering())
{
this.worldInfo.setRainTime(0);
this.worldInfo.setRaining(false);
this.setRainStrength(0.0F);
this.worldInfo.setThunderTime(0);
this.worldInfo.setThundering(false);
this.setThunderStrength(0.0F);
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(2, 0.0F));
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(7, 0.0F));
this.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketChangeGameState(8, 0.0F));
}
}
示例10: updateWeather
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
/**
* Updates all weather states.
*/
protected void updateWeather()
{
boolean flag = this.isRaining();
super.updateWeather();
if (this.prevRainingStrength != this.rainingStrength)
{
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(7, this.rainingStrength), this.provider.getDimension());
}
if (this.prevThunderingStrength != this.thunderingStrength)
{
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(8, this.thunderingStrength), this.provider.getDimension());
}
/* The function in use here has been replaced in order to only send the weather info to players in the correct dimension,
* rather than to all players on the server. This is what causes the client-side rain, as the
* client believes that it has started raining locally, rather than in another dimension.
*/
if (flag != this.isRaining())
{
if (flag)
{
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(2, 0.0F), this.provider.getDimension());
}
else
{
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(1, 0.0F), this.provider.getDimension());
}
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(7, this.rainingStrength), this.provider.getDimension());
this.mcServer.getPlayerList().sendPacketToAllPlayersInDimension(new SPacketChangeGameState(8, this.thunderingStrength), this.provider.getDimension());
}
}
示例11: updateAITasks
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
protected void updateAITasks()
{
super.updateAITasks();
if (this.isElder())
{
int i = 1200;
int j = 1200;
int k = 6000;
int l = 2;
if ((this.ticksExisted + this.getEntityId()) % 1200 == 0)
{
Potion potion = MobEffects.MINING_FATIGUE;
for (EntityPlayerMP entityplayermp : this.worldObj.getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>()
{
public boolean apply(@Nullable EntityPlayerMP p_apply_1_)
{
return EntityGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure();
}
}))
{
if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200)
{
entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F));
entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2));
}
}
}
if (!this.hasHome())
{
this.setHomePosAndDistance(new BlockPos(this), 16);
}
}
}
示例12: updateTimeAndWeatherForPlayer
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
/**
* Updates the time and weather for the given player to those of the given world
*/
public void updateTimeAndWeatherForPlayer(EntityPlayerMP playerIn, WorldServer worldIn)
{
WorldBorder worldborder = this.mcServer.worldServers[0].getWorldBorder();
playerIn.connection.sendPacket(new SPacketWorldBorder(worldborder, SPacketWorldBorder.Action.INITIALIZE));
playerIn.connection.sendPacket(new SPacketTimeUpdate(worldIn.getTotalWorldTime(), worldIn.getWorldTime(), worldIn.getGameRules().getBoolean("doDaylightCycle")));
if (worldIn.isRaining())
{
playerIn.connection.sendPacket(new SPacketChangeGameState(1, 0.0F));
playerIn.connection.sendPacket(new SPacketChangeGameState(7, worldIn.getRainStrength(1.0F)));
playerIn.connection.sendPacket(new SPacketChangeGameState(8, worldIn.getThunderStrength(1.0F)));
}
}
示例13: onRangedImpact
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
protected void onRangedImpact(RayTraceResult result)
{
result.entityHit.attackEntityFrom(DamageSource.causeIndirectDamage(this, this.getThrower()), 5);
result.entityHit.addVelocity(this.motionX, 0.6D, this.motionZ);
if (this.getThrower() != null && result.entityHit != this.getThrower() && result.entityHit instanceof EntityPlayer && this.getThrower() instanceof EntityPlayerMP)
{
((EntityPlayerMP)this.getThrower()).connection.sendPacket(new SPacketChangeGameState(6, 0.0F));
}
}
示例14: applyEntityHitEffects
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
public void applyEntityHitEffects(Entity entityHit)
{
if (isBurning() && !(entityHit instanceof EntityEnderman)) {
entityHit.setFire(5);
}
if (entityHit instanceof EntityLivingBase) {
EntityLivingBase entityliving = (EntityLivingBase) entityHit;
if (this.knockbackStrength > 0) {
float f1 = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (f1 > 0.0F) {
entityliving.addVelocity(
this.motionX * (double) this.knockbackStrength * 0.6000000238418579D / (double) f1, 0.1D,
this.motionZ * (double) this.knockbackStrength * 0.6000000238418579D / (double) f1);
}
}
if (this.shootingEntity instanceof EntityLivingBase) {
EnchantmentHelper.applyThornEnchantments(entityliving, this.shootingEntity);
EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase) this.shootingEntity, entityliving);
}
this.arrowHit(entityliving);
if (this.shootingEntity != null && entityliving != this.shootingEntity
&& entityliving instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) {
((EntityPlayerMP) this.shootingEntity).connection.sendPacket(new SPacketChangeGameState(6, 0.0F));
}
}
}
示例15: executeActivateBehavior
import net.minecraft.network.play.server.SPacketChangeGameState; //导入依赖的package包/类
@Override
public int executeActivateBehavior(TileEntityTrophy tile, EntityPlayer player) {
if (player instanceof EntityPlayerMP) {
((EntityPlayerMP)player).connection.sendPacket(new SPacketChangeGameState(10, 0.0F));
}
return 100;
}