Everything posted by poopoodice
-
Reload Listener in 1.16 (Solved)
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
-
(SOLVED) Upgrading from 1.14 to 1.16
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
-
ThrowableEntity Errors
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.
-
ThrowableEntity Errors
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?
-
Game Crashes sever side
Whole class please
-
Game Crashes sever side
post your code
-
java.lang.IllegalStateException: No renderer registered
Register you renderer in client setup using RenderRegistry.registerEntityRendererHandler() or something similar
-
I need help to find the class that infested stone is in
check spawnSilverFish(World world, BlockPos pos) in SilverFishBlock
-
I need help to find the class that infested stone is in
don't just copy what I give you.....
-
I need help to find the class that infested stone is in
if (!world.isRemote()) world.addEntity(entity); https://mcforge.readthedocs.io/en/latest/concepts/sides/
-
I need help to find the class that infested stone is in
create an instance of SilverfishEntity and use World.addEntity() to add it (do it on server)
-
[1.16] Using setBlockState with tags
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.
-
[1.14.4] ITickable crash on Server [SOLVED]
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?
-
Custom Overlay Rendering Weirdly
You don't have to worry about it since they will rebind the texture before they render, like you do.
-
1.16.1 Custom Entity attributes
Your EntityType
-
Custom Trident model not rendering
@Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } It basically creates a packet for you to notify the client.
-
[1.15.2] Capability is null
Draco is right that the player can be null, the IDE should've told you that.
-
[1.14.4] ITickable crash on Server [SOLVED]
ITickableTileEntity not ITickable
-
Check if a player is wearing a full suit of armour [1.15.2]
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.
-
Encounterred an error during the load_registries event
one for the "variants" as well, consider download a json validator in your ide
-
Encounterred an error during the load_registries event
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.
-
]Solved][1.16.1] Adding new parameter in custom entity constructor
Sorry it should be EntityType.Builder.<CustomEntity>create(CustomEntity::new, ...) my bad
-
Make keybinds "work" only when player is not chatting or etc
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.
-
]Solved][1.16.1] Adding new parameter in custom entity constructor
EntityType.<CustomEntity>Builder.create(CustomEntity::new, ...) https://docs.oracle.com/javase/tutorial/extra/generics/index.html
-
[1.15.2] Access and Set Player's Hunger
player.getFoodStats()
IPS spam blocked by CleanTalk.