-
Posts
17 -
Joined
-
Last visited
Everything posted by SatyPardus
-
Getting a block texture and binding it for use on a model
SatyPardus replied to Lance5057's topic in Modder Support
textureManager.bindTexture(new ResourceLocation("textures/blocks/planks_oak.png")); This works just fine for me when putting it on my mimic blocks. Maybe it works for your armor too, as long as the UV coordinates match. -
[1.12.2] Data syncing practices for NBT and blocks
SatyPardus replied to SatyPardus's topic in Modder Support
I mean, that is nice and all and maybe easier to read, but it would be great if there was still some way to just get numbers out of it. I don't find any good resource on how to read out these attributes. Or maybe I just overlook something. But what I would like to do, is compressing the data myself as much as possible, storing it as int, short or maybe even byte to take down traffic. It is just to much when there is a hologram with a huge house (like 1000 blocks) and it sends all this data via NBT. And it's even more when I plan to update it live. I tested it on a small server and it's just horrible. May friend even lost connection completely. I try to read through tutorials, the forge wiki but I don't seem to figure it out. private NBTTagCompound writeBlockState(int index, NBTTagCompound tag, IBlockState state) { tag.setString("Name"+index, ((ResourceLocation)Block.REGISTRY.getNameForObject(state.getBlock())).toString()); if (!state.getProperties().isEmpty()) { NBTTagCompound nbttagcompound = new NBTTagCompound(); UnmodifiableIterator unmodifiableiterator = state.getProperties().entrySet().iterator(); while (unmodifiableiterator.hasNext()) { @SuppressWarnings("unchecked") Entry < IProperty<?>, Comparable<? >> entry = (Entry)unmodifiableiterator.next(); IProperty<?> iproperty = (IProperty)entry.getKey(); nbttagcompound.setString(iproperty.getName(), getName(iproperty, entry.getValue())); } tag.setTag("Properties"+index, nbttagcompound); } return tag; } This is the only thing I could find in NBTUtil what writes these properties... but honestly, I don't understand it. A more performant way like blockids and int metadata would be much nicer in my case to work with, even when a metadata of 11 looks confusing, but wikis and documentation and own comments help there. -
Interesting. But at the same time weird. From a outside perspective this looks like it creates a empty array. Thanks for that link!
-
The important part of the class was, that the lists get filled inside the register event. When you add them in the other classes, they are probably added randomly again. Also, toArray(new Item[0]) will probably create a empty array. Didn't use toArray myself yet, but in C# that thing would be empty
-
@EventBusSubscriber public class ObjectRegistry { public static Block BLOCK_PATH; public static Block BLOCK_PATH_SLAB; public static Block BLOCK_GHOST; public static Item ITEM_PATHMAKER; public static Item ITEM_COPYTOOL; public static Set<Item> items = new HashSet<Item>(); public static Set<Block> blocks = new HashSet<Block>(); public static void prepareBlocks(){ blocks.add(BLOCK_PATH = new BlockPath()); blocks.add(BLOCK_PATH_SLAB = new BlockPathSlab()); blocks.add(BLOCK_GHOST = new BlockGhost()); } public static void prepareItems() { items.add(ITEM_PATHMAKER = new ItemPathMaker()); items.add(ITEM_COPYTOOL = new ItemCopyTool()); } //This method will be called without us calling it. This is because //Forge calls it -for- us, when the RegistryEvent happens. This is why //we had to use the @Mod.EventBusSubscriber at the top of the class. @SubscribeEvent public static void registerBlocks(Register<Block> event){ //We make sure that the list gets filled with our blocks. prepareBlocks(); for(Block block : blocks){ event.getRegistry().register(block); } } //We do not need to call prepareBlocks() in this method, because Blocks are registered before items. //Thus, our registerBlocks method has already happened. @SubscribeEvent public static void registerItems(Register<Item> event){ for(Block block : blocks){ ItemBlock iblock = new ItemBlock(block); iblock.setRegistryName(block.getRegistryName()); event.getRegistry().register(iblock); } prepareItems(); for(Item item : items) { event.getRegistry().register(item); } } } A really nice registry class from a tutorial that I can sadly not find anymore, otherwise I would link it. It's really compact and nice to use. Maybe something for you too. But it follows the Forge register order so you don't have to do it yourself hehe.
-
For blocks and items in the Blocks simple and Item simple
-
https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample I personally think this is a great resource for learning and reading into code. I don't know if there is a video guide too it, but the code itself is quite good and documented. Maybe worth a look. EDIT: Take a look at the Notes.txt - They are quite good.
-
[1.12] Threading crash when accessing chunks from GUI
SatyPardus replied to Kinniken's topic in Modder Support
The full error would be good. But I am suspecting a dictionary change while you are reading the chunks. But I can only confirm with the whole error. Edit: I am stupid. You are not modifying anything. But yet, a full error would help -
I actually had the same problem more than once while using eclipse and notepad++ as editor. The problem was, that eclipse apparently holds a cached version of textfiles in its memory or something, putting the cached version to the exceuted mod. The solution I found to always have the freshest, is to select the resources folder in eclipse and press F5 (refresh) once. After that I can start the game and the model is changed properly. The same thing is with textures. Edited outside, they doesn't seem to be taken over except when refreshing the resource folder. Maybe worth a try.
-
I hope I can post this in this Forum, as this is not completely asking for help, but more so giving ideas how to approach things. I am currently working on a hologram for my mod, that should, in the finished mod, maybe be able to live update blockchanges. It is mostly used for static rendering of a specific structure, but live rendering is possible. Now to my question: How would you approach something like this? What would be the "best" practice to sync data without lagspikes or huge traffic. The static rendering is already pretty traffic heavy, with updating it's NBT with each renderd blocks data - I probably should change that. I was thinking about custom packets, sending only the required fields that are important for rendering, but I don't seem to understand the "new" BlockState system and it's block properties yet. It was so easy years ago with block IDs and metadata lol. For the live rendering, I am curently calculating each height layer once in a TileEntity update. So each update it increases by 1, rendering the next layer in the next update. I still have to implement custom packages to only send what REALLY changed (As it currently sends the whole NBT data each update... a bit to much) Does anybody have resources or maybe even experience with large data sync? That would be great. A work in progress of the live update hologram. The unknown model is water, need to fix that too.
-
As far as I see, you are trying to render your mana with a Packet on packet receive. This would not work, except you would send a packet for each frame. (Which is bad! Only send packets when necessary) What you would have to do is creating a GUI Overlay and pass the mana value to that, rendering your string inside of there in the render method. A good resource for that would be here: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe40_hud_overlay You can then pass your mana value to your mana hud overlay and render it there.
-
[1.12.2][SOLVED] IBakedModel no getQuads for Cobblestone Wall
SatyPardus replied to SatyPardus's topic in Modder Support
Oh wow. I could have tested that myself, but didn't knew that there is any difference between them. You are absolutely right, this fixes it. Even the cobblestone_wall is showing now. Thank you a lot! -
[1.12.2][SOLVED] IBakedModel no getQuads for Cobblestone Wall
SatyPardus replied to SatyPardus's topic in Modder Support
event.getWorld().getBlockState(event.getPos()); RightClickBlock event. This blockstate is applied to the ghost block -
[1.12.2][SOLVED] IBakedModel no getQuads for Cobblestone Wall
SatyPardus replied to SatyPardus's topic in Modder Support
I obtain the block state currently by direct block to block copy. I have a "ghost" block in my mod that can mimic any block I rightclick. It copies the blockstate of the rightclicked block and puts it on the ghost, then the custom renderer kicks in and renders the block with half transparency. And yes. Every side returns 0. About the redstone, fence and stairs - They are rendered, but as I said, only the default state with rotation (At least the stairs, the redstone and post are not easy to see if they rotated. Every other block, even door, bed, rails etc work perfectly fine. It's just these 3 that wont work as expected (Which appears really weird for me) - I already tried to see if it might be because they have connected states to other blocks, but I can't figure this out. I also get some debug output from my mod now to doublecheck the sides to return 0 and will edit this post. Edit: ##### Rendermodel Cobblestone Wall ##### Side down: 0 quads Side up: 0 quads Side north: 0 quads Side south: 0 quads Side west: 0 quads Side east: 0 quads Side null: 0 quads ##### Rendermodel Oak fence post - With and without neighbor ##### Side down: 1 quads Side up: 1 quads Side north: 0 quads Side south: 0 quads Side west: 0 quads Side east: 0 quads Side null: 4 quads -
Hello. I am working on a half transparent model renderer for my mod and for some reason a few blocks are not able to render. The "getQuads" method of the IBackedModel returns 0 quads for the cobblestone_wall. At the same time, stairs, fences and redstone are not displayed correctly based on their IBlockState. Only the pure redstone dot and the fence middle post are rendered. Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state); is what I use to get the model. I also tried to get the model from the ModelManager with the same result. private void renderModel(IBlockState state, IBakedModel model, int color) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); bufferbuilder.begin(7, DefaultVertexFormats.ITEM); for (EnumFacing enumfacing : EnumFacing.values()) { this.renderQuads(bufferbuilder, model.getQuads(state, enumfacing, 0L), color); } this.renderQuads(bufferbuilder, model.getQuads(state, (EnumFacing)null, 0L), color); tessellator.draw(); } private void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color) { int i = 0; // cobblestone_wall has 0 quads here. for (int j = quads.size(); i < j; ++i) { BakedQuad bakedquad = quads.get(i); int k = color; renderQuadColor(renderer, bakedquad, k); } } Do I miss something? Why does the cobblestone_wall does not show up at all and redstone, stairs and fences only show the default state? Any help would be great! Thanks.