Everything posted by S-Spirit
-
[1.16.4] Blur screen background
I want to create screen with blur background, similar to this mode. But I need it only for my own screen, not need to change vanilla. Faced a problem to found tutorial about this - all results in Google says how install shaders, how use shaders with optifine and e.t.c Can't found any one about how to use shaders in my own mode. Tried to investigate this mode, but it is old (last version support 1.13) and have tons of dark magic related to change vanilla screnes backgrounds. Also tried to investigate how vanilla use standard blur shader, but this is also so hard way (at least with my skills). So, does any one know tutorial, how to use vanilla or my custom shader at screen rendering? Or maybe exist some specific word, which specify - I need to use shader like developer, not like a gamer.
-
[1.16.4] capNBT critical size
Oh, you are right! This string inside "capNBT" looks very similar to JSON and I thinked, NBT is system for wrapp and simplify JSON serialization. Thanks for clarification and sorry about that misunderstanding.
-
[1.16.4] capNBT critical size
Sorry, I am confused a little. I implements writeNBT and readNBT methods for my capability. In this methods I construct nested CompoundNBT, ListNBT and e.t.c. Don't serializes all data to JSON and stores like NBT with 1 element. Is it right way? Thanks. So I should remove this feature or implement it by more compact way.
-
[1.16.4] capNBT critical size
I try to stores story of item craft ingredients. In my mode recipes are not strongly determined. So it is not possible to say "if this is X it was exacly created from Y and Z". So I have case when some item was created from 4 another item, and each of them was created from few another and e.t.c I don't serialize capabilities manually. But at debug I see in ItemStack the field named "capNBT" (with JSON inside), and when I checked it size I started to worry
-
[1.16.4] capNBT critical size
I want to store in my ItemStacks big size data. I used capabilities, so all this data serializes into JSON and stores at capNBT. For now capNBT for one stack may be between 100 and 10 000 characters. I think near 3 000 is middle value. I have a few ideas, how make capNBT more short, but doesn't know, should I spend time to it or not. So I have few related questions: 1. Does Forge have limit to capNBT size? 2. Does ItemsStaks from closed chest (in loaded chanck) stores at RAM? Even if user doesn't open it? 3. Maybe exist some another nuances related to big capNBT?
-
[1.16.4] Why recipe result calculated on server side?
I want to propose to user few options, which he/she may craft from items in inventory. Client will prepare all combinations, than select only few best (in my context). Server will validate only this few combinations. Ofcouse I plans to add precheck how many combination client may construct and prevent few-seconds freezes with message like "Sorry, so many ingredients for autocompletion."
-
[1.16.4] Why recipe result calculated on server side?
For now it is impossible. My crating system is tricki a little. I didn't found way to represents necessary logic by JSON without losing my wishes about customisation. So I don't use recipes consept at all. But I hope at future resolve this problem and use it. In any case, I think your notification about cheating it a great point! So I will implement combinations calculation and filtration at client, but then send results to server for approve and apply into slots. Thanks.
-
[1.16.4] Why recipe result calculated on server side?
So, it is more ideologically question than strong restriction? I will try to prevent all situations, when count of combination will be critically big. But in theory I may miss some scenarious, which will creates overload. In this case will be better to overload client and give bad expirience for one player, than overlod server and give bad expirience for all.
-
[1.16.4] Why recipe result calculated on server side?
I want to implement my own block for crafting. So, I investigated canonical example - workbench. And found this code: protected static void updateCraftingResult(int id, World world, PlayerEntity player, CraftingInventory inventory, CraftResultInventory inventoryResult) { if (!world.isRemote) { ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)player; ItemStack itemstack = ItemStack.EMPTY; Optional<ICraftingRecipe> optional = world.getServer().getRecipeManager().getRecipe(IRecipeType.CRAFTING, inventory, world); if (optional.isPresent()) { ICraftingRecipe icraftingrecipe = optional.get(); if (inventoryResult.canUseRecipe(world, serverplayerentity, icraftingrecipe)) { itemstack = icraftingrecipe.getCraftingResult(inventory); } } inventoryResult.setInventorySlotContents(0, itemstack); serverplayerentity.connection.sendPacket(new SSetSlotPacket(id, 0, itemstack)); } } Crafting result calculates on logical server and than client will be notified about result. But why? My crafting interface propose few results, based on items, which player have. Calculation of all combinations is not easy (of couse it have options for optimisation). What a reason to execute crafting result calculations on server?
-
[1.16.4] SimplImpl sends packet to client instead server
Thanks, got it! No one. It was my own conclusion from documentation and tutorials. When you asked, I read about @OnlyIn one more time, and see - my conclusion was fully wrong. I even thinked @OnlyIn work with logical sides, but specification says - physical. So I should make a refactorng. Thanks for get my attention.
-
[1.16.4] SimplImpl sends packet to client instead server
Thank you very much! You was right - problem was related to code Minecraft.getInstance().player. I Have read page about networking few times and missed this example of common beginners mistakes... But how I should get opened container at server side? I added list of listeners into ModNetworking private static final NonNullList<WeakReference<Object>> serverListeners = NonNullList.create(); public static void addServerListener(Object obj) { serverListeners.add(new WeakReference(obj)); } public static void removeServerListener(Object obj) { serverListeners.remove(obj); } public static <T> Stream<T> listeners(Class<T> listenerClass) { serverListeners.removeIf(r -> r.get() == null); return serverListeners.stream() .filter(r -> listenerClass.isAssignableFrom(r.get().getClass())) .map(r -> ((T) r.get())); } At packet processing ModNetworking provides listeners of necessary type: public void processPacket(Supplier<NetworkEvent.Context> ctx) { Stream<IUpdateConceptPacketHandler> listeners = ModNetworking.listeners(IUpdateConceptPacketHandler.class); listeners.forEach( l -> l.handleConceptUpdate(conceptId)); ctx.get().setPacketHandled(true); } My container add itself like a listener in constructor and remove at the finalize(). This solution works, but is it brilliant idea or ugly implementation of something, which platform already may provide to me? P.S. Why you notify me to not use @OnlyIn? As I understood, it should be written everywhere, in case when method should be called only from client. Is it wrong vision?
-
[1.16.4] SimplImpl sends packet to client instead server
Added Forge version to title. Does anyone meet this network issue?
-
[1.16.4] SimplImpl sends packet to client instead server
I implementing screen, where user may select option and server should be notified about it. Simple case. I found tutorial and implemented this feature uses SimpleImp. Maybe I missed something - packet from server sends to client successfully, but when I tries to use sendToServer client get message instead server. My network class public class ModNetworking { private static final String PROTOCOL_VERSION = "1.0"; private static SimpleChannel INSTANCE; private static int ID = 0; public static int nextId () { return ID++; } public static void registerMessages() { INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation(ArtOfFood.MOD_ID, "mod_channel"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals); INSTANCE.messageBuilder(SSetConceptResultSlotPacket.class, nextId()) .encoder(SSetConceptResultSlotPacket::writePacketData) .decoder(SSetConceptResultSlotPacket::new) .consumer(SSetConceptResultSlotPacket::processPacket) .add(); INSTANCE.messageBuilder(CUpdateConceptPacket.class, nextId()) .encoder(CUpdateConceptPacket::writePacketData) .decoder(CUpdateConceptPacket::new) .consumer(CUpdateConceptPacket::processPacket) .add(); } public static void sendToClient(Object packet, ServerPlayerEntity player) { INSTANCE.sendTo(packet, player.connection.netManager, NetworkDirection.PLAY_TO_CLIENT); } public static void sendToServer(Object packet) { INSTANCE.sendToServer(packet); } } Problem packet is CUpdateConceptPacket: public class CUpdateConceptPacket { private String conceptId; public CUpdateConceptPacket(String conceptId) { this.conceptId = conceptId; } public void processPacket(Supplier<NetworkEvent.Context> ctx) { PlayerEntity playerEntity = Minecraft.getInstance().player; if (playerEntity.openContainer instanceof IUpdateConceptPacketHandler) { IUpdateConceptPacketHandler handler = (IUpdateConceptPacketHandler) playerEntity.openContainer; handler.handleConceptUpdate(conceptId); } ctx.get().setPacketHandled(true); } public CUpdateConceptPacket(PacketBuffer buf) { this.readPacketData(buf); } public void readPacketData(PacketBuffer buf) { this.conceptId = buf.readString(); } public void writePacketData(PacketBuffer buf) { buf.writeString(this.conceptId); } public String getConceptId() { return this.conceptId; } } Minimalistic handler: public interface IUpdateConceptPacketHandler { void handleConceptUpdate(String conceptId); } This is how I call it: @OnlyIn(Dist.CLIENT) public void setConcept(MBConcept concept) { this.concept = concept; CUpdateConceptPacket packet = new CUpdateConceptPacket(concept.conceptId); ModNetworking.sendToServer(packet); } And get client call (see screen, at debug value of playerEntity is ClientPlayerEntity) P.S. Can't find spoiler for hiding code listings. Is it available here? And ofcouse I tried to investigate Vanila examples few times but didn't get results.
IPS spam blocked by CleanTalk.