2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("TileEntitySmileyCloud.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-08-23 23:41:46 +02:00
|
|
|
|
package ellpeck.actuallyadditions.tile;
|
|
|
|
|
|
2015-08-25 17:59:50 +02:00
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-08-23 23:41:46 +02:00
|
|
|
|
import ellpeck.actuallyadditions.network.gui.IStringReactor;
|
|
|
|
|
import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient;
|
|
|
|
|
import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
public class TileEntitySmileyCloud extends TileEntityBase implements IPacketSyncerToClient, IStringReactor{
|
|
|
|
|
|
|
|
|
|
public String name;
|
2015-08-25 17:59:50 +02:00
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public double lastFlyHeight;
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public int flyHeight;
|
2015-10-03 10:16:18 +02:00
|
|
|
|
private String nameBefore;
|
2015-08-25 17:59:50 +02:00
|
|
|
|
|
2015-08-23 23:41:46 +02:00
|
|
|
|
@Override
|
|
|
|
|
public void updateEntity(){
|
|
|
|
|
if(!worldObj.isRemote){
|
|
|
|
|
if(!Objects.equals(this.name, this.nameBefore)){
|
|
|
|
|
this.nameBefore = this.name;
|
|
|
|
|
this.sendUpdate();
|
2015-08-27 16:54:28 +02:00
|
|
|
|
this.markDirty();
|
2015-08-23 23:41:46 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void writeToNBT(NBTTagCompound compound){
|
|
|
|
|
super.writeToNBT(compound);
|
|
|
|
|
if(this.name != null){
|
|
|
|
|
compound.setString("Name", this.name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void readFromNBT(NBTTagCompound compound){
|
|
|
|
|
super.readFromNBT(compound);
|
|
|
|
|
this.name = compound.getString("Name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int[] getValues(){
|
|
|
|
|
if(this.name != null && !this.name.isEmpty()){
|
|
|
|
|
int[] chars = new int[this.name.length()];
|
|
|
|
|
for(int i = 0; i < this.name.length(); i++){
|
|
|
|
|
char atPlace = this.name.charAt(i);
|
|
|
|
|
chars[i] = (int)atPlace;
|
|
|
|
|
}
|
|
|
|
|
return chars;
|
|
|
|
|
}
|
|
|
|
|
return new int[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setValues(int[] values){
|
|
|
|
|
if(values != null && values.length > 0){
|
|
|
|
|
String newName = "";
|
|
|
|
|
for(int value : values){
|
|
|
|
|
newName += (char)value;
|
|
|
|
|
}
|
|
|
|
|
this.name = newName;
|
|
|
|
|
}
|
2015-10-02 16:48:01 +02:00
|
|
|
|
else{
|
|
|
|
|
this.name = null;
|
|
|
|
|
}
|
2015-08-23 23:41:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sendUpdate(){
|
|
|
|
|
PacketSyncerToClient.sendPacket(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTextReceived(String text, int textID, EntityPlayer player){
|
|
|
|
|
this.name = text;
|
|
|
|
|
}
|
|
|
|
|
}
|