Jump to content

SoLegendary

Members
  • Posts

    95
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

SoLegendary's Achievements

Stone Miner

Stone Miner (3/8)

1

Reputation

  1. For some context, I am making a mod that recreates minecraft as a top-down strategy game (see: https://www.youtube.com/watch?v=2kL4vyjE2Mc). As part of this, I am implementing a "fog of war" effect where chunks outside of range of your base and mobs are greyed out and only render blocks as they appeared the last time you explored it with a mob. This currently works in my latest mod build but has the issue that when the chunk is unloaded and then reloaded (eg. by moving it out of your render chunk range and then back in), the blocks in the chunk are updated, which is not ideal. If I can keep these unexplored chunks loaded indefinitely, then this issue would be fixed because the client would never update the chunk's blocks. I'm not too concerned for performance issues here as I would only need to apply this indefinite loading to a select few chunks at a time (the ones containing other players' buildings). I've tried cancelling the ChunkEvent.Unload event but it doesn't seem to do anything, and I'm not actually sure its related to rendering at all.
  2. Ok actually nevermind, I found I can cancel BlockRenderDispatcher.renderBatched with a mixin to hide the blocks entirely. If there a way to do the transparency route though I would still like to know as that will mean I can retain the leaf texture instead of having to use some other transparent block.
  3. For some context, since this sounds like something trying to make a cheat mod would be doing, I have a mod that has you play Minecraft in a top-down perspective controlling mobs as units in a strategy game. https://www.youtube.com/watch?v=2kL4vyjE2Mc One issue I have right now is that forests are very difficult to move through because you can't easily see your mobs through leaves. To combat this, I want to be able to make these vanilla leaf blocks either completely hidden or transparent at specific locations (I know where all of the required BlockPoses will be to do this). Ideally I would like them to be transparent, but if they their rendering can be cancelled entirely, I can also render blocks which are partially transparent (eg. glass) in their place to achieve the same effect. Another idea I had was to have all vanilla leaf blocks replaced by some equivalent custom block that I have control over, but that would be a lot of work and I wanted to know if I could do it without that first before attempting it.
  4. I am trying to update my code from 1.19.3 to 1.19.4 but am having trouble adapting the NbtUtils.readBlockState method - this function used to just take one CompoundTag parameter but now it takes the CompoundTag and a HolderGetter<Block> pBlockGetter parameter. Where am I supposed to get pBlockGetter from? I primarily use this method for reading NBT structure data from my mod's resource files. The player can create structures which are saved into both client and server sides (so this method can run on both sides). My code for the method is here: https://github.com/SoLegendary/reignofnether/blob/1.19.4/src/main/java/com/solegendary/reignofnether/building/BuildingBlockData.java#L67-L74 In the future is there a guide for how to update methods like this on a new Minecraft version?
  5. I want to disable the generation of specific biomes on new world creation. I also want to tweak some other world generation features of specific other biomes (eg. changing density of trees in a forest, density of surface ores on a mountain, etc.) I see lots of options for creating new custom biomes with datapacks (eg. using https://misode.github.io/worldgen/biome/), I don't know how to modify existing biomes or remove them entirely. Is there a way to do it in the Java code or are data packs the best way? Is there a guide someone can provide for it?
  6. In case anyone else has this very specific problem managed to solve it by writing a mixin for LevelRenderer.renderLevel() with just the blockDestructionProgress snippet but with the > 1024 condition reversed: // rerun blockDestroyProgress actions but with > sqrt(1024) range @Inject( method = "renderLevel", at = @At("TAIL") ) private void renderLevel(PoseStack pPoseStack, float pPartialTick, long pFinishNanoTime, boolean pRenderBlockOutline, Camera pCamera, GameRenderer pGameRenderer, LightTexture pLightTexture, Matrix4f pProjectionMatrix, CallbackInfo ci) { Vec3 vec3 = pCamera.getPosition(); double d0 = vec3.x(); double d1 = vec3.y(); double d2 = vec3.z(); ObjectIterator var42 = this.destructionProgress.long2ObjectEntrySet().iterator(); while (var42.hasNext()) { Long2ObjectMap.Entry<SortedSet<BlockDestructionProgress>> entry = (Long2ObjectMap.Entry) var42.next(); BlockPos blockpos2 = BlockPos.of(entry.getLongKey()); double d3 = (double) blockpos2.getX() - d0; double d4 = (double) blockpos2.getY() - d1; double d5 = (double) blockpos2.getZ() - d2; if ((d3 * d3 + d4 * d4 + d5 * d5 > 1024.0)) { SortedSet<BlockDestructionProgress> sortedset1 = (SortedSet) entry.getValue(); if (sortedset1 != null && !sortedset1.isEmpty()) { int k1 = (sortedset1.last()).getProgress(); pPoseStack.pushPose(); pPoseStack.translate((double) blockpos2.getX() - d0, (double) blockpos2.getY() - d1, (double) blockpos2.getZ() - d2); PoseStack.Pose posestack$pose = pPoseStack.last(); VertexConsumer vertexconsumer1 = new SheetedDecalTextureGenerator(this.renderBuffers.crumblingBufferSource().getBuffer((RenderType) ModelBakery.DESTROY_TYPES.get(k1)), posestack$pose.pose(), posestack$pose.normal()); ModelData modelData = this.level.getModelDataManager().getAt(blockpos2); this.minecraft.getBlockRenderer().renderBreakingTexture(this.level.getBlockState(blockpos2), blockpos2, this.level, pPoseStack, vertexconsumer1, modelData == null ? ModelData.EMPTY : modelData); pPoseStack.popPose(); } } } }
  7. My mod is often viewed from far distances (up to 100s of blocks away), which means that the crack overlay textures from blocks being destroyed aren't being rendered (I have custom mobs that break blocks with these overlays applied). I am applying the destroyProgress textures like this (clientside): this.mob.level.destroyBlockProgress(this.mob.getId(), this.gatherTarget, gatherProgress); How can I extend the range that they are rendered at?
  8. I have a custom humanoid mob with arms that I can directly control the XYZ rotation values of. I want to be able to trigger a swinging animation just like the one that the player has when left clicking. I've tried using the LivingEntity.swing() method from clientside but it doesn't seem to do anything. I understand it probably needs to be triggered from serverside so that all clients can see the animation, but I'm just testing it for the time being. Is there a way I can use a swing() method here or something similar or do I need to actually meticulously set the rotation values of my mob's arm myself? If the latter, where are those calculations done so I can copy the numbers?
  9. I'm playing around with changing the client brightness of specific chunks by modifying shading functions with mixins. I've got this working properly and I set the affected chunks as dirty whenever their brightness is changed so it updates automatically. Note that this is purely clientside as I am not changing block light values, only the rendering functions. However, there are often lines at the edges of the chunks with the original brightness. This only happens when smooth lighting is enabled. For example, when I change chunks from full brightness to dark, I get effects like this left over: These are removed when I place or destroy a block in the chunk, however, they sometimes reappear when the chunk is rerendered, even when just moving it out of the view frustum by turning around. How can I trigger a lighting update in code that I can run whenever the chunk is rendered? This is what I've tried so far after reading ClientLevel.setBlock() but it doesn't seem to do anything. MC.level.getProfiler().push("queueCheckLight"); MC.level.getChunkSource().getLightEngine().checkBlock(MC.player.getOnPos()); MC.level.getProfiler().pop(); MC.level.markAndNotifyBlock(MC.player.getOnPos(), (LevelChunk) MC.level.getChunk(MC.player.getOnPos()), Blocks.AIR.defaultBlockState(), Blocks.DIRT.defaultBlockState(), 3, 512);
  10. I'm trying to add a mixin to ChunkRenderDispatcher.RenderChunk.RebuildTask I also need to access class methods from its superclass, ChunkRenderDispatcher.RenderChunk.ChunkCompileTask so I had my mixin extend this same class and put in a dummy constructor to avoid the compile error. However, I'm getting this error when I try to run: This is the code I have: https://pastebin.com/kSPaEPYU I've also tried wrapping my mixin class with a class extending ChunkRenderDispatcher.RenderChunk which in turn is wrapped with a class extending ChunkRenderDispatcher like so: https://pastebin.com/33JnUSKZ However, this gives me the error: But when I make it static, I get the same original error again. EDIT: Nevermind, found a different solution not requiring mixins here
  11. I've been playing around with how chunk rendering works, and found how to conditionally render specific chunks with this code: https://pastebin.com/5UzA0s1F This code prevents the rendering of all chunks outside of a 30 block radius around a specific mob type. However, my end goal is to just apply a shader to show those chunks are out of range, rather than just not render them at all - something simple like painting them all black or changing it to monochrome. I believe I'd have to write a fragment shader (.fsh) for this which I've done before but only in isolation, playing around with this editor here: https://patriciogonzalezvivo.github.io/glslEditor/. I am assuming here that the shader I write can get an input of the original colour of each pixel which I can then modify. Does Forge provide this compatibility and if so, how can I go about registering and applying the shader in code once it's been written? Also, I don't think I'm going worry about rendering entities or block entities in these "dark" chunks so hopefully that simplifies this. EDIT: nevermind, I found a solution that doesn't require shaders - since I just want to darken the chunks and not apply any complex effects, I realised I can just mixin ModelBlockRenderer and change the lightmap values.
  12. I think you meant to extend a class further down than LivingEntity (probably at least Mob?), there's a lot of classes in the inheritance line between LivingEntity and most vanilla mobs. Eg. a zombie: LivingEntity -> Mob -> PathfinderMob -> Monster -> Zombie
  13. Make sure where you're inserting the code is actually the last place it's being updated. In your case, PlayerRenderer.renderHand() runs setModelProperties() where your code sets it to 90F, THEN it sets the arm xRot to 0.0F again, so you probably want to set the xRot at the TAIL of renderHand()
  14. If you want to apply conditional damage (eg, bonus against a particular enemy) I'd suggest using LivingDamageEvent, where you can get the entity being damaged, the source of the damage, and get/set the amount of damage.
×
×
  • Create New...

Important Information

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