Jump to content

[1.12.2] Dynamic block transparency


Evi1Casul

Recommended Posts

For each blockstate entry you can have a model, and for each model you can have different textures, and for each texture you can have different transparency by simply having a translucent .png file. Just take the texture you want, and make several .pngs, each with the desired translucency, then hook them up to different models for your blockstate .json.

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Link to comment
Share on other sites

9 hours ago, SerpentDagger said:

For each blockstate entry you can have a model, and for each model you can have different textures, and for each texture you can have different transparency by simply having a translucent .png file. Just take the texture you want, and make several .pngs, each with the desired translucency, then hook them up to different models for your blockstate .json.

I already have an IModel with 18 different textures which are dynamically picked for each state depending on the blockstate, so I need dynamic transparency. 

Edited by Evi1Casul
Link to comment
Share on other sites

7 hours ago, Evi1Casul said:

so I need dynamic transparency

21 hours ago, Evi1Casul said:

dynamically (depending on the blockstate)

7 hours ago, Evi1Casul said:

18 different textures which are dynamically picked for each state depending on the blockstate

Perhaps I'm misunderstanding your definition of dynamic? It seems to me that you want the block's transparency to vary with the blockstate, and with the textures in the model. This can be accomplished as I described.

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Link to comment
Share on other sites

45 minutes ago, SerpentDagger said:

Perhaps I'm misunderstanding your definition of dynamic? It seems to me that you want the block's transparency to vary with the blockstate, and with the textures in the model. This can be accomplished as I described.

First, that's sort of a workaround. I don't understand why there is no system with flexible rendering control for cases where JSON is helpess (yeah, IModel/TESR is also clumsy and unobvious). However, speaking of the method you described, it's still impossible. I have a custom model that randomly picks one of six textures for each block side (the block can be attached to adjacent blocks); more than that, it has 3 different subtypes, so JSON system will be generating 3 * 2^6 * 6^6 = ~9M variants. Considering model baking time (and just logic), that's going to be processed for a long time. Transcluent textures will make it even worse (btw, not to mention manual json and texture files editing). I need a solution via IModel or whatever.
P.S. I already implemented dynamic textures and models picking.

Edited by Evi1Casul
Link to comment
Share on other sites

38 minutes ago, Evi1Casul said:

3 * 2^6 * 6^6

First off where did 2^6 come from?
 

40 minutes ago, Evi1Casul said:

I need a solution via IModel or whatever.

From what I can see here is you need to use the TextureStitchEvent(Not sure if it should be pre or post).Then you'll need to either load(if in the pre event) or get from the AtlasTexture(post event). Then you'll need to use reflection to access the NativeImage array stored in the TextureAtlasSprite via reflection and call setPixelRGBA for your pixels. Then you'll need to add this texture to the AtlasTexture(which is why I'm not sure which event you need I am leaning towards Pre).

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

34 minutes ago, Animefan8888 said:

First off where did 2^6 come from?

6 sides that may or may not be attached.

 

35 minutes ago, Animefan8888 said:

From what I can see here is you need to use the TextureStitchEvent(Not sure if it should be pre or post).Then you'll need to either load(if in the pre event) or get from the AtlasTexture(post event). Then you'll need to use reflection to access the NativeImage array stored in the TextureAtlasSprite via reflection and call setPixelRGBA for your pixels. Then you'll need to add this texture to the AtlasTexture(which is why I'm not sure which event you need I am leaning towards Pre).

I want to make smooth block fading. If 5% per frame is enough, I'll need to cache 18 * 20 = 360 textures. Is it okay in terms of performance?

Link to comment
Share on other sites

1 hour ago, Evi1Casul said:

First, that's sort of a workaround.

It's just using the Json system for what it's meant to be used for.

1 hour ago, Evi1Casul said:

generating 3 * 2^6 * 6^6 = ~9M variants

Yeah, now that you've told me that it requires ~9M variants instead of ~5 like a normal model, I can see that Json is impractical for your situation. Maybe you should have put that in the topic somewhere? The quality of the help you receive is proportional to the quality of the information you give us (in this case, poor).

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Link to comment
Share on other sites

10 hours ago, Evi1Casul said:

Is it okay in terms of performance?

Just sounds like it'll eat up a lot more ram and have a little longer startup time. Though I dont know exactly you'll have to test it and find out. If you mean in terms of fps as long as ram is sufficient the user shouldn't experience any drops in fps from the way the textures work however they may experience a drop in fps if the blockstate changes really fast. Each time it happens the whole chunk mesh has to be regenerated.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

6 hours ago, Evi1Casul said:

Is there a way to change rendering instead of model or textures?

Basically when you are doing fancy render stuff like this you need to ask yourself a few basic questions.

  1. Are there going to be a large amount of these blocks in one area? If yes it is likely better to use the model system.
  2. Is your block animated? If yes then you will need to use a TESR preferably a FastTESR.
  3. Is your block is gonna update at a ridiculous rate IE every tick? Then you should probably not use the model system unless the update has a switch. If it has a switch you should use both model and TESR. Model for non updating mode and TESR for updating mode and basically all data for the update should be in the TE for the block. And the switch should be stored in the blockstate so it is capable of switching between not having a TE and having a TE.

Basically weigh these questions against your Block then make a judgement call. If it turns out to be terrible try another implementation. I recommend using the switch method of things.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

On 10/26/2019 at 5:34 PM, Evi1Casul said:

I set the render type to INVISIBLE to use TESR, but the returned blockstate somehow misses its unlisted properties now...

Post your code. I mainly need the block class and subclasses if they are important(IE change behavior). If there are multiple a git repo would work great.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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