Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I was looking through some code about textures, and I found these lines: 

StringBuilder builder = new StringBuilder();
builder.append(" \"all\": \"" + BaseMod.MODID + ":blocks/" + texture + "\"");

The variable`texture` is  an image file.

What I understand is that the first line declares a StringBuilder (I'm not really sure what that is). Then, the second line applies textures to all sides of the block because of the `all` part. I need help understanding this, and how would I change the code so that the second line only applies textures to the front side?

Applying textures is done through JSON files ever since Minecraft 1.8

 

Normally, for blocks with specific "front" sides, you want your block to dynamically rotate depending on it's relative position to the player (most commonly face the player when placed).
For that, you need to work with BlockState's. The vanilla furnace is a good example, and the BlockFurnace class should show you how to use PropertyDirection to alter the BlockState.

 

As for the textures, you can look at the furnace.json located in forgeSrc-<mc.version>-<forge.version>.jar/assets/minecraft/models/block. Use your IDE to find that file.

 

This model.JSON file has to exist inside src/main/resources/assets/modid/models/block, and if needed, a blockstate.JSON has to exist inside src/main/resources/assets/modid/blockstates

 

The JSON files have to be completely lowercase in 1.11, and their names have to be identical to your block's RegistryName.

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

You're misunderstanding that code. A StringBuilder is a kind of mutable string object. All that line of code does is put together a string from those components - the result is (almost*) equivalent to just using the + operator on string literals directly.

 

(*StringBuilder tutorial)

 

Simple model code is usually controlled entirely in the json model files. If you want more help understanding or adapting the code that you found, we need (lots) more context to understand what it's doing.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.