net.minecraftforge.fml.common.eventhandler.SubscribeEvent Java Examples
The following examples show how to use
net.minecraftforge.fml.common.eventhandler.SubscribeEvent.
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: Scheduler.java From SkyblockAddons with MIT License | 6 votes |
@SubscribeEvent() public void ticker(TickEvent.ClientTickEvent e) { if (e.phase == TickEvent.Phase.START) { totalTicks++; Set<Command> commands = queue.get(totalTicks); if (commands != null) { for (Command command : commands) { for (int times = 0; times < command.getCount().getValue(); times++) { command.getCommandType().execute(command, times+1); } } queue.remove(totalTicks); } if (totalTicks % 12000 == 0 || delayingMagmaCall) { // check magma boss every 15 minutes if (main.getPlayerListener().getMagmaAccuracy() != EnumUtils.MagmaTimerAccuracy.EXACTLY) { if (main.getUtils().isOnSkyblock()) { delayingMagmaCall = false; main.getUtils().fetchMagmaBossEstimate(); } else if (!delayingMagmaCall) { delayingMagmaCall = true; } } } ChromaManager.increment(); // Run every tick } }
Example #2
Source File: RenderListener.java From SkyblockAddons with MIT License | 6 votes |
@SubscribeEvent() public void onRenderLiving(RenderLivingEvent.Specials.Pre<EntityLivingBase> e) { Entity entity = e.entity; if (main.getConfigValues().isEnabled(Feature.MINION_DISABLE_LOCATION_WARNING) && entity.hasCustomName()) { if (entity.getCustomNameTag().startsWith("§cThis location isn\'t perfect! :(")) { e.setCanceled(true); } if (entity.getCustomNameTag().startsWith("§c/!\\")) { for (Entity listEntity : Minecraft.getMinecraft().theWorld.loadedEntityList) { if (listEntity.hasCustomName() && listEntity.getCustomNameTag().startsWith("§cThis location isn\'t perfect! :(") && listEntity.posX == entity.posX && listEntity.posZ == entity.posZ && listEntity.posY + 0.375 == entity.posY) { e.setCanceled(true); break; } } } } }
Example #3
Source File: PlayerListener.java From SkyblockAddons with MIT License | 6 votes |
/** * Reset all the timers and stuff when joining a new world. */ @SubscribeEvent() public void onWorldJoin(EntityJoinWorldEvent e) { if (e.entity == Minecraft.getMinecraft().thePlayer) { lastWorldJoin = System.currentTimeMillis(); lastBoss = -1; magmaTick = 1; timerTick = 1; main.getInventoryUtils().resetPreviousInventory(); recentlyLoadedChunks.clear(); countedEndermen.clear(); EndstoneProtectorManager.reset(); IslandWarpGui.Marker doubleWarpMarker = IslandWarpGui.getDoubleWarpMarker(); if (doubleWarpMarker != null) { IslandWarpGui.setDoubleWarpMarker(null); Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp "+doubleWarpMarker.getWarpName()); } } }
Example #4
Source File: PlayerListener.java From SkyblockAddons with MIT License | 6 votes |
/** * Block emptying of buckets separately because they aren't handled like blocks. * The event name {@code FillBucketEvent} is misleading. The event is fired when buckets are emptied also so * it should really be called {@code BucketEvent}. * * @param bucketEvent the event */ @SubscribeEvent public void onBucketEvent(FillBucketEvent bucketEvent) { ItemStack bucket = bucketEvent.current; EntityPlayer player = bucketEvent.entityPlayer; if (main.getUtils().isOnSkyblock() && player instanceof EntityPlayerSP) { if (main.getConfigValues().isEnabled(Feature.AVOID_PLACING_ENCHANTED_ITEMS)) { String skyblockItemId = ItemUtils.getSkyBlockItemID(bucket); if (skyblockItemId != null && skyblockItemId.equals("ENCHANTED_LAVA_BUCKET")) { bucketEvent.setCanceled(true); } } } }
Example #5
Source File: BlockyEntities.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent public static void onCollision(GetCollisionBoxesEvent e) { if (e.getEntity() != null) { for (BaseVehicleEntity bsv : e.getWorld().getEntitiesWithinAABB(BaseVehicleEntity.class, e.getAabb().grow(16))) { if (bsv != e.getEntity()) { for (BlockPos bp : bsv.getBlocks().keySet()) { if (bp != null) { bsv.getBlocks().get(bp).blockstate.addCollisionBoxToList(bsv.getStorage(), bsv.localBlockPosToGlobal(bp), e.getAabb(), e.getCollisionBoxesList(), e.getEntity(), false); } } } } } }
Example #6
Source File: SquashableMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent public static void onLivingUpdate(LivingEvent.LivingUpdateEvent event) { EntityLivingBase entity = event.getEntityLiving(); if (entity.world.isRemote) { return; } if (entity.collidedHorizontally && isBeingPushedByPiston(entity)) { Squashable squashable = entity.getCapability(squashableCap(), null); if (squashable == null) { return; } double[] pistonDeltas = getPistonDeltas(entity); double pushedAngle = Math.atan2(pistonDeltas[2], pistonDeltas[0]); EnumFacing.Axis faceAxis = EnumFacing.fromAngle(entity.rotationYaw).getAxis(); EnumFacing.Axis pushAxis = EnumFacing.fromAngle(pushedAngle).getAxis(); EnumFacing.Axis squashAxis = faceAxis == pushAxis ? EnumFacing.Axis.Z : EnumFacing.Axis.X; squashable.squash(squashAxis); NETWORK.sendToAllTracking(new SquashEntityMessage(entity, squashAxis), entity); } }
Example #7
Source File: CommunityMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void onItemTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if (!stack.isEmpty() && CommunityGlobals.MOD_ID.equals(stack.getItem().getRegistryName().getNamespace())) { SubModContainer subMod = SubModLoader.getSubModOrigin(stack.getItem()); if (subMod != null) { event.getToolTip().add(TextFormatting.DARK_GRAY + "(" + subMod.getName() + " - " + subMod.getAttribution() + ")"); } } }
Example #8
Source File: CommonProxy.java From TofuCraftReload with MIT License | 6 votes |
@SubscribeEvent public static void registerRecipes(RegistryEvent.Register<IRecipe> event) { //boildEdamame GameRegistry.addSmelting( new ItemStack(ItemLoader.material,1,3), new ItemStack(ItemLoader.foodset,16,22), 0.25f); //SoyBeenParched GameRegistry.addSmelting( new ItemStack(ItemLoader.soybeans,1), new ItemStack(ItemLoader.material,1,6), 0.2f); GameRegistry.addSmelting( new ItemStack(ItemLoader.material,1,13), new ItemStack(ItemLoader.material,1,14), 0.2f); RecipesUtil.addOreDictionarySmelting("listAlltofu", new ItemStack(ItemLoader.tofu_food,1,3), 0.2f); GameRegistry.addSmelting(new ItemStack(ItemLoader.tofu_food,1,2), new ItemStack(ItemLoader.foodset,1,16), 0.2f); GameRegistry.addSmelting(new ItemStack(ItemLoader.material,1,20), new ItemStack(ItemLoader.foodset,1,8), 0.2f); GameRegistry.addSmelting(new ItemStack(ItemLoader.foodset,1,11), new ItemStack(ItemLoader.foodset,1,12), 0.2f); RecipesUtil.addOreDictionarySmelting("listAlltofuBlock", new ItemStack(BlockLoader.GRILD), 0.6f); }
Example #9
Source File: NewScheduler.java From SkyblockAddons with MIT License | 5 votes |
@SubscribeEvent public void ticker(TickEvent.ClientTickEvent event) { if (event.phase == TickEvent.Phase.START) { synchronized (this.anchor) { this.totalTicks++; this.currentTicks++; } if (Minecraft.getMinecraft() != null) { this.pendingTasks.removeIf(ScheduledTask::isCompleted); this.pendingTasks.addAll(queuedTasks); queuedTasks.clear(); try { for (ScheduledTask scheduledTask : this.pendingTasks) { if (this.getTotalTicks() >= (scheduledTask.getAddedTicks() + scheduledTask.getDelay())) { if (!scheduledTask.isCanceled()) { scheduledTask.start(); if (!scheduledTask.isCompleted() && scheduledTask.getPeriod() > 0) { scheduledTask.setDelay(scheduledTask.getPeriod()); } } } } } catch (Throwable ex) { ex.printStackTrace(); } } } }
Example #10
Source File: CellDataStorage.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLoad(WorldEvent.Load event) { if (event.getWorld().isRemote) return; if (event.getWorld().provider.getDimensionType() != StorageDimReg.storageDimensionType) return; MapStorage storage = event.getWorld().getPerWorldStorage(); CellSavedWorldData instance = (CellSavedWorldData) storage.getOrLoadData(CellSavedWorldData.class, DATA_NAME); }
Example #11
Source File: NetworkListener.java From SkyblockAddons with MIT License | 5 votes |
@SubscribeEvent public void onSkyblockLeft(SkyblockLeftEvent event) { logger.info("Left Skyblock"); main.getUtils().setOnSkyblock(false); if (main.getDiscordRPCManager().isActive()) { main.getDiscordRPCManager().stop(); } }
Example #12
Source File: RenderListener.java From SkyblockAddons with MIT License | 5 votes |
/** * Render overlays and warnings for clients without labymod. */ @SubscribeEvent() public void onRenderRegular(RenderGameOverlayEvent.Post e) { if ((!main.isUsingLabymod() || Minecraft.getMinecraft().ingameGUI instanceof GuiIngameForge)) { if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || e.type == RenderGameOverlayEvent.ElementType.JUMPBAR) { if (main.getUtils().isOnSkyblock()) { renderOverlays(); renderWarnings(e.resolution); } else { renderTimersOnly(); } drawUpdateMessage(); } } }
Example #13
Source File: RenderListener.java From SkyblockAddons with MIT License | 5 votes |
/** * Render overlays and warnings for clients with labymod. * Labymod creates its own ingame gui and replaces the forge one, and changes the events that are called. * This is why the above method can't work for both. */ @SubscribeEvent() public void onRenderLabyMod(RenderGameOverlayEvent e) { if (e.type == null && main.isUsingLabymod()) { if (main.getUtils().isOnSkyblock()) { renderOverlays(); renderWarnings(e.resolution); } else { renderTimersOnly(); } drawUpdateMessage(); } }
Example #14
Source File: ModGenuinePeoplePersonalities.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public static void onBlockPlace(BlockEvent.PlaceEvent event) { EventData data = new EventData(event); if (data.getPlayer() == null || data.getPlayer().world.isRemote) return; if (!testCooldown(data.getPlayer())) return; if (generateComplaint(StringType.PLACE, data.getPlayer(), data.getBlock(), data)) { resetCooldown(data.getPlayer()); } }
Example #15
Source File: RenderListener.java From SkyblockAddons with MIT License | 5 votes |
@SubscribeEvent() public void onRender(TickEvent.RenderTickEvent e) { if (guiToOpen == EnumUtils.GUIType.MAIN) { Minecraft.getMinecraft().displayGuiScreen(new SkyblockAddonsGui(guiPageToOpen, guiTabToOpen)); } else if (guiToOpen == EnumUtils.GUIType.EDIT_LOCATIONS) { Minecraft.getMinecraft().displayGuiScreen(new LocationEditGui(main, guiPageToOpen, guiTabToOpen)); } else if (guiToOpen == EnumUtils.GUIType.SETTINGS) { Minecraft.getMinecraft().displayGuiScreen(new SettingsGui(guiFeatureToOpen, 1, guiPageToOpen, guiTabToOpen, guiFeatureToOpen.getSettings())); } else if (guiToOpen == EnumUtils.GUIType.WARP) { Minecraft.getMinecraft().displayGuiScreen(new IslandWarpGui()); } guiToOpen = null; }
Example #16
Source File: PlayerListener.java From SkyblockAddons with MIT License | 5 votes |
/** * Keep track of recently loaded chunks for the magma boss timer. */ @SubscribeEvent() public void onChunkLoad(ChunkEvent.Load e) { if (main.getUtils().isOnSkyblock()) { int x = e.getChunk().xPosition; int z = e.getChunk().zPosition; IntPair coords = new IntPair(x, z); recentlyLoadedChunks.add(coords); main.getScheduler().schedule(Scheduler.CommandType.DELETE_RECENT_CHUNK, 20, x, z); } }
Example #17
Source File: ModGenuinePeoplePersonalities.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public static void onItemActivated(PlayerInteractEvent.RightClickItem event) { EventData data = new EventData(event); if (data.getPlayer() == null || data.getPlayer().world.isRemote) return; if (!testCooldown(data.getPlayer())) return; if (generateComplaint(StringType.ACTIVATE, data.getPlayer(), event.getItemStack(), data)) { resetCooldown(data.getPlayer()); } }
Example #18
Source File: PlayerMessager.java From MediaMod with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void tick(TickEvent.ClientTickEvent event) { if (Minecraft.getMinecraft().thePlayer == null) { return; } while (!messages.isEmpty()) { Minecraft.getMinecraft().thePlayer.addChatComponentMessage(messages.poll()); } while (!queuedMessages.isEmpty()) { sendMessage(queuedMessages.poll()); } }
Example #19
Source File: TileEntitySenderBase.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public static void onLoaded(TofuNetworkChangedEvent.NetworkLoaded event) { List<TileEntity> tes = TofuNetwork.toTiles( TofuNetwork.Instance.getReference() .entrySet() .stream() .filter(entry -> entry.getValue() instanceof TileEntitySenderBase && ((TileEntitySenderBase) entry.getValue()).isValid())); tes.forEach(te -> ((TileEntitySenderBase) te).onCache()); }
Example #20
Source File: TileEntitySenderBase.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public static void onRemoved(TofuNetworkChangedEvent.NetworkRemoved event) { List<TileEntity> tes = TofuNetwork.toTiles( TofuNetwork.Instance.getReference() .entrySet() .stream() .filter(entry -> entry.getValue() instanceof TileEntitySenderBase && ((TileEntitySenderBase) entry.getValue()).isValid())); tes.forEach(te -> ((TileEntitySenderBase) te).onCache()); }
Example #21
Source File: TofuNetwork.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public static void onUnloadWorld(WorldEvent.Unload event) { World world = event.getWorld(); for (String uid : toUUIDs(Instance.getTEWithinDim(world.provider.getDimension()))) { //It is a world unload, so isSystem is here to prevent bugs from misdetailed event. Instance.unload(uid, true); } }
Example #22
Source File: SlashBladeCompat.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public void InitIshiKatana(InitEvent event){ String name = "slashblade.tofucraft.ishikatana"; ItemStack customblade = new ItemStack(SlashBlade.bladeNamed,1,0); NBTTagCompound tag = new NBTTagCompound(); customblade.setTagCompound(tag); ItemSlashBladeNamed.CurrentItemName.set(tag, name); ItemSlashBladeNamed.CustomMaxDamage.set(tag, Integer.valueOf(183)); ItemSlashBlade.setBaseAttackModifier(tag, 3F); ItemSlashBlade.TextureName.set(tag,"tofuishi_katana"); SlashBlade.registerCustomItemStack(name, customblade); ItemSlashBladeNamed.NamedBlades.add(name); }
Example #23
Source File: SlashBladeCompat.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public void InitMetalKatana(InitEvent event){ String name = "slashblade.tofucraft.metalkatana"; ItemStack customblade = new ItemStack(SlashBlade.bladeNamed,1,0); NBTTagCompound tag = new NBTTagCompound(); customblade.setTagCompound(tag); ItemSlashBladeNamed.CurrentItemName.set(tag, name); ItemSlashBladeNamed.CustomMaxDamage.set(tag, Integer.valueOf(415)); ItemSlashBlade.setBaseAttackModifier(tag, 6F); ItemSlashBlade.TextureName.set(tag,"tofumetal_katana"); SlashBlade.registerCustomItemStack(name, customblade); ItemSlashBladeNamed.NamedBlades.add(name); }
Example #24
Source File: SlashBladeCompat.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public void InitDiamondKatana(InitEvent event){ String name = "slashblade.tofucraft.diamondkatana"; ItemStack customblade = new ItemStack(SlashBlade.bladeNamed,1,0); NBTTagCompound tag = new NBTTagCompound(); customblade.setTagCompound(tag); ItemSlashBladeNamed.CurrentItemName.set(tag, name); ItemSlashBladeNamed.CustomMaxDamage.set(tag, Integer.valueOf(0x1212)); ItemSlashBlade.setBaseAttackModifier(tag, 8F); ItemSlashBlade.TextureName.set(tag,"tofudiamond_katana"); SlashBlade.registerCustomItemStack(name, customblade); ItemSlashBladeNamed.NamedBlades.add(name); }
Example #25
Source File: ElectricBoogaloo.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void itemToolTipEvent(ItemTooltipEvent event) { if (twosList == null || twosList.length < 1 || event.getToolTip().isEmpty()) return; boolean isPotion = event.getItemStack().getItem() instanceof ItemPotion || event.getItemStack().getItem() instanceof ItemArrow; for (int i = 0; i < event.getToolTip().size(); i++) { String toolTip = event.getToolTip().get(i); String lowerTip = toolTip.toLowerCase(); boolean relocateReset = false; if (lowerTip.endsWith("§r")) { lowerTip = lowerTip.substring(0, lowerTip.length() - 2); toolTip = toolTip.substring(0, toolTip.length() - 2); relocateReset = true; } for (String to : twosList) { String boogaloo = null; if (isPotion && TIMER_PATTERN.matcher(lowerTip).find()) { String potionName = lowerTip.substring(0, lowerTip.indexOf('(') - 1); if (potionName.endsWith(to)) { int index = toolTip.indexOf('(') - 1; String beforeTimer = toolTip.substring(0, index); String timer = toolTip.substring(index); boogaloo = I18n.format("tooltip.community_mod.electric", beforeTimer) + timer; } } if (lowerTip.endsWith(to)) { boogaloo = I18n.format("tooltip.community_mod.electric", toolTip); if (relocateReset) boogaloo += "§r"; } if (!Strings.isNullOrEmpty(boogaloo)) event.getToolTip().set(i, boogaloo); } } }
Example #26
Source File: SquashableMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onEntityTrack(PlayerEvent.StartTracking event) { Entity target = event.getTarget(); Squashable squashable = target.getCapability(squashableCap(), null); if (squashable == null) { return; } EnumFacing.Axis squashedAxis = squashable.getSquashedAxis(); if (squashedAxis != null) { NETWORK.sendTo(new SquashEntityMessage(target, squashedAxis), (EntityPlayerMP) event.getEntityPlayer()); } }
Example #27
Source File: ModGenuinePeoplePersonalities.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public static void onFarmlandTrample(BlockEvent.FarmlandTrampleEvent event) { EventData data = new EventData(event); if (data.getPlayer() == null || data.getPlayer().world.isRemote) return; if (!testCooldown(data.getPlayer())) return; if (generateComplaint(StringType.TRAMPLE, data.getPlayer(), data.getBlock(), data)) { resetCooldown(data.getPlayer()); } }
Example #28
Source File: InfinitePain.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLandingCreative(PlayerFlyableFallEvent event) { EntityLivingBase elb = event.getEntityLiving(); if(elb.hasItemInSlot(EntityEquipmentSlot.FEET) && elb.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem() == PAIN_BOOTS) { if(event.getDistance() >= minTriggerHeight) { boolean notObstructed = true; double impactPosition = 0; for(int i = (int) elb.posY + 2; i < elb.world.provider.getHeight(); i++) { BlockPos pos = new BlockPos(elb.posX, i, elb.posZ); IBlockState state = elb.world.getBlockState(pos); if(state.isFullBlock() || state.isFullCube()) { notObstructed = false; impactPosition = i; break; } } if(notObstructed) { elb.setPositionAndUpdate(elb.posX, elb.world.provider.getHeight() + heightToAdd, elb.posZ); } else { elb.addVelocity(0, (impactPosition - elb.posY) / 2, 0); } } } }
Example #29
Source File: TofuEventLoader.java From TofuCraftReload with MIT License | 5 votes |
@SubscribeEvent public void decorateBiome(DecorateBiomeEvent.Post event) { World worldObj = event.getWorld(); Random rand = event.getRand(); @SuppressWarnings("deprecation") BlockPos pos = event.getPos(); // Hellsoybeans if (rand.nextInt(600) < Math.min((Math.abs(pos.getX()) + Math.abs(pos.getZ())) / 2, 400) - 100) { if (Biome.getIdForBiome(worldObj.getBiome(pos)) == Biome.getIdForBiome(Biomes.HELL)) { int k = pos.getX(); int l = pos.getZ(); BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); for (int i = 0; i < 10; ++i) { int j1 = k + rand.nextInt(16) + 8; int k1 = rand.nextInt(128); int l1 = l + rand.nextInt(16) + 8; mutable.setPos(j1, k1, l1); (new WorldGenCrops((BlockBush)BlockLoader.SOYBEAN_NETHER) { @Override protected IBlockState getStateToPlace() { return this.plantBlock.getDefaultState().withProperty(BlockSoybeanNether.AGE, 7); } }) .generate(worldObj, rand, mutable); } } } }
Example #30
Source File: InfinitePain.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void onLanding(LivingFallEvent event) { EntityLivingBase elb = event.getEntityLiving(); if(elb.hasItemInSlot(EntityEquipmentSlot.FEET) && elb.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem() == PAIN_BOOTS) { if(event.getDistance() >= minTriggerHeight) { boolean notObstructed = true; double impactPosition = 0; for(int i = (int) elb.posY + 2; i < elb.world.provider.getHeight(); i++) { BlockPos pos = new BlockPos(elb.posX, i, elb.posZ); IBlockState state = elb.world.getBlockState(pos); if(state.isFullBlock() || state.isFullCube()) { notObstructed = false; impactPosition = i; break; } } if(notObstructed) { elb.setPositionAndUpdate(elb.posX, elb.world.provider.getHeight() + heightToAdd, elb.posZ); event.setDamageMultiplier(0); } else { elb.addVelocity(0, (impactPosition - elb.posY) / 2, 0); elb.attackEntityFrom(DamageSource.GENERIC, damageOnImpact); event.setDamageMultiplier(0); } } } }