mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 20:25:19 +01:00
Forward the rest of the RegistryMaterials methods and fix player looking
This commit is contained in:
parent
0fa0d29f17
commit
07a3aeabad
@ -8,8 +8,10 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.material.Door;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@ -391,12 +393,17 @@ public class CitizensNavigator implements Navigator, Runnable {
|
|||||||
|
|
||||||
private static class DoorOpener implements PathCallback {
|
private static class DoorOpener implements PathCallback {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void run(NPC npc, Block point, ListIterator<Block> path) {
|
public void run(NPC npc, Block point, ListIterator<Block> path) {
|
||||||
|
BlockState state = point.getState();
|
||||||
|
Door door = (Door) state.getData();
|
||||||
if (npc.getStoredLocation().distance(point.getLocation()) < 2) {
|
if (npc.getStoredLocation().distance(point.getLocation()) < 2) {
|
||||||
boolean bottom = (point.getData() & 8) == 0;
|
boolean bottom = !door.isTopHalf();
|
||||||
Block set = bottom ? point : point.getRelative(BlockFace.DOWN);
|
Block set = bottom ? point : point.getRelative(BlockFace.DOWN);
|
||||||
set.setData((byte) ((set.getData() & 7) | 4));
|
state = set.getState();
|
||||||
|
door = (Door) state.getData();
|
||||||
|
door.setOpen(true);
|
||||||
|
state.setData(door);
|
||||||
|
state.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
moveOnCurrentHeading();
|
moveOnCurrentHeading();
|
||||||
}
|
}
|
||||||
|
NMSImpl.updateAI(this);
|
||||||
|
|
||||||
if (noDamageTicks > 0) {
|
if (noDamageTicks > 0) {
|
||||||
--noDamageTicks;
|
--noDamageTicks;
|
||||||
@ -330,7 +331,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void moveOnCurrentHeading() {
|
private void moveOnCurrentHeading() {
|
||||||
NMSImpl.updateAI(this);
|
|
||||||
if (bd) {
|
if (bd) {
|
||||||
if (onGround && jumpTicks == 0) {
|
if (onGround && jumpTicks == 0) {
|
||||||
cm();
|
cm();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package net.citizensnpcs.nms.v1_11_R1.util;
|
package net.citizensnpcs.nms.v1_11_R1.util;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
@ -10,6 +13,7 @@ import net.minecraft.server.v1_11_R1.Entity;
|
|||||||
import net.minecraft.server.v1_11_R1.MinecraftKey;
|
import net.minecraft.server.v1_11_R1.MinecraftKey;
|
||||||
import net.minecraft.server.v1_11_R1.RegistryMaterials;
|
import net.minecraft.server.v1_11_R1.RegistryMaterials;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public class CustomEntityRegistry extends RegistryMaterials {
|
public class CustomEntityRegistry extends RegistryMaterials {
|
||||||
private final BiMap<MinecraftKey, Class<? extends Entity>> entities = HashBiMap.create();
|
private final BiMap<MinecraftKey, Class<? extends Entity>> entities = HashBiMap.create();
|
||||||
private final BiMap<Class<? extends Entity>, MinecraftKey> entityClasses = this.entities.inverse();
|
private final BiMap<Class<? extends Entity>, MinecraftKey> entityClasses = this.entities.inverse();
|
||||||
@ -34,6 +38,11 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
|||||||
return wrapped.a((Class<? extends Entity>) key);
|
return wrapped.a((Class<? extends Entity>) key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object a(Random paramRandom) {
|
||||||
|
return wrapped.a(paramRandom);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftKey b(Object value) {
|
public MinecraftKey b(Object value) {
|
||||||
if (entityClasses.containsKey(value)) {
|
if (entityClasses.containsKey(value)) {
|
||||||
@ -43,6 +52,11 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
|||||||
return wrapped.b((Class<? extends Entity>) value);
|
return wrapped.b((Class<? extends Entity>) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean d(Object paramK) {
|
||||||
|
return wrapped.d((MinecraftKey) paramK);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Entity> get(Object key) {
|
public Class<? extends Entity> get(Object key) {
|
||||||
if (entities.containsKey(key)) {
|
if (entities.containsKey(key)) {
|
||||||
@ -52,10 +66,25 @@ public class CustomEntityRegistry extends RegistryMaterials {
|
|||||||
return wrapped.get((MinecraftKey) key);
|
return wrapped.get((MinecraftKey) key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getId(int paramInt) {
|
||||||
|
return wrapped.getId(paramInt);
|
||||||
|
}
|
||||||
|
|
||||||
public RegistryMaterials<MinecraftKey, Class<? extends Entity>> getWrapped() {
|
public RegistryMaterials<MinecraftKey, Class<? extends Entity>> getWrapped() {
|
||||||
return wrapped;
|
return wrapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<Object> iterator() {
|
||||||
|
return (Iterator) wrapped.iterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Object> keySet() {
|
||||||
|
return (Set) wrapped.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
public void put(int entityId, MinecraftKey key, Class<? extends Entity> entityClass) {
|
public void put(int entityId, MinecraftKey key, Class<? extends Entity> entityClass) {
|
||||||
entities.put(key, entityClass);
|
entities.put(key, entityClass);
|
||||||
entityIds.put(entityClass, entityId);
|
entityIds.put(entityClass, entityId);
|
||||||
|
@ -810,11 +810,11 @@ public class NMSImpl implements NMSBridge {
|
|||||||
return;
|
return;
|
||||||
EntityLiving handle = (EntityLiving) getHandle(entity);
|
EntityLiving handle = (EntityLiving) getHandle(entity);
|
||||||
yaw = Util.clampYaw(yaw);
|
yaw = Util.clampYaw(yaw);
|
||||||
handle.aN = yaw;
|
|
||||||
if (!(handle instanceof EntityHuman)) {
|
|
||||||
handle.aL = yaw;
|
|
||||||
}
|
|
||||||
handle.aO = yaw;
|
handle.aO = yaw;
|
||||||
|
if (!(handle instanceof EntityHuman)) {
|
||||||
|
handle.aN = yaw;
|
||||||
|
}
|
||||||
|
handle.aP = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user