Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Multi-tile block help. Minecraft 1.10.2


Espeonstar
 Share

Recommended Posts

This is help for my friend and these are his words. 

Basically, I'm trying to make it so that when I place a block, it places down 3 others which each have their own part property. So then I can save and load the part states and load up the model from blockstates properly.

Link to comment
Share on other sites

@Jay Avery Says he already knows that. He wants to know how to "load up multiple properties with meta data."

 

Edit: He basically wants to know how to get the other 3 blocks of his four block "block" to break when one is broken. He's bad at explaining and I should have done this before.

Edited by Espeonstar
Link to comment
Share on other sites

What exactly do you mean by "as a group"? There are a lot of different things involved in blocks - placing, breaking, activating, associated items, etc. All of those things happen independently, so have to be handled differently depending on exactly what you want to achieve.

 

I'm not frustrated, but slightly confused - why isn't your friend posting here? It would be a lot easier to give help if we could see the current code and get precise details on what isn't (and is) working as intended.

Link to comment
Share on other sites

His words. "Hey, I am not posting since I am not online. But here is the break down of what I'm trying to do. Consider a bed. You have two blocks that are codependent each other. I am trying to do this, but with 4 blocks instead. Each block "part" will have a direction IProperty and a part IProperty. What I am trying to do is load up the part correctly through meta data so that I can essentially have it as it was when I placed it. I have basically no idea how metadata should be handled although I kind of get the math behind it. If I can figure out this, I can in turn do the rest of what I need (simultaneous block breaking, same inventory use, blah blah). Currently only saving the direction metadata but I have no clue on how to add my part metadata to that."

 

Edit: If you want, I can just completely copy and paste all your answers and his replies so it's less, stupid, with me in the mix. :P

Edited by Espeonstar
Link to comment
Share on other sites

Okay, so he needs to learn how to use blockstates and metadata to save them. Start with the forge docs. Then inspect the vanilla code for blocks which store similar kinds of state information (hint: beds, doors).

 

Ultimately there isn't any maths involved in metadata. It's just a way of representing the different possible states of the block in the form of a single number (between 0 and 16). If you want, you can manually translate them by checking individual conditions: "if this particular state, return 5, if that particular state, return 6", and so on (and the same in reverse). That's just slightly awkward and verbose, so it's more concise to use some simple multiplication and bitwise operations to do the same thing if possible - but if that's confusing them start by doing it the verbose way so you can understand what you're doing.

 

Also note that if you have more than 16 different possible states, you won't be able to store them in metadata - you'd have to use a TileEntity to store them instead.

Link to comment
Share on other sites

"I tried using Tile Entities but I wasn't sure when the data saved, since it always seemed to reset my data. Also, I've been looking at fences and beds to understand how they save the metadata, but I don't understand fully how it works. Blockststes I understand, it's just the metadata hell I don't get. Any links where I can understand it more?"
Link to comment
Share on other sites

I gave a link to the forge docs. I'm not sure what else to explain about metadata. It's just a way of translating from a blockstate to a number and back again, it's essentially a simple shorthand. There are two methods you need to override: getStateFromMeta and getMetaFromState. In the first one, you get a number and return a blockstate, in the second you get a blockstate and return a number. All you need to do is make sure that those two methods do the inverse of each other: that if you get X number in getStateFromMeta and return state Y, then if you get state Y in getMetaFromState you return number X. You can use whatever technique you like to translate your states to numbers and back again, it just needs to be self-consistent in order for the blocks to be saved and loaded correctly.

Link to comment
Share on other sites

"Ah OK, that makes sense haha. Then if I want to do more than 16 states, I would use TileEntities and their writeToNBT()? If so, when does that get called? Guessing on game end, but if it does, the state I saved to it never changes even when written to NBT as a string. Most LIKELY did it wrong or set it wrong. :/"
Link to comment
Share on other sites

Yes, if you store information in a TileEntity you'll need to use writeToNBT and readFromNBT to store and retrieve the data. It's saved when the world is saved/quit, and reloaded with the world. If you want the TE data to influence the block's actual state in the world (e.g. for rendering purposes), you'll also need to override getActualState in the block class. In that method, you retrieve the information stored in your TE, and return the applicable blockstate based on that.

Link to comment
Share on other sites

One last thing @Jay Avery

"OK so, successfully saved and loaded the states with metadata! Woot! But now I am seeing about how to set the TileEntity data so I can use more states later. I am unsure of how to access the TileEntity of a block I create (I place a block down and it auto creates the 3 other blocks). I have a reference to the tile entity in the block, but how can I access that to change the data?"
Link to comment
Share on other sites

You shouldn't store a reference to the TE in the block - a block is a singleton so there's only ever one instance, but a new TE instance is created for every block of that type in the world. To get a TE at a certain position you just use world#getTileEntity.

Link to comment
Share on other sites

Assuming that the TileEntity data is properly synced with the client.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Im trying to make a moddes server with my friends but every single time we get same error https://pastebin.com/UP6P6YSd Is there a way to fix it? Thanks for solutions
    • Take a break, go for a walk. Then try again. 🙂
    • Where did you see that? Sorry if I am being a bother, it's just that I have been staring at this mod for a long time and I'm probably looking over a lot of things
    • Taking a look at AbstractContainerScreen.renderSlot() I got the following code: Method created in my AbstractContainerScreen class: private void renderCustomSlot(PoseStack poseStack,ItemStack itemstack,int x, int y) { boolean visible = true; boolean hover = false; this.setBlitOffset(100); this.itemRenderer.blitOffset = 100.0F; if (visible) { if (hover) { //Draw a rectangle behind the item fill(poseStack, x, y, x + 16, y + 16, -2130706433); } //Render item icon RenderSystem.enableDepthTest(); this.itemRenderer.renderAndDecorateItem(this.minecraft.player, itemstack, x, y, x + y * this.imageWidth); //Render item string count PoseStack posestack = new PoseStack(); if (itemstack.getCount() != 1) { String s = String.valueOf(itemstack.getCount()); posestack.translate(0.0D, 0.0D, itemRenderer.blitOffset + 200.0F); MultiBufferSource.BufferSource multibuffersource$buffersource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); /* float scale; if (s.length()<3){ scale=1f; }else if (s.length()<4){ scale = 0.75f; }else { scale=0.5f; s = s.substring(0,s.length()-3)+"k"; } float compensatingScale = 1/scale; float stringX = (x + 19f - 2 - font.width(s)*scale)*compensatingScale; float stringY =(y + 6f + 3)*compensatingScale; posestack.scale(scale,scale,scale); */ float stringX = (x + 19f - 2 - font.width(s)); float stringY =(y + 6f + 3); font.drawInBatch(s,stringX,stringY,16777215, true, posestack.last().pose(), multibuffersource$buffersource, false, 0, 15728880); //posestack.scale(compensatingScale,compensatingScale,compensatingScale); multibuffersource$buffersource.endBatch(); } } this.itemRenderer.blitOffset = 0.0F; this.setBlitOffset(0); } Now it works correctly: Thanks to warjort for the tip!
    • Hello, I am currently trying to get a forge server setup so I can play the Pixelmon mod with some friends on a private server and have run into some issues with launching my forge server file, I downloaded the forge 12.2.2-14.23.5.2859 installer, downloaded it into a folder on my desktop, ran the Mc server file, agreed to Eula, made a run.bat file to launch the forge server at 6GBs, and when I try launching I get this issue: Pixelmon Server>java -Xmx6144M -Xms6144M -jar forge-1.12.2-14.23.5.2859-universal.jar --nogui We appear to be missing one or more essential library files. You will need to add them to your server before FML and Forge will run successfully.java.lang.ClassNotFoundException: org.objectweb.asm.Type         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)         at java.base/java.lang.Class.forName0(Native Method)         at java.base/java.lang.Class.forName(Class.java:466)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:53)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34)   I've tried using another minecraft server jar file from a different source to see if that would solve anything but its still coming up with this issue. Any help is greatly appreciated, thanks for your help in advance.
  • Topics

×
×
  • Create New...

Important Information

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