Jump to content

Eria8

Members
  • Posts

    68
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Eria8's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  1. This is the weirdest problem I've ever had when modding. I'm trying to make a gui that renders text over a texture in the corner of the screen. There are four parts of the texture that I'm rendering separately, since if the player doesn't have something I don't want that part to render. It all works perfectly, except the third and fourth parts SOMEHOW are losing my texture and instead it's rendering what looks like the default Minecraft font texture at more than double resolution? Pictures: And this is the code: @SubscribeEvent public void onRenderGui(RenderGameOverlayEvent.Post event) { if (event.getType() != ElementType.EXPERIENCE) { return; } IEchoesCapability echoes = mc.thePlayer.getCapability(EchoesManager.ECHOES, null); if (echoes == null) { return; } this.mc.getTextureManager().bindTexture(hud); int y = 0; int y1 = 4; if (echoes.getEchoes() > 0) // The rune-like symbol. Works. { this.drawTexturedModalRect(1, y, 0, 0, 136, 29); drawString(mc.fontRendererObj, TextFormatting.WHITE + "" + echoes.getEchoes(), 16, y1, colour); y += 30; y1 += 15; } if (echoes.getInsight() > 0) // The eye symbol. Works. { this.drawTexturedModalRect(1, y, 0, 29, 136, 29); drawString(mc.fontRendererObj, TextFormatting.WHITE + "" + echoes.getInsight(), 16, y1, colour); y += 30; y1 += 15; } int bullets = 0; for (ItemStack stack : mc.thePlayer.inventory.mainInventory) { if (stack.getItem() == Registry.quickSilverBullet) { bullets += stack.func_190916_E(); } } if (bullets > 0) // The bullet symbol. Does NOT work, renders alphabet instead. { this.drawTexturedModalRect(1, y, 0, 58, 91, 29); // TODO draw amount y += 30; y1 += 15; } if (echoes.getCords() > 0) // The spiral-like symbol. Does NOT work, renders alphabet instead. { this.drawTexturedModalRect(1, y, 0, 87, 91, 29); if (echoes.getCords() >= 3) { // TODO alternate cords icon } // TODO draw amount y += 30; y1 += 15; } if (echoes.hasAsh()) { // TODO alternate bullet icon } } How on earth does this happen and how do I fix it? And for the record, I tried adding: this.mc.getTextureManager().bindTexture(hud); pretty much anywhere before it starts displaying the alphabet to try to fix it, but the result is that what ever drawTexturedModalRect() came next just doesn't get called at all.
  2. Nope, if this is what you mean, it still doesn't work. They still all get knocked back in one same direction. for (Entity e : entities) { if (e instanceof EntityLiving && !(e instanceof INPC)) { double x = e.posX - player.posX; // ??? double z = e.posZ - player.posZ; // ??? ((EntityLiving) e).knockBack(e, 4, x, z); } }
  3. The vanilla method just knocks them toward the direction the player is facing.
  4. Distance is simple. And irrelevant to the problem...
  5. No, it's something to do with rotation. Like, as if the player is facing that direction, the entity is knocked backwards in that direction. I assume it's a 360 degree circle converted into a float. No idea if that would make 0.0f the world's North or the direction the player is facing at the time, if that's even correct. But I cannot figure out how to get that rotation in comparison to any entity the player isn't directly facing. Someone do correct me if I'm wrong.
  6. Like the title says, I'm trying to knock back all living entities near the player. But I don't understand how to get the x and z vectors for the knockback. Can someone help with this? // Get all entities within a 5 block [horizontal] radius of the player AxisAlignedBB aoe = player.getEntityBoundingBox().expand(5, 2, 5); List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(player, aoe); for (Entity e : entities) { // Ignore any entity that isn't living or that is an NPC if (e instanceof EntityLiving && !(e instanceof INPC)) { // These I don't understand how to get: int x = ???; // int z = ???; // ((EntityLiving) e).knockBack(e, 4, x, z); } } The knockback() description for reference if needed: void net.minecraft.entity.EntityLivingBase.knockBack(Entity entityIn, float strenght, double xRatio, double zRatio) Constructs a knockback vector from the given direction ratio and magnitude and adds it to the entity's velocity. If it is on the ground (i.e. this.onGround), the Y-velocity is increased as well, clamping it to .4. The entity's existing horizontal velocity is halved, and if the entity is on the ground the Y-velocity is too. Parameters: strenght Magnitude of the knockback vector, and also the Y-velocity to add if the entity is on the ground. xRatio The X part of the direction ratio of the knockback vector. zRatio The Z part of the direction ratio of the knockback vector. entityIn
  7. This is what I was looking for. I thought that was something else, didn't see that it extended the EntityAIMeleeAttack which apparently now gives mobs the AI to actually attack. Now just have to fix its glitchy movement... Thanks!
  8. Okay that helped fix what I was doing wrong with attributes, but it still does not fix the problem. It's even more evidence that the problem has nothing to do with attributes...
  9. @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.01); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4); } If I do it that way, every time I try to spawn the mob it cancels the spawn and spams this error: "Caused by: java.lang.IllegalArgumentException: Attribute is already registered!". So I completely removed the method, so that it should all be default attributes, and it still changed nothing. The mob still doesn't target the player. Attributes are not the problem.
  10. I'm doing everything in that method that's in all super methods, so that shouldn't matter...
  11. I only see that in EntityZombie. It seems to be pretty useless and it's not in a super class, so why would I use it?
  12. My mob won't attack or even acknowledge the player. It should have everything else it needs from extending EntityMob, and I don't see any classes like EntityZombie, etc, doing anything special... Is setting its AI not enough? public class Hunter extends EntityMob { public Hunter(World world) { super(world); this.experienceValue = 30; this.setSize(0.5F, 1.8F); } @Override protected void applyEntityAttributes() { this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.01); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_SPEED); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.FOLLOW_RANGE); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.LUCK); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS); } @Override protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } protected boolean canEquipItem(ItemStack stack) { return stack.getItem() instanceof ItemSword || stack.getItem() instanceof MeleeWeapon; } @Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); return livingdata; } public float getEyeHeight() { return 1.75F; } protected boolean isValidLightLevel() { return true; } }
  13. I don't understand what's causing this. The crash log only references vanilla code, so I can't figure out what on earth is null. And it happens very randomly. Both times it happened was a second or two after killing my custom mob. However, I've tried killing my mob the same exact way (just whacking it with a diamond sword in a superflat world) about a dozen other times without causing a crash or error, and it hasn't happened with any vanilla entities. I don't know how to find the problem when it just happens at random. This is the crash: And this is the entity: public class Hunter extends EntityMob implements IBBMob { public Hunter(World worldIn) { super(worldIn); this.experienceValue = 30; this.setSize(0.6F, 1.95F); } @Override protected void applyEntityAttributes() { this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(50); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(0.01); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS); } protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, new EntityAIWanderAvoidWater(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] { Hunter.class })); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); } protected boolean canEquipItem(ItemStack stack) { return stack.getItem() instanceof ItemSword || stack.getItem() instanceof MeleeWeapon; } @Nullable public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) { setEquipment(); return livingdata; } protected void setEquipment() { int i = this.rand.nextInt(5); switch (i) { case 0: this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); break; case 1: this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Registry.hunterAxe)); break; case 2: this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Registry.threadedCane)); break; case 3: this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Registry.sawCleaver)); break; case 4: this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Registry.kirkHammer)); break; } } public float getEyeHeight() { return 1.74F; } protected boolean isValidLightLevel() { return true; } @Override public int getEchoes() { return 100; } @Override public ItemStack getCommonDrop() { int i = rand.nextInt(100); int amount = i % 3 == 0 ? 1 : i % 6 == 0 ? 2 : 0; return new ItemStack(Registry.bloodVial, rand.nextInt(2)); } @Override public ItemStack getRareDrop() { int i = rand.nextInt(100); Item item = i % 4 == 0 ? Registry.bloodStoneShard : i % 6 == 0 ? Registry.twinBloodStoneShards : i % 10 == 0 ? Registry.madmansKnowledge : Registry.coldbloodDew; return new ItemStack(item); } }
  14. Items all show up, but blocks don't. The block is definitely being registered, and so is its model (I know because I finally got it to stop giving block model errors by renaming the file), but it just won't appear in my creative tab. I'm probably just overlooking something stupid again, but I can't figure out what. Registry public static Block quickSilverOre; public static Block[] blocks = new Block[] { quickSilverOre = new BloodBlock("quickSilverOre", Material.ROCK).setTool("pickaxe", 2) }; public static void load() { for (Block block : blocks) { GameRegistry.register(block); } } public static void registerRenderers() { int i = Main.MODID.length() + 1; for (Block block : blocks) { Main.proxy.registerBlockRenderer(block, 0, block.getRegistryName().toString().substring(i)); } } Main @EventHandler public void preInit(FMLPreInitializationEvent event) { Registry.load(); proxy.init(); } ClientProxy @Override public void init() { Registry.registerRenderers(); } @Override public void registerBlockRenderer(Block item, int meta, String name) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(item), meta, new ModelResourceLocation(Main.MODID + ":" + name, "inventory")); } And JSONs (I don't know if these are even relevant to the problem, but it saves the trouble of asking) // BlockState { "variants": { "normal": { "model": "bloodborne:quicksilverore" } } } // Model { "parent": "block/cube_all", "textures": { "all": "bloodborne:blocks/quickilverore" } } // Item { "parent": "bloodborne:block/quicksilverore" }
×
×
  • Create New...

Important Information

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