Don't call bukkit events so often.

This commit is contained in:
filoghost 2015-01-13 12:40:15 +01:00
parent ccad2f9cd1
commit 950092d6fd
32 changed files with 518 additions and 94 deletions

View File

@ -1,5 +1,5 @@
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
public interface NMSArmorStand extends NMSNameable, NMSRideable {
public interface NMSArmorStand extends NMSNameable {
}

View File

@ -1,8 +1,8 @@
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
public interface NMSRideable extends NMSEntityBase {
public interface NMSCanMount extends NMSEntityBase {
// Sets the passenger of this entity through NMS.
public void setPassengerNMS(NMSEntityBase passenger);
public void setPassengerOfNMS(NMSEntityBase vehicleBase);
}

View File

@ -1,5 +1,5 @@
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
public interface NMSHorse extends NMSNameable {
public interface NMSHorse extends NMSNameable, NMSCanMount {
}

View File

@ -2,7 +2,7 @@ package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
import org.bukkit.inventory.ItemStack;
public interface NMSItem extends NMSEntityBase {
public interface NMSItem extends NMSEntityBase, NMSCanMount {
// Sets the bukkit ItemStack for this item.
public void setItemStackNMS(ItemStack stack);

View File

@ -1,5 +1,5 @@
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
public interface NMSSlime extends NMSEntityBase {
public interface NMSSlime extends NMSEntityBase, NMSCanMount {
}

View File

@ -1,5 +1,5 @@
package com.gmail.filoghost.holographicdisplays.nms.interfaces.entity;
public interface NMSWitherSkull extends NMSRideable {
public interface NMSWitherSkull extends NMSEntityBase {
}

View File

@ -1,13 +1,17 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityHorse;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.World;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@ -154,4 +158,28 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "f", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
import net.minecraft.server.v1_6_R3.Block;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.EntityItem;
import net.minecraft.server.v1_6_R3.EntityPlayer;
@ -15,9 +16,12 @@ import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSItem extends EntityItem implements NMSItem {
@ -90,7 +94,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -180,4 +184,28 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "f", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,14 +1,18 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntitySlime;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.World;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@ -69,7 +73,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -140,5 +144,28 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "f", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -2,12 +2,10 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_6_R3;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.Utils;
import net.minecraft.server.v1_6_R3.Entity;
import net.minecraft.server.v1_6_R3.EntityWitherSkull;
import net.minecraft.server.v1_6_R3.NBTTagCompound;
import net.minecraft.server.v1_6_R3.Packet34EntityTeleport;
@ -63,7 +61,7 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -151,14 +149,7 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
public boolean isDeadNMS() {
return this.dead;
}
@Override
public void setPassengerNMS(NMSEntityBase passenger) {
if (passenger instanceof Entity) {
((Entity) passenger).setPassengerOf(this);
}
}
@Override
public int getIdNMS() {
return this.id;

View File

@ -1,13 +1,17 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R1;
import net.minecraft.server.v1_7_R1.Entity;
import net.minecraft.server.v1_7_R1.EntityHorse;
import net.minecraft.server.v1_7_R1.NBTTagCompound;
import net.minecraft.server.v1_7_R1.World;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@ -153,4 +157,28 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R1;
import net.minecraft.server.v1_7_R1.Blocks;
import net.minecraft.server.v1_7_R1.Entity;
import net.minecraft.server.v1_7_R1.EntityHuman;
import net.minecraft.server.v1_7_R1.EntityItem;
import net.minecraft.server.v1_7_R1.EntityPlayer;
@ -15,9 +16,12 @@ import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSItem extends EntityItem implements NMSItem {
@ -90,7 +94,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -180,4 +184,28 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,14 +1,18 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R1;
import net.minecraft.server.v1_7_R1.Entity;
import net.minecraft.server.v1_7_R1.EntitySlime;
import net.minecraft.server.v1_7_R1.NBTTagCompound;
import net.minecraft.server.v1_7_R1.World;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@ -69,7 +73,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -141,4 +145,28 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -2,12 +2,10 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_7_R1;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.Utils;
import net.minecraft.server.v1_7_R1.Entity;
import net.minecraft.server.v1_7_R1.EntityWitherSkull;
import net.minecraft.server.v1_7_R1.NBTTagCompound;
import net.minecraft.server.v1_7_R1.PacketPlayOutEntityTeleport;
@ -61,7 +59,7 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -141,13 +139,6 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
return this.dead;
}
@Override
public void setPassengerNMS(NMSEntityBase passenger) {
if (passenger instanceof Entity) {
((Entity) passenger).setPassengerOf(this);
}
}
@Override
public int getIdNMS() {
return this.getId();

View File

@ -1,13 +1,17 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R2;
import net.minecraft.server.v1_7_R2.Entity;
import net.minecraft.server.v1_7_R2.EntityHorse;
import net.minecraft.server.v1_7_R2.NBTTagCompound;
import net.minecraft.server.v1_7_R2.World;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@ -153,5 +157,29 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R2;
import net.minecraft.server.v1_7_R2.Blocks;
import net.minecraft.server.v1_7_R2.Entity;
import net.minecraft.server.v1_7_R2.EntityHuman;
import net.minecraft.server.v1_7_R2.EntityItem;
import net.minecraft.server.v1_7_R2.EntityPlayer;
@ -15,9 +16,12 @@ import org.bukkit.craftbukkit.v1_7_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSItem extends EntityItem implements NMSItem {
@ -90,7 +94,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -180,4 +184,28 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,14 +1,18 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R2;
import net.minecraft.server.v1_7_R2.Entity;
import net.minecraft.server.v1_7_R2.EntitySlime;
import net.minecraft.server.v1_7_R2.NBTTagCompound;
import net.minecraft.server.v1_7_R2.World;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@ -69,7 +73,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -140,5 +144,29 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R2;
import net.minecraft.server.v1_7_R2.Entity;
import net.minecraft.server.v1_7_R2.EntityPlayer;
import net.minecraft.server.v1_7_R2.EntityWitherSkull;
import net.minecraft.server.v1_7_R2.NBTTagCompound;
@ -9,7 +8,6 @@ import net.minecraft.server.v1_7_R2.World;
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.Utils;
@ -63,7 +61,7 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -143,13 +141,6 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
return this.dead;
}
@Override
public void setPassengerNMS(NMSEntityBase passenger) {
if (passenger instanceof Entity) {
((Entity) passenger).setPassengerOf(this);
}
}
@Override
public int getIdNMS() {
return this.getId();

View File

@ -1,13 +1,17 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R3;
import net.minecraft.server.v1_7_R3.Entity;
import net.minecraft.server.v1_7_R3.EntityHorse;
import net.minecraft.server.v1_7_R3.NBTTagCompound;
import net.minecraft.server.v1_7_R3.World;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@ -153,4 +157,28 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R3;
import net.minecraft.server.v1_7_R3.Blocks;
import net.minecraft.server.v1_7_R3.Entity;
import net.minecraft.server.v1_7_R3.EntityHuman;
import net.minecraft.server.v1_7_R3.EntityItem;
import net.minecraft.server.v1_7_R3.EntityPlayer;
@ -15,9 +16,12 @@ import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSItem extends EntityItem implements NMSItem {
@ -90,7 +94,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -180,4 +184,28 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,14 +1,18 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R3;
import net.minecraft.server.v1_7_R3.Entity;
import net.minecraft.server.v1_7_R3.EntitySlime;
import net.minecraft.server.v1_7_R3.NBTTagCompound;
import net.minecraft.server.v1_7_R3.World;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@ -69,7 +73,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -140,4 +144,28 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -2,12 +2,10 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_7_R3;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.Utils;
import net.minecraft.server.v1_7_R3.Entity;
import net.minecraft.server.v1_7_R3.EntityWitherSkull;
import net.minecraft.server.v1_7_R3.NBTTagCompound;
import net.minecraft.server.v1_7_R3.PacketPlayOutEntityTeleport;
@ -61,7 +59,7 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -141,13 +139,6 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
return this.dead;
}
@Override
public void setPassengerNMS(NMSEntityBase passenger) {
if (passenger instanceof Entity) {
((Entity) passenger).setPassengerOf(this);
}
}
@Override
public int getIdNMS() {
return this.getId();

View File

@ -1,13 +1,17 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R4;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityHorse;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSHorse;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSHorse extends EntityHorse implements NMSHorse {
@ -153,5 +157,29 @@ public class EntityNMSHorse extends EntityHorse implements NMSHorse {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,6 +1,7 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R4;
import net.minecraft.server.v1_7_R4.Blocks;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityItem;
import net.minecraft.server.v1_7_R4.EntityPlayer;
@ -15,9 +16,12 @@ import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSItem extends EntityItem implements NMSItem {
@ -90,7 +94,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -180,4 +184,28 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -1,14 +1,18 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_7_R4;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntitySlime;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.World;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@ -69,7 +73,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -140,4 +144,28 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "g", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "h", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -2,12 +2,10 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_7_R4;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSWitherSkull;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.Utils;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityWitherSkull;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityTeleport;
@ -61,7 +59,7 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
@Override
public boolean isInvulnerable() {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -142,13 +140,6 @@ public class EntityNMSWitherSkull extends EntityWitherSkull implements NMSWither
return this.dead;
}
@Override
public void setPassengerNMS(NMSEntityBase passenger) {
if (passenger instanceof Entity) {
((Entity) passenger).setPassengerOf(this);
}
}
@Override
public int getIdNMS() {
return this.getId();

View File

@ -2,7 +2,6 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_8_R1;
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
import net.minecraft.server.v1_8_R1.DamageSource;
import net.minecraft.server.v1_8_R1.Entity;
import net.minecraft.server.v1_8_R1.EntityArmorStand;
import net.minecraft.server.v1_8_R1.EntityHuman;
import net.minecraft.server.v1_8_R1.EntityPlayer;
@ -15,7 +14,6 @@ import net.minecraft.server.v1_8_R1.World;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSArmorStand;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
import com.gmail.filoghost.holographicdisplays.util.Utils;
@ -203,13 +201,6 @@ public class EntityNMSArmorStand extends EntityArmorStand implements NMSArmorSta
return this.dead;
}
@Override
public void setPassengerNMS(NMSEntityBase passenger) {
if (passenger instanceof Entity) {
((Entity) passenger).mount(this);
}
}
@Override
public int getIdNMS() {
return this.getId();

View File

@ -1,5 +1,6 @@
package com.gmail.filoghost.holographicdisplays.nms.v1_8_R1;
import net.minecraft.server.v1_8_R1.Entity;
import net.minecraft.server.v1_8_R1.Blocks;
import net.minecraft.server.v1_8_R1.DamageSource;
import net.minecraft.server.v1_8_R1.EntityHuman;
@ -16,9 +17,12 @@ import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import com.gmail.filoghost.holographicdisplays.listener.MainListener;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.object.line.CraftItemLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ItemUtils;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSItem extends EntityItem implements NMSItem {
@ -96,7 +100,7 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
@Override
public boolean isInvulnerable(DamageSource source) {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -186,4 +190,28 @@ public class EntityNMSItem extends EntityItem implements NMSItem {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "ap", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "aq", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -2,14 +2,19 @@ package com.gmail.filoghost.holographicdisplays.nms.v1_8_R1;
import net.minecraft.server.v1_8_R1.AxisAlignedBB;
import net.minecraft.server.v1_8_R1.DamageSource;
import net.minecraft.server.v1_8_R1.Entity;
import net.minecraft.server.v1_8_R1.EntitySlime;
import net.minecraft.server.v1_8_R1.NBTTagCompound;
import net.minecraft.server.v1_8_R1.World;
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.line.CraftHologramLine;
import com.gmail.filoghost.holographicdisplays.object.line.CraftTouchSlimeLine;
import com.gmail.filoghost.holographicdisplays.util.DebugHandler;
import com.gmail.filoghost.holographicdisplays.util.ReflectionUtils;
public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@ -74,7 +79,7 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
@Override
public boolean isInvulnerable(DamageSource source) {
/*
/*
* The field Entity.invulnerable is private.
* It's only used while saving NBTTags, but since the entity would be killed
* on chunk unload, we prefer to override isInvulnerable().
@ -145,4 +150,28 @@ public class EntityNMSSlime extends EntitySlime implements NMSSlime {
public org.bukkit.entity.Entity getBukkitEntityNMS() {
return getBukkitEntity();
}
@Override
public void setPassengerOfNMS(NMSEntityBase vehicleBase) {
if (vehicleBase == null || !(vehicleBase instanceof Entity)) {
// It should never dismount
return;
}
Entity entity = (Entity) vehicleBase;
try {
ReflectionUtils.setPrivateField(Entity.class, this, "ap", (double) 0.0);
ReflectionUtils.setPrivateField(Entity.class, this, "aq", (double) 0.0);
} catch (Exception ex) {
DebugHandler.handleDebugException(ex);
}
if (this.vehicle != null) {
this.vehicle.passenger = null;
}
this.vehicle = entity;
entity.passenger = this;
}
}

View File

@ -10,8 +10,8 @@ import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
import com.gmail.filoghost.holographicdisplays.api.handler.PickupHandler;
import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
import com.gmail.filoghost.holographicdisplays.api.line.ItemLine;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSItem;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSRideable;
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
import com.gmail.filoghost.holographicdisplays.util.Offsets;
import com.gmail.filoghost.holographicdisplays.util.Validator;
@ -22,7 +22,7 @@ public class CraftItemLine extends CraftTouchableLine implements ItemLine {
private PickupHandler pickupHandler;
private NMSItem nmsItem;
private NMSRideable nmsVehicle;
private NMSEntityBase nmsVehicle;
public CraftItemLine(CraftHologram parent, ItemStack itemStack) {
super(0.7, parent);
@ -88,7 +88,7 @@ public class CraftItemLine extends CraftTouchableLine implements ItemLine {
nmsVehicle = HolographicDisplays.getNMSManager().spawnNMSWitherSkull(world, x, y + offset, z, this);
}
nmsVehicle.setPassengerNMS(nmsItem);
nmsItem.setPassengerOfNMS(nmsVehicle);
nmsItem.setLockTick(true);
nmsVehicle.setLockTick(true);
@ -143,7 +143,7 @@ public class CraftItemLine extends CraftTouchableLine implements ItemLine {
return nmsItem;
}
public NMSRideable getNmsVehicle() {
public NMSEntityBase getNmsVehicle() {
return nmsVehicle;
}

View File

@ -7,8 +7,9 @@ import org.bukkit.World;
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
import com.gmail.filoghost.holographicdisplays.api.handler.TouchHandler;
import com.gmail.filoghost.holographicdisplays.api.line.TextLine;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSCanMount;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSNameable;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSRideable;
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
import com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager;
import com.gmail.filoghost.holographicdisplays.util.Offsets;
@ -20,7 +21,7 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
private NMSNameable nmsNameble;
// Legacy code for < 1.7, not used in 1.8 and greater
private NMSRideable nmsSkullVehicle;
private NMSEntityBase nmsSkullVehicle;
public CraftTextLine(CraftHologram parent, String text) {
@ -79,8 +80,9 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
} else {
nmsNameble = HolographicDisplays.getNMSManager().spawnNMSHorse(world, x, y + Offsets.WITHER_SKULL_WITH_HORSE, z, this);
nmsSkullVehicle = HolographicDisplays.getNMSManager().spawnNMSWitherSkull(world, x, y + Offsets.WITHER_SKULL_WITH_HORSE, z, this);
nmsSkullVehicle.setPassengerNMS(nmsNameble);
// In 1.7 it must be an instanceof NMSCanMount
((NMSCanMount) nmsNameble).setPassengerOfNMS(nmsSkullVehicle);
nmsSkullVehicle.setLockTick(true);
}
@ -146,7 +148,7 @@ public class CraftTextLine extends CraftTouchableLine implements TextLine {
return nmsNameble;
}
public NMSRideable getNmsSkullVehicle() {
public NMSEntityBase getNmsSkullVehicle() {
return nmsSkullVehicle;
}

View File

@ -3,7 +3,7 @@ package com.gmail.filoghost.holographicdisplays.object.line;
import org.bukkit.World;
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSRideable;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSEntityBase;
import com.gmail.filoghost.holographicdisplays.nms.interfaces.entity.NMSSlime;
import com.gmail.filoghost.holographicdisplays.object.CraftHologram;
import com.gmail.filoghost.holographicdisplays.util.Offsets;
@ -17,7 +17,7 @@ public class CraftTouchSlimeLine extends CraftHologramLine {
private CraftTouchableLine touchablePiece;
private NMSSlime nmsSlime;
private NMSRideable nmsVehicle;
private NMSEntityBase nmsVehicle;
protected CraftTouchSlimeLine(CraftHologram parent, CraftTouchableLine touchablePiece) {
@ -43,8 +43,8 @@ public class CraftTouchSlimeLine extends CraftHologramLine {
} else {
nmsVehicle = HolographicDisplays.getNMSManager().spawnNMSWitherSkull(world, x, y + offset, z, this);
}
nmsVehicle.setPassengerNMS(nmsSlime);
nmsSlime.setPassengerOfNMS(nmsVehicle);
nmsSlime.setLockTick(true);
nmsVehicle.setLockTick(true);
@ -68,7 +68,7 @@ public class CraftTouchSlimeLine extends CraftHologramLine {
@Override
public void teleport(double x, double y, double z) {
public void teleport(double x, double y, double z) {
double offset = HolographicDisplays.is1_8() ? Offsets.ARMOR_STAND_WITH_SLIME : Offsets.WITHER_SKULL_WITH_SLIME;
@ -94,7 +94,7 @@ public class CraftTouchSlimeLine extends CraftHologramLine {
return nmsSlime;
}
public NMSRideable getNmsVehicle() {
public NMSEntityBase getNmsVehicle() {
return nmsVehicle;
}