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

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

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

World.getGameRules介绍

暂无

代码示例

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

  1. @Override
  2. public @Nonnull GameRules getGameRules() {
  3. return wrapped.getGameRules();
  4. }

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

  1. @SubscribeEvent
  2. public static void onDeath(LivingDeathEvent evt) {
  3. if(!evt.getEntityLiving().world.isRemote
  4. && evt.getEntityLiving() instanceof EntityPlayer
  5. && !evt.getEntityLiving().world.getGameRules().getBoolean("keepInventory")
  6. && !((EntityPlayer) evt.getEntityLiving()).isSpectator()) {
  7. IItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) evt.getEntityLiving());
  8. for(int i = 0; i < inv.getSlots(); i++) {
  9. ItemStack stack = inv.getStackInSlot(i);
  10. if (!stack.isEmpty() && stack.getItem().getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) {
  11. ((ItemBauble) stack.getItem()).onUnequipped(stack, evt.getEntityLiving());
  12. }
  13. }
  14. }
  15. }

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

  1. /**
  2. * Sets the state of the rule for a world.
  3. *
  4. * @param world The world to apply the state to.
  5. * @param state The state to set.
  6. */
  7. public void setRuleState (World world, boolean state) {
  8. world.getGameRules().setOrCreateGameRule(this.getId(), String.valueOf(state));
  9. }
  10. }

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

  1. public static void register(World world) {
  2. GameRules gameRules = world.getGameRules();
  3. for (GameRuleHandler rule : GameRuleHandler.values()) {
  4. if (!gameRules.hasRule(rule.name)) {
  5. gameRules.addGameRule(rule.name, String.valueOf(rule.defaultValue), rule.valueType);
  6. }
  7. }
  8. }
  9. }

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

  1. public void killWeapon(DamageSource source) {
  2. this.setDead();
  3. if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  4. doItemDrops();
  5. }
  6. }

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

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

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

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

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

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

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

  1. @Override
  2. public void onBroken(Entity entity) {
  3. if (this.world.getGameRules().getBoolean("doTileDrops")) {
  4. if (entity instanceof EntityPlayer) {
  5. EntityPlayer player = (EntityPlayer) entity;
  6. if (player.capabilities.isCreativeMode) {
  7. return;
  8. }
  9. }
  10. this.entityDropItem(new ItemStack(ItemHandler.ATTRACTION_SIGN, 1, this.type.ordinal()), 0.0F);
  11. }
  12. }

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

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

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

  1. @Override
  2. protected void onDeathUpdate() {
  3. if (this.deathTime == 19) {
  4. if (!this.world.isRemote && (dropSoul && this.world.getGameRules().getBoolean("doMobLoot"))) {
  5. this.world.spawnEntity(new EntitySoulOrb(this.world, this.posX, this.posY, this.posZ, EntitySoulOrb.TYPE.VAMPIRE));
  6. }
  7. }
  8. super.onDeathUpdate();
  9. }

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public void killMinecart(DamageSource source) {
  3. this.setDead();
  4. if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  5. ItemStack itemstack = getCartItem();
  6. if (this.hasCustomName()) {
  7. itemstack.setStackDisplayName(this.getCustomNameTag());
  8. }
  9. this.entityDropItem(itemstack, 0.0F);
  10. }
  11. }

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

  1. @Override
  2. public void killMinecart(DamageSource source) {
  3. this.setDead();
  4. if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  5. ItemStack itemstack = getCartItem();
  6. if (this.hasCustomName()) {
  7. itemstack.setStackDisplayName(this.getCustomNameTag());
  8. }
  9. this.entityDropItem(itemstack, 0.0F);
  10. }
  11. }

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

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

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

  1. @Override
  2. public void killMinecart(DamageSource source) {
  3. this.setDead();
  4. if (this.world.getGameRules().getBoolean("doEntityDrops")) {
  5. dropCartBlock();
  6. ItemStack itemstack = getCartItem();
  7. if (this.hasCustomName()) {
  8. itemstack.setStackDisplayName(this.getCustomNameTag());
  9. }
  10. this.entityDropItem(itemstack, 0.0F);
  11. }
  12. }

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

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

相关文章

World类方法