Java Code Examples for net.minecraftforge.fml.common.gameevent.TickEvent#WorldTickEvent
The following examples show how to use
net.minecraftforge.fml.common.gameevent.TickEvent#WorldTickEvent .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaMod.java From MediaMod with GNU General Public License v3.0 | 6 votes |
/** * Fired when the world fires a tick * * @param event WorldTickEvent * @see net.minecraftforge.fml.common.gameevent.TickEvent.WorldTickEvent */ @SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent event) { if (firstLoad && !VersionChecker.INSTANCE.IS_LATEST_VERSION && Minecraft.getMinecraft().thePlayer != null) { PlayerMessager.sendMessage("&cMediaMod is out of date!" + "\n&7Latest Version: &r&lv" + VersionChecker.INSTANCE.LATEST_VERSION_INFO.latestVersionS + "\n&7Changelog: &r&l" + VersionChecker.INSTANCE.LATEST_VERSION_INFO.changelog); /*IChatComponent urlComponent = new ChatComponentText(ChatColor.GRAY + "" + ChatColor.BOLD + "Click this to automatically update now!"); urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "mediamodupdate")); urlComponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(ChatColor.translateAlternateColorCodes('&', "&7Runs /mediamodupdate")))); PlayerMessager.sendMessage(urlComponent);*/ firstLoad = false; } }
Example 2
Source File: ClayRainMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent public void rain(TickEvent.WorldTickEvent e) { if (e.world.isRaining()) { if (e.world.rand.nextInt(5) == 0) { for (EntityPlayer player : e.world.playerEntities) { if (e.world.getBiome(player.getPosition()).canRain()) { double x = e.world.rand.nextInt(maxRange * 2) - maxRange; double y = 255; if (player.posY < 100) y = 130; double z = e.world.rand.nextInt(maxRange * 2) - maxRange; EntityItem clay = new EntityItem(e.world, x + player.posX, y, z + player.posZ, new ItemStack(Items.CLAY_BALL)); clay.lifespan = 200; e.world.spawnEntity(clay); } } } } }
Example 3
Source File: EntityFairy.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public static void onStun(TickEvent.WorldTickEvent event) { if (event.side == Side.CLIENT) return; for (EntityFairy fairy : event.world.getEntities(EntityFairy.class, input -> input != null && !input.isDead)) { fairy.stunned = false; secondary: for (EntityPlayer player : event.world.getEntitiesWithinAABB(EntityPlayer.class, fairy.getEntityBoundingBox().grow(5))) { for (EnumHand hand : EnumHand.values()) { ItemStack stack = player.getHeldItem(hand); if (stack.getItem() == ModItems.FAIRY_BELL) { fairy.stunned = true; break secondary; } } } } }
Example 4
Source File: EventManager.java From Logistics-Pipes-2 with MIT License | 6 votes |
@SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent event){ if (!event.world.isRemote && event.phase == TickEvent.Phase.END){ NBTTagList list = new NBTTagList(); TileEntity[] updateArray = toUpdate.values().toArray(new TileEntity[toUpdate.size()]); for (int i = 0; i < updateArray.length; i ++){ TileEntity t = updateArray[i]; if (!event.world.isRemote){ list.appendTag(t.getUpdateTag()); } } if (!list.hasNoTags()){ NBTTagCompound tag = new NBTTagCompound(); tag.setTag("data", list); LPPacketHandler.INSTANCE.sendToAll(new MessagePipeContentUpdate(tag)); } toUpdate.clear(); } }
Example 5
Source File: NemezEventHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public static void worldTick(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.START) reversals.removeIf((reversal) -> { if (reversal.world.get() == event.world) { if (reversal.nemez.hasNext()) { reversal.nemez.applySnapshot(event.world); if (reversal.pos != null && reversal.world.get().getTotalWorldTime() % PacketNemezReversal.SYNC_AMOUNT == 0) PacketHandler.NETWORK.sendToAllAround(new PacketNemezReversal(reversal.nemez), new NetworkRegistry.TargetPoint(reversal.world.get().provider.getDimension(), reversal.pos.getX() + 0.5, reversal.pos.getY() + 0.5, reversal.pos.getZ() + 0.5, 96)); } else { for (Entity entity : reversal.nemez.getTrackedEntities(event.world)) entity.setNoGravity(false); return true; } } return reversal.world.get() == null; }); }
Example 6
Source File: TofuEventLoader.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public void worldTick(TickEvent.WorldTickEvent event) { String s = TofuVillageCollection.fileNameForProvider(event.world.provider); TofuVillageCollection tofuVillageCollection = (TofuVillageCollection) event.world.getPerWorldStorage().getOrLoadData(TofuVillageCollection.class, s); if (tofuVillageCollection != null) { tofuVillageCollection.tick(); } }
Example 7
Source File: WorldExtensionManager.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public void serverTick(TickEvent.WorldTickEvent event) { if(!worldMap.containsKey(event.world)) WorldExtensionManager.onWorldLoad(event.world); if(event.phase == TickEvent.Phase.START) preTick(event.world); else postTick(event.world); }
Example 8
Source File: WorldRetrogen.java From simpleretrogen with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void tickStart(TickEvent.WorldTickEvent tick) { World w = tick.world; if (!(w instanceof WorldServer)) { return; } if (tick.phase == TickEvent.Phase.START) { counter = 0; getSemaphoreFor(w); } else { ListMultimap<ChunkPos, String> pending = pendingWork.get(w); if (pending == null) { return; } ImmutableList<Entry<ChunkPos, String>> forProcessing = ImmutableList.copyOf(Iterables.limit(pending.entries(), maxPerTick + 1)); for (Entry<ChunkPos, String> entry : forProcessing) { if (counter++ > maxPerTick) { FMLLog.fine("Completed %d retrogens this tick. There are %d left for world %s", counter, pending.size(), w.getWorldInfo().getWorldName()); return; } runRetrogen((WorldServer)w, entry.getKey(), entry.getValue()); } } }
Example 9
Source File: PlanetEventHandler.java From AdvancedRocketry with MIT License | 5 votes |
@SubscribeEvent public void serverTickEvent(TickEvent.WorldTickEvent event) { if(zmaster587.advancedRocketry.api.Configuration.allowTerraforming && event.world.provider.getClass() == WorldProviderPlanet.class) { if(DimensionManager.getInstance().getDimensionProperties(event.world.provider.getDimension()).isTerraformed()) { Collection<Chunk> list = ((WorldServer)event.world).getChunkProvider().getLoadedChunks(); if(list.size() > 0) { try { int listSize = list.size(); for(Chunk chunk : list) { if(Configuration.terraformingBlockSpeed > listSize || event.world.rand.nextFloat() < Configuration.terraformingBlockSpeed/(float)listSize) { int coord = event.world.rand.nextInt(256); int x = (coord & 0xF) + chunk.x*16; int z = (coord >> 4) + chunk.z*16; BiomeHandler.changeBiome(event.world, Biome.getIdForBiome(((ChunkManagerPlanet)((WorldProviderPlanet)event.world.provider).chunkMgrTerraformed).getBiomeGenAt(x,z)), x, z); } } } catch (NullPointerException e) { //Ghost } } } } }
Example 10
Source File: ServerHandler.java From NotEnoughItems with MIT License | 5 votes |
@SubscribeEvent public void tickEvent(TickEvent.WorldTickEvent event) { if (event.phase == Phase.START && !event.world.isRemote && NEIServerConfig.dimTags.containsKey(event.world.provider.getDimension()))//fake worlds that don't call Load { processDisabledProperties(event.world); } }
Example 11
Source File: LPWorldGen.java From Logistics-Pipes-2 with MIT License | 5 votes |
@SubscribeEvent public void serverWorldTick(TickEvent.WorldTickEvent event) { if(event.side==Side.CLIENT || event.phase==TickEvent.Phase.START) { return; } int dimension = event.world.provider.getDimension(); int counter = 0; List<ChunkPos> chunks = retrogenChunks.get(dimension); if(chunks!=null && !chunks.isEmpty()) { for(int i=0; i<2; i++) { chunks = retrogenChunks.get(dimension); if(chunks == null || chunks.isEmpty()) { break; } counter++; ChunkPos loc = chunks.get(0); long worldSeed = event.world.getSeed(); Random fmlRandom = new Random(worldSeed); long xSeed = (fmlRandom.nextLong()>>3); long zSeed = (fmlRandom.nextLong()>>3); fmlRandom.setSeed(xSeed * loc.x + zSeed * loc.z ^ worldSeed); this.generateOres(fmlRandom, loc.x, loc.z, event.world, false); chunks.remove(0); } } if(counter>0 && Config.retrogenRemaining) { LogisticsPipes2.logger.info("Retrogen was performed on "+counter+" Chunks, "+Math.max(0, chunks.size())+" chunks remaining"); } }
Example 12
Source File: LightningTracker.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void tick(TickEvent.WorldTickEvent event) { newEntries.forEach(e -> entityToEntry.put(e.getTarget(), e)); newEntries.clear(); entityToEntry.keySet().removeIf(entity -> { TrackingEntry entry = entityToEntry.get(entity); Entity caster = entry.getCaster(); int ticks = entry.getTicks(); double potency = entry.getPotency(); double duration = entry.getDuration(); if (ticks > 0) { entry.setTicks(ticks - 1); return false; } entity.setFire((int) duration); int invTime = entity.hurtResistantTime; entity.hurtResistantTime = 0; if (caster instanceof EntityPlayer) entity.attackEntityFrom(new EntityDamageSource("lightningbolt", caster), (float) potency); else entity.attackEntityFrom(DamageSource.LIGHTNING_BOLT, (float) potency); entity.hurtResistantTime = invTime; return true; }); }
Example 13
Source File: VanishTracker.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void vanishTicker(TickEvent.WorldTickEvent event) { if (event.phase != TickEvent.Phase.END) return; if (event.type != TickEvent.Type.WORLD) return; if (event.side != Side.SERVER) return; final int sizeAddsBefore = adds.size(); final int sizeVanishesBefore = vanishes.size(); for (VanishedObject entry; ((entry = adds.pollFirst()) != null); ) { vanishes.add(entry); } vanishes.removeIf(entry -> { if (--entry.tick < 0) { Entity e = event.world.getEntityByID(entry.entityID); if (e != null && !event.world.isRemote) { event.world.playSound(null, e.getPosition(), ModSounds.ETHEREAL_PASS_BY, SoundCategory.NEUTRAL, 0.5f, 1); } return true; } return false; }); final int sizeAddsAfter = adds.size(); final int sizeVanishesAfter = vanishes.size(); if (!event.world.isRemote && sizeAddsAfter != sizeAddsBefore || sizeVanishesAfter != sizeVanishesBefore) { PacketHandler.NETWORK.sendToAll(new PacketSyncVanish(serialize())); } }
Example 14
Source File: ManaTickHandler.java From YouTubeModdingTutorial with MIT License | 5 votes |
@SubscribeEvent public void onWorldTick(TickEvent.WorldTickEvent evt) { if (evt.phase == TickEvent.Phase.START) { return; } World world = evt.world; WorldMana.get(world).tick(world); }
Example 15
Source File: WorldTickHandler.java From YouTubeModdingTutorial with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(TickEvent.WorldTickEvent event) { if (event.side != Side.SERVER) { return; } if (event.phase == TickEvent.Phase.END) { World world = event.world; int dim = world.provider.getDimension(); ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim); if (chunks != null && !chunks.isEmpty()) { ChunkPos c = chunks.pollFirst(); long worldSeed = world.getSeed(); Random rand = new Random(worldSeed); long xSeed = rand.nextLong() >> 2 + 1L; long zSeed = rand.nextLong() >> 2 + 1L; rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed); OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false); chunksToGen.put(dim, chunks); } else if (chunks != null) { chunksToGen.remove(dim); } } }
Example 16
Source File: TaskScheduler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void onWorldTick(TickEvent.WorldTickEvent event) { if(!event.world.isRemote) { List<Task> taskList = tasksPerWorld.getOrDefault(event.world, Collections.emptyList()); taskList.removeIf(task -> !task.run()); } }
Example 17
Source File: WorldTickHandler.java From EmergingTechnology with MIT License | 5 votes |
@SubscribeEvent public void tickEnd(TickEvent.WorldTickEvent event) { if (event.side != Side.SERVER) { return; } if (event.phase == TickEvent.Phase.END) { World world = event.world; int dim = world.provider.getDimension(); ArrayDeque<ChunkPos> chunks = chunksToGen.get(dim); if (chunks != null && !chunks.isEmpty()) { ChunkPos c = chunks.pollFirst(); long worldSeed = world.getSeed(); Random rand = new Random(worldSeed); long xSeed = rand.nextLong() >> 2 + 1L; long zSeed = rand.nextLong() >> 2 + 1L; rand.setSeed(xSeed * c.x + zSeed * c.z ^ worldSeed); OreGenerator.instance.generateWorld(rand, c.x, c.z, world, false); chunksToGen.put(dim, chunks); } else if (chunks != null) { chunksToGen.remove(dim); } } }
Example 18
Source File: EventHandler.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent public void tickEvent(TickEvent.WorldTickEvent event) { if (event.phase == TickEvent.Phase.END && event.side == Side.SERVER) { FluidTracker.INSTANCE.tick(event.world); } }
Example 19
Source File: ServerHandler.java From NotEnoughItems with MIT License | 4 votes |
@SubscribeEvent public void tickEvent(TickEvent.WorldTickEvent event) { if (event.phase == Phase.START && !event.world.isRemote && NEIServerConfig.dimTags.containsKey(event.world.provider.getDimensionId()))//fake worlds that don't call Load processDisabledProperties(event.world); }