Skip to content

Commit

Permalink
Looks like Minecraft uses UUIDs for owners now, so this is the *actua…
Browse files Browse the repository at this point in the history
…l* fix for the sitting bug
  • Loading branch information
ata4 committed Aug 13, 2014
1 parent bdde553 commit 434d36e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.DataWatcher.WatchableObject;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
Expand All @@ -44,6 +45,7 @@
import net.minecraftforge.client.GuiIngameForge;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.lwjgl.input.Keyboard;

Expand Down Expand Up @@ -191,6 +193,7 @@ private void renderEntityInfo() {
text.println("Side: " + (dragon.isServer() ? "server" : "client"));

text.println("ID: " + dragon.getEntityId());
text.println("UUID: " + StringUtils.abbreviate(dragon.getUniqueID().toString(), 22));
text.println("Name: " + dragon.getCommandSenderName());

// position
Expand Down Expand Up @@ -232,11 +235,16 @@ private void renderEntityInfo() {

// tamed flag/owner name
//String tamedString = dragon.getOwnerName();
String tamedString = dragon.func_152113_b();
if (tamedString.isEmpty()) {
tamedString = "no";
String tamedString;
if (dragon.isTamed()) {
EntityLivingBase player = dragon.getOwner();
if (player != null) {
tamedString = "yes (" + player.getCommandSenderName() + ")";
} else {
tamedString = "yes (" + StringUtils.abbreviate(dragon.func_152113_b(), 22) + ")";
}
} else {
tamedString = "yes (" + tamedString + ")";
tamedString = "no";
}
text.println("Tamed: " + tamedString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ public boolean interact(EntityPlayer player) {
return true;
}

if (!isOwner(player)) {
//if (!isOwner(player)) {
if (!func_152114_e(player)) {
if (isServer()) {
// that's not your dragon!
player.addChatMessage(new ChatComponentTranslation("dragon.owned"));
Expand All @@ -465,9 +466,7 @@ public boolean interact(EntityPlayer player) {
} else if (ItemUtils.hasEquipped(player, Items.bone)) {
if (isServer()) {
// toggle sitting state with the bone item
boolean sitting = !isSitting();
setSitting(sitting);
aiSit.setSitting(sitting);
aiSit.setSitting(!isSitting());
isJumping = false;
setPathToEntity(null);
}
Expand Down Expand Up @@ -505,7 +504,7 @@ public void tamedFor(EntityPlayer player, boolean successful) {
setPathToEntity(null);
setAttackTarget(null);
//setOwner(player.getCommandSenderName());
func_152115_b(player.getCommandSenderName());
func_152115_b(player.getUniqueID().toString());
playTameEffect(true);
worldObj.setEntityState(this, (byte) 7);
} else {
Expand Down Expand Up @@ -773,15 +772,6 @@ public DragonBreed getBreed() {
public void setBreed(DragonBreed breed) {
getBreedHelper().setBreed(breed);
}

public boolean isOwner(EntityPlayer player) {
//return player.getCommandSenderName().equalsIgnoreCase(getOwnerName());
return player.getCommandSenderName().equalsIgnoreCase(func_152113_b());
}

public boolean isRiddenByOwner() {
return riddenByEntity == getOwner();
}

public EntityPlayer getRidingPlayer() {
if (riddenByEntity instanceof EntityPlayer) {
Expand Down Expand Up @@ -853,12 +843,7 @@ public boolean isInvulnerableTo(DamageSource src) {
return true;
}

// breed-dependent immunities
if (getBreed().isImmuneToDamage(src)) {
return true;
}

return false;
return getBreed().isImmuneToDamage(src);
}

/**
Expand Down

0 comments on commit 434d36e

Please sign in to comment.