Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

izofar

Members
  • Posts

    37
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

izofar's Achievements

Tree Puncher

Tree Puncher (2/8)

4

Reputation

  1. I am making a modded armor item that replaces itself with another tier of armor on break. The replacement tier is used to craft the modded armor. I want the replacement armor to have the same durability as the ingredient did when it was used in crafting the modded armor. Is there a way to get the damage value in the json? Do I have to mod my own recipe class? Where would I store this damage value, in preparation for break, a modded itemstack class? In addition, I want the durability of the armor on crafting to be proportional to that of the durability of of the ingredient. Currently, the modded armor has less durability, but is stronger than the ingredient. So, crafting with an almost-broken ingredient gives negative durability to the modded armor. Not sure the best way to approach this, thanks!
  2. I may have posted this prematurely... I came across the WorldTickEvent hook through which I can access the ServerWorld. I'd still appreciate any feedback from more knowledgeable modders... would my implementation with WorldTickEvent be equivalent according to my specification in my original post? Otherwise, I hope this is useful reference to anyone experiencing the same problem.
  3. So I am trying to invoke a custom siege (rather than a zombie siege). I want this event to be independent of zombie sieges (ruling out cancelling the zombie siege event hook). The following code in ServerWorld#tickCustomSpawners loops through the ISpecialSpawners, one of which is a net.minecraft.village.VillageSiege: public void tickCustomSpawners(boolean p_241123_1_, boolean p_241123_2_) { for(ISpecialSpawner ispecialspawner : this.customSpawners) { ispecialspawner.tick(this, p_241123_1_, p_241123_2_); } } I've written my own Siege class... almost identical to VillageSiege for now... and I want it to tick on the ServerWorld with siegeObject.tick(serverWorld, bool1, bool2). However, I can't access the ServerWorld of a ServerTickEvent. Is there a static ServerWorld I can access for my purposes? Or is there a better event hook I can use that will offer up the ServerWorld object?
  4. The Chunk#isLoaded seems to be depreciated, nor is there a ChunkLoader#chunkExists (my research)... what's the new way of doing this? The Chunk#loaded field is private, and the Chunk#getStatus method always returns ChunkStatus.FULL... I can get the chunk with entity.level.getChunk(entity.getBlockPosition()), but what then? Must I use reflection for this? Surely there's a cleaner way. What was previously isChunkLoaded (which Jabelar said World#isAreaLoaded utilizes) seems to be hasChunksAt, which is marked depreciated. Any guidance on this?
  5. Is there an easier way to do this? How would the iron golem have spawned in the first place without chunk deadlocks? Is it easier to modify the villager behavior to spawn the modded entity instead?
  6. Goal My goal is to replace naturally spawning iron golems with my modded clay golems, but still allowing for players to build their own iron golems. I have the following SubscribeEvent: Code @SubscribeEvent public static void onIronGolemJoinWorld(EntityJoinWorldEvent event) { if(event.getEntity() instanceof IronGolemEntity) { if(event.getWorld() instanceof ServerWorld) { IronGolemEntity entity = (IronGolemEntity) event.getEntity(); ServerWorld world = (ServerWorld)event.getWorld(); if(!entity.isPlayerCreated()) { ExampleMod.LOGGER.info("Iron Golem Found!"); ModEntities.CLAY_GOLEM.spawn(world, null, null, entity.blockPosition(), SpawnReason.MOB_SUMMONED, false, false); ExampleMod.LOGGER.info("Spawned Clay Golem"); } } event.setCanceled(true); ExampleMod.LOGGER.info("Removed Iron Golem"); } } Context I Hope This Isn't a Duplicate Question, I have read the link but still do not understand what I've done wrong. I have read the vanilla code and understand that in order to call the private World#addEntity, I must call ServerWorld#addFreshEntity (true for spawning golems with pumpkins, and silverfish blocks, etc.). Alternatively, spawn eggs call EntityType<?>#spawn, but check that the world parameter is a ServerWorld. The result of the code above is the same as when I use: ClayGolemEntity claygolementity = ModEntities.CLAY_GOLEM.create(world); ExampleMod.LOGGER.info("Created Clay Golem"); claygolementity.moveTo(entity.position()); ExampleMod.LOGGER.info("Moved Clay Golem"); world.addFreshEntity(claygolementity); ExampleMod.LOGGER.info("Spawned Clay Golem"); Results My issue is that the following occurs: (1) using /summon examplemod:iron_golem spawns in a clay golem. Not ideal, but I'm fine with this at the moment. (2) Constructing Iron Golems constructs and iron golem, as intended (3) Any naturally spawning golems in villages lags out the game to the point of needing to force quit. (4) using /summon to spawn an iron golem (with the event.canceled(true) commented out) and then reloading the world lags out as well. The last print statement is either "Iron Golem Found" as in the first code example, or "Moved Clay Golem" as in the second code example. I appreciate the help. I haven't yet been able to spawn an entity in the world in code yet.
  7. The IForgeItem method ends up being called in the following snippet by makesPiglingsNeutral: public static boolean isWearingGold(LivingEntity p_234460_0_) { for(ItemStack itemstack : p_234460_0_.getArmorSlots()) { Item item = itemstack.getItem(); if (itemstack.makesPiglinsNeutral(p_234460_0_)) { return true; } } return false; } And the default IForgeItemStack method is: default boolean makesPiglinsNeutral(LivingEntity wearer) { return getStack().getItem().makesPiglinsNeutral(getStack(), wearer); } Will getItem().makesPiglingsNeutral return my overridden method? Or the default, since getItem() will return type Item rather than my ModdedArmorItem class?
  8. Part 1) I want to add an armor material that piglins won't attack. I've traced a single line of code... if only I could modify! In IForgeItem#makesPiglinsNeutral, the input is checked that it is of gold material. How do I add my custom Armor material to this? Do I need reflection, or does forge allow an easier way to achieve/override this? This method is called by IForgeItemStack#makesPiglinsNeutral, which is called by entity.monster.piglin.PiglinTasks#isWearingGold, called by PiglinMobSensor#doTick to update MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD Part 2) I want to extend this behavior to piglin brutes. This likely requires an exponentially more difficult workaround. Any insight to this, and generally overriding vanilla mob features that aren't represented in Forge events?
  9. I'm familiar with generics, just not its use in function definitions. I appreciate your patience. I at first failed to notice that this is a Java-specific concept not attributable to Forge. I apologize for the Java questions. Thank you for your help.
  10. Ah, I see. Is the <T extends LivingEntity> the player, in this case? In addition, I'm not familiar with the <> Notation as used in `public <T extends LivingEntity> int damageItem(...)`. Does this just place restriction on T? How does one use the Consumer<T> input? I'm looking at ItemStack#hurtAndBreak for direction on how to use the inputs. But, I've found that breaking an item occurs outside of the damageItem call. which means that giving the player the replacement item inside of damageItem will happen before the original is broken and removed.
  11. I have a ModdedArmorItem extends ArmorItem class which overrides setDamage(ItemStack stack, int damage), in which i want to check if the durability is zero, then replace the item stack with another item. Functionally, I want armor to leave an item when it breaks (to simplify, break into another armor item that resides in the same slot).
  12. Is there a way to access the player owning the inventory an item stack is in? If any? Or to change the item in an itemstack? Two ways I've looked at this is to do onArmorTick(PlayerEntity player) to store the player but I don't think this would work for multiplayer (since there is only one modded armor class instantiated?). The other means I'm trying is to set the entity representation of the item stack obtained from setDamage to the entity representation of a newly instantiated itemstack of the desired replacement material. I am not optimistic about either approach.
  13. Excellent, thanks. If I wanted, for example, gold armor to drop ingots upon breaking, how would I achieve this for vanilla armor? Would I have to duplicate the gold armor item instantiations (except inherited from the custom class) and register them under the minecraft:golden_*slot* resource? Or is writing a hook for the trigger a more desirable solution? In addition, where is this damage item method? I can't find it in the type hierarchy. I thought this would be a member of the item stack, not the item class.
  14. This is my modded armor. Instantiated: Item moddedHelmet = new ArmorItem( ...); If I'm correct, are you about to suggest I make my own armor class that inherits from ArmorItem (or something) and override some itemDamaged method? Because now that makes sense Despite this, I do intend to do this for other armor items as well in the future
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.