Skip to content

Commit

Permalink
Fix compile error with potions
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 16, 2016
1 parent b0bffb9 commit 71c38d3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/main/java/net/citizensnpcs/npc/EntityControllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static void setEntityControllerForType(EntityType type, Class<? extends E
TYPES.put(EntityType.IRON_GOLEM, IronGolemController.class);
TYPES.put(EntityType.ITEM_FRAME, ItemFrameController.class);
TYPES.put(EntityType.LEASH_HITCH, LeashController.class);
TYPES.put(EntityType.LINGERING_POTION, ThrownPotionController.class);
TYPES.put(EntityType.MAGMA_CUBE, MagmaCubeController.class);
TYPES.put(EntityType.MINECART, MinecartRideableController.class);
TYPES.put(EntityType.MINECART_CHEST, MinecartChestController.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package net.citizensnpcs.npc.entity.nonliving;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftLingeringPotion;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.util.Vector;

import net.citizensnpcs.api.event.NPCPushEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.MobEntityController;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_9_R1.EntityPotion;
import net.minecraft.server.v1_9_R1.Items;
import net.minecraft.server.v1_9_R1.NBTTagCompound;
import net.minecraft.server.v1_9_R1.World;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R1.CraftServer;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftThrownPotion;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.util.Vector;

public class ThrownPotionController extends MobEntityController {
public ThrownPotionController() {
super(EntityThrownPotionNPC.class);
Expand All @@ -34,11 +35,6 @@ public EntityThrownPotionNPC(World world) {
this(world, null);
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

public EntityThrownPotionNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
Expand All @@ -54,6 +50,11 @@ public void collide(net.minecraft.server.v1_9_R1.Entity entity) {
}
}

@Override
public boolean d(NBTTagCompound save) {
return npc == null ? super.d(save) : false;
}

@Override
public void g(double x, double y, double z) {
if (npc == null) {
Expand All @@ -79,7 +80,11 @@ public void g(double x, double y, double z) {
@Override
public CraftEntity getBukkitEntity() {
if (bukkitEntity == null && npc != null) {
bukkitEntity = new ThrownPotionNPC(this);
if (getItem() != null && getItem().getItem().equals(Items.LINGERING_POTION)) {
bukkitEntity = new LingeringThrownPotionNPC(this);
} else {
bukkitEntity = new SplashThrownPotionNPC(this);
}
}
return super.getBukkitEntity();
}
Expand All @@ -99,10 +104,24 @@ public void m() {
}
}

public static class ThrownPotionNPC extends CraftThrownPotion implements NPCHolder {
public static class LingeringThrownPotionNPC extends CraftLingeringPotion implements NPCHolder {
private final CitizensNPC npc;

public LingeringThrownPotionNPC(EntityThrownPotionNPC entity) {
super((CraftServer) Bukkit.getServer(), entity);
this.npc = entity.npc;
}

@Override
public NPC getNPC() {
return npc;
}
}

public static class SplashThrownPotionNPC extends CraftLingeringPotion implements NPCHolder {
private final CitizensNPC npc;

public ThrownPotionNPC(EntityThrownPotionNPC entity) {
public SplashThrownPotionNPC(EntityThrownPotionNPC entity) {
super((CraftServer) Bukkit.getServer(), entity);
this.npc = entity.npc;
}
Expand Down

0 comments on commit 71c38d3

Please sign in to comment.