Jump to content

Recommended Posts

Posted

just a float, it gets set after Tile Entity creation and should stay the same until the Tile Entity is deleted. The variable does get set client side on creation but not on world load.

Posted

I would assume that the furnace would be a good place to look for it.

 

Oops.. Scratch that. The furnace doesn't use it.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

how do I pass or receive the nbttagcompound? so far I have:

 

public class TileEntityController extends TileEntity {
public float rotation;

@Override
public void writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	nbt.setFloat("rotation", rotation);
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	rotation = nbt.getFloat("rotation");
}

@Override
public Packet getDescriptionPacket() {
	new NBTTagCompound().setFloat("rotation", rotation);
        return new S35PacketUpdateTileEntity();
    }

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {

}
}

 

(sorry, new to all this)

Posted

Ok, figured it out! I was trying to use a method named the same thing but with different parameters. Finished code for people with the same problem:

 

package com.deb.debmodularships.tileentities;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntityController extends TileEntity {
public float rotation;

@Override
public void writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	nbt.setFloat("rotation", rotation);
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	rotation = nbt.getFloat("rotation");
}

@Override
public Packet getDescriptionPacket() {
	NBTTagCompound nbttagcompound = new NBTTagCompound();
	nbttagcompound.setFloat("rotation", rotation);
        return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbttagcompound);
    }

@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
	rotation = pkt.func_148857_g().getFloat("rotation");
}
}

Posted

As Alix said you already have methods to read and write your nbt data so just change what you have to

package com.deb.debmodularships.tileentities;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntityController extends TileEntity {
public float rotation;

@Override
public void writeToNBT(NBTTagCompound nbt) {
	super.writeToNBT(nbt);
	nbt.setFloat("rotation", rotation);
}

@Override
public void readFromNBT(NBTTagCompound nbt) {
	super.readFromNBT(nbt);
	rotation = nbt.getFloat("rotation");
}

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

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

 

Edit: Fixed typo

 

I am the author of Draconic Evolution

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

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

Announcements



×
×
  • Create New...

Important Information

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