ThePiekar
Members-
Posts
9 -
Joined
-
Last visited
Everything posted by ThePiekar
-
[1.16.5] Changing how a specific block is rendered.
ThePiekar replied to ThePiekar's topic in Modder Support
Got it working with mixin for now, can't tell I'm satisfied with injecting a custom block check into a random renderer function, but as long as it works it's good I suppose. For future reference, I hijacked the render fluid function within BlockRendererDispatcher if I recall correctly. -
So i have been trying to implement a fluid that flows up instead of down. I got the mechanics right, but the look is off. The main problem is: the model that is rendered, depending on the flkuid height (the thing that makes flowing water into slopes) is kinda hardcoded into fluid renderer from what i see (although in a perfect world it would use a model declared in a flowingfluid class). And to make it look not as bad, I'd need to either somehow supply a custom renderer for my block (or FlowingFluidBlock to be precise) or add a check in the fluid renderer for if the fluid is a instance of my block and patch a custom function in there. Neither of which are trivial, from what i can see at least. My question is, is it doable to lightly patch a core class or pass a custom renderer to a block within forge? Or by any miracle if theres a way to somehow influence the rendered model from within fluid class afterall? And yes im quite aware, that you never should modify base classes, but I can't find an event I could intercept to achieve the same result.
-
Ok, I've set up something that resembles a proper repo now, same link. Even if i make loadColor method always return let's say red it still renders the bed white after reolading. That's why i suspect it to be a sync issue, as destroy particles have the correct texture, as if getActualState was called on breaking the block but not on choosing a model for it. I'm trying to further investigate the loadColor right now. Replacing code in getActualState to make it always return a let's say red as color property makes the bed be still white but always have red destruction particles. Is there any way for me to pass the state from TE to the block before it's rendered (I was convinced getActualState already did it)? ///Edit/// ~~I managed to get the color of bed loaded last( I'm not entirely sure)(so still not the desired one, particles and drops match the desired one) of TE to be the color of the block until the game is restarted, after which it gets back ot block default (white). Even after game restart item drops and particles are correct, so I'd assume TE saves and reads the data correctly. Im as confused as it gets (code added to TE) @Override public void onLoad() { Block bed = getWorld().getBlockState(getPos()).getBlock(); BlockFancyBed fbed = (BlockFancyBed) bed; fbed.setRenderState(fbed.getActualState(getWorld().getBlockState(getPos()), getWorld(), getPos())); notifyBlockUpdate(); } (code added to Block) public void setRenderState(IBlockState state) { this.setDefaultState(state); } ~~ doesn't work anymore for some reason ///Edit2/// Woking with debugger confirms that getActualState is called after interacting with block and not on rendering it, so thats why clolor stays default. So the question is how to change the state of a single block before it's rendered (defaulst state and actual state don't seem to cut it) ///Edit3/// i played around with setBlockState in onLoad method of the TE and discovered it gets seemingly called twice per TE, once by Server (color values from debugger seem fine here) and second time by the client Thread (with either null or default color value declared in the TE class) ///Edit4/// Even if I don't get to solve it just yet, thank You for giving me great leads, I have learned a lot.
-
Sorry for lack of proffesionality, lot of things are there temporary, like block and item base, for me to just test if certain things work on an easier basis. I'll look into renaming stuff according to the rules and getting rid of IHasModel and CommonProxy ( to be fair by the time I introduced them I had no idea what anything did), where do you advise me to put the things i had in common proxy (basically a empty void called registerItemRenderer)? That's all the code I have, maybe besides json files, they are a bit ugly, since I didn't want to spend my whole life checking where I missed the coma, but I'll upload them as well. Sorry to be difficult but if that's not what you mean by rendering code, could you specify and/or give examples? ///EDIT/// Updated github with jsons Also i wouldn't really know what to do with debugger information
-
So I've been trying to add some more beds to Minecraft. (1.12.2) Naturally for my block i extended BlockBed class and for my item ItemBed class. I've got most of the funcionality working but due to lack of expirience I resorted to having Blocks be the model and not the tile entity. (i know i should just make the colored part a TE model but I have no real idea how to) Limited by block meta I stored the color property in the tile entity, upon placing the bed has its desired color, testing for drops also confirms that the entity works. However after reolading the bed (via either leaving the area or loading up the save again) the bed is always white, but upon breaking the particles have the correct color, the dropped items also correspond to the color stored in TE. (note that im not very expirienced in java or forge, code is mostly what i picked up from others and slight modifications to vanilla) Block class pastebin Item class (i dont think this one matters in this situation) pastebin TileEntity class pastebin