/** * Initializes an entities type on construction to specify what group this * entity is in for activation ranges. * * @param entity * @return group id */ public static byte initializeEntityActivationType(Entity entity) { Chunk chunk = null; // Cauldron start - account for entities that dont extend EntityMob, EntityAmbientCreature, EntityCreature if ( entity instanceof EntityMob || entity instanceof EntitySlime || entity.isCreatureType(EnumCreatureType.monster, false)) // Cauldron - account for entities that dont extend EntityMob { return 1; // Monster } else if ( entity instanceof EntityCreature || entity instanceof EntityAmbientCreature || entity.isCreatureType(EnumCreatureType.creature, false) || entity.isCreatureType(EnumCreatureType.waterCreature, false) || entity.isCreatureType(EnumCreatureType.ambient, false)) { return 2; // Animal // Cauldron end } else { return 3; // Misc } }
protected Relation determineRelation() { if (entity instanceof EntityMob) { return Relation.FOE; } else if (entity instanceof EntitySlime) { return Relation.FOE; } else if (entity instanceof EntityGhast) { return Relation.FOE; } else if (entity instanceof EntityAnimal) { return Relation.FRIEND; } else if (entity instanceof EntitySquid) { return Relation.FRIEND; } else if (entity instanceof EntityAmbientCreature) { return Relation.FRIEND; } else { return Relation.UNKNOWN; } }
@Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { if (entity instanceof EntityLivingBase && !(entity instanceof EntityAmbientCreature)) { EntityLivingBase living = (EntityLivingBase) entity; BlockPos feetPos = new BlockPos(living.posX, living.getEntityBoundingBox().minY + 0.5D, living.posZ); if (feetPos.equals(pos) && !EBlockWeight.getWeight(world .getBlockState(pos.down())) .canSupport(this.getWeight(state))) { world.destroyBlock(pos, true); } } }
/** * Initializes an entities type on construction to specify what group this * entity is in for activation ranges. * * @param entity * @return group id */ public static byte initializeEntityActivationType(Entity entity) { Chunk chunk = null; // Cauldron start - account for entities that dont extend EntityMob, EntityAmbientCreature, EntityCreature if ( entity.getClass().equals(EntityMob.class) || entity.getClass().equals(EntitySlime.class) || entity.isCreatureType(EnumCreatureType.monster, false)) // Cauldron - account for entities that dont extend EntityMob { return 1; // Monster } else if ( entity.getClass().equals(EntityCreature.class) || entity.getClass().equals(EntityAmbientCreature.class) || entity.isCreatureType(EnumCreatureType.creature, false) || entity.isCreatureType(EnumCreatureType.waterCreature, false) || entity.isCreatureType(EnumCreatureType.ambient, false)) { return 2; // Animal // Cauldron end } else { return 3; // Misc } }
private static EnumCreatureType getCreatureType(EntityLiving entity) { Class<? extends EntityLiving> entityClass = entity.getClass(); if (IMob.class.isAssignableFrom(entityClass)) { return EnumCreatureType.MONSTER; } else if (EntityAnimal.class.isAssignableFrom(entityClass)) { return EnumCreatureType.CREATURE; } else if (EntityAmbientCreature.class.isAssignableFrom(entityClass)) { return EnumCreatureType.AMBIENT; } else if (EntityWaterMob.class.isAssignableFrom(entityClass)) { return EnumCreatureType.WATER_CREATURE; } else { return null; } }
public boolean instanceOf(EntityType e) { // Generic types and players if (e.equals(EntityType.ENTITY_PLAYER_SP)) { return entity instanceof EntityPlayerSP; } else if (e.equals(EntityType.ENTITY_PLAYER)) { return entity instanceof EntityPlayer; } else if (e.equals(EntityType.ENTITY_LIVING_BASE)) { return entity instanceof EntityLivingBase; } else if (e.equals(EntityType.ENTITY_LIVING)) { return entity instanceof EntityLiving; } // Mobs if (e.equals(EntityType.ENTITY_WOLF)) { return entity instanceof EntityWolf; } else if (e.equals(EntityType.Entity_Ageable)) { return entity instanceof EntityAgeable; } else if (e.equals(EntityType.EntityAmbientCreature)) { return entity instanceof EntityAmbientCreature; } else if (e.equals(EntityType.EntityWaterMob)) { return entity instanceof EntityWaterMob; } else if (e.equals(EntityType.EntityMob)) { return entity instanceof EntityMob; } else if (e.equals(EntityType.EntitySlime)) { return entity instanceof EntitySlime; } else if (e.equals(EntityType.EntityFlying)) { return entity instanceof EntityFlying; } else if (e.equals(EntityType.EntityGolem)) { return entity instanceof EntityGolem; } else if (e.equals(EntityType.ENTITY_SPIDER)) { return entity instanceof EntitySpider; } else if (e.equals(EntityType.ENTITY_SPIDER)) { return entity instanceof EntitySpider; } else if (e.equals(EntityType.ENTITY_ZOMBIE_PIGMAN)) { return entity instanceof EntityZombie; } else if (e.equals(EntityType.ENTITY_ENDERMAN)) { return entity instanceof EntityEnderman; } return false; }
@SubscribeEvent public void onEntityAttack(AttackEntityEvent event) { if (event.entity instanceof EntityAmbientCreature || event.entity instanceof EntityAnimal || event.entity instanceof EntityPlayer) { EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer; if (CoreClaim.claimManager.checkEventCancel(event.entityPlayer, (int) event.entity.posX, (int) event.entity.posZ)) { event.setCanceled(true); Utils.messageToPlayer(player, EnumChatFormatting.RED + "Oh snap, you are not allowed to harm this entity!"); } } }
public static EnumCreatureType getDefaultMobType(Class<? extends EntityLiving> cls) { EnumCreatureType type = defaultMap.get(cls); if (type == null) { if (EntityAmbientCreature.class.isAssignableFrom(cls)) return EnumCreatureType.ambient; if (EntityWaterMob.class.isAssignableFrom(cls)) return EnumCreatureType.waterCreature; if (IMob.class.isAssignableFrom(cls)) return EnumCreatureType.monster; if (EntityCreature.class.isAssignableFrom(cls)) return EnumCreatureType.creature; } return type; }
public CraftAmbient(CraftServer server, EntityAmbientCreature entity) { super(server, entity); }
@Override public EntityAmbientCreature getHandle() { return (EntityAmbientCreature) entity; }
public boolean itemInteractionForEntity(final ItemStack par1ItemStack, final EntityPlayer par2EntityPlayer, final EntityLivingBase par2EntityLiving) { if (par1ItemStack.hasTagCompound()) { if (par1ItemStack.getItemDamage() != 0) { return false; } par1ItemStack.setTagCompound((NBTTagCompound)null); } if (!(par2EntityLiving instanceof EntityCreature) && !(par2EntityLiving instanceof EntityAmbientCreature)) { return false; } if (par2EntityLiving instanceof EntityMob) { return false; } if (((EntityLiving)par2EntityLiving).getAttackTarget() != null) { return false; } final NBTTagCompound entityTags = new NBTTagCompound(); entityTags.setBoolean("com.rwtema.extrautils.goldenlasso", true); if (!par2EntityLiving.writeMountToNBT(entityTags)) { return false; } if (!entityTags.hasKey("com.rwtema.extrautils.goldenlasso") | !entityTags.getBoolean("com.rwtema.extrautils.goldenlasso")) { return false; } String name = ""; if (((EntityLiving)par2EntityLiving).hasCustomNameTag()) { name = ((EntityLiving)par2EntityLiving).getCustomNameTag(); } if (!par2EntityLiving.worldObj.isRemote) { par2EntityLiving.setDead(); } par1ItemStack.setTagCompound(entityTags); if (name.equals("")) { if (par2EntityLiving instanceof EntityVillager) { par1ItemStack.setItemDamage(2); } else { par1ItemStack.setItemDamage(1); } } else { par1ItemStack.setStackDisplayName(name); par1ItemStack.setItemDamage(2); } return true; }
public static boolean isCorrectEntity(Object o, boolean ignoreFriends) { // non-entities if (!(o instanceof Entity)) return false; // friends if (ignoreFriends && o instanceof EntityPlayer) { if (WurstClient.INSTANCE.friends.contains(((EntityPlayer) o).getName())) return false; } TargetFeature targetFeature = WurstClient.INSTANCE.specialFeatures.targetFeature; // invisible entities if (((Entity) o).isInvisibleToPlayer(Minecraft.getMinecraft().thePlayer)) { return targetFeature.invisibleMobs.isChecked() && o instanceof EntityLiving || targetFeature.invisiblePlayers.isChecked() && o instanceof EntityPlayer; } // players if (o instanceof EntityPlayer) { return (((EntityPlayer) o).isPlayerSleeping() && targetFeature.sleepingPlayers.isChecked() || !((EntityPlayer) o).isPlayerSleeping() && targetFeature.players.isChecked()) && (!targetFeature.teams.isChecked() || checkName(((EntityPlayer) o).getDisplayName().getFormattedText())); } // animals if (o instanceof EntityAgeable || o instanceof EntityAmbientCreature || o instanceof EntityWaterMob) { return targetFeature.animals.isChecked() && (!targetFeature.teams.isChecked() || !((Entity) o).hasCustomName() || checkName(((Entity) o).getCustomNameTag())); } // monsters if (o instanceof EntityMob || o instanceof EntitySlime || o instanceof EntityFlying) { return targetFeature.monsters.isChecked() && (!targetFeature.teams.isChecked() || !((Entity) o).hasCustomName() || checkName(((Entity) o).getCustomNameTag())); } // golems return o instanceof EntityGolem && targetFeature.golems.isChecked() && (!targetFeature.teams.isChecked() || !((Entity) o).hasCustomName() || checkName(((Entity) o).getCustomNameTag())); }
@Override public boolean isAmbient() { return entity instanceof EntityAmbientCreature; }
@SuppressWarnings("unchecked") @Override public void processCommand(ICommandSender commandSender, String[] args) { int radius; try { radius = args.length >= 2 ? parseInt(args[1], 5) : -1; } catch (NumberInvalidException e2) { e2.printStackTrace(); return; } String target = args[0].toUpperCase().trim(); Class<?> targetClazz = target.equals("CREATURES") ? EntityCreature.class : target.equals("MONSTERS") ? EntityMob.class : target.equals("ALL") ? EntityLiving.class : target.equals("AMBIENT") ? EntityAmbientCreature.class : null; List<Entity> entities; try { entities = radius < 0 ? commandSender.getEntityWorld().loadedEntityList : commandSender.getEntityWorld().getEntitiesWithinAABB(EntityLivingBase.class, getCommandSenderAsPlayer(commandSender).getBoundingBox().expand(radius, radius, radius)); } catch (PlayerNotFoundException e1) { e1.printStackTrace(); return; } int count = 0; for (Entity e : entities){ if (e instanceof EntityPlayer) //never kill players! continue; if ( (targetClazz == null && e.getClass().getName().endsWith(args[0].trim())) || (targetClazz != null && targetClazz.isAssignableFrom(e.getClass())) ){ e.setDead(); count++; } } commandSender.addChatMessage(new ChatComponentTranslation("griefguardian.commands.execute", count)); }