Jump to content

Godis_apan

Members
  • Posts

    109
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Godis_apan

  1. Yes, I mean the vanilla classes. So if I’m doing a new block for instance, I look at vanilla block classes that does something similar. For documentation I’m using: https://mcforge.readthedocs.io/
  2. Add a capability to the player, send a packet and change model in render events.
  3. 1. Look for vanilla code that handles this and see if that is helpful. 2. Check forge documentation. 3. Search the forge modder support for similar questions or issues. 4. Check established GitHub repos such as choonster’s or cadiboo’s. 5. Ask myself here
  4. Okay so I debugged this and it seems that the ItemColors registers before I reflect into the map. When I added a breakpoint in the ItemColors only the last egg I added showed up in the for loop where SpawnEggItem#getEggs() gets called. But when I run the same for loop after my reflection has taken place my entities also shows up. So how do I reflect into the map before ItemColors are registered? https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/util/Utils.java
  5. I have, still no result.
  6. Well it still isn't working, all the eggs except the last still appear white
  7. Okay Im using that method now but how do I store the map? Do I need to use setPrivateValue afterwards? Map<EntityType<?>, SpawnEggItem> map = (Map<EntityType<?>, SpawnEggItem>) ObfuscationReflectionHelper.getPrivateValue(SpawnEggItem.class, null, "field_195987_b"); map.keySet().removeIf(Objects::isNull); map.putAll(EGG_MAP);
  8. I'm sorry to be such a dum-dum here but I can't see how I would do this. Wouldn't this be better to do with ATs? Or is that bad? Thanks for the help it's very much appreciated.
  9. Okay! Checked with breakpoints and as far as I could tell the map is modified but still no result. What am I doing wrong here? public static final Map<EntityType<?>, SpawnEggItem> EGG_MAP = Maps.newHashMap(); public static void addSpawnEggs() { try { Map<EntityType<?>, SpawnEggItem> map = (Map<EntityType<?>, SpawnEggItem>) ObfuscationReflectionHelper.findField(SpawnEggItem.class, "field_195987_b").get(null); map.keySet().removeIf(Objects::isNull); map.putAll(EGG_MAP); } catch (IllegalAccessException | IllegalArgumentException e) { throw new RuntimeException("Failed to spawn eggs to map", e); } }
  10. Can't get this to work yet: public static void addSpawnEgg(IItemProvider item) { if (item instanceof EntitySpawnItem) { EntitySpawnItem egg = (EntitySpawnItem) item; try { Field field = ObfuscationReflectionHelper.findField(SpawnEggItem.class, "field_195987_b"); Map<EntityType<?>, SpawnEggItem> map = (Map<EntityType<?>, SpawnEggItem>) field.get(null); map.put(egg.getType(null), egg); } catch (IllegalAccessException | IllegalArgumentException e) { throw new RuntimeException("Could not add " + item.asItem().getRegistryName().toString() + " to spawn eggs map", e); } } } This is called from FMLCommonSetup: event.enqueueWork(() -> { Utils.addSpawnEgg(ModItems.PERCH_SPAWN_EGG); Utils.addSpawnEgg(ModItems.EEL_SPAWN_EGG); Utils.addSpawnEgg(ModItems.PIKE_SPAWN_EGG); Utils.addSpawnEgg(ModItems.TUNA_SPAWN_EGG); Utils.addSpawnEgg(ModItems.SWAMP_DWELLER_SPAWN_EGG); });
  11. Alright that makes sense. Is this thread safe to do or should I use event.enqueueWork?
  12. Hello! For some reason when adding multiple spawn eggs for my entities, only the last one registered renders in the inventory with its proper colors. All eggs registered before the last on appear white and I can't figure out why. Item register code: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/init/ModItems.java
  13. Ah of course, I took this route and it seems to be working fine now: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/loot/LootTableHandler.java
  14. What I'm trying to achieve is adding a new fish and then when fishing, either my fish or a vanilla one get fished up. I can't add it to gamplay/fishing/fish.json since like you said: "nested" loot tables will not be affected by GLM. So how do I go about adding a fish to a vanilla loot table without using LootTableLoadEvent that will allow a random fish (vanilla or modded) to be captured. And not wto fish at the same time.
  15. Still no luck I'm afraid, now I'm back to the same problem where both the vanilla fish and my fish is added at the same time... Updated my git repo for reference: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/loot/LootTableHandler.java
  16. Ah yes of course, I fixed that error but now my fish doesn't show up at all, just the vanilla fish.
  17. Is this the way to do it? Because this isn't working for me yet. This extends my previous LootModifier which handles the serialization. public static class FishLootModifier extends LootTableDropModifier { public FishLootModifier(ILootCondition[] conditions, TableLootEntry lootTable, Item[] overwrite) { super(conditions, lootTable, overwrite); } @Nonnull @Override protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) { try { Field field = context.getClass().getField("lootTables"); //Just for testing purposes, change to obfuscated name later field.setAccessible(true); Set<LootTable> set = (Set<LootTable>) field.get(context); if (set.size() == 1) { return super.doApply(generatedLoot, context); //Adds my table to the list } } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException("Could not add access lootTables", e); } return generatedLoot; } }
  18. Alright then I'll try this out
  19. Would I need reflection to do this?
  20. Yes but when something is fished it calls the fishing loot table which in turn calls fish.json in which I add my loot. How would I otherwise go about adding this? Because if I modify fishing.json more than one fish will added to the loot table.
  21. Hello again. I've been for some time trying to add fishing to loot tables and it seems it is now possible with GLM using the new loot_table_id condition. However, I've run into a hurdle. I'm adding fish and therefore want to add loot to this loot table: loot_tables/gameplay/fishing/fish.json. But when I do this the fish is not possible to get from fishing or using "/loot give @p fish minecraft:gameplay/fishing ~ ~ ~ ". Only when I use this command can I get my fish: "/loot give @p fish minecraft:gameplay/fishing/fish ~ ~ ~". I've tried debugging it and it seems like the doApply does not get fired when I'm fishing even though I'm modifying that loot table. Loot table class: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/loot/LootTableHandler.java Loot modifier json: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/resources/data/vanillaboom/loot_modifiers/fish.json Fish loot table (referenced in the loot modifier json): https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/resources/data/vanillaboom/loot_tables/gameplay/fishing/fish.json
  22. Have a look in Minecraft's NetherFossilStructure for placement in the nether, this will give you an idea of how to check for correct positions. I did a similar thing in my mod here for a Nether Well to be generated: https://github.com/Phrille/Vanilla-Boom/blob/master/src/main/java/phrille/vanillaboom/world/structures/NetherWellStructure.java Now keep in mind that my code does not do any placement checks other than the first check to see if I start the gen on a block. For instance no checks are done to check if the is enough air to fit the structure in and so on.
×
×
  • Create New...

Important Information

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