ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java

59 lines
1.8 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("TileEntitySmileyCloud.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.tile;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor{
public String name;
2015-10-03 10:16:18 +02:00
private String nameBefore;
2015-08-25 17:59:50 +02:00
public TileEntitySmileyCloud(){
super("smileyCloud");
}
@Override
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
super.writeSyncableNBT(compound, type);
if(this.name != null && type != NBTType.SAVE_BLOCK){
compound.setString("Name", this.name);
}
}
2015-10-18 15:31:01 +02:00
@Override
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
super.readSyncableNBT(compound, type);
if(type != NBTType.SAVE_BLOCK){
this.name = compound.getString("Name");
}
2015-10-18 15:31:01 +02:00
}
2016-02-01 17:49:55 +01:00
@Override
public void updateEntity(){
super.updateEntity();
2016-11-26 21:32:27 +01: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;
if(nameChanged && this.sendUpdateWithInterval()){
2016-02-01 17:49:55 +01:00
this.nameBefore = this.name;
this.markDirty();
}
}
}
@Override
public void onTextReceived(String text, int textID, EntityPlayer player){
this.name = text;
}
}