@SuppressWarnings({"ReturnOfNull", "ConstantConditions"}) @Override public IMessage onMessage(SpawnCustomParticleMessage message, MessageContext ctx) { final ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; final IForgeRegistry<ICustomParticleFactory> registry = GameRegistry.findRegistry(ICustomParticleFactory.class); final ICustomParticleFactory factory = registry.getValue(message.getParticleResourceLocation()); final Particle particle = factory.getParticleFactory().createParticle(-1, Minecraft.getMinecraft().thePlayer.worldObj, message.getXCoordinate(), message.getYCoordinate(), message.getZCoordinate(), message.getParticleSpeed(), message.getParticleSpeed(), message.getParticleSpeed(), message.getParticleArgs() ); effectRenderer.addEffect(particle); return null; }
@SuppressWarnings({"ReturnOfNull", "ConstantConditions"}) @Override public IMessage onMessage(PlayCustomSoundMessage message, MessageContext ctx) { final IForgeRegistry<SoundEvent> registry = GameRegistry.findRegistry(SoundEvent.class); Minecraft.getMinecraft().thePlayer.worldObj.playSound( message.getPosX(), message.getPosY(), message.getPosZ(), registry.getValue(message.getSoundEvent()), message.getCategory(), message.getVolume(), message.getPitch(), message.shouldDistanceDelay() ); return null; }
@SubscribeEvent(priority = EventPriority.HIGH) public static void registerDarkSteelUpgrades(@Nonnull RegistryEvent.Register<IDarkSteelUpgrade> event) { final IForgeRegistry<IDarkSteelUpgrade> registry = event.getRegistry(); registry.register(EnergyUpgrade.EMPOWERED); registry.register(EnergyUpgrade.EMPOWERED_TWO); registry.register(EnergyUpgrade.EMPOWERED_THREE); registry.register(EnergyUpgrade.EMPOWERED_FOUR); registry.register(JumpUpgrade.JUMP_ONE); registry.register(JumpUpgrade.JUMP_TWO); registry.register(JumpUpgrade.JUMP_THREE); registry.register(SpeedUpgrade.SPEED_ONE); registry.register(SpeedUpgrade.SPEED_TWO); registry.register(SpeedUpgrade.SPEED_THREE); registry.register(GliderUpgrade.INSTANCE); registry.register(ElytraUpgrade.INSTANCE); registry.register(SoundDetectorUpgrade.INSTANCE); registry.register(SwimUpgrade.INSTANCE); registry.register(NightVisionUpgrade.INSTANCE); registry.register(TravelUpgrade.INSTANCE); registry.register(SpoonUpgrade.INSTANCE); registry.register(ExplosiveUpgrade.INSTANCE); }
/** * Register IForgeRegistryEntries in registry * @param features Class with IForgeRegistryEntries * @param registry Registry to where the entries should get registered * @param <T> IForgeRegistryEntry<T> */ public static <T extends IForgeRegistryEntry<T>> void register(Class features, IForgeRegistry<T> registry){ Field[] fields = features.getDeclaredFields(); for (Field field : fields) { if (field.isAnnotationPresent(Feature.class) && registry.getRegistrySuperType().isAssignableFrom(field.getType())){ try { registry.register((T) field.get(null)); MrglgaghCore.logger.info(field.getName() + " registered!"); } catch (IllegalAccessException | IllegalArgumentException e) { MrglgaghCore.logger.error("Can't access feature field: " + field.getName() + ". Make sure it is public static!", e); } } } }
@SubscribeEvent @Optional.Method(modid = ChanceCubesReference.CHANCE_CUBES_MODID) public static void onRegisterSounds(RegistryEvent.Register<SoundEvent> event) { final IForgeRegistry<SoundEvent> registry = event.getRegistry(); registry.register(new SoundEvent(ChanceCubeSheepDied).setRegistryName(ChanceCubeSheepDied)); registry.register(new SoundEvent(ChanceCubeGiantCubeSpawned).setRegistryName(ChanceCubeGiantCubeSpawned)); }
@SubscribeEvent @Optional.Method(modid = ChanceCubesReference.CHANCE_CUBES_MODID) public static void onRegisterCustomParticles(RegistryEvent.Register<ICustomParticleFactory> event) { final IForgeRegistry<ICustomParticleFactory> registry = event.getRegistry(); registry.register(new SheepHeadParticle.Factory() .setRegistryName(new ResourceLocation(CommonReference.MOD_ID, "sheep_head")) ); }
@SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { LOG.info("Registering blocks"); IForgeRegistry<Block> registry = event.getRegistry(); GeoBlocks.BLOCKS.forEach(registry::register); }
@SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { LOG.info("Registering items"); IForgeRegistry<Item> registry = event.getRegistry(); GeoItems.ITEMS.forEach(registry::register); }
private static List<ResourceLocation> createAllowedValues(IForgeRegistry<?> registry) { List<ResourceLocation> values = Lists.newArrayList(registry.getKeys()); Collections.sort(values, new Comparator<ResourceLocation>() { @Override public int compare(ResourceLocation first, ResourceLocation second) { return String.CASE_INSENSITIVE_ORDER.compare(first.toString(), second.toString()); } }); return values; }
/** * Register this mod's {@link Block}s. * * @param event The event */ @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { final IForgeRegistry<Block> registry = event.getRegistry(); final Block[] blocks = {SIGN_STANDING_WOOD, SIGN_WALL_WOOD, SIGN_STANDING_METAL, SIGN_WALL_METAL}; registry.registerAll(blocks); }
/** * Register this mod's {@link ItemBlock}s. * * @param event The event */ @SubscribeEvent public static void registerItemBlocks(RegistryEvent.Register<Item> event) { final ItemBlock[] items = { }; final IForgeRegistry<Item> registry = event.getRegistry(); for (final ItemBlock item : items) { registry.register(item.setRegistryName(item.getBlock().getRegistryName())); ITEM_BLOCKS.add(item); } }
/** * Register this mod's {@link Item}s. * * @param event The event */ @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { NuggetRegistry.init(); final Item[] items = {SIGN, DEBUG, NUGGET, SIGN_TOOLBOX}; final IForgeRegistry<Item> registry = event.getRegistry(); for (final Item item : items) { registry.register(item); ITEMS.add(item); } }
@SubscribeEvent public static void registerDarkSteelUpgrades(@Nonnull RegistryEvent.Register<IDarkSteelUpgrade> event) { final IForgeRegistry<IDarkSteelUpgrade> registry = event.getRegistry(); registry.register(SolarUpgrade.SOLAR1); registry.register(SolarUpgrade.SOLAR2); registry.register(SolarUpgrade.SOLAR3); }
@SubscribeEvent public static void registerDarkSteelUpgrades(@Nonnull RegistryEvent.Register<IDarkSteelUpgrade> event) { final IForgeRegistry<IDarkSteelUpgrade> registry = event.getRegistry(); registry.register(new NaturalistEyeUpgrade()); registry.register(new ApiaristArmorUpgrade(EntityEquipmentSlot.FEET)); registry.register(new ApiaristArmorUpgrade(EntityEquipmentSlot.LEGS)); registry.register(new ApiaristArmorUpgrade(EntityEquipmentSlot.CHEST)); registry.register(new ApiaristArmorUpgrade(EntityEquipmentSlot.HEAD)); Log.info("Dark Steel Upgrades: Forestry integration loaded"); }
public static void injectBlocks(@Nonnull IForgeRegistry<Block> registry) { registry.register(Glowstone.createGlowstone()); registry.register(Redstone.createRedstone()); registry.register(Ender.createEnder()); NNList.of(Alloy.class).apply(new Callback<Alloy>() { @Override public void apply(@Nonnull Alloy alloy) { registry.register(Metal.createMetal(alloy)); } }); }
@SubscribeEvent public static void registerDarkSteelUpgrades(@Nonnull RegistryEvent.Register<IDarkSteelUpgrade> event) { if (Loader.isModLoaded("Thaumcraft")) { final IForgeRegistry<IDarkSteelUpgrade> registry = event.getRegistry(); registry.register(GogglesOfRevealingUpgrade.INSTANCE); Log.info("Dark Steel Upgrades: Thaumcraft integration loaded"); } }
public Register(ResourceLocation location, IForgeRegistry<T> registry) { super(registry.getRegistrySuperType()); this.location = location; this.registry = registry; }
public IForgeRegistry<T> getRegistry() { return registry; }
public GuiSelectFromRegistry(GuiScreen prevScreen, ICallback<ResourceLocation> callback, IForgeRegistry<T> registry, String title) { super(prevScreen, callback, createAllowedValues(registry), title); this.registry = registry; }
public GuiSelectFromRegistry(GuiScreen prevScreen, ICallback<ResourceLocation> callback, IForgeRegistry<T> registry, String title, int slotHeight) { super(prevScreen, callback, createAllowedValues(registry), title, slotHeight); this.registry = registry; }
public CommandSlotSelectFromRegistry(String nullLabel, String nullErrorMessage, IForgeRegistry<T> registry) { super(nullLabel, nullErrorMessage); this.registry = registry; }
@Override public void injectBlocks(@Nonnull IForgeRegistry<Block> registry) { if (isLoaded()) { TicControl.injectBlocks(registry); } }
@SuppressWarnings("unchecked") @Override public void onCreate(Map<ResourceLocation, ?> slaveset, BiMap<ResourceLocation, ? extends IForgeRegistry<?>> doNotTouch) { ((Map<ResourceLocation, NNList<ResourceLocation>>) slaveset).put(Registry.PRIOLIST, new NNList<ResourceLocation>()); }
@SuppressWarnings("unchecked") @Override public void onClear(IForgeRegistry<IFarmerJoe> joe, Map<ResourceLocation, ?> slaveset) { ((Map<ResourceLocation, NNList<ResourceLocation>>) slaveset).get(Registry.PRIOLIST).clear(); }
@Override public void onCreate(Map<ResourceLocation, ?> slaveset, BiMap<ResourceLocation, ? extends IForgeRegistry<?>> registries) { }
@Override public void onClear(IForgeRegistry<Research> is, Map<ResourceLocation, ?> slaveset) { }
/** * This allows addons to manually register additional blocks during Ender IO's block registration, i.e. using {@link EnderIO#DOMAIN} for their blocks' * registry name. * <p> * Don't use this for your general blocks, those go into the {@link ModObjectRegistry}. This is for things like fluid blocks that cannot be mod-objected. * */ default void injectBlocks(@Nonnull IForgeRegistry<Block> registry) { }