Jump to content

JimiIT92

Members
  • Posts

    867
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JimiIT92

  1. Yeah, but the source method is private
  2. In my mod I add several new creative tabs, and I want them to be displayed in a specific order. Specifically, I register these tabs inside the CreativeModeTabEvent.Register event @SubscribeEvent public static void register(CreativeModeTabEvent.Register event) { BUILDING_BLOCKS = registerTab(event, "building_blocks", () -> new ItemStack(BLBlocks.RUBY_BLOCK.get())); COLORED_BLOCKS = registerTab(event, "colored_blocks", () -> new ItemStack(BLBlocks.YELLOW_CONCRETE_STAIRS.get())); NATURAL = registerTab(event, "natural", () -> new ItemStack(BLBlocks.HOLLOW_BIRCH_LOG.get())); FUNCTIONAL = registerTab(event, "functional", () -> new ItemStack(Items.PAINTING)); REDSTONE = registerTab(event, "redstone", () -> new ItemStack(BLBlocks.COPPER_BUTTON.get())); TOOLS = registerTab(event, "tools", () -> new ItemStack(BLItems.EMERALD_PICKAXE.get())); COMBAT = registerTab(event, "combat", () -> new ItemStack(BLItems.KATANA.get())); FOOD_AND_DRINK = registerTab(event, "food_and_drink", () -> new ItemStack(BLItems.SASHIMI.get())); INGREDIENTS = registerTab(event, "ingredients", () -> new ItemStack(BLItems.RUBY.get())); SPAWN_EGGS = registerTab(event, "spawn_eggs", () -> new ItemStack(BLItems.COPPER_GOLEM_SPAWN_EGG.get())); } private static CreativeModeTab registerTab(CreativeModeTabEvent.Register event, String name, Supplier<ItemStack> iconSupplier) { return event.registerCreativeModeTab(new ResourceLocation(BlazersMod.MOD_ID, name), builder -> builder .icon(iconSupplier) .title(Component.translatable("itemGroup." + BlazersMod.MOD_ID + "." + name)) .build()); } and I thought they were displayed in this order, so the first mod tab would be building blocks, the next would be colored blocks etc... However when I load the game they are misplaced. Specifically the first tab I see is the mod's spawn eggs tab, which is the last one registered, than the mod's ingredients tab and then the tools tabs, so isn't in the reverse registration order. If I intercept the CreativeModeTabEvent.BuildContents event to see when those tabs are populated I get the same wrong ordering, so it makes sense that in game they are ordered like this. Do I need to specify something to make them ordered in the same order as they are registered?
  3. I added some paintings to my mod and I want them to be displayed only in my custom creative tab. However the vanilla game puts them also in the Functional Blocks tab, because when that tab is created all painting variants are added. Is there a way to prevent this? So far I tried intercepting the CreativeModeTabEvent.BuildContents event and remove those item stacks from both dispalyItems and SearchTabDisplayItems, but they still appears in the vanilla tab tab.getDisplayItems().removeIf(BLTabs::isEblPainting); tab.getSearchTabDisplayItems().removeIf(BLTabs::isEblPainting); private static boolean isEblPainting(ItemStack stack) { if(stack.is(Items.PAINTING) && stack.getTagElement("EntityTag") != null) { Optional<Holder<PaintingVariant>> paintingVariant = ForgeRegistries.PAINTING_VARIANTS.getHolder(ResourceLocation.tryParse(stack.getTagElement("EntityTag").getString("variant"))); return paintingVariant.map(paintingVariantHolder -> paintingVariantHolder.containsTag(BLTags.Paintings.EBL_PAINTINGS)).orElse(false); } return false; } I'm sure the vent gets called because in the same event listener I add the painting variants to my own creative tab. What I've noticed also is that when I search the painting and hover the item, only the vanilla tab is reported, despite the item being correctly placed into the mod tab as well What am I missing here? I'm really new to this new tabs system
  4. I did it this way: I have a class with all the Damage Types I need to declare and then in the bootstrap method I register them public static final ResourceKey<DamageType> SPEAR = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("mod_id", "spear")); public static void bootstrap(BootstapContext<DamageType> context) { context.register(SPEAR, new DamageType("spear", 0.1F)); } Then, where I need to use that damage type, I can call it like this DamageSource damagesource = new DamageSource(this.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(MyDamageTypes.SPEAR), this, entity1 == null ? this : entity1); In this case I'm providing 2 more arguments to the constructor since I need them, but these depends on the type of damage. What I'm trying to mimic here is something similar to the trident damage, so that's why I need those parameters. Anyawy the key here is how you retrieve the DamageType this.level.registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(MyDamageTypes.SPEAR) Essentially we get the RegistryAccess instance from a Level (world) instance (in this case the Level instance of the entity I'm calling this in). From here we get the Damage Type registry and from here we get the DamageType we want providing a Resouce Key (in this case we provide oure resource key). This method is similar to how vanilla/forge implements it, you can see the vanilla game damage sources inside the DamageSources class After all this you need the JSON files inside your mod's assets data folder. Under <your_mod_id> you need to add a new folder called "damage_type". Inside you need to add a json file named like the damage type you're adding. In the example above I'm adding a "spear" damage type, so I create a "spear.json" file in which I specify the damage type properties { "exhaustion": 0.1, "message_id": "spear", "scaling": "when_caused_by_living_non_player" } This may vary based on the damage type you're trying to add/mimic and of course on your needs. You may also want to add your damage type to the minecraft tags, if there is one that fits your new damage type, under minecraft/tags/damage_type. In my case my new damage is a projectile type one, so I added the "is_projectile.json" file { "replace": false, "values": [ "mod_id:spear" ] }
  5. Thank you, for some reasone I didn't tried that and I thought it wasn't necessary since you override it ๐Ÿ˜… Added outside the base object, now it works
  6. I'm porting my mod to 1.19.2 and I noticed that Items with the forge:separate_transforms loader in the Item Model are rendered too dark inside the Inventory. This is how one of them looks right now And this is how it looks inside an Item Frame (which is correct) This is the Item model file { "loader": "forge:separate_transforms", "base": { "parent": "builtin/entity", "gui_light": "front", "textures": { "particle": "blazersmod:item/spear" }, "display": { "thirdperson_righthand": { "rotation": [ 0, 60, 0 ], "translation": [ 11, 17, -2 ], "scale": [ 1, 1, 1 ] }, "thirdperson_lefthand": { "rotation": [ 0, 60, 0 ], "translation": [ 3, 17, 12 ], "scale": [ 1, 1, 1 ] }, "firstperson_righthand": { "rotation": [ 0, -90, 25 ], "translation": [ -3, 17, 1], "scale": [ 1, 1, 1 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -25 ], "translation": [ 13, 17, 1], "scale": [ 1, 1, 1 ] } } }, "perspectives": { "gui": { "parent": "blazersmod:item/spear_inventory" }, "fixed": { "parent": "blazersmod:item/spear_inventory" }, "ground": { "parent": "blazersmod:item/spear_inventory" } }, "overrides": [ { "predicate": { "throwing": 1 }, "model": "blazersmod:item/spear_throwing" } ] } And this is the Inventory model file { "parent": "item/generated", "gui_light": "front", "textures": { "layer0": "blazersmod:item/spear" } } As you can see I already tried to add the gui_light: front property to the Inventory model, but it looks like is ignored. What should I add to light those items correctly?
  7. You don't need mixins for this. If you want to follow the "entity path" you can either summon an invisible, unkillable and uncollidable shulker with the glowing effect where the arrow lands or either create your own entity that by default has no rendering (it's just a transparent cube) or can camouflage to a blockstate you pass in when summoning (and then render the block as the entity texture)
  8. I suspected that ๐Ÿ˜… And what about the "vanilla events", the ones that are used for Sculk Sensors? Will we eventually switch to use that instead of Forge ones?
  9. So I was recently talking with another user in the "Modder Support" category, which asked if there was a way to catch when a block ticks. So that got me thinking: why there isn't such event? What are the reasons behind the choice to not fire an event when a block ticks? And in general what are the reasons that lead to fire/not firing an event?
  10. I ended up using an AT to make the FallingBlockEntity constructor with the pos public, as this is what I need in the dripstone code and so I can create an extended entity that overrides the fall method and set the dropItem property to false
  11. You can get the collision shape of a block using the BlockState#getCollisionShape method. You can then call the isEmpty method on the result, and if is true it means that the block you get the collision shape from has no collision
  12. Yes, this is exactly what I want to change. Not the fact that the block is placed (although it never does), but rather the "drops". I was trying to avoid using mixins as much as I can, and was rather curious about if there was a "proper" event to listen to change this behaviour
  13. A Feature is generally used (or at least in 99% of the cases is what I've used them for) for something that can be "placed" naturally inside the world (like ores, flowers, trees, structures....). An Event is something that Forge fires when something particular occurs (like an entity being spawned, a block being placed, a message bein sent...). So in this case what you want to use is an Event that listens for a blocks ticking and then, if some random criteria you decide are met, you can turn it into your own custom block. Unfortunately, as warjort said... So unless it comes out you need to find a "manual" solution to achieve what you want
  14. I made a custom Pointed Dripstone that, when the block above is broken, it falls and on landing it spawns some dripstone drops (like vanilla dripstone does). However what if I don't want those drops but instead I just want the FallingBlockEntity that is spawned to just be destroyed? I tried this in the onFall and onBrokenAfterFall methods fallingBlockEntity.dropItem = false; but that doesn't seem to do anything. I also tried to listen for the LivingDropsEvent but since the dropped dripstone aren't technically drops, but rather ItemEntitys added to the world, that event never gets called. I even tried to listen to the EntityJoinWorldEvent and indeed I can cancel it and no dripstone will be "dropped". However there's no way that I've found to actually tell if the ItemEntity has been "spawned" by the Falling Entity or not. I can only check if it has been tossed as a drop by an entity (checking the entity owner), but I guess that's not ideal. So how can I stop the falling entity to "drop" items when it lands?
  15. Thank you For reference if anyone has the same issue, this is what the JSON file now looks like { "loader": "forge:separate-perspective", "base": { "parent": "blazersmod:item/spear_in_hand" }, "perspectives": { "gui": { "parent": "blazersmod:item/spear_inventory" }, "fixed": { "parent": "blazersmod:item/spear_inventory" }, "ground": { "parent": "blazersmod:item/spear_inventory" } } } You don't need to specify the whole model inside, you can just reference an existing JSON file as "parent" for the given perspective (for instance, here I've set the "in_hand" model as my base model and the "inventory" model for when the Item is in Inventory, dropped on the ground or inside an Item Frame
  16. I have an Item that is also associated with an entity, and so the entity model is rendered in inventory. However how can I make so in Inventory a plain texture is rendered? This is what I tried so far: the JSON file for the Item is the following { "parent": "minecraft:builtin/entity", "gui_light": "front", "textures": { "particle": "blazersmod:item/spear" }, "display": { "thirdperson_righthand": { "rotation": [ 0, 60, 0 ], "translation": [ 11, 17, -2 ], "scale": [ 1, 1, 1 ] }, "thirdperson_lefthand": { "rotation": [ 0, 60, 0 ], "translation": [ 3, 17, 12 ], "scale": [ 1, 1, 1 ] }, "firstperson_righthand": { "rotation": [ 0, -90, 25 ], "translation": [ -3, 17, 1], "scale": [ 1, 1, 1 ] }, "firstperson_lefthand": { "rotation": [ 0, 90, -25 ], "translation": [ 13, 17, 1], "scale": [ 1, 1, 1 ] }, "fixed": { "rotation": [ 0, 180, 0 ], "translation": [ -2, 4, -5], "scale":[ 0.5, 0.5, 0.5] }, "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 4, 4, 2], "scale":[ 0.25, 0.25, 0.25] }, "gui": { "rotation": [ 15, -25, -5 ], "translation": [ 2, 3, 0 ], "scale": [ 0.65, 0.65, 0.65 ] } }, "overrides": [ { "predicate": { "throwing": 1 }, "model": "blazersmod:item/spear_throwing" } ] } And in the Item class I override the initializeClient method to return my custom ItemRenderer instance @Override public void initializeClient(Consumer<IItemRenderProperties> consumer) { consumer.accept(new IItemRenderProperties() { @Override public BlockEntityWithoutLevelRenderer getItemStackRenderer() { return BlazersMod.getItemsRenderer(); } }); } for which, in the renderByItem method, I do this @Override public void renderByItem(ItemStack stack, ItemTransforms.@NotNull TransformType transformType, @NotNull PoseStack pose, @NotNull MultiBufferSource buffer, int packedLight, int packedOverlay) { if(stack.getItem() instanceof SpearItem) { pose.pushPose(); pose.scale(1.0F, -1.0F, -1.0F); EntityModel<ThrownSpear> model = this.spearModel; ResourceLocation layerLocation = ThrownSpearRenderer.SPEAR_LOCATION; VertexConsumer vertexConsumer = ItemRenderer.getFoilBufferDirect(buffer, model.renderType(layerLocation), false, stack.hasFoil()); model.renderToBuffer(pose, vertexConsumer, packedLight, packedOverlay, 1.0F, 1.0F, 1.0F, 1.0F); pose.popPose(); } } What should I specify to render not the model but a plain texture in Inventory? Or where can I look at? I tried looking at the Trident but can't find anything related
  17. I think a good starting point, as you already mentioned it, is to look at Zombie entity class and see what happens when the Zombie starts breaking a door. Specifically you can look at the BreakDoorGoal class that is used by the Zombie. Inside it, in the tick method, you will find this line this.mob.level.destroyBlockProgress(this.mob.getId(), this.doorPos, i); Essentially the function destroyBlockProgress is called by the zombie on its world (level) instance. I'm not sure if this is the actual method that shows the breaking overlay and also what values the last parameter (progress) should have, but by the name is definitively something I would try and see what it does
  18. Ok, so I've created the Recipe Category, but in the log I have this Unknown recipe category: blazersmod:fletching/blazersmod:carbon_bow carbon bow being an Item that can be crafted using the custom recipe type. I've created it like this RecipeBookCategories.create(BlazersMod.MOD_ID + ":fletching", new ItemStack(BLItems.CARBON_BOW.get())); and the JSON file for the recipe is the following { "type": "blazersmod:fletching", "addition": { "item": "blazersmod:carbon" }, "base": { "item": "minecraft:bow" }, "result": { "item": "blazersmod:carbon_bow" } } So I don't understand why is actually trying to recognize that category instead of the "main" fletching category
  19. Got it, during which event should I call the create method?
  20. So I made a custom recipe type to add functionalities to the Fletching Table. Everything works, but I want to show the toast "Recipe unlocked" when the Player either meets the criteria (like for any other recipe) or craft the item at the fletching table. The idea is that in the upper-right corner it should pop-up a notification similar to the one for smithing table, but with the fletching table icon and the craft result item icon instead. I tried to use the RecipeBookCategories#create method, since it looks like every recipe category is hardcoded into that enum, however that method has an hardcoded IllegalStateException. So how can I add my own custom crafting category into the game?
  21. If he's using a custom block, yes, absolutely no need for mixins. But since he didn't mention it I assume he's just using the Vanilla Smithing Table, in which specify the NBT Tags in the recipe JSON is not sufficient (unless there's a way to bind custom recipe serializer to Vanilla Blocks, which I'm not aware of)
  22. I was also thinking: if you are NOT using a custom block, but rather you want to change the output from the vanilla smithing table, you could use a mixin. The smithing recipe JSON file actually can read NBT tags from the output, however they are straight up ignored in the UpgradeRecipe class, specifically the assemble method public ItemStack assemble(Container pInv) { ItemStack itemstack = this.result.copy(); CompoundTag compoundtag = pInv.getItem(0).getTag(); if (compoundtag != null) { itemstack.setTag(compoundtag.copy()); } return itemstack; } The Vanilla class essentially takes whatever tags the first Item has (the "base" ingredient), if any, and copy them to the output Item, ignoring whatever tags that Item could have. By using a mixin for this method you can change how it work and make so the result Item tags are not ignored, but rather merged with the base ingredient tags. You can see how to configure the project for using mixins here: https://github.com/SpongePowered/Mixin/wiki/Mixins-on-Minecraft-Forge. You can also check this repository that contains an example of how to actually use it
  23. In 1.18 there was the Item#isFoil method. I think it is the same in 1.19, however you can always look at the NetherStar Item class or how the Item is registered to ser how this is achieved in Vanilla
×
×
  • Create New...

Important Information

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