@Override protected boolean matches(EntityLivingBase entity) { if (type == BOSS) return !entity.isNonBoss(); else if (!entity.isNonBoss()) return false; switch (type) { case ANIMAL: return entity instanceof EntityAnimal; case MONSTER: return entity instanceof IMob; case TAMEABLE: return entity instanceof IEntityOwnable; case PLAYER: return entity instanceof EntityPlayer; case WATER: return entity instanceof EntityWaterMob || entity instanceof EntityGuardian; case NPC: return entity instanceof INpc; case GOLEM: return entity instanceof EntityGolem; default: return false; } }
@Override public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) { stack.damageItem(1, player); if (victim instanceof EntityHorse || victim instanceof EntityPig) victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 5)); else if (victim instanceof EntityPlayer || victim instanceof EntityGolem) { victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 1)); victim.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 200, 1)); victim.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 200, 1)); } if (!player.worldObj.isRemote && !Config.noLust && player.worldObj.provider.dimensionId == -1 && player.worldObj.rand.nextInt(15) == 1) { EntityItem ent = victim.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F); ent.motionY += player.worldObj.rand.nextFloat() * 0.05F; ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F; ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F; } return true; }
/** * Applies all related effects on a golem that was just created * with a enchanted pumpkin. * */ public static void applyMagicEffectsOnNewlySpawnedGolem(EntityGolem golem, ItemStack enchantedPumpkin) { if (ConfigurationHandler.onDebug) { LogHelper.info("-- Enchanted Golem found at [" + golem.getPosition() + "], applying extra info"); } MagicHelper.applyPumpkinExtraInfo(golem, enchantedPumpkin); MagicHelper.applyPassiveEffects(golem); MagicHelper.applyRefreshEffects(golem); // Heals the golem, if needed (so enchantments that raise health actually work) if (golem.getHealth() < golem.getMaxHealth()) { golem.heal(golem.getMaxHealth()); } }
@SideOnly(Side.CLIENT) private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event) { EntityPlayer player = FMLClientHandler.instance().getClient().player; if (event.getTarget() == player && (event.getEntityLiving() instanceof EntityGolem || event.getEntityLiving() instanceof EntityMob)) { ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (helmetStack.getItem() == Itemss.PNEUMATIC_HELMET && ((IPressurizable) helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(EnumUpgrade.ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) { HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.getEntity()); } } else { HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.getEntityLiving()); } }
@Override public boolean isMobType(Entity entity) { return entity.isCreatureType(EnumCreatureType.CREATURE, false) || entity.isCreatureType(EnumCreatureType.AMBIENT, false) || entity.isCreatureType(EnumCreatureType.WATER_CREATURE, false) || entity instanceof EntityVillager || entity instanceof EntityGolem; }
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; }
private boolean isApplicableType(final Entity e) { if (e instanceof EntityLiving) { if (e instanceof IMob) return true; if (e instanceof EntityPlayer) return true; if (e instanceof EntityGolem) return true; if (e instanceof EntityPolarBear) return true; } return false; }
public Config() { mobs = new ArrayList<Entity>(Arrays.asList(new Entity[]{ new Entity(EntityBat.class), new Entity(EntityChicken.class), new Entity(EntityCow.class), new Entity(EntityHorse.class), new Entity(EntityMooshroom.class), new Entity(EntityOcelot.class), new Entity(EntityPig.class), new Entity(EntityRabbit.class), new Entity(EntitySheep.class), new Entity(EntitySquid.class), new Entity(EntityVillager.class), new Entity(EntityWolf.class), new Entity(EntityBlaze.class), new Entity(EntityCaveSpider.class), new Entity(EntityCreeper.class), new Entity(EntityEnderman.class), new Entity(EntityGhast.class), new Entity(EntityGolem.class), new Entity(EntityGuardian.class), new Entity(EntityIronGolem.class), new Entity(EntityMagmaCube.class), new Entity(EntityPigZombie.class), new Entity(EntitySilverfish.class), new Entity(EntitySkeleton.class), new Entity(EntitySlime.class), new Entity(EntitySnowman.class), new Entity(EntitySpider.class), new Entity(EntityWitch.class), new Entity(EntityZombie.class), new Entity(EntityItem.class), new Entity(EntityMinecart.class), new Entity(EntityPlayer.class) })); }
/** * Applies permanent buffs / debuffs to vanilla mobs */ private void initBuffs(EntityLivingBase entity) { ZSSEntityInfo info = ZSSEntityInfo.get(entity); if (!info.getActiveBuffs().isEmpty()) { return; } // double damage from cold effects, highly resistant to fire damage if (entity.isImmuneToFire()) { info.applyBuff(Buff.RESIST_FIRE, Integer.MAX_VALUE, 75); info.applyBuff(Buff.WEAKNESS_COLD, Integer.MAX_VALUE, 100); } if (entity.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { if (!entity.isImmuneToFire()) { info.applyBuff(Buff.WEAKNESS_FIRE, Integer.MAX_VALUE, 50); } info.applyBuff(Buff.WEAKNESS_HOLY, Integer.MAX_VALUE, 300); info.applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 50); info.applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 50); } if (entity instanceof EntityGolem) { info.applyBuff(Buff.RESIST_COLD, Integer.MAX_VALUE, 100); info.applyBuff(Buff.RESIST_STUN, Integer.MAX_VALUE, 100); } if (entity instanceof EntityWitch) { info.applyBuff(Buff.RESIST_MAGIC, Integer.MAX_VALUE, 75); } if (entity instanceof EntityWither) { info.removeBuff(Buff.WEAKNESS_COLD); } }
private static String getEntityTypeNonCache(Entity e) { if (e instanceof EntityGolem) { return "Golem"; } else if (e instanceof IBossDisplayData) { return "Boss"; } else if (e instanceof IAnimals) { return "Animal"; } else if (e instanceof IMob) { return "Monster"; } else if (e instanceof IProjectile) { return "Projectile"; } else if (e instanceof INpc) { return "NPC"; } else if (e instanceof EntityItem) { return "Item"; } else if (e instanceof EntityMob) { return "Monster"; } else if (e instanceof EntityPlayer) { return "Player"; } else if (e instanceof EntityFireball) { return "Projectile"; } else if (e instanceof EntityTNTPrimed) { return "TNT"; } else { return "Unknown"; // e.getClass().getName(); } }
@SideOnly(Side.CLIENT) private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event){ EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; if(event.target == player && (event.entityLiving instanceof EntityGolem || event.entityLiving instanceof EntityMob)) { ItemStack helmetStack = player.getCurrentArmor(3); if(helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet && ((IPressurizable)helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) { HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.entityLiving); } } else { HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.entityLiving); } }
/** * Applies the extra info (name, enchantments) in the pumpkin to the golem created with it. * */ public static void applyPumpkinExtraInfo(EntityGolem golem, ItemStack pumpkin) { if (golem == null || pumpkin == null) return; int[] pumpkinEnchants = getEnchantmentIds(pumpkin); String customName = pumpkin.getDisplayName(); if (customName.equals(Blocks.pumpkin.getLocalizedName())) customName = ""; // Check if a custom name exists if (customName != "") { // Applies the custom name to the golem golem.setCustomNameTag(customName); } // Check if it's an enchanted pumpkin if (pumpkinEnchants != null && pumpkinEnchants.length > 0) { final ExtendedGolem properties = ExtendedGolem.get(golem); if (properties == null) { LogHelper.warn("Could not load extened properties for Iron Golem ID " + golem.getEntityId() + ", enchantments won't be applied."); } else { properties.setEnchantments(pumpkinEnchants); LogHelper.info("--> Applying enchantments on golem " + golem.getEntityId() + ": " + Arrays.toString(pumpkinEnchants)); NetworkHelper.sendEnchantedGolemInfoMessage(golem, properties); } } }
@SubscribeEvent public void onLivingAttack(LivingAttackEvent event) { Entity target = event.entity; if (target instanceof EntityGolem || event.source.getSourceOfDamage() instanceof EntityGolem) { LogHelper.info("== onLivingAttack() =="); } // NOTE: since the offensive enchantments apply special effect and don't just add more damage, // I can intercept this event. If I were to do any damage modifier, the correct event is LivingHurtEvent. // NOTE 2: This code also works on LivingHurtEvent, but I feel it's more appropriate here. // An iron golem attacked a target, apply the offensive enchantments if (event.source.getDamageType() == "mob" && event.source.getSourceOfDamage() instanceof EntityIronGolem) { MagicHelper.applyAttackEffects(event.source.getSourceOfDamage(), target); } // A snow golem attacked a target, apply the offensive enchantments else if (event.source.getSourceOfDamage() instanceof EntitySnowball && ((EntitySnowball)event.source.getSourceOfDamage()).getThrower() instanceof EntitySnowman) { MagicHelper.applyAttackEffects(((EntitySnowball)event.source.getSourceOfDamage()).getThrower(), target); } // A golem was attacked by a target, check if should cancel the event if (target instanceof EntityGolem) { boolean ignoreDamage = MagicHelper.applyDamageCancelEffects(target, event.source); if (ignoreDamage) event.setCanceled(true); } }
@SubscribeEvent public void onLivingHurt(LivingHurtEvent event) { Entity target = event.entity; if (target instanceof EntityGolem || event.source.getSourceOfDamage() instanceof EntityGolem) { LogHelper.info("== onLivingHurt() =="); LogHelper.info(" " + event.entity); LogHelper.info(" source: " + event.source.getDamageType()); LogHelper.info(" source: " + event.source.getSourceOfDamage()); LogHelper.info(" damage: " + event.ammount); } // A golem was attacked, apply the defensive enchantments if (target instanceof EntityGolem) { event.ammount = MagicHelper.applyDefenseEffects(target, event.source, event.ammount); } // An iron golem caused damage, apply damage modifiers else if (event.source.getDamageType() == "mob" && event.source.getSourceOfDamage() instanceof EntityIronGolem) { event.ammount = MagicHelper.applyDamagingEffects(event.source.getSourceOfDamage(), target, event.ammount); } // A snow golem caused damage, apply damage modifiers else if (event.source.getSourceOfDamage() instanceof EntitySnowball && ((EntitySnowball)event.source.getSourceOfDamage()).getThrower() instanceof EntitySnowman) { event.ammount = MagicHelper.applyDamagingEffects(((EntitySnowball)event.source.getSourceOfDamage()).getThrower(), target, event.ammount); } }
@SubscribeEvent public void onEntityConstructing(EntityConstructing event) { // Adds the Extended Properties to zombies if (GenericHelper.isVanillaZombie(event.entity) && ExtendedVillagerZombie.get((EntityZombie) event.entity) == null) { ExtendedVillagerZombie.register((EntityZombie) event.entity); } // Adds the Extended Properties to golems else if (event.entity instanceof EntityGolem && ExtendedGolem.get((EntityGolem)event.entity) == null) { ExtendedGolem.register((EntityGolem) event.entity); } }
/** * Attempts to locate the entity by it's ID and apply the * extended properties. */ @SideOnly(Side.CLIENT) public static void SyncGolemMessage(int entityID) { // Seeks if the entity ID is loaded WorldClient world = Minecraft.getMinecraft().theWorld; if (world == null) return; Entity entity = world.getEntityByID(entityID); // If found the entity, attempt to sync with info sent by the server if (entity instanceof EntityGolem) { ClientInfoTracker.SyncGolemMessage((EntityGolem)entity); } }
/** * Attempts to locate a message with Extended Properties and apply to the golem. */ @SideOnly(Side.CLIENT) public static void SyncGolemMessage(EntityGolem golem) { // Try to locate messages sent by the server, containing special zombie info MessageGolemEnchantments msg = ClientInfoTracker.getGolemMessage(golem.getEntityId()); // If a message was found, update the local zombie with that info if (msg != null) { ExtendedGolem properties = ExtendedGolem.get(golem); properties.setEnchantments(msg.getEnchantments()); } }
public CraftGolem(CraftServer server, EntityGolem entity) { super(server, entity); }
@Override public EntityGolem getHandle() { return (EntityGolem) entity; }
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())); }
protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.getSquidTextures((EntityGolem)par1Entity); }
protected ResourceLocation getSquidTextures(EntityGolem par1EntitySkyChicken) { return this.textures[(getTextureIndex(par1EntitySkyChicken) % this.textures.length)]; }