Jump to content

RInventor7

Members
  • Posts

    87
  • Joined

  • Last visited

Everything posted by RInventor7

  1. Hey. I created by custom bus entity, so it's narrow (3 blocks) and long (11 blocks). The problem is that if the bounding box is 3x3x3 then when the bus center point/bounding box is behind the player but the player is still inside or next to the bus facing the same direction, then the model is not rendered even though the front end should still be visible. Is there any other way to force the model to be rendered rather than changing the bounding box to 11x11x3 (which causes a lot more other issues)? It is possible to create a custom AABB of course but is it possible to rotate it (the AABB) 15 degrees for example? Thanks.
  2. Hey. I'm using the FTB Chunks and Teams mods in my server with my own mod. It has an overlay that is rendered when any screen is open (for example pause screen or inventory) When I open some custom screen from my mod then the FTB overlay is rendered on top of my screen hiding parts of my screen. Is it possible to somehow disable that overlay from being rendered when my custom screen is open? Thanks.
  3. That worked. Thanks for clarifying everything else.
  4. That was my mistake, I had remebered it incorrectly. That's a good point. I understand I need to specify my model location in my BER render method by changing the ModelData argument, right? blockRenderer.renderSingleBlock(bs, poseStack, bufferSource, combinedLight, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, RenderType.cutout()); The problem is can't seem to find a way to specify my model's resource location anyhow... ModelData modelData = ModelData.builder().with(somePropertySomething???).build(); Is this even the correct way or is it done differently? ModelData modelData = ModelData.builder().with(new ModelProperty<>(), new ResourceLocation(MyMod.MOD_ID, "models/block/rail.json")).build(); This also doesn't seem to do anything... I'm probably doing it wrong? Are there any examples somewhere (I couldn't seem to find any)?
  5. Hi! I'm trying to get my block entity rederer working, which in fact already works. When I set the RenderType to ENTITYBLOCK_ANIMATED then BER doesn't render anything. When I don't set it, then minecraft reders my block and BER redner's it again. If I change my BER's rotation or translation I wish to not see the original block model. So I set RenderType to ENTITYBLOCK_ANIMATED. The model isn't loaded by default, so I force the model to load myself using ModelEvent$RegisterAdditional event on the mod bus, but it's not doing anything. Subscribing works and the event fires noramally. Thanks for any help. @SubscribeEvent public static void registerBlockEntityModels(ModelEvent.RegisterAdditional event) { event.register(new ResourceLocation(MyMod.MOD_ID, "models/block/rail.json")); }
  6. Hello. I have a screen with 5 buttons and some rendered text. If I just change the text rendering location a little then the HotSwap works. Then I close the game and add another 6th button to the screen and start the game again. And if I now want to change the text rendering location or anything else in any other method then HotSwap fails. Does anybody know why the HotSwap fails after adding the 6th button and how to solve this strange issue? Thanks.
  7. Yeah nothing that I already don't know. In my case it's not so simple as just a block. I'm trying to implement a map editor/system into my mod like JourneyMap's fullscreen map with some extras. The problem is that when I try to map all regions of the world, it only maps what's in the player's view distance and everything else will be blank/transparent images, because the level.getBlockState(pos) in unloaded chunks always returns Block{minecraft:void_air}. So at the moment I'm trying to read the block data from the world region files (.mca). But I have no idea how to decode the 64-bit integers into actual understandable hints to the chunk section palette...
  8. Hi! If I want to know what block is for example at position (10, 64, 100), it is very easy to get that block as long as this position is in the players view distance (which means the chunk where the block is located is loaded). But how can I get a block from a location where the player has been previously but what is out of the player's view distance at the moment. Since the chunk is not loaded I get always the same result (Block{void_air}) even if there is grass block. How can I fix this issue and is it even possible to fix it? Thanks.
  9. Hello. I'd like to save some data to custom client config file. The problem is, that the data has to be associated with a Minecraft world. For single player I can just add the world name prefix to the data. But how can I get a unique identifier (There might be 2 different servers with a same name for example.) of a public server where the player has been playing? Thanks.
  10. Hello. I'm trying to add a fullscreen map editor with layers to my mod. I'm still experimenting with a lot of stuff. When player presses a custom key binding then a screen opens. I have some .png images I'd like to display on that screen. I can render the image easily when it is within the mod and has a ResourceLocation, but when I have dynamically created my png image as a BufferedImage I can't render it on the screen? Or can I? Or should I be using something else and not BufferedImage? Thanks.
  11. That made things more clear. And I am using SimpleChannel to do networking, I just don’t know where to use it. I know I have to send the clientbound packet at some point to the player when the screen is opened, but I don’t understand where I have to send it in order to get the SavedData value on client for the screen. Code updated.
  12. This is where I got stuck. I looked bunch of Vanilla classes and tried to do this myself, but now I have so many questions. The code is here. I added comments to the places in code where I am confused. (I’m not even sure what I’m doing wrong...)
  13. Hi! I have some problems with world saved data since it is server-side only. I have created like an in-game computer system with a lot of screens. I'm using world saved data to store the data and so all players can access it from anywhere in the world. Problems arise with getting data to display on the screen. If player edits data on a screen I can send a custom packet to server and save the data to world saved data. How can I get the data from world saved data when I reopen the screen on client to display the data on the screen? Send packet to server -> get data -> send 2nd packet back to client?? Thanks.
  14. Hi! I have a block entity and when you right click it opens a screen. I want to open the screen always when on singleplayer and only for operators when on multiplayer. How can I check if the player is in singleplayer or multiplayer world? And how can I check if the player is an operator when on multiplayer? Thanks in advance.
  15. Hi! I am saving a number to the level. In single player world it works fine. In multiplayer not. I’d like all the players to be able to edit it and see the changes somebody else has made. I have all the communication already setup, but when a player changes the number -> world saved data instance is marked dirty, but the actual writing to the .dat file happens 20-60 seconds later or when the world is closed and reopened. Is it possible to somehow force the saved data to write to the file as soon as it’s marked dirty? (Don’t really want to wait 45 seconds for everybody else to see the changes) Thanks in advance.
  16. I had accidentally put the dependency mod jar file in testing environment run/mods folder not the Minecraft/mods where I should've put it.
  17. Hi. I was updating my mod from 1.19.2 -> 1.19.3. I’m also using a dependency GeckoLib. When I try to start Minecraft it will crash saying Geckolib has failed to load correctly and the my mod fails to loead correctly because of the previous. Crash report Geckolib support said this: Does anybody know how to fix that issue or what exactly causes this crash?
  18. I have looked SignRenderer class many times and just now, but there is no method called renderSignText in that class.
  19. Hi! I have created a custom sign block. Works almost like regular Minecraft wall sign. The problem is that if the sign is inside a house, the player can see the custom redered text that is on the sign even from outside of the house. How to stop the text from being rendered when there is an object between the sign block and the player? I tried to create a custom method for that which checks if there is a solid object between the block and player. But sometimes the text is still rendered too early and it shines through some solid block. I couldn't find any Minecraft code showing how to achieve that. Here is my function: public static boolean shouldRenderText(LevelAccessor world, BlockPos blockPos, BlockPos playerPos, int range) { boolean shouldRender = true; int bX = blockPos.getX(); int bY = blockPos.getY(); int bZ = blockPos.getZ(); int pX = playerPos.getX(); int pY = playerPos.getY(); int pZ = playerPos.getZ(); Vec3 bp = new Vec3(pX-bX, pY-bY, pZ-bZ); if (bp.length() > range) return false; double max = Math.abs(bp.x); if (Math.abs(bp.y) > max) max = Math.abs(bp.y); if (Math.abs(bp.z) > max) max = Math.abs(bp.z); double stepX = bp.x/max; double stepY = bp.y/max; double stepZ = bp.z/max; for(int i = 1; i < max; i++) { double x = bX + (i*stepX); double y = bY + (i*stepY); double z = bZ + (i*stepZ); if (PTMBlock.isSolid(world, Math.floor(x), y, z)) shouldRender = false; if (PTMBlock.isSolid(world, Math.ceil(x), y, z)) shouldRender = false; if (PTMBlock.isSolid(world, x, y, Math.floor(z))) shouldRender = false; if (PTMBlock.isSolid(world, x, y, Math.ceil(z))) shouldRender = false; if (PTMBlock.isSolid(world, Math.floor(x), y, Math.floor(z))) shouldRender = false; if (PTMBlock.isSolid(world, Math.ceil(x), y, Math.ceil(z))) shouldRender = false; if (PTMBlock.isSolid(world, Math.ceil(x), y, Math.floor(z))) shouldRender = false; if (PTMBlock.isSolid(world, Math.floor(x), y, Math.ceil(z))) shouldRender = false; if (!shouldRender) return false; } return shouldRender; } The PTMBlock#isSolid will just get a block at the position and will check if it is solid or not. Any ideas how to make this system more efficient or if there may be already is a functions that does that? Thanks.
  20. Hi! I have screen that has some edit boxes on it. When player opens the screen I would like the first edit box be active so I could start typing in that without having to click on it before. @Override public void init() { super.init(); this.minecraft.keyboardHandler.setSendRepeatsToGui(true); TBDisplay = new EditBox(this.font, this.leftPos + 7, this.topPos + 11, 150, 20, Component.literal("")); this.addWidget(this.TBDisplay); //Initialize other components //Trying to set the focus TBDisplay.setCanLoseFocus(false); TBDisplay.active = true; TBDisplay.setFocus(true); } Setting the focus after initializing this and all other components on the screen highlights the edit box, but I still have to click on it before I can write something in it. How to make the edit box focused and writable without clicking on it? Thanks.
  21. Hi! I have a custom entity and I wish it would run some logic (e.g. play some sound) in every 2 seconds and some other logic in every half a second. For that I’m at the moment using 2 different timers. In entity baseTick function (runs every tick, 20 times per second): entity.getPersistentData().putInt("timer1", entity.getPersistentData().getInt("timer1") + 1); if (entity.getPersistentData().getInt("timer1") >= 40) {// evry 2 seconds entity.getPersistentData().putInt("timer1", 0); } if (entity.getPersistentData().getInt("timer1") == 1) { //Run logic 1 } Then I have second timer for the half second logic. Since both timers logic will run on every second it’s not very efficient. And it gets worse as I add more timers. Is there a way to replace this timer with something else that would be more efficient? Thanks.
  22. Well, apparently my way of handling the pack is was not very good. Improved it and everything works now.
  23. Okay, I’ll create custom packets then. I thought it was more but mod needs to save 87 variables (just counted them) per world to be exact. In addition to that the players can create new data by using custom block entities and I need to save all the data created by players and store it, so that it would be accessible after restarting the server and etc. Double checked everything and it all seems to be okay, yet it still crashes, but weirdly only when FMLEnvironment.dist == Dist.DEDICATED_SERVER. All the other S2C packets that I send will also crash when Dist == DEDICATED_SERVER. So there’s either something wrong with my packet (code above) or there’s something wrong with the registering of the packets (code above).
  24. Using saved data when I have 200 variables is not very easy. I’m mean that I would like to access the variables more easily, like static variables. I don’t want to make a MySavedData object. Is it possible to make the saved data work with static variables and then maybe send some custom packets to sync the static variables with client? Maybe it’s possible to read all the variable in and sync them when player joins the world and then have a static method to save changes in the static variables to the MySavedData instance and set it dirty then (I don’t want to set and save each variable separately using setter nor do I wish to use getters in order to access the variables)? How can I achieve that? package com.rinventor.mymod.core.data; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.saveddata.SavedData; public class PTMData { private static int test = 0; public static class PTMSavedData extends SavedData { private int test = 0; private static PTMSavedData create() { return new PTMSavedData(); } private static PTMSavedData load(CompoundTag tag) { PTMSavedData data = create(); data.test = tag.getInt("test"); return data; } public CompoundTag save(CompoundTag tag) { tag.putInt("test", test); return tag; } /* * #server-side ONLY * Gets current instance of the saved data * Return new instance when on client */ public static PTMSavedData getInstance(LevelAccessor level) { MinecraftServer server = level.getServer(); if (server == null) { return create(); } return server.overworld().getDataStorage().computeIfAbsent(PTMSavedData::load, PTMSavedData::create, "ptm-data"); } public void save() { this.setDirty(); } } public static void save(LevelAccessor level) { if (!level.isClientSide()) { PTMSavedData data = PTMSavedData.getInstance(level); data.test = PTMData.test; //set other 200 varibales data.save(); } } public static void read(LevelAccessor level) { if (!level.isClientSide()) { PTMSavedData data = PTMSavedData.getInstance(level); PTMData.test = data.test; //set other 200 varibales //sync PTMData.test with client using custom packet } } } When the player joins the world I would just call PTMData.read(); and after player changes some data (e.g. PTMData.test = 9;) I would call PTMData.save(); And if I want I can just access the static variables like PTMData.test. Only problem I can see is that when one player would change some data then other players would still have the old data. I now understand why the non-static way is better (because data always in-sync between all player on the server). This all sounds too complicated. All I wish is to save the data on client to the SavedData and then get/access/change the data on client. But since SavedData is server-side it make everything more difficult. What would be the easiest and most reasonable way to do this?
×
×
  • Create New...

Important Information

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