Jump to content

_Cruelar_

Members
  • Posts

    292
  • Joined

  • Last visited

Everything posted by _Cruelar_

  1. Look at what I colored black. There he tries to find the texture for the overlay. Look how much there is. He basically tries to use texture that wasn't made for him. Maybe you should move some of that stuff to the lower half of the texture.
  2. Have you run gradle.build to get your jar. Look at this (General issues #1)
  3. After implementing some mobs with high health and attackdamage values I thought I should allow the Player to increase his maximumhealth(with heartcontainers) to a quite high value (I planned 120) but capping his life at this value even with absorption. This would result in six rows of hearts. This is a Problem as you can't see what's behind them. So I subscribed to the RenderGameOverlayEvent.Pre And the hearts render like they should. But the armorvalue is always diplayed in the first row of hearts. Also I noticed that when using a normal java approach the count of used items will be saved for all worlds. I think I should use Capabilities for that but while following the docs I got completely lost.(I never used them before). My Code: My EventHandler (Mostly adapted from GuiIngame): package com.cruelar.cruelars_triforcemod.util; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiIngame; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.IAttributeInstance; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.util.FoodStats; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.util.Random; @Mod.EventBusSubscriber @SideOnly(Side.CLIENT) public class PlayerHealthHandler { protected static final Random rand = new Random(); public static int playerHealth; protected static long healthUpdateCounter; protected static int lastPlayerHealth; protected static long lastSystemTime; protected static Minecraft minecraft=Minecraft.getMinecraft(); protected static GuiIngame ingameGUI = minecraft.ingameGUI; protected static int updateCounter; @SubscribeEvent public static void renderPlayerHealth(RenderGameOverlayEvent.Pre event){ if (event.getType()==RenderGameOverlayEvent.ElementType.HEALTH){ ScaledResolution scaledRes =event.getResolution(); if (!event.isCanceled()) { event.setCanceled(true); } if (minecraft.getRenderViewEntity() instanceof EntityPlayer) { updateCounter=ingameGUI.getUpdateCounter(); EntityPlayer entityplayer = (EntityPlayer)minecraft.getRenderViewEntity(); int health = MathHelper.ceil(entityplayer.getHealth()); boolean flag = healthUpdateCounter > (long)updateCounter && (healthUpdateCounter - (long)updateCounter) / 3L % 2L == 1L; if (health < playerHealth && entityplayer.hurtResistantTime > 0) { lastSystemTime = Minecraft.getSystemTime(); healthUpdateCounter = (long)(updateCounter + 20); } else if (health > playerHealth && entityplayer.hurtResistantTime > 0) { lastSystemTime = Minecraft.getSystemTime(); healthUpdateCounter = (long)(updateCounter + 10); } if (Minecraft.getSystemTime() - lastSystemTime > 1000L) { playerHealth = health; lastPlayerHealth = health; lastSystemTime = Minecraft.getSystemTime(); } playerHealth = health; int lastHealth = lastPlayerHealth; rand.setSeed((long)(updateCounter * 312871)); FoodStats foodstats = entityplayer.getFoodStats(); int foodLevel = foodstats.getFoodLevel(); IAttributeInstance iattributeinstance = entityplayer.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); int widthleft = scaledRes.getScaledWidth() / 2 - 91; int widthright = scaledRes.getScaledWidth() / 2 + 91; int height = scaledRes.getScaledHeight() - 39; float maxHealth = (float)iattributeinstance.getAttributeValue(); int absorption = MathHelper.ceil(entityplayer.getAbsorptionAmount()); int rows = Math.max(MathHelper.ceil((maxHealth + (float)absorption) / 4.0F / 10.0F),1); int rows1 = Math.max(10 - (rows - 2), 3); int armorPosY = height-(rows-1)*rows1-10; int airPosY = height - 10; int absorption1 = absorption; int armorValue = entityplayer.getTotalArmorValue(); int regen = -1; if (entityplayer.isPotionActive(MobEffects.REGENERATION)) { regen = updateCounter % MathHelper.ceil(maxHealth + 5.0F); } minecraft.mcProfiler.startSection("armor"); minecraft.getTextureManager().bindTexture(new ResourceLocation("cruelars_triforcemod:textures/gui/icons.png")); for (int i = 0; i < 10; ++i) { if (armorValue > 0) { int armorPosX = widthleft + i * 8; if (i * 2 + 1 < armorValue) { ingameGUI.drawTexturedModalRect(armorPosX, armorPosY, 18, 36, 9, 9); } if (i * 2 + 1 == armorValue) { ingameGUI.drawTexturedModalRect(armorPosX, armorPosY, 9, 36, 9, 9); } if (i * 2 + 1 > armorValue) { ingameGUI.drawTexturedModalRect(armorPosX, armorPosY, 0, 36, 9, 9); } } } //minecraft.ingameGUI.drawTexturedModalRect(9+12, 9,12 , , , ); minecraft.mcProfiler.endStartSection("health"); minecraft.getTextureManager().bindTexture(new ResourceLocation("cruelars_triforcemod:textures/gui/icons.png")); for (int heartsToDraw = MathHelper.ceil((maxHealth + (float)absorption) / 4.0F) - 1; heartsToDraw >= 0; --heartsToDraw) { int textureX = 0; if (entityplayer.isPotionActive(MobEffects.POISON)) { textureX += 108; } else if (entityplayer.isPotionActive(MobEffects.WITHER)) { textureX += 180; } int textureXOffset = 0; if (flag) { textureXOffset = 1; } int posYHelper = MathHelper.ceil((float)(heartsToDraw + 1) / 10.0F) - 1; int posX = widthleft + heartsToDraw % 10 * 8; int posY = height - posYHelper * rows1; if (health <= 6) { posY += rand.nextInt(2); } if (absorption1 <= 0 && heartsToDraw == regen) { posY -= 2; } int hardcore = 0; if (entityplayer.world.getWorldInfo().isHardcoreModeEnabled()) { hardcore = 1; } ingameGUI.drawTexturedModalRect(posX, posY, textureXOffset * 9, 18 * hardcore, 9, 9); if (flag) { if (heartsToDraw * 4 + 3 < lastHealth) { ingameGUI.drawTexturedModalRect(posX, posY, textureX + 36, 18 * hardcore, 9, 9); } if (heartsToDraw*4+2<lastHealth) { ingameGUI.drawTexturedModalRect(posX,posY,textureX+45,18*hardcore,9,9); } if (heartsToDraw*4+1<lastHealth) { ingameGUI.drawTexturedModalRect(posX,posY,textureX+54,18*hardcore,9,9); } if (heartsToDraw * 4 + 1 == lastHealth) { ingameGUI.drawTexturedModalRect(posX, posY, textureX + 63, 18 * hardcore, 9, 9); } } if (absorption1 > 0) { if (absorption1 % 4 == 0) { ingameGUI.drawTexturedModalRect(posX, posY, textureX, 18 * hardcore+9, 9, 9); absorption1=absorption1-4; } else if (absorption1 == absorption&&(absorption1-3)%4==0) { ingameGUI.drawTexturedModalRect(posX, posY, textureX+9, 18 * hardcore+9, 9, 9); absorption1=absorption1-3; } else if (absorption1 == absorption&&(absorption1-2)%4==0) { ingameGUI.drawTexturedModalRect(posX, posY, textureX+18, 12 * hardcore+9, 9, 9); absorption1=absorption1-2; } else if (absorption1 == absorption&&(absorption1-1)%4==0) { ingameGUI.drawTexturedModalRect(posX,posY,textureX+27,9*hardcore+9,9,9); absorption1--; } } else { if (heartsToDraw * 4 + 3 < health) { ingameGUI.drawTexturedModalRect(posX, posY, textureX + 36, 18 * hardcore, 9, 9); } if (heartsToDraw*4+2<health) { ingameGUI.drawTexturedModalRect(posX, posY, textureX + 45, 18 * hardcore, 9, 9); } if (heartsToDraw * 4 + 1 < health) { ingameGUI.drawTexturedModalRect(posX, posY, textureX + 54, 18 * hardcore, 9, 9); } if (heartsToDraw *4+1==health) { ingameGUI.drawTexturedModalRect(posX,posY,textureX+63,18*hardcore,9,9); } } } Entity entity = entityplayer.getRidingEntity(); if (entity == null || !(entity instanceof EntityLivingBase)) { minecraft.mcProfiler.endStartSection("food"); minecraft.getTextureManager().bindTexture(new ResourceLocation("minecraft:textures/gui/icons.png")); for (int foodToDraw = 0; foodToDraw < 10; ++foodToDraw) { int j6 = height; int l6 = 16; int j7 = 0; if (entityplayer.isPotionActive(MobEffects.HUNGER)) { l6 += 36; j7 = 13; } if (entityplayer.getFoodStats().getSaturationLevel() <= 0.0F && updateCounter % (foodLevel * 3 + 1) == 0) { j6 = height + (rand.nextInt(3) - 1); } int l7 = widthright - foodToDraw * 8 - 9; ingameGUI.drawTexturedModalRect(l7, j6, 16 + j7 * 9, 27, 9, 9); if (foodToDraw * 2 + 1 < foodLevel) { ingameGUI.drawTexturedModalRect(l7, j6, l6 + 36, 27, 9, 9); } if (foodToDraw * 2 + 1 == foodLevel) { ingameGUI.drawTexturedModalRect(l7, j6, l6 + 45, 27, 9, 9); } } } minecraft.mcProfiler.endStartSection("air"); if (entityplayer.isInsideOfMaterial(Material.WATER)) { int i6 = minecraft.player.getAir(); int k6 = MathHelper.ceil((double)(i6 - 2) * 10.0D / 300.0D); int i7 = MathHelper.ceil((double)i6 * 10.0D / 300.0D) - k6; for (int k7 = 0; k7 < k6 + i7; ++k7) { if (k7 < k6) { ingameGUI.drawTexturedModalRect(widthright - k7 * 8 - 9, airPosY, 16, 18, 9, 9); } else { ingameGUI.drawTexturedModalRect(widthright - k7 * 8 - 9, airPosY, 25, 18, 9, 9); } } } minecraft.mcProfiler.endSection(); } } } } My Current MaxHealth Setting System: package com.cruelar.cruelars_triforcemod.util; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; @Mod.EventBusSubscriber public class AbilityHandler { private static int usedHealthcontainers=0; @SubscribeEvent public static void updatePlayerAbilityStatus(LivingEvent.LivingUpdateEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.getEntityLiving(); player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(12.0+(usedHealthcontainers*4)); } } public void addHealth(){ usedHealthcontainers=usedHealthcontainers+1; } public void reduceHealth(){ usedHealthcontainers=usedHealthcontainers-1; } } My CapabilityRegistration(I think): package com.cruelar.cruelars_triforcemod.util; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagInt; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityManager; import javax.annotation.Nullable; public class HearthContainerCounter { @CapabilityInject(IHearthContainerCount.class) public static Capability<IHearthContainerCount> HEARTHCOUNTER = null; public static void register() { CapabilityManager.INSTANCE.register(IHearthContainerCount.class, new Capability.IStorage<IHearthContainerCount>() { @Nullable @Override public NBTBase writeNBT(Capability<IHearthContainerCount> capability, IHearthContainerCount instance, EnumFacing side) { NBTTagInt nbtTagInt = new NBTTagInt(instance.getUsedHearthContainer()); return nbtTagInt; // return an NBT tag } @Override public void readNBT(Capability<IHearthContainerCount> capability, IHearthContainerCount instance, EnumFacing side, NBTBase nbt) { NBTTagInt nbtTagInt = (NBTTagInt) nbt; instance.setUsedHearthContainer(nbtTagInt.getInt()); // load from the NBT tag } },new HearthContainerFactory()); } } The Interface: package com.cruelar.cruelars_triforcemod.util; public interface IHearthContainerCount { public void setUsedHearthContainer(int value); public int getUsedHearthContainer(); public void increaseUsedHearthContainer(int value); public void decreaseUsedHearthContainer(int value); } The Factory: package com.cruelar.cruelars_triforcemod.util; import java.util.concurrent.Callable; public class HearthContainerFactory implements Callable<IHearthContainerCount> { @Override public IHearthContainerCount call() throws Exception { return new HearthContainerImpl(); } } The Default Implementation: package com.cruelar.cruelars_triforcemod.util; public class HearthContainerImpl implements IHearthContainerCount { public int usedHearthContainer; @Override public void setUsedHearthContainer(int value) { this.usedHearthContainer=value; } @Override public int getUsedHearthContainer() { return usedHearthContainer; } @Override public void increaseUsedHearthContainer(int value) { this.usedHearthContainer=this.usedHearthContainer+value; } @Override public void decreaseUsedHearthContainer(int value) { this.usedHearthContainer=this.usedHearthContainer-value; } } The Provider: package com.cruelar.cruelars_triforcemod.util; import net.minecraft.nbt.NBTBase; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class HearthContainerCounterProvider implements ICapabilitySerializable<NBTBase> { @CapabilityInject(IHearthContainerCount.class) public static final Capability<IHearthContainerCount> HEARTHCOUNT = null; @Override public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) { return capability == HearthContainerCounter.HEARTHCOUNTER; } @Nullable @Override public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) { return capability==HearthContainerCounter.HEARTHCOUNTER?;//don't know what to put here } @Override public NBTBase serializeNBT() { return null; } @Override public void deserializeNBT(NBTBase nbt) { } } Link to the docs if needed Screenshots of my Health bar with absorption 21 so 21 additional hearts
  4. Works after I moved the setCombatTask From addEquipmentBasedonDifficulty to after super.onUpdate. Btw. wasn't a good idea to make a mod which lowers players basehealth and making high health and high attackdamage Mobs.
  5. You return ItemStack.EMPTY from your second Try to return your airsword.
  6. Look like your texture parts are misplaced. I recommend tabula for checking. tabula can import models and their textures. Can I copy your code so I can check it myself?
  7. Have you tried what Animefn8888 said?
  8. I have an Entity with a RangedBow Attack and a Melee Attack. To swap between them it checks for the Item in his MainHand. If it is a Bow it uses the RangedAttack. I've wrote a custom Ai to say when it should change his equipment to a sword and a shield. To store the items he uses I made a NonNullList. My Problem is it crashes cause of Ticking Entity. It also says me it occurs at super.onUpdate in my onUpdate method and that's somehow related to my Ai. But I don't have any Idea what exactly causes this (I'm not experienced with writing AIs) My Code: Entity: package com.cruelar.cruelars_triforcemod.entities.monster; import com.cruelar.cruelars_triforcemod.entities.IChangeWeaponAI; import com.cruelar.cruelars_triforcemod.entities.IModRangedAttackMob; import com.cruelar.cruelars_triforcemod.entities.ai.EntityAIChangeWeapon; import com.cruelar.cruelars_triforcemod.entities.ai.ModAIAttackRangedBow; import com.cruelar.cruelars_triforcemod.entities.ai.ModAINearestAttackableTarget; import com.cruelar.cruelars_triforcemod.init.ModItems; import com.cruelar.cruelars_triforcemod.items.Lynel_Bow; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.*; import net.minecraft.entity.item.EntityBoat; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArrow; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.play.server.SPacketEntityEquipment; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import javax.annotation.Nullable; public class Red_Maned_Lynel extends EntityMob implements IChangeWeaponAI,IModRangedAttackMob { private static final DataParameter<Boolean> SWINGING_ARMS = EntityDataManager.<Boolean>createKey(Red_Maned_Lynel.class, DataSerializers.BOOLEAN); private final ModAIAttackRangedBow<Red_Maned_Lynel> aiArrowAttack = new ModAIAttackRangedBow<Red_Maned_Lynel>(this,1.0D,20,32F); private final EntityAIAttackMelee aiAttackOnCollide = new EntityAIAttackMelee(this, 1.2D, false){ /** * Reset the task's internal state. Called when this task is interrupted by another one */ @Override public void resetTask() { super.resetTask(); Red_Maned_Lynel.this.setSwingingArms(false); } /** * Execute a one shot task or start executing a continuous task */ @Override public void startExecuting() { super.startExecuting(); Red_Maned_Lynel.this.setSwingingArms(true); } }; public static final ResourceLocation LOOT = new ResourceLocation("cruelars_triforcemod:entities/red_maned_lynel"); public static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("cruelars_triforcemod:textures/entity/red_maned_lynel.png"); private final NonNullList<ItemStack> arrowInventory = NonNullList.<ItemStack>withSize(1, ItemStack.EMPTY); private final NonNullList<ItemStack> unusedInventory = NonNullList.<ItemStack>withSize(2,ItemStack.EMPTY); private static final DataParameter<Byte> STATUS = EntityDataManager.<Byte>createKey(Red_Maned_Lynel.class, DataSerializers.BYTE); public int tailCounter; private float rearingAmount; private float prevRearingAmount; public Red_Maned_Lynel(World worldIn) { super(worldIn); this.setSwingingArms(true); this.setSize(1.3964844F,2F); this.stepHeight = 1.0F; this.setCombatTask(); } @Override protected void entityInit(){ super.entityInit(); this.dataManager.register(STATUS, Byte.valueOf((byte)0)); this.dataManager.register(SWINGING_ARMS, Boolean.valueOf(false)); } @Override protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty){ this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ModItems.lynel_bow)); ItemStack itemStack = new ItemStack(ModItems.bomb_arrow); itemStack.setCount(10); this.arrowInventory.set(0,itemStack); this.unusedInventory.set(0,new ItemStack(Items.IRON_SWORD)); this.unusedInventory.set(1,new ItemStack(Items.SHIELD)); } } @Override protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(1500.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D); this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0.0D); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(32.0D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(100.0D); } @Override protected void initEntityAI(){ this.tasks.addTask(0,new EntityAISwimming(this)); this.tasks.addTask(2,new EntityAIAttackMelee(this,1.0D,true)); this.tasks.addTask(5,new EntityAIMoveTowardsRestriction(this,1.0D)); this.tasks.addTask(7,new EntityAIWander(this,1.0D)); this.tasks.addTask(8,new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8,new EntityAILookIdle(this)); this.tasks.addTask(1,new EntityAIChangeWeapon<>(this)); this.applyEntityAI(); } protected void applyEntityAI() { this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, EntityPigZombie.class)); this.targetTasks.addTask(2, new ModAINearestAttackableTarget<>(this, EntityPlayer.class, true)); this.targetTasks.addTask(3, new ModAINearestAttackableTarget<>(this, EntityVillager.class, true)); this.targetTasks.addTask(3, new ModAINearestAttackableTarget<>(this, EntityIronGolem.class, true)); } @Override public int getMaxSpawnedInChunk(){ return 1; } @Override protected boolean isValidLightLevel(){ return true; } @Override public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) { EntityArrow entityarrow = this.getArrow(distanceFactor); EntityArrow entityarrow2 = this.getArrow(distanceFactor); EntityArrow entityarrow3 = this.getArrow(distanceFactor); double d0 = target.posX - this.posX; double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entityarrow.posY; double d2 = target.posZ - this.posZ; double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4)); entityarrow2.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4)); entityarrow3.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4)); entityarrow2.rotationYaw=entityarrow2.rotationYaw+2F; entityarrow3.rotationYaw=entityarrow3.rotationYaw-2F; this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); this.world.spawnEntity(entityarrow); this.world.spawnEntity(entityarrow2); this.world.spawnEntity(entityarrow3); } protected EntityArrow getArrow(float p_190726_1_) { if (getArrowInInventory().getItem()!=Items.AIR) { EntityArrow entityarrow = ((ItemArrow) getArrowInInventory().getItem()).createArrow(world, getArrowInInventory(), this); entityarrow.setEnchantmentEffectsFromEntity(this, p_190726_1_); return entityarrow; }else { ItemStack itemStack = new ItemStack(Items.ARROW); ItemArrow itemArrow = (ItemArrow) itemStack.getItem(); return itemArrow.createArrow(world,itemStack,this); } } private void moveTail() { this.tailCounter = 1; } @Override public boolean canBeSteered() { return false; } @Override public void changeHeldItems() { ItemStack itemStackOld1 = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); ItemStack itemStackOld2 = this.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND); ItemStack itemStackNew1 = this.unusedInventory.get(0); ItemStack itemStackNew2 = this.unusedInventory.get(1); this.unusedInventory.set(0,itemStackOld1); this.unusedInventory.set(1,itemStackOld2); this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND,itemStackNew1); this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND,itemStackNew2); } @Override public void setCombatTask() { if (this.world != null && !this.world.isRemote) { this.tasks.removeTask(this.aiAttackOnCollide); this.tasks.removeTask(this.aiArrowAttack); ItemStack itemstack = this.getHeldItemMainhand(); System.out.println(itemstack.getItem()); if (itemstack.getItem() == ModItems.lynel_bow) { int i = 20; if (this.world.getDifficulty() != EnumDifficulty.HARD) { i = 40; } this.aiArrowAttack.setAttackCooldown(i); this.tasks.addTask(1, this.aiArrowAttack); } else { this.tasks.addTask(1, this.aiAttackOnCollide); } } } @Nullable @Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.setEquipmentBasedOnDifficulty(difficulty); this.setEnchantmentBasedOnDifficulty(difficulty); this.setCombatTask(); return livingdata; } @Override public void setDropChance(EntityEquipmentSlot slotIn, float chance) { switch (slotIn.getSlotType()) { case HAND: this.inventoryHandsDropChances[slotIn.getIndex()] = 1F; break; case ARMOR: this.inventoryArmorDropChances[slotIn.getIndex()] = 1F; } } @Override public void setItemStackToSlot(EntityEquipmentSlot slotIn, ItemStack stack) { super.setItemStackToSlot(slotIn, stack); if (!this.world.isRemote && slotIn == EntityEquipmentSlot.MAINHAND) { this.setCombatTask(); } } protected boolean getLynelWatchableBoolean(int p_110233_1_) { return (((Byte)this.dataManager.get(STATUS)).byteValue() & p_110233_1_) != 0; } protected void setLynelWatchableBoolean(int p_110208_1_, boolean p_110208_2_) { byte b0 = ((Byte)this.dataManager.get(STATUS)).byteValue(); if (p_110208_2_) { this.dataManager.set(STATUS, Byte.valueOf((byte)(b0 | p_110208_1_))); } else { this.dataManager.set(STATUS, Byte.valueOf((byte)(b0 & ~p_110208_1_))); } } public void setRearing(boolean rearing) { this.setLynelWatchableBoolean(2, rearing); } public boolean isRearing() { return this.getLynelWatchableBoolean(2); } @Override public void onUpdate() { super.onUpdate(); if (this.tailCounter > 0 && ++this.tailCounter > 8) { this.tailCounter = 0; } this.prevRearingAmount = this.rearingAmount; if (this.isRearing()) { this.rearingAmount += (1.0F - this.rearingAmount) * 0.4F + 0.05F; if (this.rearingAmount > 1.0F) { this.rearingAmount = 1.0F; } } else { this.rearingAmount += (0.8F * this.rearingAmount * this.rearingAmount * this.rearingAmount - this.rearingAmount) * 0.6F - 0.05F; if (this.rearingAmount < 0.0F) { this.rearingAmount = 0.0F; } } } @SideOnly(Side.CLIENT) public float getRearingAmount(float p_110223_1_) { return this.prevRearingAmount + (this.rearingAmount - this.prevRearingAmount) * p_110223_1_; } @Override public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); for (ItemStack itemstack : this.unusedInventory) { NBTTagCompound nbttagcompound = new NBTTagCompound(); if (!itemstack.isEmpty()) { itemstack.writeToNBT(nbttagcompound); } nbttaglist.appendTag(nbttagcompound); } compound.setTag("UnusedItems", nbttaglist); this.setCombatTask(); } @Override public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); if (compound.hasKey("UnusedItems", 9)) { NBTTagList nbttaglist = compound.getTagList("UnusedItems", 10); for (int i = 0; i < this.unusedInventory.size(); ++i) { this.unusedInventory.set(i, new ItemStack(nbttaglist.getCompoundTagAt(i))); } } this.setCombatTask(); } @SideOnly(Side.CLIENT) public boolean isSwingingArms() { return ((Boolean)this.dataManager.get(SWINGING_ARMS)).booleanValue(); } @Override public void setSwingingArms(boolean swingingArms) { this.dataManager.set(SWINGING_ARMS, Boolean.valueOf(swingingArms)); } } Ai: package com.cruelar.cruelars_triforcemod.entities.ai; import com.cruelar.cruelars_triforcemod.entities.IChangeWeaponAI; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.item.ItemBow; public class EntityAIChangeWeapon<T extends EntityLiving & IChangeWeaponAI> extends EntityAIBase { private final T entity; public EntityAIChangeWeapon(T executer) { this.entity = executer; this.setMutexBits(0); } @Override public boolean shouldExecute() { return this.entity.getAttackTarget()!=null; } @Override public void startExecuting() { super.startExecuting(); ((IChangeWeaponAI)this.entity).changeHeldItems(); } @Override public boolean shouldContinueExecuting() { return (this.shouldExecute() || !this.entity.getNavigator().noPath()); } @Override public void resetTask() { super.resetTask(); this.entity.resetActiveHand(); } protected boolean isBowInMainhand() { return !this.entity.getHeldItemMainhand().isEmpty() && this.entity.getHeldItemMainhand().getItem()instanceof ItemBow; } public void updateTask() { EntityLivingBase entitylivingbase = this.entity.getAttackTarget(); if (entitylivingbase != null) { double d0 = this.entity.getDistanceSq(entitylivingbase.posX, entitylivingbase.getEntityBoundingBox().minY, entitylivingbase.posZ); boolean flag = this.entity.getEntitySenses().canSee(entitylivingbase); boolean flag1 = this.isBowInMainhand(); if (d0>16D||!flag){ if(!flag1) { ((IChangeWeaponAI) this.entity).changeHeldItems(); } }else { if (flag1) { ((IChangeWeaponAI) this.entity).changeHeldItems(); } } } } } Interface: package com.cruelar.cruelars_triforcemod.entities; public interface IChangeWeaponAI { void changeHeldItems(); void setCombatTask(); } log
  9. Updated code I was able to spawn the Entity for a short amount of time until I added th updating code for the Legs in onLivingUpdate in The MainEntity class. Comments are ideas I had to fix my Problems. Log Could anyone give me a other Solution for updating the Position of the Legs? Or at least an idea where to search. Note currently I use the EntityDragon code.
  10. After teleporting to the Blockpos where the Error occurs I found out that the False Blocks are the Problem. Yes BlockAir for Example. the Block I copied the Passable behavior from
  11. It works only have to fix some typos, have changed some registry names since I opened this topic.
  12. More like this? package com.cruelar.cruelars_triforcemod.entities.monster; import com.cruelar.cruelars_triforcemod.entities.ai.ModAIHunt; import com.cruelar.cruelars_triforcemod.entities.ai.ModAINearestAttackableTarget; import net.minecraft.entity.*; import net.minecraft.entity.ai.*; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.passive.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import javax.annotation.Nullable; public class Bokoblin extends EntityMob { public static final ResourceLocation LOOT = new ResourceLocation("cruelars_triforcemod:entities/bokoblin.json"); public static final ResourceLocation RESOURCE_LOCATION = new ResourceLocation("cruelars_triforcemod:textures/entity/bokoblin.png"); private int angerLevel; private int randomSoundDelay; private static final ResourceLocation deathLootTable = LOOT; public Bokoblin(World world){ super(world); setSize(0.6F,1.8F ); this.canDropLoot(); } @Override protected void entityInit(){ super.entityInit(); } @Override protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); if (this.rand.nextFloat() < (this.world.getDifficulty() == EnumDifficulty.HARD ? 1F : 0.75F)) { int i = this.rand.nextInt(3); if (i == 0) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.WOODEN_SWORD)); } else if (i == 1){ this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.WOODEN_SWORD)); this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND,new ItemStack(Items.SHIELD)); } else if (i == 2){ this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND,new ItemStack(Items.BOW)); ItemStack itemStack = new ItemStack(Items.ARROW); itemStack.setCount(20); this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND,itemStack); } } } @Override protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(13.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(0.0D); this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(16.0D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2.0D); } @Override protected void initEntityAI(){ this.tasks.addTask(0,new EntityAISwimming(this)); this.tasks.addTask(2,new EntityAIAttackMelee(this,1.0D,true)); this.tasks.addTask(5,new EntityAIMoveTowardsRestriction(this,1.0D)); this.tasks.addTask(7,new EntityAIWander(this,1.0D)); this.tasks.addTask(8,new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8,new EntityAILookIdle(this)); this.applyEntityAI(); } protected void applyEntityAI() { this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, EntityPigZombie.class)); this.targetTasks.addTask(2, new ModAINearestAttackableTarget<>(this, EntityPlayer.class, true)); this.targetTasks.addTask(3, new ModAINearestAttackableTarget<>(this, EntityVillager.class, true)); this.targetTasks.addTask(3, new ModAINearestAttackableTarget<>(this, EntityIronGolem.class, true)); this.targetTasks.addTask(3, new ModAIHunt<>(this, EntitySheep.class, true)); this.targetTasks.addTask(2, new ModAIHunt<>(this, EntityCow.class, true)); this.targetTasks.addTask(3, new ModAIHunt<>(this, EntityPig.class, true)); this.targetTasks.addTask(3, new ModAIHunt<>(this, EntityChicken.class, true)); this.targetTasks.addTask(3, new ModAIHunt<>(this, EntityRabbit.class, true)); this.targetTasks.addTask(1, new Bokoblin.AIHurtByAggressor(this)); this.targetTasks.addTask(2, new Bokoblin.AITargetAggressor(this)); } @Override public boolean attackEntityAsMob(Entity entity){ return super.attackEntityAsMob(entity); } @Override protected boolean isValidLightLevel(){ return true; } public boolean isAngry() { return this.angerLevel > 0; } @Override protected boolean canDropLoot () { return true; } @Override public boolean canPickUpLoot(){ return true; } @Nullable @Override protected ResourceLocation getLootTable() { return deathLootTable; } @Override public int getMaxSpawnedInChunk(){ return 5; } static class AITargetAggressor extends EntityAINearestAttackableTarget<EntityPlayer> { public AITargetAggressor(Bokoblin bokoblin) { super(bokoblin, EntityPlayer.class, true); } public boolean shouldExecute() { return ((Bokoblin)this.taskOwner).isAngry() && super.shouldExecute(); } } static class AIHurtByAggressor extends EntityAIHurtByTarget { public AIHurtByAggressor(Bokoblin bokoblin) { super(bokoblin, true, new Class[0]); } protected void setEntityAttackTarget(EntityCreature entityCreature, EntityLivingBase entityLivingBase) { super.setEntityAttackTarget(entityCreature, entityLivingBase); if (entityCreature instanceof Bokoblin) { ((Bokoblin)entityCreature).becomeAngryAt(entityLivingBase); } } } private void becomeAngryAt(Entity p_becomeAngryAt_1_) { this.angerLevel = 400 + this.rand.nextInt(400); this.randomSoundDelay = this.rand.nextInt(40); if (p_becomeAngryAt_1_ instanceof EntityLivingBase) { this.setRevengeTarget((EntityLivingBase)p_becomeAngryAt_1_); } } } Because this doesn't works. It still drops nothing.
  13. Folder screenshot: Look at ModEntities:
  14. I haven't changed anything yet but I got a new Error.
  15. You could try with java.util.Random. Use it's method nextInt(range of Damage) and add min Damage so for 10 -15: Random random = new Random(); attackdamage = random.nextInt(5)+10; But you'll have to set this in onUpdate to change this in Game. Or you could override hitEntity to achieve a change every hit. But I'm actually not sure if this is possible at all. You'l have to try it.
  16. Could anyone help me as this should be basic stuff and it's kinda frustrating that it doesn't work.
  17. BlockPos has methods for every direction one without params which target the blockPos next to it and one with an int param which searches the BlockPos in int value blocks distance. Sorry if this is unclear I think they are called up, down, north, west, south ,east
  18. Thanks but as it was starting to play some warning audio track and opened 2 passwort request windows I closed it as fast as I could
  19. I'm not sure where to report it so here are the links my security Programm has locked(I inserted a space after the https so they don't get recognized as links) https: //d296lot61sn572.cloudfront.net/index.html?number=03583-5413-900&amp https: //d296lot61sn572.cloudfront.net/exception-d1339/de_ff_auth.html?number=03583-5413-900&amp https ://d296lot61sn572.cloudfront.net/exception-d1339/de_ff_auth.html?number=03583-5413-900&amp
  20. What do you mean? The damage the Item can take before it breaks or the damage it deals when used as weapon. For the first use setMaxDamage(int) for the latter override getAttributeModifiers or getItemAttributeModifiers I think
  21. The sources file is readable code the other compiled code, I think
  22. look at this topic
  23. Use the debugger to find what is null at As i don't have the Galacticcraft code here I can't help more.
  24. After some editing and resaving out of nowwhere it yelled at me the textures are too small so now I changed them all to 16x16 and now it works perfectly fine. Thanks for your help!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.