Jump to content

poopoodice

Members
  • Posts

    1160
  • Joined

  • Days Won

    7

Everything posted by poopoodice

  1. Hi, I had actually just finish implementing a similar feature, so I find I may be able to help here. The previous way (calling fill for every pixel) is definitely going to eat up lots of performance, thus it's not an ideal way. This is what it looks like: As always, I'm not able to guarantee the efficiency and if it's the correct way/best practice to do so, so please take this as a reference only. For how to get map colours check out MapItem#update. The first two for loops are z and x coordinates, and the other two should be x2 and z2 offset coordinates (I think they are used for blending colours around... not really sure and didn't look into it). You will then get a list of integers ("packed id" of material colours), and you are able to create a new DynamicTexture, fill in all the pixels, and register a render type of RenderType.textSeeThrough() with your texture. Then, you can render the map with your renderType along with your positioned texture. static DynamicTexture MAP_TEXTURE; static RenderType MAP_RENDER_TYPE; public static void run(UpdateScoreboardMapMessage message) { AVAScoreboardManager manager = AVAWorldData.getInstance().scoreboardManager; manager.updateMap(message.compound); if (AVARenderer.MAP_TEXTURE != null) AVARenderer.MAP_TEXTURE.close(); AVARenderer.MAP_TEXTURE = new DynamicTexture(manager.getMapWidth(), manager.getMapHeight(), true); NativeImage pixels = AVARenderer.MAP_TEXTURE.getPixels(); if (pixels != null && manager.hasMap()) { for (int y = 0; y < manager.getMapHeight(); y ++) for (int x = 0; x < manager.getMapWidth(); x ++) pixels.setPixelRGBA(x, y, MaterialColor.getColorFromPackedId(manager.getMapColours().get(x + y * manager.getMapWidth()))); AVARenderer.MAP_TEXTURE.upload(); AVARenderer.MAP_RENDER_TYPE = RenderType.textSeeThrough(Minecraft.getInstance().textureManager.register(AVA.MODID + "_" + "scoreboard_map", AVARenderer.MAP_TEXTURE)); } } (Maybe it is not the proper way of resource managing??) private static void renderMap(PoseStack stack, Direction direction, float x, float y, float x2, float y2) { MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); VertexConsumer consumer = buffer.getBuffer(MAP_RENDER_TYPE); Matrix4f matrix4f = stack.last().pose(); putTextureVertex(consumer, matrix4f, x, y, x2, y2, AVAConstants.VANILLA_FULL_PACKED_LIGHT, 0.8F, direction); buffer.endBatch(); } public static void putTextureVertex(VertexConsumer consumer, Matrix4f matrix4f, float x, float y, float x2, float y2, int light, float alpha, @Nullable Direction direction) { int a = (int) (alpha * 255.0F); consumer.vertex(matrix4f, x, y2, 0.0F).color(255, 255, 255, a).uv(0.0F, 1.0F).uv2(light).endVertex(); consumer.vertex(matrix4f, x2, y2, 0.0F).color(255, 255, 255, a).uv(1.0F, 1.0F).uv2(light).endVertex(); consumer.vertex(matrix4f, x2, y, 0.0F).color(255, 255, 255, a).uv(1.0F, 0.0F).uv2(light).endVertex(); consumer.vertex(matrix4f, x, y, 0.0F).color(255, 255, 255, a).uv(0.0F, 0.0F).uv2(light).endVertex(); } Hopefully this helps a bit with the direction.
  2. You will need to notify the server for the recipe update too. Check out: https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/
  3. You can possibly make a Style with your font, and then apply it on the MutableComponents. Just by viewing the code, never interact with such.
  4. You can simply override hasContainerItem and return a damaged item in getContainerItem, the names probably had changed. If you can't figure out yourself look for the previous posts in the forum, there is a lot of them.
  5. What do you mean, isn't it just resource pack related?
  6. Scaling the matrix should work, maybe you want to show us how you do it.
  7. You will probably need to change the value through getDestroyProgress.
  8. Yes, you can rotate models in the blockstate.json, check any blocks that is directional, for example furnace's blockstate. Instead of making all possible models manually, you can also checkout how fences add model parts according to the state.
  9. Entity in fluid motion are handled through fluid tags.
  10. Can you post your code?
  11. I will recommend only place the top block when the bottom one is fully grown.
  12. You can't check for keybinds on server side ๐Ÿ‘€
  13. Sorry, to be more specific the "screen" stands for the window. It is the dimension of the texture you are rendering on the screen, for example you want to render a 1920 x 1080 texture on a 16 x 8 button, then the width and height is 16 x 8. In your case you want to fill the whole window, then the width and height is the window width/height got from iirc Minecraft.getInstance().getWindow().getScaledWidth() or getScaledHeight(.
  14. It's the "Width on the screen" and "Height on the screen", so in this case the screen width and height.
  15. Could be "write", check vanilla for examples, or provide details of which version you're currently on.
  16. AxisAlignedBB is simply a box, contains the min coord and the max coord of the box. VoxelShape is a list of AxisAlignedBBs, so it can be different shaped other than cuboid shape. I'm not quite sure about MutableBoundingBox as I've never seen or hear it before.
  17. Because it's more of an in-between and half completed version of latest (1.18)
  18. You have to declare the dimension of the texture, the default value is 256x256 (from the method you are using)
  19. Looked very nice ๐Ÿ˜€ Effect#removeAttributeModifiers gets called upon effect removal, you may find it useful in your case.
  20. Amplifier is like the strength of the effect, for example movement speed boost with amplifier 0 will be Speed I, and 1 will be Speed II, 2 will be Speed III. Effect is just an...effect type, EffectInstance contains all information for the actual effect being applied to the entity (duration, amplifier...etc). For example there's only an effect type "Speed", but for an EffectInstance it could be: "Level 2 Speed for 10 seconds" "Level 4 Speed for 2 seconds"... The first method applyEffectTick is called when a effect is impacting the entity, the first arg is the entity that has the effect/is affected by the effect, and amplifier is the strength of the effect. The second method isDurationEFfectTick is to check whether the effect should impact/affect the entity this tick (the effects usually don't trigger every tick!), if true, then the first method is called.
  21. Hi, I'm facing an issue that a custom datapack is always loaded before the mod's datapack. Means the users/players are not able to override mod's configurations/data at all. I've tried to alternate the order of datapack by using the /datapack commands, however the actual loading order does not change at all. (I can confirm that both datapacks are working as usual by disabling one of them at a time, the correspond data is loaded correctly), is it the mod's problem or...? Thanks.
  22. Is there any error/warning in the console telling something went wrong when trying to load the model? Or reload resources in game (F3 + T) and it will show errors again if there are any.
×
×
  • Create New...

Important Information

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