Jump to content

TheOrangeInd

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by TheOrangeInd

  1. I'm trying to create a custom renderer for my entity and in order to do so I need to draw a sprite that has a lava texture and also a mask indicating which pixels to apply texture colors to. I've made quite a few attempts to implement this sort of thing, but all my scripts have either rendered nothing or just rendered a texture. Below is the code for my latest attempt. This code renders just a texture (instead of lava, I temporarily use a custom image). I would be grateful for any hints on how to fix it. So this is my test script: @Override public void render(EntityEruptionSource entity, float entityYaw, float partialTicks, PoseStack pose, MultiBufferSource buffer, int packedLight) { pose.pushPose(); Vector3f vertexRotAxis = new Vector3f(0, 1, 0); GL11.glEnable(GL11.GL_STENCIL_TEST); GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); GL11.glStencilMask(0xFF); GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE); VertexConsumer builder = buffer.getBuffer(RenderType.entityCutout(MainClass.RLof("textures/entities/eruption_source_mask.png"))); Vector3f vertexPos = new Vector3f(-0.5f, 0.2f, 0.5f); for(int i = 0; i < 4; i++) { builder.vertex(pose.last().pose(), -vertexPos.x(), vertexPos.y(), -vertexPos.z()) .color(255, 255, 255, 255) .uv(0, 0) .overlayCoords(OverlayTexture.NO_OVERLAY) .uv2(packedLight) .normal(0, 1, 0) .endVertex(); vertexPos.transform(new Quaternion(vertexRotAxis, 90, true)); } GL11.glStencilMask(0x00); GL11.glStencilFunc(GL11.GL_NOTEQUAL, 0, 0xFF); vertexPos = new Vector3f(-0.5f, 0.2f, 0.5f); VertexConsumer builder1 = buffer.getBuffer(RenderType.entityCutout(MainClass.RLof("textures/entities/eruption_source_c.png"))); for(int i = 0; i < 4; i++) { builder1.vertex(pose.last().pose(), -vertexPos.x(), vertexPos.y(), -vertexPos.z()) .color(255, 255, 255, 255) .uv(0, 0) .overlayCoords(OverlayTexture.NO_OVERLAY) .uv2(packedLight) .normal(0, 1, 0) .endVertex(); vertexPos.transform(new Quaternion(vertexRotAxis, 90, true)); } GL11.glDisable(GL11.GL_STENCIL_TEST); pose.popPose(); super.render(entity, entityYaw, partialTicks, pose, buffer, packedLight); }
  2. I tried to update the forge and the library used, and then completely rebuilt the project. I'm still not sure what exactly the problem was, but it has now been resolved.
  3. In my mod, I need to use some libraries (GeckoLib), which I have not done before. So, I decided to just follow the API developer's instructions. Now I can successfully build my mod with the library connected and I see the library classes in my IDE. The problem is that I cannot start the game client to test my mod. The client gives me the error "NoSuchMethodError". As far as I understand, this should be related to mappings (I use the official ones). If anyone knows what I am doing wrong, please explain to me. This is my 'build.gradle': This is the Crash Report:
  4. Fixed this. Thanks again for your help.
  5. Okay. Now I think that I figured out my mistake and this is how my Provider looks now:
  6. Should I just create a new instance of RadiationCapability in my Provider? Or should I not use LazyOptional at all?
  7. Should I use an instance of my RadiationCapability for this?
  8. Okay. The second link was really helpful to me. Thanks for it. I managed to implement the capability I needed, but I'm not sure about the correctness of my approach to serialization. Anyway, I post the resulting code here. Thanks again for your help. My interface: Its implementation: And its provider:
  9. I'm trying to add a radiation to my mod and I need to store its value for each player. As I understand it, I should use capability for this. The problem is that I don't understand well the new capability system in 1.17. So, can I create a capability to store an integer value? What are the main components of capability in its present form?
  10. I tried to make a multipart entity using a Forge class called "PartEntity" and I think I found a flaw in the hooks associated with this class. Currently, such entity parts cannot take damage (their "hurt" method is simply not called). It seems to me that this is due to the fact that the "getEntities" methods in the vanilla class "Level" have not been modified. It would be nice if these methods were also modified to notify the game when there are custom entity parts in the world (similar to vanilla dragon parts). P. S. Sorry for my English.
  11. So, after researching how vanilla projectiles work, I found that when determining whether to hit the target, they request a list of entities using a method from the Level class (the method is called getEntities). So the fact is that in this method they directly check whether the entity is a vanilla Dragon and, if true, request its PartEntities. That is, this method cannot add custom PartEntities to the returned list as ordinary entities, since they do not exist in the world, but they are a logical continuation of the parent class. At the same time, the getEntities method does not ask the checked entity to check the isMultipartEntity (from IForgeEntity interface) and, accordingly, does not add entities returned by the getParts method to the list. I still do not rule out the possibility that I misunderstand the principle of this system. But at the moment it seems to me that in the current version of Forge, the correct implementation of Multipart Entities in the way conceived by the API developers is not possible. I will be glad if I'm wrong and someone will correct me.
  12. Experimenting with multiparty entities, I ran into a problem. My part entity does not detect incoming damage. I was making my entities following the example of vanilla dragon, and I think I missed some important detail. I would be grateful for any hints. So this is my Parent Entity class: and a Part Entity:
  13. As a result, I came to the conclusion that the problem was a conflict between the render of the fluid and its tank. That is, a tank whose render type was set to Translucent simply did not allow fluids with similar render types to be rendered. I'm not sure if there is a way to fix this, but for now I decided to just change the render type of the tank.
  14. I tried to change the buffer value, but it didn't work. Current buffer value: IVertexBuilder builder = buffer.getBuffer(RenderType.getText(AtlasTexture.LOCATION_BLOCKS_TEXTURE));
  15. I have a custom fluid tank tileentity with attached special renderer for internal fluid. The problem is that fluid rendering does not happen when the player is not looking at any block. If I remove the interface with the F1 key, the rendering also fails. Does anyone know what could be causing this renderer behavior? This is how I registering my Renderer: private void setupClient(final FMLClientSetupEvent event) { RenderTypeLookup.setRenderLayer(RegistryHandler.BLOCK_FLUID_TANK.get(), RenderType.getTranslucent()); ClientRegistry.bindTileEntityRenderer(HTUTileEntityType.FLUID_TANK.get(), RendererFluidTank::new); }
  16. Since I couldn't find a way to do it like in earlier game versions, I decided to make each side of the model a separate flat box. If anyone knows a better way, please let me know.
  17. I have a translucent block with custom model. What I need to include in my Java or JSON code to make the sides of my block always render? (I want to see the other side of block, when looking through it). I will be very grateful for any help.
  18. After fixing some mistakes, I managed to write my Grid to the world NBT. But the reading is still not happening. Under what conditions is the read() method called? NBTHandler class: public class NBTHandler extends WorldSavedData { private static final String DATA_IDENTIFIER = MainClass.MODID + "_nbt"; public final Set<ISaveable> subscribers = new HashSet(); public NBTHandler() { this(DATA_IDENTIFIER); } public NBTHandler(String name) { super(name); } public static NBTHandler get(World world) { if(!(world instanceof ServerWorld)) throw new RuntimeException("Attempted to get data from client."); DimensionSavedDataManager storage = ServerLifecycleHooks.getCurrentServer().func_241755_D_().getWorld().getSavedData(); //DimensionSavedDataManager storage = ((ServerWorld)world).getSavedData(); return storage.getOrCreate(NBTHandler::new, DATA_IDENTIFIER); } public void addSubscriber(ISaveable s) { subscribers.add(s); } @Override public boolean isDirty() { boolean flag = false; for (ISaveable item : subscribers) flag |= item.isDirty(); return super.isDirty() || flag; } @Override public void read(CompoundNBT nbt) { subscribers.forEach(item -> item.readFromNBT(nbt)); } @Override public CompoundNBT write(CompoundNBT nbt) { subscribers.forEach(item -> item.writeToNBT(nbt)); return nbt; } } And get() method call in my Grid class: @Override public boolean addPipe(IPipe pipe) { if(this.world == null) { world = ((TileEntity)pipe).getWorld(); if(world != null) NBTHandler.get(world).addSubscriber(this); } /*some code*/ return false; }
  19. For some reason, the read(), wright() and isDirty() methods are not called. I cannot figure out what I am missing.
  20. Should I call the read and write methods of my NBTHandler in any event?
  21. Is there any recent documentation for WorldSaveData? I have a rather poor understanding of how it should be attached to the world.
  22. The point is that my Grid is not tied to any position in the world. It acts as a data store for connected pipes, from which these pipes can extract information about the contained fluid when interacting with the world. So, is there a way to avoid binding the Grid to specific chunks?
  23. I have fluid pipes in my mod and I use a custom Grid object to distribute fluid in this pipes. This Grid object does not inherit either Tilentity or Entity, but I need to write data from it to the world NBT. The only solution that I have found is to create my own class that inherits WorldSavedData. The problem is that I don't quite understand how to use it correctly in newer versions of the game and I'm not sure if this is the best way. I would be very grateful for any advice. Custom WorldSavedData implementation: public class NBTHandler extends WorldSavedData { private static final String DATA_IDENTIFIER = MainClass.MODID + "_nbt"; public final Set<ISaveable> subscribers = new HashSet(); public NBTHandler() { this(DATA_IDENTIFIER); } public NBTHandler(String name) { super(name); } public static NBTHandler get(World world) { if(!(world instanceof ServerWorld)) throw new RuntimeException("Attempted to get data from client."); ServerWorld w = (ServerWorld)world; DimensionSavedDataManager storage = w.getSavedData(); return storage.getOrCreate(NBTHandler::new, DATA_IDENTIFIER); } public void addSubscriber(ISaveable s) { subscribers.add(s); } @Override public boolean isDirty() { boolean flag = false; for (ISaveable item : subscribers) flag &= item.isDirty(); return super.isDirty() || flag; } @Override public void read(CompoundNBT nbt) { subscribers.forEach(item -> item.readFromNBT(nbt)); } @Override public CompoundNBT write(CompoundNBT nbt) { subscribers.forEach(item -> item.writeToNBT(nbt)); return nbt; } }
  24. I need to move one entity together with another. I do this by setting the position of the second entity in the class of the first. The problem is that the second entity moves in jerks, slightly ahead of the first. If anyone knows what could be the reason, I would be very grateful for the tips. P.s. Sorry for my English. Code from the first class, responsible for the movement of the second entity: private void movePart(EntityPart part) { part.setPosition( this.getPosX(), this.getPosY() + 1.3f, this.getPosZ() ); } @Override public void tick() { super.tick(); for (EntityPart part : bodyParts) { if(part != null) { movePart(part); } } }
×
×
  • Create New...

Important Information

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