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

Hey, I was having some fun with custom model rendering blocks and stuff and I wanted the center cube of the model to rotate. But however, the way I was doing it, the more blocks you have, the faster the spinning gets. I want to know how I would make that per-block or something.

 

Doing the actual rendering: https://github.com/mrkirby153/StevesBoats/blob/master/src/main/java/me/mrkirby153/StevesBoats/blocks/renderers/TileEntityBlockCrafterRenderer.java

Model Class: https://github.com/mrkirby153/StevesBoats/blob/master/src/main/java/me/mrkirby153/StevesBoats/models/ModelBlockCrafter.java

 

Let me know if I forgot something

Save the rotation value in the TileEntity. (not static)

 

Have the renderer read the value from the TileEntity, edit it as needed, and save back.

 

In my TileEntity:

public float rotation;

 

In my Renderer:

tile.rotation += 0.25F;

if (tile.rotation > 360) tile.rotation = 0F;

GL11.glRotatef(tile.rotation, 1F, 0F, 0F);

 

I would say save it to NBT to be safe

 

@Override
public void writeToNBT(NBTTagCompound tag)
{
      tag.setInteger("rot", rot);
}

@Override
public void readFromNBT(NBTTagCompound tag)
{
      rot = tag.getInteger("rot");
}

No need to save it, its just visual.

Now I've long replaced my Techne models with OBJ's so lets see if I can get this from memory.

 

In TileEntityBlockCrafter.java add:

public float rotation; // you want this a float for better speed control

 

In ModelBlockCrafter.java add:

public void rotateCube(float rotation)
{
    this.CenterCube.rotateAngleY = rotation;
}

 

Now in TileEntityBlockCrafterRenderer.java before this.model.render:

((TileEntityBlockCrafter)te).rotation += 0.25F; // Change this number to change speed
if (((TileEntityBlockCrafter)te).rotation > 180) ((TileEntityBlockCrafter)te).rotation = -180F; // I believe Techne uses -180 to 180, instead of 0 to 360
this.model.rotateCube(((TileEntityBlockCrafter)te).rotation);

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.