-
Posts
3284 -
Joined
-
Last visited
-
Days Won
62
Everything posted by ChampionAsh5357
-
I recently started creating a test example for a six way block and tried to waterlog it. I then tried to extending it to all fluids but not only would it render, it would also throw an error if the fluid block being read wasn't the source. I'm not sure what to do to allow any fluid at any level to render properly and work correctly when the block contains a fluid. I know that it has something to do with Block#getFluidState however I'm not sure why. Block class: Error:
-
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
I've already tried that, but your tip gave me the solution. I had to remove the tile entity before setting the block to air and canceling since the shulker box only drops in the normal way as long as the tile entity exists. I just have to create a player capability to allow storage of blocks to reverse recipes with more than one output. Thank you for the all the help you have provided. -
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
Okay, I've managed to work around three of the four blocks using event canceling and triggering the HarvestDropsEvent in the BreakEvent. However, I still haven't managed to get the shulker box to disappear without having it drop its item. Is there any way to set a block to air within BreakEvent without having it drop its item? -
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
I was able to find a decomposition using BannerPattern and EnumDyeColor by reading the nbt. However, the same issue as before persists where HarvestDropsEvent is not triggered. The other three mentioned above do not seem to not trigger the event either. I'm not exactly sure where the method needed to use it was overwritten, but the trigger is never called to allow the event to happen at least in these four cases. -
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
Backing up to the banner, could you instead reverse the patterns with the colors and calculate the output that way? Basically, read the itemstack nbt if it is a banner and drop items corresponding to the color and the pattern used? -
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
If you looked at the above code, you can see that I have been using Block#getPickBlock since you've suggested it. The issue is with actual Minecraft programming itself it seems as the Bed (BlockBed) and Shulker Box (BlockShulkerBox) has no call to triggering the BlockEvent#HarvestDropsEvent within it. For the Piston Extension (BlockPistonMoving or BlockPistonExtension), it calls the command twice first dropping the block and then the recipe. The reason why I mentioned Block#dropBlockAsItemWithChance is because that is the only place the trigger fires when a block is broken in this way. The other trigger provides no use. The above three classes do not have access to the trigger or accesses it abnormally. -
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
After further research, it seems as there 4 3 main problems excluding the banner nbt one. 1. The piston if mined when extended at the head will drop the block and the uncrafted recipe. 2. The bed drops the block instead of the recipe. 3. The shulker box drops the block with the items still inside instead of the recipe. 4. There seems to be some sort of item duplication that increases over each block mined with recipes having more than one of the same block. The first three seem to originate from Block#dropBlockAsItemWithChance while I can't seem to find the cause of the fourth problem. -
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
The issue is here that getRecipeOutput() will work for and Shaped or Shapeless recipe defined in the json files since they all have getRecipeOutput() as the main output. Anything pertaining to banners would not work with the current setup due to patterns. That would require complete markings of all banner inputs with IRecipe which I don't believe is possible without freezing or lagging out the game. If we were to ignore those custom IRecipes, that would just make it impossible to uncraft anything customly defined. However, this still leaves the question of multiblock structures being mined. The bed, for example, should output its contents but instead returns the block itself. -
Entities are registered through the EntityEntry registry event. This can be accessed using EntityEntryBuilder#create and finished with EntityEntryBuilder#build to get the EntityEntry. There are a number of optional and required parameters such as EntityEntryBuilder#spawn or EntityEntryBuilder#id respectively that can be chained before ending with EntityEntryBuilder#build. Spawners are set using MobSpawnerBaseLogic#setEntityId like the one used in your example. However, you need the resourcelocation such as "skeleton" or "modid:entityid" if you are not using a Minecraft entity. You can set the id of your entity by chaining EntityEntryBuilder#id to the created instance.
-
[1.12.2] Reversing a Crafting Recipe on Mined
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
That would make sense, I'm assuming that the RayTraceResult can just be gathered by the position of the block and a insignificant EnumFacing. Can that be obtained by going through getIngredients()? Otherwise, I do not know how to get an instance of InventoryCrafting for the IRecipe. Switching to ItemStack#areItemStacksEqual then. The line referred to is "ItemStack ing = ingredient.getMatchingStacks()[(new Random()).nextInt(ingredient.getMatchingStacks().length)];" I misread the error. Apologies. Fixed the issue. Here is the rearranged code (getRecipeOutput not changed yet as for lack of knowledge of how to): -
I've recently taken the task of trying to create an uncrafting enchantment where a block is mined and then disassembles itself according to its crafting recipe. I've created the code that allows this to work, however, there are a few problems I can't seem to figure out. First, the items outputted don't always come out in the correct amounts. For example, mining a diamond block outputs three stacks instead of just nine diamonds. This occurs semi-randomly based on the number of items. Second, some blocks when broken throw an ArrayOutOfBoundsException such as the chest when breaking. I'm not sure how this is possible as the index pulled out of the getMatchingStacks is only as large as the size of the array. If you could provide a solution to either problem, it would be greatly appreciated. Here's the code:
-
Currently, I am working on creating custom particles for 1.13.2. However, the public static final value of the particle type seems to throw null each time rather than getting the value. When I try adding an ObjectHolder annotation, the game says it cannot get the registry (which in my opinion is very confusing since Particles.class has a ObjectHolder annotation). If anyone could help, it would be much appreciated. Particle: Extension of BasicParticleType: ParticleType: ParticleManager: Particles: Main (Common and Client setup):
-
My understanding of a registry is a database used to hold information about a specific object. That would make sense why recipes were removed in 1.13.2 and tile entities were added as a registry. It does make adding an object to the game much easier. I also understand that in the case of capabilities, since it isn't a implementation of registry, it is not one. However, the CriteriaTriggers.class is seems to be the exact same in implementation of the TileEntityType.class missing the ForgeRegistryEntry. Could you not technically create a registry by using a similar implementation to that of the tile entity?
-
Hello. I understand that registry events are the recommended way to register things in Minecraft Forge nowadays. However, if that is the case, shouldn't all registries be converted to RegistryEvents? Why are only blocks, items, potions, biomes, sounds, potions, enchantments, recipes, villager professions, and entities supported at the moment? Capabilities and KeyBindings have been around for a few versions yet they do not have their own registry event. You could even include StatBase and Criterions in this list as well. To me, it seems odd not to have a major function of Minecraft still using an outdated system compared to villager professions.
-
Hello. I've created a sort of slot/lottery machine in which I am working on getting the animations working. However, the only animation that seems to work is the lever. The other ones for the spinners that line up and the button that you push does not seem to do the animation. Any help is appreciated. Tile Entity Renderer (The few ones commented out were for testing purposes) Model
-
I recently started using nbt data to hold item variants. However, when using ModelLoader.setCustomMeshDefinition and ModelBakery.registerItemVariants, the textures do not render whatsoever. The text that says "modid:location#inventory" does not appear on the not rendered item either. Any help is much appreciated. Render register class: package com.championash5357.tabletop.event; import com.championash5357.tabletop.client.Namespace; import com.championash5357.tabletop.init.Items; import com.championash5357.tabletop.init.Items.ItemRegistration; import com.championash5357.tabletop.registry.CardType; import com.championash5357.tabletop.util.CardUtil; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelBakeEvent; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.GameRegistry; @Mod.EventBusSubscriber(modid = Namespace.ID) public class Events { @SubscribeEvent public static void registerModels(final ModelRegistryEvent event) { final NonNullList<Item> items = NonNullList.<Item>create(); items.addAll(ItemRegistration.ITEMS); for(Item item : items) ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); ModelLoader.setCustomMeshDefinition(Items.CARD, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { String name = CardUtil.getRegistryNameFromNBT(stack); return new ModelResourceLocation(stack.getItem().getRegistryName() + "_" + name.split("\\.")[1], "inventory"); } }); } @SubscribeEvent public static void registerVariants(final ModelBakeEvent event) { for(CardType card : GameRegistry.findRegistry(CardType.class).getValuesCollection()) ModelBakery.registerItemVariants(Items.CARD, new ResourceLocation(Namespace.ID, "card_" + card.getRegistryName().getResourcePath().split("\\.")[1])); } }
-
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
The player was returning null because I called it in the beginning of the message. The player might not have been loaded yet so it couldn't set it. I moved the EntityPlayerSP inside the addScheduledTask and now everything works. Thank you for taking the time to help me do this. -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
It's not a crash, the packet just throws an exception; the game still runs because the only thing it does it try and load the slot. If it fails then it's just air until I load it via opening the custom inventory. The line it is referring to, since I didn't post the entire packet class, is the line where I set the ItemStack in the slot. -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
I realized that after posting it. So I tried with the EntityJoinWorldEvent and I check if the entity joined is the player. I got the server information and tried to sync it with the client. However, it only works one time on login and then the packet throws a NullPointerException somehow when I add the scheduled task. I also tried with PlayerEvent.PlayerLoggedInEvent with the same issue. Packet Event Inventory Sync Method -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
Okay, I created everything so that it works properly. The only problem I have left is that when I first load up the world, the data in the slot does not get loaded until I open up the tab with it. Since I created a KeyBinding to change the item with what the player has in hand, the data from the slot has to be loaded by the time the entity joins the world. -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
I tried using getSlotTexture to create a back image for the slot similar to the offhand slot and it comes up with a null texture even though the texture is defined at the place I set it to. Also, when I try to give the player an item, it only detects that once the extended inventory has been opened. Extended Inventory Container Gui Extended Inventory Updated Player Inventory (I know I'm reusing the recipe book texture on the button but its only until I can manage to get it working) Extended Inventory Slot -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
So, just to make sure I understand everything correctly. Use an instance of ItemStackHandler to attach to the player to hold the inventory information. Then when creating the container and gui use that same instance to store the custom slots added to the player. Then to call that instance from the gui handler I would just use player.getCapability(<? extends ItemStackHandler>, null); for calling it? -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
Ok. I think I'm going to rewrite everything so that it takes out the IInventory use and just add it on as a tab instead of just putting it off. That way it should get everything working properly and stick with the conventions. Do I need to create a class extended from ItemStackHandler then, or can I just call IItemHandler? I think I only need to store the slot I'm adding if the player inventory does it manually. I was reading the documentation of the deprecated IEntityExtenedProperties to see if that could potentially work with what I had before. -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
I did read the forge documentation. Understanding it, maybe. From my understanding, I do not see why I can't create the inventory with an implementation of ICapabilitySerializable (which is what I did originally) and then just attach the capability via that to the player. As far as I know through NBT checking, the player inventory does save on the server side and I can see it. The problem I actually have is with loading it to the client which is actually what I didn't do when I made this thread. However, I do not really know what event or tick handler I should notify to sync the data already stored in the NBT to the client. I tried a couple of ways using EntityJoinWorldEvent and PlayerEvent.StartTracking, but I could not manage to get them to work. So that would actually be the actual issue I'm having as of this moment. I will repost my inventory and network handler along with the event class. If you have any recommendation on how I would do that, I would be interested to hear. Custom Inventory Packet Handler Event Class Apologies for the late reply. -
[1.12.2] Persisting Player Capability Inventory Data
ChampionAsh5357 replied to ChampionAsh5357's topic in Modder Support
Updated writeToNBT and readToNBT in the InventoryPlayer extended class: Event Registering: Crash Report: The rest of the code remained exactly the same. The mod crashes when the player saves its NBT data at any time.