2020-09-09 16:48:43 +02:00
|
|
|
package de.ellpeck.actuallyadditions.common.tile;
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2020-09-09 16:48:43 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.network.gui.IStringReactor;
|
2015-08-23 23:41:46 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor {
|
2015-08-23 23:41:46 +02:00
|
|
|
|
|
|
|
public String name;
|
2015-10-03 10:16:18 +02:00
|
|
|
private String nameBefore;
|
2015-08-25 17:59:50 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public TileEntitySmileyCloud() {
|
2016-05-06 23:23:29 +02:00
|
|
|
super("smileyCloud");
|
|
|
|
}
|
|
|
|
|
2015-08-23 23:41:46 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void writeSyncableNBT(NBTTagCompound compound, NBTType type) {
|
2016-07-02 15:01:46 +02:00
|
|
|
super.writeSyncableNBT(compound, type);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (this.name != null && type != NBTType.SAVE_BLOCK) {
|
2015-08-23 23:41:46 +02:00
|
|
|
compound.setString("Name", this.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 15:31:01 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void readSyncableNBT(NBTTagCompound compound, NBTType type) {
|
2016-07-02 15:01:46 +02:00
|
|
|
super.readSyncableNBT(compound, type);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (type != NBTType.SAVE_BLOCK) {
|
2016-07-02 15:01:46 +02:00
|
|
|
this.name = compound.getString("Name");
|
|
|
|
}
|
2015-10-18 15:31:01 +02:00
|
|
|
}
|
|
|
|
|
2016-02-01 17:49:55 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void updateEntity() {
|
2016-02-01 17:49:55 +01:00
|
|
|
super.updateEntity();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (!this.world.isRemote) {
|
2016-05-10 19:00:35 +02:00
|
|
|
boolean nameChanged = this.name != null ? !this.name.equals(this.nameBefore) : this.nameBefore != null;
|
2019-05-02 09:10:29 +02:00
|
|
|
if (nameChanged && this.sendUpdateWithInterval()) {
|
2016-02-01 17:49:55 +01:00
|
|
|
this.nameBefore = this.name;
|
|
|
|
this.markDirty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-23 23:41:46 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void onTextReceived(String text, int textID, EntityPlayer player) {
|
2015-08-23 23:41:46 +02:00
|
|
|
this.name = text;
|
|
|
|
}
|
|
|
|
}
|