Cryotron
Members-
Posts
17 -
Joined
-
Last visited
Cryotron's Achievements
Tree Puncher (2/8)
1
Reputation
-
[1.15.2] Enchantment Weight and Item Stack Transformation
Cryotron replied to Cryotron's topic in Modder Support
NBT data seems new, I'll look more into it. Seems like it is possible to do the two objectives. -
Alright, so I've looked into enchantments for awhile and there are so many things that perplexes me. I've seen a lot of tutorials that creates the custom enchants that grants various effects of the modders desire. However, my intent with the enchantments are creating items that has specialized different weights as well as functions like an enchantment book but with a capability. In fact, there are two things that I would like to accomplish: 1. If I put the custom item in the Enchanting Table and select one of the three given enchantment options, the item becomes its enchanted version of it and put the selected enchantment on it and only the selected enchantment. Currently, I'm struggling to understand how can an item stack such as a book turning into enchantment book and there are a lot of different class files that checks the book that's all over the place. This is kind of a reason why I asked if there is such a thing for an Enchantment Event. So how do I transform an item stack on an enchantment table much like the book? Is there a way to limit the number of enchantments applied on that item? 2. How do I adjust the weight of the enchantment rarity based on the item that the Enchantment Table is enchanting? For instance, I have Ruby that has a fixed weight for Sharpness, Fire Aspect, Power, Flame and Impale in contrasts of their normal weights of 10, 2, 10, 2, 2 respectively. When you put a Ruby on an Enchantment Table, all the listed Enchantments have fixed and equal amount of rarity and weights and like example shown from #1, it would turn into Enchanted Ruby with whichever the three enchantment a player selected. So #1 is about Enchanting an Item Stack that turns it into an Enchanted Version of the Item with only one enchantment on it and #2 is about adjusting Enchantment weight based on item stack. My question that fits the two is: Is there a feasible way to accomplish those two objectives? Or in fact, I would like to know if the two objectives are possible to achieve with the tools given to me. @Override public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) { return true; } Looking at this method, the only thing I have done so far is to restrict enchantments which is not what I'm trying to achieve. My question is how do I change the enchantment rarity and weight based on the item, transform an item stack to the enchanted version of it and only apply ONE selected enchantment regardless of the enchantment level? ...
-
See, one of my other close friend of mine have done this and restricted the types of enchants that can be applied on a gem. That was not our intent, our intent was the usage of gems can manipulate of what type of enchantment you can get on a gem. That's pretty much my objective for today: put the gem on the enchantment table with modified enchantment weights for only those gems and then transform those gems into Enchanted Gems (Like the Book but without the modified weights) I'll probably look into server-client syncing anyway since I used capability and networking for socketing anyway.
-
Salutations! I have made a big leap progress towards my mod by adding a capability to add socket slots into items. It was pretty satisfying after weeks of deciphering packet networking and capabilities. Then I was left with options: to enchant a gem and then add the enchantments into the socketed item (making "Sharpness X" possible) or to make the gem give static bonuses based on the type of item that the gem is socketed in. I've talked to my close ones for more insight and one of them explicitly expressed the importance of enchantment of my mod. While the latter sounds more feasible but removing depths from the mod, the former has left me thinking with a question: Is there such a thing as an enchantment event where the color of the gems adds the weight of the certain enchantments? Like an example would be: just like adding the book to the enchanting table and selecting an enchantment stores it into the book and transforms it into the enchanted book; is it through an Enchantment Event that a gem would be turned into an enchanted gem with the given different weights of each enchantment depending the color of the gem? TL;DR Is Enchantment Event a thing? Probably... Just not that what I was expecting given that each enchantment has different weights on their respective class files rather than the Event class itself.
-
Potion of Healing harms them. Potion of Harming heals them. Extra damage taken from Smite. Withers do not attack them. Immune to Poison and Regen. This would make Vexes a bit more feasible to deal with using Splash Potions of Healing. The Ghast however...... I mean I guess I really don't have to make them undead.
-
The Lightning Event seems doable then. I think I misunderstood your 3rd sentence on a capability that adds something that's "not my own" such as adding a capability to a vanilla entity. Like adding a mana pool, socketed items, energy, etc. I kind of took it as property can be used as a capability since IEEP has been depreciated in favor of capabilities which is something I'm not fully familiar with. The reason why I want to make Ghasts and Vexes undead because it conceptually makes sense. They are incorporeal creatures (But hey, it's Minecraft so it's whatever I guess xD). Worst case is that I would probably leave them alone or use events to "replace" the list of entities that spawns in a dimension or what evokers summon. The most feasible way is to just leave them be. :L But if there is a way to turn the Ghasts and Vexes into undead, I'm happy to read it thoroughly. I would like to update vanilla mobs that makes it synergize with my mod: E.G. Smite works on Demons in 1.16 update where Piglins would be Demons later.
-
Yes. I wish to add Creature Attributes onto Ghasts and Vexes and an outcome when a Skeleton gets struck by lightning. Does the event AttachCapabilitiesEvent allow as such? I'm still scratching my head of capabilities in terms of functionality. EDIT: I'll look into AttachCapabilitiesEvent and see what comes out of it.
-
Hello, I've asked an advice for adding the Wither Mages in the Nether Fortress... and I succeeded. Adding an event is something I'm now used to. Hopefully I can do so to add world events like Nevermine did. Now, it is then I believed that I can move on to something more complicated. I've looked into it from the origin of Extended Entity Properties (IEEP) and it is depreciated in favor of capabilities. It seems capabilities can do something that is not really ordinary to the game such as adding a mana bar or an extra resource that players need to track (as I've seen plethora of examples that capabilities are added to players). As the title suggests, the objective is to add a creature attribute and other non-primitive data type objects to the existing entities created by vanilla Minecraft. In the other words, I'd like to add something like: - Adding Undead Creature Attribute onto Ghasts (Since they are ghosts...) - Adding Undead Creature Attribute onto Vexes (Since they are also ghosts...) - Adding Demon Creature Attribute onto Piglins and Hoglins (Demons don't exist, it will be a mod made attribute. I plan to update this mod when 1.16 releases) - Adding OnStruckByLightning onto Vanilla Skeletons into Skeletal Mages (Skeleton -> Skeleton Mage with Fire Res for 8 seconds) - Adding OnStruckByLightning onto Pillager or Vindicators into Warlocks (Warlocks are not implemented but you get the idea. They're basically the Illager Version of Witches) - Adding OnStruckByLightning onto Foxes into Nine-Tailed Demon Fox (In the mod sequel) So far, I only know a capability that involves around primitive data types such as integers. I think adding a mana bar is pretty straightforward. But when it comes to object related, it gets pretty hectic depending on the NBT. I checked on the referenced folder and these are the following NBTs available to the game and some of them are not even a primitive data types I'm familiar with: Byte, ByteArrays, Collections, Compound, CompressedStreamTools, Doubles, Ends, Floats, Integer, IntegerArray, JsonTo, Lists, Long, LongArray, Shorts and Strings. I'm using an example for Ghasts. For them, the NBTs are: Explosion Power, Silent, NoAI, CustomName, AbsorptionAmount, Invulnerable, PersistenceRequired, Fire, PortalCooldown, Air, UUID, ID and Passengers... So my question is that it is even possible to add a creatureAttribute.UNDEAD to Ghasts? It's kind of like adding a new method of an existing entity instead of overwriting an existing one. I made a new project to test the capability of a Ghast and these are the files: capabilitytest.java(Main file) package com.cryotron.capabilitytest; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.cryotron.capabilitytest.capability.interfaces.IGhastCapability; import com.cryotron.capabilitytest.instances.GhastInstance; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; // The value here should match an entry in the META-INF/mods.toml file @Mod(CapabilityTest.MODID) public class CapabilityTest { public static final String MODID = "capabilitytest"; public static final Logger LOGGER = LogManager.getLogger(MODID); public CapabilityTest() { LOGGER.info("\"Hello World\" -Capability Test"); final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::onCommonSetup); } private void onCommonSetup(FMLCommonSetupEvent e) { CapabilityManager.INSTANCE.register(IGhastCapability.class, new GhastInstance.Storage(), GhastInstance::new); } } ForgeSubscriber.java package com.cryotron.capabilitytest; import com.cryotron.capabilitytest.capability.interfaces.IGhastCapability; import com.cryotron.capabilitytest.capability.GhastCapability; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = CapabilityTest.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) public class ForgeSubscriber { private static final ResourceLocation GHAST_UPDATE = new ResourceLocation(CapabilityTest.MODID, "ghast"); @SubscribeEvent public static void onAttachGhast(AttachCapabilitiesEvent<Entity> e) { if (e.getObject().getEntity() instanceof IGhastCapability) e.addCapability(GHAST_UPDATE, new GhastCapability()); } } EventBusSubscriber.java package com.cryotron.capabilitytest; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.IForgeRegistryEntry; @Mod.EventBusSubscriber(modid = CapabilityTest.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class EventBusSubscriber { public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final String name) { return setup(entry, new ResourceLocation(CapabilityTest.MODID, name)); } public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final ResourceLocation registryName) { entry.setRegistryName(registryName); return entry; } } GhastInstance.java (This is the part that I think I have trouble with) package com.cryotron.capabilitytest.instances; import javax.annotation.Nullable; import com.cryotron.capabilitytest.capability.interfaces.IGhastCapability; import net.minecraft.entity.CreatureAttribute; import net.minecraft.nbt.INBT; import net.minecraft.nbt.IntNBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; public class GhastInstance implements IGhastCapability { @Override public CreatureAttribute getCreatureAttribute() { // TODO Auto-generated method stub return CreatureAttribute.UNDEAD; } @Override public void updateCreatureAttribute(CreatureAttribute GhastAttribute) { // TODO Auto-generated method stub GhastAttribute = CreatureAttribute.UNDEAD; } public static class Storage implements Capability.IStorage<IGhastCapability> { @Nullable @Override public INBT writeNBT(Capability<IGhastCapability> capability, IGhastCapability instance, Direction side) { return (INBT) instance.getCreatureAttribute(); } @Override public void readNBT(Capability<IGhastCapability> capability, IGhastCapability instance, Direction side, INBT nbt) { instance.updateCreatureAttribute(null); // This is the part where I need to put a specific type of NBT to read it. } } } GhastCapability.java package com.cryotron.capabilitytest.capability; import javax.annotation.Nonnull; import com.cryotron.capabilitytest.capability.interfaces.IGhastCapability; import net.minecraft.nbt.IntNBT; //Originally it is IntNBT. Anywhere it has /*Object NBT Type*/ used to be integer NBT types. import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; public class GhastCapability implements ICapabilitySerializable</*Object NBT Type*/> { @CapabilityInject(IGhastCapability.class) public static final Capability<IGhastCapability> GHAST_PROPERTIES = null; private LazyOptional<IGhastCapability> instance = LazyOptional.of(GHAST_PROPERTIES::getDefaultInstance); @Nonnull @Override public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) { // TODO Auto-generated method stub return GHAST_PROPERTIES.orEmpty(cap, instance); } @Override public void deserializeNBT(/*Object NBT Type*/ nbt) { GHAST_PROPERTIES.getStorage().readNBT(GHAST_PROPERTIES, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty!")), null, nbt); } //Ignore the format for a second since we're not dealing with an NBT with an integer. @Override public /*Object NBT Type*/ serializeNBT() { return (/*Object NBT Type*/) GHAST_PROPERTIES.getStorage().writeNBT(GHAST_PROPERTIES, instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional cannot be empty!")), null); } } IGhastCapability.java package com.cryotron.capabilitytest.capability.interfaces; import net.minecraft.entity.CreatureAttribute; public interface IGhastCapability { CreatureAttribute getCreatureAttribute(); void updateCreatureAttribute(CreatureAttribute GhastAttribute); } My biggest question is: Is it possible to add a capability on a non-player entity this way that doesn't involve around integer or string but with objects? I'm pretty sure I need to fully grasp this concept before adding a capability on each item in this mod that involves around Gem Socketing. That would be my next big thing... Could any of the experts shed a light on this?
-
[SOLVED][1.15.2] Updating the spawn list in the Nether Fortress...
Cryotron replied to Cryotron's topic in Modder Support
Finally nailed it. It wasn't as intuitive but I finally did it. Here is the code for those who want to add mobs in the Fortress. package com.cryotron.skyspaceproject.entities; import com.cryotron.skyspaceproject.init.EntityInit; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityClassification; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.Feature; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class SSNetherEntitySpawn { Biome.SpawnListEntry skeleMageSpawn = new Biome.SpawnListEntry(EntityInit.SKELETON_MAGE.get(), 2, 5, 5); Biome.SpawnListEntry witherMageSpawn = new Biome.SpawnListEntry(EntityInit.WITHER_MAGE.get(), 8, 5, 5); @SubscribeEvent public void registerNetherWorldSpawn(WorldEvent.PotentialSpawns event) { if(event.getType() == EntityClassification.MONSTER) { if (Feature.NETHER_BRIDGE.isPositionInsideStructure(event.getWorld(), event.getPos())) { event.getList().add(skeleMageSpawn); event.getList().add(witherMageSpawn); } if (Feature.NETHER_BRIDGE.isPositionInStructure(event.getWorld(), event.getPos()) && event.getWorld().getBlockState(event.getPos().down()).getBlock() == Blocks.NETHER_BRICKS) { event.getList().add(skeleMageSpawn); event.getList().add(witherMageSpawn); } } } } I made this new class that is exclusively used to add the mages that spawns in the Nether Fortress. You need to initialize the entities you made and register the EVENT_BUS in your main class under the FMLCommonSetupEvent. What a rush lol -
[SOLVED][1.15.2] Updating the spawn list in the Nether Fortress...
Cryotron replied to Cryotron's topic in Modder Support
Ah, thank you for pointing that point for future reference. Also I suppose I can learn more things about event handlers. I'll look into them as well. -
[SOLVED][1.15.2] Updating the spawn list in the Nether Fortress...
Cryotron replied to Cryotron's topic in Modder Support
package com.cryotron.skyspaceproject.entities; import com.cryotron.skyspaceproject.init.EntityInit; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityClassification; import net.minecraft.entity.EntitySpawnPlacementRegistry; import net.minecraft.entity.monster.MonsterEntity; import net.minecraft.entity.EntityType; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biome.SpawnListEntry; import net.minecraft.world.gen.Heightmap; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.biome.Biomes; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.registries.ForgeRegistries; public class SSEntitySpawn { public static EntityType<?> skeleton_mage = EntityInit.SKELETON_MAGE.get(); public static EntityType<?> stray_mage = EntityInit.STRAY_MAGE.get(); public static EntityType<?> wither_mage = EntityInit.WITHER_MAGE.get(); public static WorldEvent world_event = null; // <<<This line>>> public static void registerEntityWorldSpawns() { for (Biome biome : ForgeRegistries.BIOMES) { if (biome != Biomes.THE_END | biome != Biomes.NETHER) { if (biome != Biomes.SNOWY_TUNDRA | biome != Biomes.SNOWY_MOUNTAINS | biome != Biomes.ICE_SPIKES | biome != Biomes.FROZEN_RIVER | biome != Biomes.FROZEN_OCEAN | biome != Biomes.DEEP_FROZEN_OCEAN) { registerEntityWorldSpawn(skeleton_mage, 2, 1, 2, Biomes.BADLANDS,Biomes.BADLANDS_PLATEAU, Biomes.BAMBOO_JUNGLE, Biomes.BAMBOO_JUNGLE_HILLS, Biomes.BEACH, Biomes.BIRCH_FOREST,Biomes.BIRCH_FOREST_HILLS, Biomes.COLD_OCEAN, Biomes.DARK_FOREST, Biomes.DARK_FOREST_HILLS, Biomes.DEEP_COLD_OCEAN, Biomes.DEEP_LUKEWARM_OCEAN, Biomes.DEEP_OCEAN, Biomes.DEEP_WARM_OCEAN, Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.FLOWER_FOREST, Biomes.FOREST, Biomes.GIANT_SPRUCE_TAIGA, Biomes.GIANT_SPRUCE_TAIGA_HILLS, Biomes.GIANT_TREE_TAIGA, Biomes.GIANT_TREE_TAIGA_HILLS, Biomes.GRAVELLY_MOUNTAINS, Biomes.JUNGLE, Biomes.JUNGLE_EDGE, Biomes.JUNGLE_HILLS, Biomes.LUKEWARM_OCEAN, Biomes.MODIFIED_BADLANDS_PLATEAU, Biomes.MODIFIED_GRAVELLY_MOUNTAINS, Biomes.MODIFIED_JUNGLE, Biomes.MODIFIED_JUNGLE_EDGE, Biomes.MODIFIED_WOODED_BADLANDS_PLATEAU, Biomes.MOUNTAIN_EDGE, Biomes.MOUNTAINS, Biomes.MUSHROOM_FIELD_SHORE, Biomes.MUSHROOM_FIELDS, Biomes.OCEAN, Biomes.PLAINS, Biomes.SAVANNA, Biomes.SAVANNA_PLATEAU, Biomes.SHATTERED_SAVANNA, Biomes.SHATTERED_SAVANNA_PLATEAU, Biomes.SNOWY_BEACH, Biomes.SNOWY_TAIGA, Biomes.SNOWY_TAIGA_HILLS, Biomes.SNOWY_TAIGA_MOUNTAINS, Biomes.STONE_SHORE, Biomes.SUNFLOWER_PLAINS, Biomes.SWAMP, Biomes.SWAMP_HILLS, Biomes.TAIGA, Biomes.TAIGA_HILLS, Biomes.TAIGA_MOUNTAINS, Biomes.TALL_BIRCH_FOREST, Biomes.TALL_BIRCH_HILLS, Biomes.WARM_OCEAN, Biomes.WOODED_BADLANDS_PLATEAU, Biomes.WOODED_HILLS, Biomes.WOODED_MOUNTAINS ); } if (biome == Biomes.SNOWY_TUNDRA | biome == Biomes.SNOWY_MOUNTAINS | biome == Biomes.ICE_SPIKES | biome == Biomes.FROZEN_RIVER | biome == Biomes.FROZEN_OCEAN | biome == Biomes.DEEP_FROZEN_OCEAN) { registerEntityWorldSpawn(stray_mage, 2, 1, 2, Biomes.SNOWY_TUNDRA, Biomes.SNOWY_MOUNTAINS, Biomes.ICE_SPIKES, Biomes.FROZEN_RIVER, Biomes.FROZEN_OCEAN, Biomes.DEEP_FROZEN_OCEAN); } } if (biome != Biomes.THE_END | biome == Biomes.NETHER) { registerNetherSpawn(world_event); } } } public static void registerNetherSpawn(WorldEvent.PotentialSpawns event) { if(event.getType() == EntityClassification.MONSTER) { if (Feature.NETHER_BRIDGE.isPositionInsideStructure(event.getWorld(), event.getPos())) { registerEntityWorldSpawn(skeleton_mage,2,5,5); registerEntityWorldSpawn(wither_mage,8,5,5); } if (Feature.NETHER_BRIDGE.isPositionInStructure(event.getWorld(), event.getPos()) && event.getWorld().getBlockState(event.getPos().down()).getBlock() == Blocks.NETHER_BRICKS) { registerEntityWorldSpawn(skeleton_mage,2,5,5); registerEntityWorldSpawn(wither_mage,8,5,5); } } } public static void registerEntityWorldSpawn(EntityType<?> entity, int weight, int minGroupIn, int maxGroupIn, Biome... biomes) { for(Biome biome : biomes) { if(biome != null) { biome.getSpawns(entity.getClassification()).add(new SpawnListEntry(entity, weight, minGroupIn, maxGroupIn)); } } } static { EntitySpawnPlacementRegistry.register(EntityInit.SKELETON_MAGE.get(), EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::canMonsterSpawnInLight); EntitySpawnPlacementRegistry.register(EntityInit.STRAY_MAGE.get(), EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::canMonsterSpawnInLight); EntitySpawnPlacementRegistry.register(EntityInit.WITHER_MAGE.get(), EntitySpawnPlacementRegistry.PlacementType.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::canMonsterSpawnInLight); } } All three entities are successfully spawned elsewhere aside of the Nether Fortress, so I'm pretty sure this class works with the Main class of the mod. Also pardon with the mess. -
[SOLVED][1.15.2] Updating the spawn list in the Nether Fortress...
Cryotron replied to Cryotron's topic in Modder Support
Alright, so I am subscribing the event of spawning entities through a class and now what i'm stuck on is that what initializes the WorldEvent.PotentialSpawns?. I've replicated the logic found in NetherChunkGenerator#getPossibleCreatures. I'm sorry for such a seemingly basic question. It's one last step that I seem to stuck on. EDIT: I got rid of Reflections. -
[SOLVED][1.15.2] Updating the spawn list in the Nether Fortress...
Cryotron replied to Cryotron's topic in Modder Support
Does that mean I have to find a chunk generating class to modify the spawnlist? I'm also trying to figure out how reflections can apply to this.