Skip to content

Instantly share code, notes, and snippets.

@PitchBright
Created October 19, 2016 01:34
package com.khufu.stonetitans.entity;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Iterables;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import com.mojang.authlib.properties.Property;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraft.world.World;
public class EntityPlayerStasis extends EntityLivingBase {
public GameProfile m_profile = null;
private NBTTagCompound m_playerNBT;
public InventoryPlayer inventory = new InventoryPlayer(null);
public EntityPlayerStasis(World world) {
super(world);
// FIRST PROBLEM: RENDERED ONLY ACCEPTS M_PROFILE FROM CONSTRUCTOR BUT
// WE CAN'T HAVE player.getGameProfile() HERE
// Hardcoded profile is not what we want
m_profile = new GameProfile(UUID.fromString("893daf0b-b2a4-47ad-bc19-739fc60b0721"), "tim4242");
}
public EntityPlayerStasis(World world, EntityPlayer player) {
super(world);
m_profile = player.getGameProfile();
setPosition(player.posX, player.posY, player.posZ);
NBTTagCompound comp = new NBTTagCompound();
player.writeToNBT(comp);
m_playerNBT = comp;
}
@Override
public void onUpdate() {
}
@Override
public ItemStack getHeldItem() {
return new ItemStack(Items.iron_helmet, 1, 1);
}
@Override
public ItemStack getEquipmentInSlot(int p_71124_1_) {
return new ItemStack(Items.iron_helmet, 1, 1);
}
@Override
public void setCurrentItemOrArmor(int p_70062_1_, ItemStack p_70062_2_) {
}
@Override
public ItemStack[] getLastActiveItems() {
return new ItemStack[1];
}
@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
super.readEntityFromNBT(nbt);
m_playerNBT = nbt.getCompoundTag("KF_PLAYER_DATA");
if (nbt.hasKey("Owner", 10)) {
this.m_profile = NBTUtil.func_152459_a(nbt.getCompoundTag("Owner"));
}
}
@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setTag("KF_PLAYER_DATA", m_playerNBT);
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTUtil.func_152460_a(nbttagcompound1, this.m_profile);
nbt.setTag("Owner", nbttagcompound1);
}
public GameProfile func_152108_a() {
return this.m_profile;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment