com.captainbern.reflection.Reflection Java Examples
The following examples show how to use
com.captainbern.reflection.Reflection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@Override public <T extends ControllableEntityHandle<? extends LivingEntity>> T createHandle(ControllableEntity entity, Location location) { SafeConstructor<ControllableEntityHandle> entityConstructor = new Reflection().reflect(entity.getEntityType().getHandleClass()).getSafeConstructor(World.class, entity.getEntityType().getControllableInterface()); EntityRegistrationEntry oldEntry = GameRegistry.get(IEntityRegistry.class).getDefaultEntryFor(entity.getEntityType()); GameRegistry.get(IEntityRegistry.class).register(new EntityRegistrationEntry( entity.getEntityType().getName(), entity.getEntityType().getId(), entity.getEntityType().getHandleClass() )); WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle(); T handle = (T) entityConstructor.getAccessor().invoke(worldServer, entity); handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); worldServer.addEntity((net.minecraft.server.v1_7_R1.Entity) handle, CreatureSpawnEvent.SpawnReason.CUSTOM); GameRegistry.get(IEntityRegistry.class).register(oldEntry); Material beneath = location.getBlock().getRelative(BlockFace.DOWN).getType(); if (beneath.isBlock()) { // What lies beneath ((Entity) handle).onGround = true; } return handle; }
Example #2
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@Override public <T extends ControllableEntityHandle<? extends LivingEntity>> T createHandle(ControllableEntity entity, Location location) { SafeConstructor<ControllableEntityHandle> entityConstructor = new Reflection().reflect(entity.getEntityType().getHandleClass()).getSafeConstructor(World.class, entity.getEntityType().getControllableInterface()); EntityRegistrationEntry oldEntry = GameRegistry.get(IEntityRegistry.class).getDefaultEntryFor(entity.getEntityType()); GameRegistry.get(IEntityRegistry.class).register(new EntityRegistrationEntry( entity.getEntityType().getName(), entity.getEntityType().getId(), entity.getEntityType().getHandleClass() )); WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle(); T handle = (T) entityConstructor.getAccessor().invoke(worldServer, entity); handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); worldServer.addEntity((net.minecraft.server.v1_7_R1.Entity) handle, CreatureSpawnEvent.SpawnReason.CUSTOM); GameRegistry.get(IEntityRegistry.class).register(oldEntry); Material beneath = location.getBlock().getRelative(BlockFace.DOWN).getType(); if (beneath.isBlock()) { // What lies beneath ((Entity) handle).onGround = true; } return handle; }
Example #3
Source File: EntityAPICore.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
private void initializeGameComponents() { try { Class<? extends IEntityRegistry> entityRegistry = Class.forName(EntityAPI.INTERNAL_NMS_PATH + ".game.EntityRegistry").asSubclass(IEntityRegistry.class); GameRegistry.registerPermanently(IEntityRegistry.class, new Reflection().reflect(entityRegistry).getSafeConstructor().getAccessor().invoke()); Class<? extends IEntitySpawnHandler> spawnHandler = Class.forName(EntityAPI.INTERNAL_NMS_PATH + ".game.EntitySpawnHandler").asSubclass(IEntitySpawnHandler.class); GameRegistry.register(IEntitySpawnHandler.class, new Reflection().reflect(spawnHandler).getSafeConstructor().getAccessor().invoke()); } catch (Exception e) { ConsoleCommandSender console = this.getServer().getConsoleSender(); console.sendMessage(ChatColor.RED + "-------------------------------"); console.sendMessage(ChatColor.RED + "Failed to initialize the game components!"); console.sendMessage(ChatColor.RED + "-------------------------------"); } }
Example #4
Source File: NMSEntityUtil.java From EchoPet with GNU General Public License v3.0 | 5 votes |
protected static void initializeFields() { try { ClassTemplate goalTemplate = new Reflection().reflect(MinecraftReflection.getMinecraftClass("PathfinderGoalSelector")); List<SafeMethod<Void>> methodCandidates = goalTemplate.getSafeMethods(withArguments(int.class, MinecraftReflection.getMinecraftClass("PathfinderGoal"))); if (methodCandidates.size() > 0) { ADD_GOAL = methodCandidates.get(0).getAccessor(); } else { throw new RuntimeException("Failed to get the addGoal method!"); } List<SafeField<List>> fieldCandidates = goalTemplate.getSafeFields(withType(List.class)); if (fieldCandidates.size() > 1) { GOALS = fieldCandidates.get(0).getAccessor(); ACTIVE_GOALS = fieldCandidates.get(0).getAccessor(); } else { throw new RuntimeException("Failed to initialize the goal-lists!"); } // The GoalSelector ClassTemplate entityTemplate = new Reflection().reflect(MinecraftReflection.getMinecraftClass("EntityInsentient")); List<SafeField<Object>> candidates = entityTemplate.getSafeFields(withType(goalTemplate.getReflectedClass())); if (candidates.size() > 0) { GOAL_SELECTOR = candidates.get(0).getAccessor(); // the normal selector is the first one } else { throw new RuntimeException("Failed to initialize the GoalSelector field for the entities"); } } catch (Exception ಠ_ಠ) { throw new RuntimeException("Failed to initialize the goal-related fields!", ಠ_ಠ); } }
Example #5
Source File: NMSEntityUtil.java From EchoPet with GNU General Public License v3.0 | 5 votes |
protected static void initializeFields() { try { ClassTemplate goalTemplate = new Reflection().reflect(MinecraftReflection.getMinecraftClass("PathfinderGoalSelector")); List<SafeMethod<Void>> methodCandidates = goalTemplate.getSafeMethods(withArguments(int.class, MinecraftReflection.getMinecraftClass("PathfinderGoal"))); if (methodCandidates.size() > 0) { ADD_GOAL = methodCandidates.get(0).getAccessor(); } else { throw new RuntimeException("Failed to get the addGoal method!"); } List<SafeField<List>> fieldCandidates = goalTemplate.getSafeFields(withType(List.class)); if (fieldCandidates.size() > 1) { GOALS = fieldCandidates.get(0).getAccessor(); ACTIVE_GOALS = fieldCandidates.get(0).getAccessor(); } else { throw new RuntimeException("Failed to initialize the goal-lists!"); } // The GoalSelector ClassTemplate entityTemplate = new Reflection().reflect(MinecraftReflection.getMinecraftClass("EntityInsentient")); List<SafeField<Object>> candidates = entityTemplate.getSafeFields(withType(goalTemplate.getReflectedClass())); if (candidates.size() > 0) { GOAL_SELECTOR = candidates.get(0).getAccessor(); // the normal selector is the first one } else { throw new RuntimeException("Failed to initialize the GoalSelector field for the entities"); } } catch (Exception ಠ_ಠ) { throw new RuntimeException("Failed to initialize the goal-related fields!", ಠ_ಠ); } }
Example #6
Source File: FixedNetworkManager.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
protected void swapFields() { if (CHANNEL_FIELD == null) { CHANNEL_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(Channel.class).getAccessor(); } if (ADDRESS_FIELD == null) { ADDRESS_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(SocketAddress.class).getAccessor(); } CHANNEL_FIELD.set(this, new NullChannel(null)); ADDRESS_FIELD.set(this, new SocketAddress() {}); }
Example #7
Source File: ControlledRidingAttributeBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRide(float[] motion) { EntityLiving entity = (EntityLiving) this.getControllableEntity().getHandle(); if (entity.passenger == null) { return; } if (!canControl((LivingEntity) entity.getBukkitEntity())) { return; } entity.X = 0.5F; entity.lastYaw = entity.yaw = entity.passenger.yaw; entity.pitch = entity.passenger.pitch * 0.5F; if (this.isVehicleMotionOverriden() || motion[0] == 0.0F) { motion[0] = ((EntityLiving) entity.passenger).be * 0.5F; } if (this.isVehicleMotionOverriden() || motion[2] == 0.0F) { motion[2] = ((EntityLiving) entity.passenger).bf; } // boolean bD boolean jumping = (Boolean) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Boolean.class)).get(2).getAccessor().get(entity); if (this.canFly()) { if (jumping) { motion[1] = 0.5F; } else if (entity.passenger.pitch >= 50) { motion[1] = -0.25F; } } else if (entity.onGround && this.isJumpingEnabled()) { if (jumping) { motion[1] = 0.5F; } } }
Example #8
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cS() { if (!this.world.isStatic) { // int bF SafeField<Integer> field_bF = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(2); field_bF.getAccessor().set(this, 1); // Stop looking down (animation 32) this.p(true); } }
Example #9
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cQ() { // Possibly just call the method instead...But that won't work with Cauldron :\ if (!this.world.isStatic) { // int bE SafeField<Integer> field_bE = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(1); field_bE.getAccessor().set(this, 1); // Open the horse's mouth (animation 128) this.horseVisual(128, true); } }
Example #10
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private SafeConstructor<ControllableEntityHandle> getConstructorFor(ControllableEntityType type) { SafeConstructor<ControllableEntityHandle> entityTypeSafeConstructor = typeToConstructor.get(type); if (entityTypeSafeConstructor == null) { entityTypeSafeConstructor = (SafeConstructor<ControllableEntityHandle>) new Reflection().reflect(type.getHandleClass()).getSafeConstructor(World.class, type.getControllableInterface()); typeToConstructor.put(type, entityTypeSafeConstructor); } return entityTypeSafeConstructor; }
Example #11
Source File: EntityUtil.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
protected static void initializeFields() { try { ClassTemplate goalTemplate = new Reflection().reflect(MinecraftReflection.getMinecraftClass("PathfinderGoalSelector")); List<SafeMethod<Void>> methodCandidates = goalTemplate.getSafeMethods(withArguments(int.class, MinecraftReflection.getMinecraftClass("PathfinderGoal"))); if (methodCandidates.size() > 0) { ADD_GOAL = methodCandidates.get(0).getAccessor(); } else { throw new RuntimeException("Failed to get the addGoal method!"); } List<SafeField<List>> fieldCandidates = goalTemplate.getSafeFields(withType(List.class)); if (fieldCandidates.size() > 1) { GOALS = fieldCandidates.get(0).getAccessor(); ACTIVE_GOALS = fieldCandidates.get(0).getAccessor(); } else { throw new RuntimeException("Failed to initialize the goal-lists!"); } // The GoalSelector ClassTemplate entityTemplate = new Reflection().reflect(MinecraftReflection.getMinecraftClass("EntityInsentient")); List<SafeField<Object>> candidates = entityTemplate.getSafeFields(withType(goalTemplate.getReflectedClass())); if (candidates.size() > 0) { GOAL_SELECTOR = candidates.get(0).getAccessor(); // the normal selector is the first one } else { throw new RuntimeException("Failed to initialize the GoalSelector field for the entities"); } } catch (Exception ಠ_ಠ) { throw new RuntimeException("Failed to initialize the goal-related fields!", ಠ_ಠ); } }
Example #12
Source File: ControllableBaseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
public ControllableBaseEntity(int id, ControllableEntityType entityType, EntityManager manager) { this.accessor = (NMSAccessor<T, S>) new Reflection().reflect(EntityAPI.INTERNAL_NMS_PATH + ".NMSAccessorImpl").getSafeConstructor(ControllableEntity.class).getAccessor().invoke(this); this.manager = manager; this.ID = id; this.mind = new Mind(); this.mind.setControllableEntity(this); this.entityType = entityType; this.initSounds(); }
Example #13
Source File: Behaviour.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
protected Behaviour(Object... args) { Class<?>[] classes = new Class[args.length]; if (args.length > 0) { for (int i = 0; i < args.length; i++) { classes[i] = args[i].getClass(); } } this.behaviourGoal = (BehaviourGoal) new Reflection().reflect(EntityAPI.INTERNAL_NMS_PATH + ".entity.mind.behaviour.goals.BehaviourGoal" + this.getKey()).getSafeConstructor(classes).getAccessor().invoke(args); }
Example #14
Source File: FixedNetworkManager.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
protected void swapFields() { if (CHANNEL_FIELD == null) { CHANNEL_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(Channel.class).getAccessor(); } if (ADDRESS_FIELD == null) { ADDRESS_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(SocketAddress.class).getAccessor(); } CHANNEL_FIELD.set(this, new NullChannel(null)); ADDRESS_FIELD.set(this, new SocketAddress() {}); }
Example #15
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cS() { if (!this.world.isStatic) { // int bF SafeField<Integer> field_bF = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(2); field_bF.getAccessor().set(this, 1); // Stop looking down (animation 32) this.p(true); } }
Example #16
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cQ() { // Possibly just call the method instead...But that won't work with Cauldron :\ if (!this.world.isStatic) { // int bE SafeField<Integer> field_bE = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(1); field_bE.getAccessor().set(this, 1); // Open the horse's mouth (animation 128) this.horseVisual(128, true); } }
Example #17
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cS() { if (!this.world.isStatic) { // int bF SafeField<Integer> field_bF = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(2); field_bF.getAccessor().set(this, 1); // Stop looking down (animation 32) this.p(true); } }
Example #18
Source File: ControlledRidingAttributeBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRide(float[] motion) { EntityLiving entity = (EntityLiving) this.getControllableEntity().getHandle(); if (entity.passenger == null) { return; } if (!canControl((LivingEntity) entity.getBukkitEntity())) { return; } entity.X = 0.5F; entity.lastYaw = entity.yaw = entity.passenger.yaw; entity.pitch = entity.passenger.pitch * 0.5F; if (this.isVehicleMotionOverriden() || motion[0] == 0.0F) { motion[0] = ((EntityLiving) entity.passenger).be * 0.5F; } if (this.isVehicleMotionOverriden() || motion[2] == 0.0F) { motion[2] = ((EntityLiving) entity.passenger).bf; } // boolean bD boolean jumping = (Boolean) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Boolean.class)).get(2).getAccessor().get(entity); if (this.canFly()) { if (jumping) { motion[1] = 0.5F; } else if (entity.passenger.pitch >= 50) { motion[1] = -0.25F; } } else if (entity.onGround && this.isJumpingEnabled()) { if (jumping) { motion[1] = 0.5F; } } }
Example #19
Source File: FixedNetworkManager.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
protected void swapFields() { if (CHANNEL_FIELD == null) { CHANNEL_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(Channel.class).getAccessor(); } if (ADDRESS_FIELD == null) { ADDRESS_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(InetSocketAddress.class).getAccessor(); } CHANNEL_FIELD.set(this, new NullChannel(null)); ADDRESS_FIELD.set(this, null); }
Example #20
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cQ() { // Possibly just call the method instead...But that won't work with Cauldron :\ if (!this.world.isStatic) { // int bE SafeField<Integer> field_bE = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(1); field_bE.getAccessor().set(this, 1); // Open the horse's mouth (animation 128) this.horseVisual(128, true); } }
Example #21
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cS() { if (!this.world.isStatic) { // int bF SafeField<Integer> field_bF = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(2); field_bF.getAccessor().set(this, 1); // Stop looking down (animation 32) this.p(true); } }
Example #22
Source File: ControlledRidingAttributeBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRide(float[] motion) { EntityLiving entity = (EntityLiving) this.getControllableEntity().getHandle(); if (entity.passenger == null) { return; } if (!canControl((LivingEntity) entity.getBukkitEntity())) { return; } entity.X = 0.5F; entity.lastYaw = entity.yaw = entity.passenger.yaw; entity.pitch = entity.passenger.pitch * 0.5F; if (this.isVehicleMotionOverriden() || motion[0] == 0.0F) { motion[0] = ((EntityLiving) entity.passenger).be * 0.5F; } if (this.isVehicleMotionOverriden() || motion[2] == 0.0F) { motion[2] = ((EntityLiving) entity.passenger).bf; } // boolean bD boolean jumping = (Boolean) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Boolean.class)).get(2).getAccessor().get(entity); if (this.canFly()) { if (jumping) { motion[1] = 0.5F; } else if (entity.passenger.pitch >= 50) { motion[1] = -0.25F; } } else if (entity.onGround && this.isJumpingEnabled()) { if (jumping) { motion[1] = 0.5F; } } }
Example #23
Source File: FixedNetworkManager.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
protected void swapFields() { if (CHANNEL_FIELD == null) { CHANNEL_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(Channel.class).getAccessor(); } if (ADDRESS_FIELD == null) { ADDRESS_FIELD = new Reflection().reflect(NetworkManager.class).getSafeFieldByType(InetSocketAddress.class).getAccessor(); } CHANNEL_FIELD.set(this, new NullChannel(null)); ADDRESS_FIELD.set(this, null); }
Example #24
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private SafeConstructor<ControllableEntityHandle> getConstructorFor(ControllableEntityType type) { SafeConstructor<ControllableEntityHandle> entityTypeSafeConstructor = typeToConstructor.get(type); if (entityTypeSafeConstructor == null) { entityTypeSafeConstructor = (SafeConstructor<ControllableEntityHandle>) new Reflection().reflect(type.getHandleClass()).getSafeConstructor(World.class, type.getControllableInterface()); typeToConstructor.put(type, entityTypeSafeConstructor); } return entityTypeSafeConstructor; }
Example #25
Source File: ControllableHorseEntity.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
private void cQ() { // Possibly just call the method instead...But that won't work with Cauldron :\ if (!this.world.isStatic) { // int bE SafeField<Integer> field_bE = (SafeField<Integer>) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Integer.class)).get(1); field_bE.getAccessor().set(this, 1); // Open the horse's mouth (animation 128) this.horseVisual(128, true); } }
Example #26
Source File: ControlledRidingAttributeBase.java From EntityAPI with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onRide(float[] motion) { EntityLiving entity = (EntityLiving) this.getControllableEntity().getHandle(); if (entity.passenger == null) { return; } if (!canControl((LivingEntity) entity.getBukkitEntity())) { return; } entity.X = 0.5F; entity.lastYaw = entity.yaw = entity.passenger.yaw; entity.pitch = entity.passenger.pitch * 0.5F; if (this.isVehicleMotionOverriden() || motion[0] == 0.0F) { motion[0] = ((EntityLiving) entity.passenger).be * 0.5F; } if (this.isVehicleMotionOverriden() || motion[2] == 0.0F) { motion[2] = ((EntityLiving) entity.passenger).bf; } // boolean bD boolean jumping = (Boolean) new Reflection().reflect(EntityHorse.class).getSafeFields(withExactType(Boolean.class)).get(2).getAccessor().get(entity); if (this.canFly()) { if (jumping) { motion[1] = 0.5F; } else if (entity.passenger.pitch >= 50) { motion[1] = -0.25F; } } else if (entity.onGround && this.isJumpingEnabled()) { if (jumping) { motion[1] = 0.5F; } } }
Example #27
Source File: EntityUtil.java From EntityAPI with GNU Lesser General Public License v3.0 | 4 votes |
protected static Class<?> getNmsFromMethod(Class<?> type) { final MethodAccessor<Object> accessor = new Reflection().reflect(type).getSafeMethod("getHandle").getAccessor(); return accessor.getMethod().member().getReturnType(); }
Example #28
Source File: EntityUtil.java From EntityAPI with GNU Lesser General Public License v3.0 | 4 votes |
protected static Class<?> getNmsFromField(Class<?> type) { final FieldAccessor<Object> accessor = new Reflection().reflect(type).getSafeFieldByName("handle").getAccessor(); return accessor.getField().member().getType(); }
Example #29
Source File: EntityBuilder.java From EntityAPI with GNU Lesser General Public License v3.0 | 4 votes |
public ControllableEntity create() { if (this.type == null) throw new NullPointerException("ControllableEntity Type cannot be null."); if (this.location == null) throw new NullPointerException("Location cannot be null."); if (this.type.isNameRequired() && this.name.isEmpty()) throw new IllegalStateException("Entity: " + this.type.toString() + " requires a name!"); int id = this.entityManager.getNextID(); ControllableEntity entity; if (this.type.isNameRequired()) { // Fix the name, in case it's too long if (this.name.length() > 16) this.name = name.substring(0, 16); entity = new Reflection().reflect(this.type.getControllableClass()).getSafeConstructor(int.class, String.class, EntityManager.class).getAccessor().invoke(id, this.name, this.entityManager); } else { entity = new Reflection().reflect(this.type.getControllableClass()).getSafeConstructor(int.class, EntityManager.class).getAccessor().invoke(id, this.entityManager); } if (entity != null) { if (this.prepare || this.mind == null) { this.mind = new Mind(); } this.mind.setControllableEntity(entity); if (this.prepare) { entity.setDefaultBehaviours(); } else { for (Map.Entry<Behaviour, Integer> entry : this.behaviours.entrySet()) { entity.getMind().getMovementBehaviourSelector().addBehaviour(entry.getKey(), entry.getValue()); } } if (this.name != null) { entity.setName(this.name); } if (forceSpawn) { if (!this.location.getChunk().isLoaded()) { this.location.getChunk().load(); } } entityManager.getChunkManager().queueSpawn(entity, this.location); return entity; } return null; }
Example #30
Source File: EntityPacketPet.java From EchoPet with GNU General Public License v3.0 | 4 votes |
private void injectToList(PacketPlayOutPlayerInfo playerInfoPacket, PlayerInfoData infoData) { List playerList = (List) new Reflection().reflect(playerInfoPacket.getClass()).getSafeFields(Matchers.withExactType(List.class)).get(0).getAccessor().get(playerInfoPacket); playerList.add(infoData); }