Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MobEquipEvent {
- @SubscribeEvent
- public void changeToModdedEquipment(EntityJoinWorldEvent event){
- if ((event.getEntity() instanceof ZombieEntity &&
- !(event.getEntity() instanceof ZombiePigmanEntity) &&
- !(event.getEntity() instanceof HuskEntity) &&
- !(event.getEntity() instanceof ZombieVillagerEntity)
- ) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()) {
- ZombieEntity zombie = (ZombieEntity) event.getEntity();
- IReArmer reArmer = zombie.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockLoaded(zombie.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(zombie.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- ZombieEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, zombie);
- ZombieEquipUtilities.setHeldItemsBasedOnDifficulty(world, zombie);
- ZombieEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, zombie);
- }
- reArmer.setReArmed(true);
- }
- }
- if ((event.getEntity() instanceof HuskEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()) {
- HuskEntity husk = (HuskEntity) event.getEntity();
- IReArmer reArmer = husk.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockLoaded(husk.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(husk.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- HuskEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, husk);
- HuskEquipUtilities.setHeldItemsBasedOnDifficulty(world, husk);
- HuskEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, husk);
- }
- reArmer.setReArmed(true);
- }
- }
- if ((event.getEntity() instanceof ZombieVillagerEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()) {
- ZombieVillagerEntity zombieVillager = (ZombieVillagerEntity) event.getEntity();
- IReArmer reArmer = zombieVillager.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockLoaded(zombieVillager.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(zombieVillager.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- ZombieVillagerEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, zombieVillager);
- ZombieVillagerEquipUtilities.setHeldItemsBasedOnDifficulty(world, zombieVillager);
- ZombieVillagerEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, zombieVillager);
- }
- reArmer.setReArmed(true);
- }
- }
- if((event.getEntity() instanceof SkeletonEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
- SkeletonEntity skeleton = (SkeletonEntity) event.getEntity();
- IReArmer reArmer = skeleton.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockLoaded(skeleton.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(skeleton.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- SkeletonEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, skeleton);
- SkeletonEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, skeleton);
- }
- reArmer.setReArmed(true);
- }
- }
- if((event.getEntity() instanceof StrayEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
- StrayEntity stray = (StrayEntity) event.getEntity();
- IReArmer reArmer = stray.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockLoaded(stray.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(stray.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- StrayEquipUtilities.setArmorBasedOnDifficulty(difficultyInstance, world, stray);
- StrayEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, stray);
- }
- reArmer.setReArmed(true);
- }
- }
- if((event.getEntity() instanceof WitherSkeletonEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
- //HardSteel.logger.info("Spawned a Wither Skeleton!");
- WitherSkeletonEntity witherSkeleton = (WitherSkeletonEntity) event.getEntity();
- IReArmer reArmer = witherSkeleton.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockLoaded(witherSkeleton.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(witherSkeleton.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- WitherSkeletonEquipUtilities.setHeldItemsBasedOnDifficulty(witherSkeleton);
- WitherSkeletonEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, witherSkeleton);
- }
- reArmer.setReArmed(true);
- }
- }
- if((event.getEntity() instanceof ZombiePigmanEntity) && GeneralModConfig.MOBS_USE_HARD_STEEL_GEAR.get()){
- ZombiePigmanEntity zombiePigman = (ZombiePigmanEntity) event.getEntity();
- IReArmer reArmer = zombiePigman.getCapability(ReArmerProvider.REARMER_CAPABILITY).orElseThrow(IllegalStateException::new);
- if(!reArmer.getReArmed()){
- World world = event.getWorld().getWorld();
- if(world.isBlockPresent(zombiePigman.getPosition())){
- HardSteel.logger.info("Getting difficulty instance");
- DifficultyInstance difficultyInstance = event.getWorld().getDifficultyForLocation(zombiePigman.getPosition());
- HardSteel.logger.info("Got the difficulty instance");
- ZombiePigmanEquipUtilities.setHeldItemsBasedOnDifficulty(zombiePigman);
- ZombiePigmanEquipUtilities.setEnchantmentBasedOnDifficulty(difficultyInstance, zombiePigman);
- }
- reArmer.setReArmed(true);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement