Jump to content

Triphion

Members
  • Posts

    122
  • Joined

  • Last visited

Everything posted by Triphion

  1. These also don't disappear even if I were to extend another vanilla class. These.
  2. I recently started to use deferred registries instead of the old way of registering stuff such as items and blocks. And i've gotten all other stuff i've tried to work splendidly, all but entities. It just gives me error messages for every single solution I try; and it's driving me nuts. Help please. What is it that's so wrong with this code? public static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, Reference.MODID); public static final RegistryObject<EntityType<ChupnutEntity>> CHUPNUT = ENTITIES.register("chupnut", () -> EntityType.Builder.create(ChupnutEntity::new, EntityClassification.CREATURE) .size(0.8f, 0.6f) .setShouldReceiveVelocityUpdates(false) .build("chupnut")); Also, this error doesn't pop up if i change the entity class to any of the vanilla ones, and so this leads me to believe that there is something that is supposed to go into the entity class that i'm not aware of. And so, this is my entity class: public class ChupnutEntity extends CreatureEntity { protected ChupnutEntity(EntityType<? extends CreatureEntity> type, World worldIn) { super(type, worldIn); this.experienceValue = 5; } @Override protected void registerGoals() { this.goalSelector.addGoal(0, new SwimGoal(this)); this.goalSelector.addGoal(3, new MeleeAttackGoal(this, 1.0D, true)); this.goalSelector.addGoal(5, new WaterAvoidingRandomWalkingGoal(this, 1.0D)); this.goalSelector.addGoal(7, new LookAtGoal(this, LivingEntity.class, 16.0f)); this.targetSelector.addGoal(0, new HurtByTargetGoal(this, new Class[0])); this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, ChickenEntity.class, true)); } @Override protected void registerAttributes() { super.registerAttributes(); this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D); this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(2.0D); } @Override protected void updateAITasks() { super.updateAITasks(); } public boolean attackEntityAsMob(Entity entityIn) { boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float)((int)this.getAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue())); if (flag) { this.applyEnchantments(this, entityIn); } return flag; } @Override protected SoundEvent getAmbientSound() { return super.getAmbientSound(); } @Override protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return super.getHurtSound(damageSourceIn); } @Override protected SoundEvent getDeathSound() { return super.getDeathSound(); } @Override protected float getStandingEyeHeight(Pose poseIn, EntitySize sizeIn) { return 0.4f; } } Oh, and these errors are the ones that keep popping up: These also don't disappear even if I were to extend another vanilla class.
  3. Did this and it works! Thank you! Only issue i have now is that the Crafting Book is behaving oddly, the recipes themselves aren't showing up when i click on them and my custom recipe for sword is showing up as a 90 degrees rotated sword recipe. The Crafting Book issue regarding the recipes that aren't showing up inside the crafting window however has something to do with the container, don't know where this gets called since i have checked withing the vanilla Crafting Table and my code looks pretty identical.
  4. I want my special recipes to work ONLY on my new crafting table. I have everything set-up: Custom Crafting Table, Custom IRecipe implementation and a _factories.json. My Crafting Table is just like a normal Crafting Table so my custom IRecipe is essentially the same as a "shaped" recipe. This is what my custom IRecipe implementation looks like: Custom IRecipe implementation - https://gist.github.com/triphion/ac318db6a9a38789e219bbc71adea2b8 My guess is that i can somehow change this inside the matches function.
  5. After looking into it for a day, i found out that you can never have two of the same item in the same pool, even if the other one is enchanted. So i made some alternative pools to overcome this and now everything works.
  6. To be clear, i have added loot_tables before, and i have also added loot_tables in this mod i'm making right now. However, some loot_table jsons aren't working and i can't get my head around why they don't. So here is one of them that i think should work but doesn't. There aren't any problems with the registering of the loot_table either, i have tried with the same name with different loot inside and it works, but this loot does not.
  7. Okay, i looked a bit into it, however, i have a REALLY hard time understanding how everything regarding IRecipe works. I have however created a _factories.json now, so i think that one will work once i get everything else done. Also, to clear up, i have added recipes. But the recipes are normal recipes, and since my custom crafting table is basically a vanilla with a retexture, it adds onto that table aswell. But i want the recipes to only work on my custom table, and not the vanilla one. How do i make use of a custom IRecipe by the way?
  8. UPDATE: I have figured out the part of adding new recipes to my crafting table, but the problem is that i don't want the custom recipes to register for the standard crafting table aswell. I only want the custom recipes to be registered onto my custom crafting table. How would i do this? Would really appreciate some help.
  9. I have my working custom crafting table and everything like that set up. But now i'd like to have some new recipes added on-top of the vanilla ones. I have some insight into it, such as i'd probably need a crafting manager/handler or something like that. But i don't know how to make one or how to use it. So i'd like some guidance here if possible. Such as: What is important inside a crafting manager/handler? How do i make use of it? How do i register it? Worth noting is that crafting recipes in json format is new to me aswell since this is my first mod in 1.12.2, so some insight onto that aswell would be great! ?
  10. Thank you Winnetrie! Changed it and it worked. ❤️
  11. I have everything handled and in order for this to work, and everything does work, except for the inventory. When i click on some slots and/or items in the inventory, they move to other places inside the inventory or duplicates or something else. I have no idea why this happens and would very much appreciate some help here. The block: The Container: The Inventory: Basically all of it is copy-pasted from the normal workbench, but with my own block instead.
  12. Oh wow! Worked wonders, didn't know you could actually do it like that. Thanks for tellinig me. ?
  13. I need the integer since i have added more than just 2 modes. This is how it looks now: public void setLightningIndex(ItemStack item, int lightningValue) { NBTTagCompound nbtTagCompound = item.getTagCompound(); if (nbtTagCompound == null) { nbtTagCompound = new NBTTagCompound(); item.setTagCompound(nbtTagCompound); } if (lightningValue == 4) { lightningValue = 0; } nbtTagCompound.setInteger("lIndex", lightningValue); } And this works just fine for this case. But i am very appreciative of the advice however. ^^ EDIT: Actually, i do not need that integer parameter, my bad, thanks for pointing that out. This works easier than the above mentioned, thanks Draco. ^^
  14. Hi again, i've been posting quite frequently on here now hehe, it's just that i'm trying out so many new things and have no idea which methods do which in some of these cases. So i'd like some information on how this would be done. I have my item set up, a bottle that fills with fire whenever a block of my choosing is right-clicked. However, i can't seem to get any fire-blocks from raytracing, and the case seems to be that fire-blocks has no hitbox, and so, i would like to know how i can go around this issue. I have tried looking into waterliquid to see how it distinguishes fires, however i did not find anything there, i then also tried looking into how the player can extinguish fires by left-clicking on top of the block that is burning to no avail. So i'd like some info on this issue. ^^
  15. I have removed the printlns, and i usually use the logger, but for this i used the printlns because of a whim i guess? ? And that check is actually not needed, so i removed it. I always add +1 as the lightning index, so it always goes up, then i check if it goes up to 2, and if it does, it resets the value. But thanks for pointing those out. ?
  16. I SOLVED IT! Thank you so much diesieben! ❤️ This is how i did it:
  17. EDIT: I realized that there is actually the setLightningIndex function that gets the server to crash. And this is the error i get everytime: And this is how my setLightningFunction looks right now:
  18. I do in-fact know how static works, this was actually me being frustrated and just trying everything(which is never a good thing). Static is a declaration that has the same value for the class, including all individual objects that stem from the class has the same value. I have now removed those. I realized now aswell, but i don't know how to get that specific itemstack and then use the method since i cannot cast directly to an itemstack. This is what i have for now, and it is not valid/or working method, just starting the method. if (player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.ZEUS_LIGHTNING_CHARGED) { System.out.println("Succesfully retrieved Item."); ItemStack weapon = player.getHeldItem(EnumHand.MAIN_HAND); ((ItemZeusLightningCharged)weapon).setLightningIndex(weapon, + 1); } How do i cast directly to the itemstack and not the item class as a whole? Because i can get the itemstack, but not cast it directly to the itemstack and change that specific itemstack. [16:42:22] [Netty Server IO #1/INFO] [STDOUT]: [com.etauricstaff.etauricmod.network.MessageGetPlayer:handleServerSide:36]: Succesfully retrieved Item. [16:42:22] [Netty Server IO #1/INFO] [STDOUT]: [com.etauricstaff.etauricmod.network.MessageGetPlayer:handleServerSide:39]: Itemstack: 1xitem.zeus_lightning_charged@0
  19. Thank you for the advice. I have tried to make something like that. However, the problem is that the player doesn't register the active itemstack, and instead has it as simple air. And i don't really know how to fix that. ((ItemZeusLightningCharged)player.getHeldItemMainhand().getItem()).setLightningIndex(player.getActiveItemStack(), +1); This is the function that i'm calling when the player presses a button to change the firing mode. After that, the lightning index is going up, and then the item property is supposed to override and give the item a new texture. public static int getLightningIndex(ItemStack item) { NBTTagCompound nbtTagCompound = item.getTagCompound(); if(nbtTagCompound != null) return nbtTagCompound.getInteger("lIndex"); return 0; } public static void setLightningIndex(ItemStack item, int lightningValue) { NBTTagCompound nbtTagCompound = item.getTagCompound(); if (lightningValue < 2) { } else if (lightningValue == 2) { lightningValue = 0; } nbtTagCompound.setInteger("lIndex", lightningValue); ItemZeusLightningCharged.lightningIndex = lightningValue; Utils.getLogger().info(lightningValue); } This is the methods i'm using to get the index number. public static int lightningIndex; This is the int/float i'm using to check if the item should override.
  20. So the problem is very simple, i want the item i'm holding to change, and not the other ones of the same item in my inventory. Here is the class with the method. Any ideas? EntityLightningBolt lightning; private int lightning_index; public ItemZeusLightningCharged(String unlocalizedName) { super(unlocalizedName); this.setCreativeTab(CreativeTabs.COMBAT); this.lightning_index = 0; this.addPropertyOverride(new ResourceLocation(Reference.MODID, "zeus_mode"), new IItemPropertyGetter() { @Override public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) { Utils.getLogger().info("Itemstack: " + stack); if (entityIn != null && entityIn.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.ZEUS_LIGHTNING_CHARGED) { Utils.getLogger().info("Player has Item."); return (float)((ItemZeusLightningCharged)entityIn.getHeldItem(EnumHand.MAIN_HAND).getItem()).lightning_index; } else { return 0.0F; } } }); } To clarify, the lightning index is an int that resembles the different modes. Edit: This doesn't actually work serverside either.
  21. To start off. The item in question is working, the problem lies in my eventhandler that is responsible for switching the firing modes when a button is pressed. private static boolean first_keypress = true; private static EntityLivingBase player; private static ItemZeusLightningCharged z_lightning; These are the variables that i'm using. The first_keypress is used to keep the key triggered once, and then you can trigger it once more after you release it. The player is to check if the entity is a player. The lightning is used as the weapon reference. @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public static void onItemCheck(LivingUpdateEvent event) { if (event.getEntityLiving() instanceof EntityPlayerMP) { player = (EntityPlayerMP) event.getEntityLiving(); if (event.getEntity() == player && player.getHeldItemMainhand().getItem() == ModItems.ZEUS_LIGHTNING_CHARGED) { z_lightning = (ItemZeusLightningCharged) player.getHeldItemMainhand().getItem(); } else { z_lightning = null; } } } This is the method that checks if the entity is an instance of entityplayer, and if it is, it changes the player variable to the entity. And under that we have a check to see if the player is holding the lightning weapon. And if it is, it changes the weapon variable to the weapon the player is holding. And if it isn't holding the weapon, the weapon reference is null. @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public static void onEvent(KeyInputEvent event) { KeyBinding[] keyBindings = ClientProxy.keyBindings; if (keyBindings[0].isPressed()) { if (first_keypress) { first_keypress = false; Utils.getLogger().info("Trying to check Item."); checkItem(); } } else if (!keyBindings[0].isPressed()) { first_keypress = true; } } private static void checkItem() { if (z_lightning != null) { Utils.getLogger().info("Checked Item."); z_lightning.lightningIndexController(); } } Next we have the keycheck. If the player presses the designated keybinding and it's the first keypress, then it calls checkItem();. It then changes the first_keypress to false and when you release the button, it changes to true. I am probably going to change the boolean to something as a timer instead if i have more of these events. Anyway, the checkItem(); checks if the weapon reference isn't null, and if it isn't null, it then gets the weapon reference and calls indexController(); on the weapon reference. public void lightningIndexController() { if (this.lightning_index < 2) { this.lightning_index += 1; } if (this.lightning_index == 2) { this.lightning_index = 0; } Utils.getLogger().info("Lightning Index: " + this.lightning_index); } The index controller adds a number to the index if it is lower than the maximum number, and resets to 0 if it goes to the maximum number. Now, the problem is that this doesn't work on servers, it does however work on singleplayer worlds. I have done several checks, and the problem seems to be that the weapon reference doesn't get stored, it only changes to the current weapon inside the weaponcheck. After the weaponcheck inside the updateevent, it just goes back to null. I don't know why this is the case on servers, but not on singleplayer worlds. Would appreciate some pointers here. ^^ EDIT: SOLVED IT! I created and used packets to fix it.
  22. for (Entity entity : this.friendlyList) { if (entity.isDead) { this.friendlyList.remove(entity); } } Noticed aswell that if an undead dies, it crashes, i tried making this method to fix it, but to no avail. Edit: fixed it. Removed the method in its entirety and it somehow solved the problem ¯\_(ツ)_/¯ But i still need help regarding selecting target that is closest to the entity. @Override public void setAttackTarget(EntityLivingBase entitylivingbaseIn) { if (this.canTarget) { this.enemyList.removeAll(this.friendlyList); Entity enemy = (Entity) this.enemyList.get(0); double d0 = this.getDistanceSqToEntity((Entity) enemy); EntityLivingBase entityToAttack = (EntityLivingBase) enemy; if (d0 < 30.0D && d0 > 0) { entitylivingbaseIn = (EntityLivingBase) enemy; super.setAttackTarget(entitylivingbaseIn); } else { super.setAttackTarget(null); } } } I've started with this, but it's nowhere near done. So i need a few pointers to get the target i want. Edit: I fixed it! Thanks for all your help guys! ^^ @Override public void setAttackTarget(EntityLivingBase entitylivingbaseIn) { if (this.canTarget) { for (Entity entity : this.enemyList) { double d0 = this.getDistanceSqToEntity(entity); if (d0 < 40.0D) { super.setAttackTarget((EntityLivingBase) entity); } } } else { super.setAttackTarget(null); } } @Override protected void updateAITasks() { this.targetList = this.world.getEntitiesWithinAABBExcludingEntity(this, new AxisAlignedBB((double)this.posX - 17.5D, (double)this.posY - 17.5D, (double)this.posZ - 17.5D, (double)this.posX + 17.5D, (double)this.posY + 17.5D, (double)this.posZ + 17.5D)); if (this.getAttackTarget() == null && this.isAlly()) { for (Entity entity : this.targetList) { if (entity instanceof EntityUndead && ((EntityUndead) entity).isAlly() && !this.friendlyList.contains(entity)) { this.friendlyList.add(entity); } if (entity instanceof EntityPlayerMP && !this.friendlyList.contains(entity)) { this.friendlyList.add(entity); } } } else if (!(this.getAttackTarget() == null)) { this.canTarget = false; if (this.friendlyList.contains(this.getAttackTarget())) { this.setAttackTarget(null); } } this.targetList.removeAll(this.friendlyList); this.enemyList.clear(); this.enemyList.addAll(this.targetList); if (!this.enemyList.isEmpty()) { this.canTarget = true; } else if (this.enemyList.isEmpty()) { this.canTarget = false; } }
  23. Tried a much higher limit aswell as no limit. But it still crashes. Any other suggestion on why it crashes? It gets called too often in updateAITasks and i should use some other update method? Undead class: https://github.com/triphion/Ancient-Mod/blob/master/src/main/java/ancient/entity/EntityUndead
  24. if (this.getAttackTarget() == null && this.isAlly()) { for (Entity entity : this.targetList) { if (entity instanceof EntityUndead && ((EntityUndead) entity).isAlly() && !friendlyList.contains(entity)) { friendlyList.add(entity); } if (entity instanceof EntityPlayerMP && !friendlyList.contains(entity)) { friendlyList.add(entity); } } } Did it and it works, now however i need to check for all entities in the enemy list for the one that is closest to the entity. Any suggestions? Edit: I realized that the game crashes when there's too many loyal undeads. Not sure where in the code it gets overexerted.
  25. What i'm trying to achieve is a filtering system where my loyal undeads will select its next target based on a list that will get updated in updateAITasks. I think i have almost got it, but i'm still running into a few problems, such as the entity selecting a few targets that is not supposed to be targeted. To make sure this does what it's supposed to, i made a targetList which creates an aabb around the entity and then checks if there are any allies in that aabb, if there are, it adds the allies in the aabb. Or atleast is supposed to, but my problem is that i don't know how to reference all the friendly ones and then add them all at the same time. My entity class = https://github.com/triphion/Ancient-Mod/blob/master/src/main/java/ancient/entity/EntityUndead Worth noting is the way i'm adding and filtering. So first of i start with checking if the current target is null and if the targetList has any loyal undeads or players in it. If it has, then it's supposed to add them all. Then i remove them from the targetList and then add all of the remaining entities in the enemyList. Then every time this method gets called, so as to not overexert anything, i remove all the entities in the enemyList and then the process continue.
×
×
  • Create New...

Important Information

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