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

So I'm trying to make an electric cable system, which obviously requires an ability to connect/detach from other cables. Currently I am only working on the aesthetics and so want to change whether or not each part of a wire is shown.

My wire model is made in Techne and consists of 7 parts (a core and up, down, north, south, east, west). They can be toggled currently when the model is first instanced using a boolean for each direction (I don't need to toggle the core):

public RenderCable()
{
this.modelCable = new ModelCableAll(true, true, true, false, false, false);
}

 

The problem with this is that the state can only be changed by restarting the game, so how can I live update the state/edit the existing instance/remake the instance of the model?

 

Here is the full class:

package foodTech.tileEntities.render;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import foodTech.tileEntities.models.cable.ModelCableAll;

public class RenderCable extends TileEntitySpecialRenderer {

    ResourceLocation textureOff = (new ResourceLocation("roboguy99:textures/models/cableOff.png"));
    ResourceLocation textureOn = (new ResourceLocation("roboguy99:textures/models/cableOn.png"));

private final ModelCableAll modelCable;

public RenderCable()
{
	this.modelCable = new ModelCableAll(false, false, false, false, false, false);
}

public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) 
{
	GL11.glTranslatef((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
	setConnections();
	GL11.glTranslatef((float) x - 0.5F, (float) y + 0.5F, (float) z - 0.5F);
}

public void setConnections()
{
	GL11.glPushMatrix();
		Minecraft.getMinecraft().renderEngine.bindTexture(textureOff);
		this.modelCable.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
	GL11.glPopMatrix();
}
}

I have no idea what I'm doing.

Add the following to your tileentity class

 

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
NBTTagCompound nbttagcompound = pkt.func_148857_g();
this.readFromNBT(nbttagcompound);
}

@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
this.writeToNBT(nbttagcompound);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.blockMetadata, nbttagcompound);
}

 

this will sync to the client, mostly used for renders.

  • Author

Thanks. I'll test this out tomorrow and get back to you, as it's late now.

I have no idea what I'm 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.