Jump to content

poopoodice

Members
  • Posts

    1160
  • Joined

  • Days Won

    7

Everything posted by poopoodice

  1. Hello, I'm facing some problems implementing a custom resource listener, it was working before updating 1.15 to 1.16. How I register the listener in mod class: MinecraftForge.EVENT_BUS.addListener(this::addReloadListenerEvent); //in constructor public void addReloadListenerEvent(AddReloadListenerEvent e) { e.addListener(new ReloadListenerCropListEntryConfiguration()); } Listener class public class ReloadListenerCropListEntryConfiguration implements IFutureReloadListener { public static final String PATH = "pt2_crops"; public static final String EXTENTION = ".json"; private void tryDeserialization(IResourceManager resourceManager, ResourceLocation file, Gson gson,Map<String, CropListEntryConfiguration> configs, boolean merge) { String name = file.getPath().replace(PATH, "").replace(EXTENTION, "").replace("/", ""); try (IResource iresource = resourceManager.getResource(file)) { JsonObject jsonobject = JSONUtils.fromJson(gson, IOUtils.toString(iresource.getInputStream(), StandardCharsets.UTF_8), JsonObject.class); if (jsonobject == null) { PlantTechMain.LOGGER.error("Couldn't load recipe {} as it's null or empty", file); } else { if(!merge) { configs.put(name, CropListEntryConfiguration.Deserializer.read(name, jsonobject)); } else { configs.get(name).merge(CropListEntryConfiguration.Deserializer.read(name, jsonobject)); } } } catch (IllegalArgumentException | JsonParseException jsonparseexception) { PlantTechMain.LOGGER.error("Parsing error loading recipe {}", name, jsonparseexception); } catch (IOException ioexception) { PlantTechMain.LOGGER.error("Couldn't read custom advancement {} from {}", name, file, ioexception); } } @Override public CompletableFuture<Void> reload(IStage stage, IResourceManager resourceManager, IProfiler preparationsProfiler, IProfiler reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) { PlantTechMain.LOGGER.info("Load crop configuration from data packs"); Gson gson = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create(); Map<String, CropListEntryConfiguration> configs = new HashMap<String, CropListEntryConfiguration>(); Collection<ResourceLocation> files = resourceManager.getAllResourceLocations(PATH, f -> { return f.endsWith(EXTENTION); }); // First load all default configurations for (ResourceLocation file : files.stream().filter(file -> file.getNamespace().equals("planttech2")).collect(Collectors.toList())) { tryDeserialization(resourceManager, file, gson, configs, false); } // Then then load overrides for (ResourceLocation file : files.stream().filter(file -> !file.getNamespace().equals("planttech2")).collect(Collectors.toList())) { tryDeserialization(resourceManager, file, gson, configs, true); } //Apply values for(CropListEntryConfiguration config: configs.values()) { config.applyToEntry(); } //save on server PlantTechMain.croplist.setConfigs(configs); //Sync all Clients for (ServerPlayerEntity player : ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayers()) PlantTech2PacketHandler.sendTo(new CropConfigChangeMessage(configs), player); CompletableFuture<Void> completablefuture = new CompletableFuture<>(); completablefuture.complete(null); return completablefuture; } } repo: https://bitbucket.org/kaneka/planttech2/src/1.16.x/ Problems: 1. ServerLifecycleHooks.getCurrentServer() is null when the world starts, is there another replacement for it? 2. When the error above is skipped (by comment them out / null check), the game just freezes without any messages. Thanks in advance to solve problem 1, instead of implemting IFutureReloadListener, extend JsonReloadListener problem 2 isn't a problem
  2. the latest version https://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.16.1.html previous versions (in Changelog) https://files.minecraftforge.net/maven/net/minecraftforge/forge/1.16.1-32.0.98/forge-1.16.1-32.0.98-changelog.txt
  3. Override createSpawnPacket and return NetworkHooks.createEntityPacket or something to notify the client. What I mean by ”is it not being rendered” is I want you to check if the entity does exist but just not being rendered on client.
  4. What makes you think it doesn't work? Is it not being rendered, or if it's like you've said that it can't even be summoned, what did the log printed out?
  5. Whole class please
  6. post your code
  7. Register you renderer in client setup using RenderRegistry.registerEntityRendererHandler() or something similar
  8. check spawnSilverFish(World world, BlockPos pos) in SilverFishBlock
  9. don't just copy what I give you.....
  10. if (!world.isRemote()) world.addEntity(entity); https://mcforge.readthedocs.io/en/latest/concepts/sides/
  11. create an instance of SilverfishEntity and use World.addEntity() to add it (do it on server)
  12. The only two ways I can think of is either use SkullTileEntity.setPlayerProfile() or call onBlockPlacedBy() and pass in a stack with the nbt data you want. Both of them basically do the same thing.
  13. There's probably something wrong with your TileEntityType. https://github.com/TheRealZeher/DimensionalPocketsII/blob/1.14.4-0.1.32/src/main/java/com/zeher/dimpockets/core/manager/TileEntityManager.java#L13 is your TileEntityType correctly initialized?
  14. You don't have to worry about it since they will rebind the texture before they render, like you do.
  15. Your EntityType
  16. @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } It basically creates a packet for you to notify the client.
  17. Draco is right that the player can be null, the IDE should've told you that.
  18. ITickableTileEntity not ITickable
  19. Compare ItemStacks using some provided methods in ItemStack (I don't remember what they're called), but you should be checking if their Items are equal (which == is fine), not the ItemStacks.
  20. one for the "variants" as well, consider download a json validator in your ide
  21. setRegistryName() is in the Item class not the Item Properties class Any error msg in the console? It should clearly tell you where went wrong.
  22. Sorry it should be EntityType.Builder.<CustomEntity>create(CustomEntity::new, ...) my bad
  23. I just have a quick look at the vanilla key binding processing (L1510 in Minecraft), it uses while loop with a condition of KeyBinding.isPressed() in runTick() which you should probably follow how Minecraft does it.
  24. EntityType.<CustomEntity>Builder.create(CustomEntity::new, ...) https://docs.oracle.com/javase/tutorial/extra/generics/index.html
  25. player.getFoodStats()
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.