net.minecraft.world.World.getGameRules()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中net.minecraft.world.World.getGameRules()方法的一些代码示例,展示了World.getGameRules()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getGameRules()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getGameRules

World.getGameRules介绍

暂无

代码示例

代码示例来源:origin: SleepyTrousers/EnderIO

@Override
public @Nonnull GameRules getGameRules() {
 return wrapped.getGameRules();
}

代码示例来源:origin: Vazkii/Botania

@SubscribeEvent
public static void onDeath(LivingDeathEvent evt) {
  if(!evt.getEntityLiving().world.isRemote
      && evt.getEntityLiving() instanceof EntityPlayer
      && !evt.getEntityLiving().world.getGameRules().getBoolean("keepInventory")
      && !((EntityPlayer) evt.getEntityLiving()).isSpectator()) {
    IItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) evt.getEntityLiving());
    for(int i = 0; i < inv.getSlots(); i++) {
      ItemStack stack = inv.getStackInSlot(i);
      if (!stack.isEmpty() && stack.getItem().getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) {
        ((ItemBauble) stack.getItem()).onUnequipped(stack, evt.getEntityLiving());
      }
    }
  }
}

代码示例来源:origin: Darkhax-Minecraft/Bookshelf

/**
   * Sets the state of the rule for a world.
   *
   * @param world The world to apply the state to.
   * @param state The state to set.
   */
  public void setRuleState (World world, boolean state) {
    
    world.getGameRules().setOrCreateGameRule(this.getId(), String.valueOf(state));
  }
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

public static void register(World world) {
    GameRules gameRules = world.getGameRules();
    for (GameRuleHandler rule : GameRuleHandler.values()) {
      if (!gameRules.hasRule(rule.name)) {
        gameRules.addGameRule(rule.name, String.valueOf(rule.defaultValue), rule.valueType);
      }
    }
  }
}

代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped

public void killWeapon(DamageSource source) {
  this.setDead();
  if (this.world.getGameRules().getBoolean("doEntityDrops")) {
    doItemDrops();
  }
}

代码示例来源:origin: vadis365/TheErebus

public static final void dropStack(World world, BlockPos pos, ItemStack is) {
  if (!world.isRemote && world.getGameRules().getBoolean("doTileDrops")) {
    float f = 0.7F;
    double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
    double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
    double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
    EntityItem entityitem = new EntityItem(world, pos.getX() + d0, pos.getY() + d1, pos.getZ() + d2, is);
    entityitem.setPickupDelay(10);
    world.spawnEntity(entityitem);
  }
}

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent
public void login(PlayerLoggedInEvent event) {
  if(!event.player.getEntityWorld().getGameRules().getBoolean(StoreToChests.GAME_RULE))
    DropoffHandler.disableClientDropoff(event.player);
}

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent
public void worldLoad(WorldEvent.Load event) {
  GameRules rules = event.getWorld().getGameRules();
  if(!rules.hasRule(StoreToChests.GAME_RULE))
    rules.addGameRule(StoreToChests.GAME_RULE, "true", ValueType.BOOLEAN_VALUE);
}

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

@Override
public void onBroken(Entity entity) {
  if (this.world.getGameRules().getBoolean("doTileDrops")) {
    if (entity instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) entity;
      if (player.capabilities.isCreativeMode) {
        return;
      }
    }
    this.entityDropItem(new ItemStack(ItemHandler.ATTRACTION_SIGN, 1, this.type.ordinal()), 0.0F);
  }
}

代码示例来源:origin: Silentine/GrimoireOfGaia

private void explode() {
  if (!world.isRemote) {
    boolean flag = world.getGameRules().getBoolean("mobGriefing");
    float f = getPowered() ? 2.0F : 1.0F;
    dead = true;
    world.createExplosion(this, posX, posY, posZ, explosionRadius * f, flag);
    setDead();
  }
}

代码示例来源:origin: TeamLapen/Vampirism

@Override
protected void onDeathUpdate() {
  if (this.deathTime == 19) {
    if (!this.world.isRemote && (dropSoul && this.world.getGameRules().getBoolean("doMobLoot"))) {
      this.world.spawnEntity(new EntitySoulOrb(this.world, this.posX, this.posY, this.posZ, EntitySoulOrb.TYPE.VAMPIRE));
    }
  }
  super.onDeathUpdate();
}

代码示例来源:origin: Electrical-Age/ElectricalAge

public void dropItem(ItemStack itemStack) {
  if (itemStack == null) return;
  if (coordonate.world().getGameRules().getGameRuleBooleanValue("doTileDrops")) {
    float var6 = 0.7F;
    double var7 = (double) (coordonate.world().rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
    double var9 = (double) (coordonate.world().rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
    double var11 = (double) (coordonate.world().rand.nextFloat() * var6) + (double) (1.0F - var6) * 0.5D;
    EntityItem var13 = new EntityItem(coordonate.world(), (double) coordonate.x + var7, (double) coordonate.y + var9, (double) coordonate.z + var11, itemStack);
    var13.delayBeforeCanPickup = 10;
    coordonate.world().spawnEntityInWorld(var13);
  }
}

代码示例来源:origin: Vazkii/Quark

@SubscribeEvent 
public void onPlayerLoggedIn(PlayerLoggedInEvent event) {
  if(event.player instanceof EntityPlayerMP) {
    ArrayList<IRecipe> recipes = Lists.newArrayList(CraftingManager.REGISTRY);
    recipes.removeIf((recipe) -> ignored.contains(recipe.getRegistryName().toString()) || recipe.getRecipeOutput().isEmpty());
    ((EntityPlayerMP) event.player).unlockRecipes(recipes);
    if(forceLimitedCrafting)
      event.player.world.getGameRules().setOrCreateGameRule("doLimitedCrafting", "true");
  }
}

代码示例来源:origin: CoFH/ThermalFoundation

@SubscribeEvent (priority = EventPriority.NORMAL)
public void handleLivingDropsEvent(LivingDropsEvent event) {
  Entity entity = event.getEntity();
  if (entity.isImmuneToFire() && TFProps.dropSulfurFireImmuneMobs && event.getEntityLiving().world.getGameRules().getBoolean("doMobLoot")) {
    boolean s = entity instanceof EntitySlime;
    if (event.getEntityLiving().getRNG().nextInt(6 + (s ? 16 : 0)) != 0) {
      return;
    }
    event.getDrops().add(new EntityItem(entity.world, entity.posX, entity.posY, entity.posZ, ItemMaterial.dustSulfur.copy()));
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public void killMinecart(DamageSource damageSource) {
  super.killMinecart(damageSource);
  if (this.world.getGameRules().getBoolean("doEntityDrops")) {
    Block block = getDisplayTile().getBlock();
    entityDropItem(new ItemStack(block), 0.0F);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public void killMinecart(DamageSource source) {
 this.setDead();
 if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  ItemStack itemstack = getCartItem();
  if (this.hasCustomName()) {
   itemstack.setStackDisplayName(this.getCustomNameTag());
  }
  this.entityDropItem(itemstack, 0.0F);
 }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public void killMinecart(DamageSource source) {
 this.setDead();
 if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  ItemStack itemstack = getCartItem();
  if (this.hasCustomName()) {
   itemstack.setStackDisplayName(this.getCustomNameTag());
  }
  this.entityDropItem(itemstack, 0.0F);
 }
}

代码示例来源:origin: vadis365/TheErebus

public static void dropStackNoRandom(World world, BlockPos pos, ItemStack stack) {
  if (!world.isRemote && !stack.isEmpty() && world.getGameRules().getBoolean("doTileDrops")) {
    EntityItem entityItem = new EntityItem(world, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, stack);
    entityItem.motionX = 0;
    entityItem.motionY = 0;
    entityItem.motionZ = 0;
    entityItem.setPickupDelay(10);
    world.spawnEntity(entityItem);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
public void killMinecart(DamageSource source) {
 this.setDead();
 if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  dropCartBlock();
  ItemStack itemstack = getCartItem();
  if (this.hasCustomName()) {
   itemstack.setStackDisplayName(this.getCustomNameTag());
  }
  this.entityDropItem(itemstack, 0.0F);
 }
}

代码示例来源:origin: vadis365/TheErebus

private void explode() {
  Explosion explosion = new Explosion(getEntityWorld(), this, posX, posY, posZ, 3F, true, getEntityWorld().getGameRules().getBoolean("mobGriefing"));
  explosion.doExplosionA();
  if (!getEntityWorld().isRemote)
    Erebus.NETWORK_WRAPPER.sendToAll(new PacketParticle(ParticleType.BEETLE_LARVA_SQUISH, (float) posX, (float)posY, (float)posZ));
  getEntityWorld().playSound((EntityPlayer)null, getPosition(), getJumpedOnSound(), SoundCategory.NEUTRAL, 1.0F, 0.5F);
  getEntityWorld().playSound((EntityPlayer)null, getPosition(), getDeathSound(), SoundCategory.NEUTRAL, 1.0F, 0.7F);
  setDead();
}

相关文章

微信公众号

最新文章

更多

World类方法