Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.harry.customgems.gems;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import com.harry.customgems.init.ModItems;
- import mod.akrivus.kagic.entity.EntityGem;
- import mod.akrivus.kagic.entity.ai.EntityAICommandGems;
- import mod.akrivus.kagic.entity.ai.EntityAIFollowDiamond;
- import mod.akrivus.kagic.entity.ai.EntityAIStandGuard;
- import mod.akrivus.kagic.entity.ai.EntityAIStay;
- import mod.akrivus.kagic.entity.gem.EntityAgate;
- import mod.akrivus.kagic.entity.gem.EntityQuartzSoldier;
- import mod.akrivus.kagic.entity.gem.GemCuts;
- import mod.akrivus.kagic.entity.gem.GemPlacements;
- import mod.heimrarnadalr.kagic.util.Colors;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.EntityAILookIdle;
- import net.minecraft.entity.ai.EntityAIWatchClosest;
- import net.minecraft.entity.passive.IAnimals;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.MobEffects;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.math.AxisAlignedBB;
- import net.minecraft.world.World;
- public class EntityFort extends EntityAgate implements IAnimals
- {
- public static final HashMap<IBlockState, Double> FORT_YIELDS = new HashMap<IBlockState, Double>();
- public static final double AGATE_DEFECTIVITY_MULTIPLIER = 1;
- public static final double AGATE_DEPTH_THRESHOLD = 42;
- public static final HashMap<Integer, ResourceLocation> AGATE_HAIR_STYLES = new HashMap<Integer, ResourceLocation>();
- private int waterTicks = 0;
- public boolean atWater = false;
- //public static final float[][] BANDCOLORS = {{0xF9 / 255f, 0xFF / 255f, 0xFE / 255f}}; // #F9FFFE
- public static final int SKIN_COLOR_BEGIN = 0xDF5400;
- public static final int SKIN_COLOR_END = 0xFF5B42;
- private static final int NUM_HAIRSTYLES = 1;
- public static final int HAIR_COLOR_BEGIN = 0xDBAA65;
- public static final int HAIR_COLOR_END = 0xDBAA42;
- public EntityFort(World worldIn) {
- super(worldIn);
- this.isSoldier = true;
- this.setSize(0.6F, 2.0F);
- this.nativeColor = 11;
- this.setInsigniaColor(0);
- this.droppedGemItem = ModItems.FORT_GEM;
- this.droppedCrackedGemItem = ModItems.CRACKED_FORT_GEM;
- //Define valid gem cuts and placements
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.BACK_OF_HEAD);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.LEFT_EYE);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.RIGHT_EYE);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.FOREHEAD);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.NOSE);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.LEFT_CHEEK);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.RIGHT_CHEEK);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.BACK);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.CHEST);
- this.setCutPlacement(GemCuts.TEARDROP, GemPlacements.BELLY);
- this.stayAI = new EntityAIStay(this);
- this.tasks.addTask(1, new EntityAIFollowDiamond(this, 1.0D));
- this.tasks.addTask(1, new EntityAICommandGems(this, 0.6D));
- this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 16.0F));
- //this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityMob.class, 16.0F));
- this.tasks.addTask(7, new EntityAIStandGuard(this, 0.6D));
- this.tasks.addTask(8, new EntityAILookIdle(this));
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50.0D);
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(15.0D);
- this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4D);
- }
- public boolean processInteract(EntityPlayer player, EnumHand hand) {
- return super.processInteract(player, hand);
- }
- public void onDeath(DamageSource cause) {
- super.onDeath(cause);
- }
- public void whenDefective() {
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D);
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(10.0D);
- }
- public void whenPrimary() {
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(80.D);
- this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(50.0D);
- }
- private void startScreamingAtTheWater() {
- if (!this.world.isRemote) {
- AxisAlignedBB axisalignedbb = new AxisAlignedBB(this.posX, this.posY, this.posZ, this.posX + 1, this.posY + 1, this.posZ + 1).grow(16.0, this.world.getHeight(), 16.0);
- List<EntityLivingBase> list = this.world.<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
- for (EntityLivingBase entity : list) {
- if (!entity.isDead || entity.getHealth() > 0.0F) {
- if (entity instanceof EntityGem) {
- EntityGem gem = (EntityGem) entity;
- if (this.getServitude() == gem.getServitude()) {
- if (this.getServitude() == EntityGem.SERVE_HUMAN) {
- if (this.isOwnerId(gem.getOwnerId())) {
- entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 300));
- }
- } else {
- entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 300));
- }
- }
- }
- if (this.isOwner(entity)) {
- entity.addPotionEffect(new PotionEffect(MobEffects.WATER_BREATHING, 100));
- }
- }
- }
- }
- }
- @Override
- public void onLivingUpdate() {
- if (this.waterTicks > 80 && !this.isDefective() && !(this.isDead || this.getHealth() <= 0.0F)) {
- this.startScreamingAtTheWater();
- this.waterTicks = 0;
- }
- this.waterTicks += 1;
- super.onLivingUpdate();
- }
- protected int generateGemColor() {
- return 0x003BE0;
- }
- @Override
- protected int generateSkinColor() {
- ArrayList<Integer> skinColors = new ArrayList<Integer>();
- skinColors.add(EntityFort.SKIN_COLOR_BEGIN);
- skinColors.add(EntityFort.SKIN_COLOR_END);
- return Colors.arbiLerp(skinColors);
- }
- @Override
- protected int generateHairColor() {
- ArrayList<Integer> hairColors = new ArrayList<Integer>();
- hairColors.add(EntityFort.HAIR_COLOR_BEGIN);
- hairColors.add(EntityFort.HAIR_COLOR_END);
- return Colors.arbiLerp(hairColors);
- }
- @Override
- protected int generateHairStyle() {
- return this.rand.nextInt(EntityFort.NUM_HAIRSTYLES);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement