mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-11 01:38:07 +02:00
Fix enderman disguise
This commit is contained in:
parent
11a26a36c0
commit
dedc043558
@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
@ -128,8 +129,8 @@ public class FlagType<Y>
|
|||||||
|
|
||||||
public static FlagType<Boolean> ENDERMAN_AGRESSIVE = new FlagType<Boolean>(EndermanWatcher.class, 1, false);
|
public static FlagType<Boolean> ENDERMAN_AGRESSIVE = new FlagType<Boolean>(EndermanWatcher.class, 1, false);
|
||||||
|
|
||||||
public static FlagType<Optional<Integer>> ENDERMAN_ITEM = new FlagType<Optional<Integer>>(EndermanWatcher.class, 0,
|
public static FlagType<Optional<WrappedBlockData>> ENDERMAN_ITEM = new FlagType<Optional<WrappedBlockData>>(
|
||||||
Optional.of(1));
|
EndermanWatcher.class, 0, Optional.<WrappedBlockData> absent());
|
||||||
|
|
||||||
public static FlagType<Integer> ENTITY_AIR_TICKS = new FlagType<Integer>(FlagWatcher.class, 1, 0);
|
public static FlagType<Integer> ENTITY_AIR_TICKS = new FlagType<Integer>(FlagWatcher.class, 1, 0);
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|
||||||
|
|
||||||
public class EndermanWatcher extends InsentientWatcher
|
public class EndermanWatcher extends InsentientWatcher
|
||||||
{
|
{
|
||||||
@ -20,13 +20,13 @@ public class EndermanWatcher extends InsentientWatcher
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInMainHand()
|
public ItemStack getItemInMainHand()
|
||||||
{
|
{
|
||||||
Optional<Integer> value = getValue(FlagType.ENDERMAN_ITEM);
|
Optional<WrappedBlockData> value = getValue(FlagType.ENDERMAN_ITEM);
|
||||||
|
|
||||||
if (value.isPresent())
|
if (value.isPresent())
|
||||||
{
|
{
|
||||||
Pair<Integer, Integer> pair = ReflectionManager.getFromCombinedId(value.get());
|
WrappedBlockData pair = value.get();
|
||||||
int id = pair.getLeft();
|
Material id = pair.getType();
|
||||||
int data = pair.getRight();
|
int data = pair.getData();
|
||||||
|
|
||||||
return new ItemStack(id, 1, (short) data);
|
return new ItemStack(id, 1, (short) data);
|
||||||
}
|
}
|
||||||
@ -42,16 +42,33 @@ public class EndermanWatcher extends InsentientWatcher
|
|||||||
setItemInMainHand(itemstack.getTypeId(), itemstack.getDurability());
|
setItemInMainHand(itemstack.getTypeId(), itemstack.getDurability());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setItemInMainHand(int typeId)
|
public void setItemInMainHand(int typeId)
|
||||||
{
|
{
|
||||||
setItemInMainHand(typeId, 0);
|
setItemInMainHand(typeId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItemInMainHand(Material type)
|
||||||
|
{
|
||||||
|
setItemInMainHand(type, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemInMainHand(Material type, int data)
|
||||||
|
{
|
||||||
|
Optional<WrappedBlockData> optional;
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
optional = Optional.<WrappedBlockData> absent();
|
||||||
|
else
|
||||||
|
optional = Optional.<WrappedBlockData> of(WrappedBlockData.createData(type, data));
|
||||||
|
|
||||||
|
setValue(FlagType.ENDERMAN_ITEM, optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void setItemInMainHand(int typeId, int data)
|
public void setItemInMainHand(int typeId, int data)
|
||||||
{
|
{
|
||||||
int combined = ReflectionManager.getCombinedId(typeId, data);
|
setItemInMainHand(Material.getMaterial(typeId), data);
|
||||||
|
|
||||||
setValue(FlagType.ENDERMAN_ITEM, Optional.of(combined));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive()
|
public boolean isAggressive()
|
||||||
|
Loading…
Reference in New Issue
Block a user