-
Posts
200 -
Joined
-
Last visited
Everything posted by urbanxx001
-
[SOLVED] How do I make my custom crossbow shoot a custom arrow?
urbanxx001 replied to EveryBlu's topic in Modder Support
Yeah I modified my reply while you were likely replying 🙃 See above again. Instanceof will be better than defaultinstance check. -
[SOLVED] How do I make my custom crossbow shoot a custom arrow?
urbanxx001 replied to EveryBlu's topic in Modder Support
To have your custom crossbow only use your custom arrow, then you should override (in 1.20.1), one or both of the following methods in your crossbow class: public Predicate<ItemStack> getSupportedHeldProjectiles() { return ARROW_OR_FIREWORK; } public Predicate<ItemStack> getAllSupportedProjectiles() { return ARROW_ONLY; } And modify the return predicate to check for your arrow, something like: Predicate<ItemStack> CUSTOM_ARROW = (stack) -> {return stack.getItem() instanceof (custom arrow class)}; And if a special item is required to launch an arrow, then in the following method you'll just need to check if the player has the item in their inventory: public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pHand) { if (pPlayer.getInventory().items.contains(your custom item)) { (fire arrow) } } -
Hi gbln00, welcome to the forums! Some of the best resources for modding are the forge documentation and vanilla classes. From the documentation, I would start at menus and then look at screens below that: https://docs.minecraftforge.net/en/1.19.x/gui/menus/ Also: https://docs.minecraftforge.net/en/1.19.x/misc/keymappings/ Since you're using keymappings, it sounds like the custom GUI you want is related to some type of settings menu. In that case, I would start by looking at a vanilla class such as OptionsScreen.class, found (in 1.20.1): net.minecraft.client.gui.screens The easiest way to navigate here is to type OptionsScreen somewhere in your mod, import it, and then middle click it. Hope that helps.
-
After a long hiatus in modding I'm updating a mod to 1.20.1. After downloading the appropriate Forge MDK and upgrading to Java 17 (through Adoptium JDK), I'm attempting to download sources but encounter this error: I've double checked that my system variables are correct and that the Intellij gradle JVM is pointing to the new Java version. This is likely a simple fix that's eluding me. Below are my build.gradle and settings.gradle. Any help is appreciated. build.gradle settings.gradle
-
[1.18.2] Assert Starting Frame of Animated Block Texture [Solved]
urbanxx001 replied to urbanxx001's topic in Modder Support
Thanks -
I have 2 blockstates for a block. One is for a static texture and the other is animated. On interaction, the blockstate changes to the animated one. But as far as I’m aware, you can’t define when the starting frame should actually start, as it loops indefinitely at all times. Is my approach to this impossible? Thanks.
-
Meant to follow up on this, but I discovered that brewing recipes can also be registered to BrewingRecipeRegistry vs trying to swap out textures for potions. I was only familiar with the reflection method, but it's neat that there's two ways. Doesn't address the original problem, but code below for future visitors: Registry: private static void commonSetup(FMLCommonSetupEvent event) { event.enqueueWork(() -> { ModEffects.addBrews1(); }); ModEffects.addBrews2(); } Methods: public class ModEffects extends Effects { public static final DeferredRegister<Effect> EFFECTS = DeferredRegister.create(ForgeRegistries.POTIONS, Main.MOD_ID); public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTION_TYPES, Main.MOD_ID); public static RegistryObject<Effect> MY_EFFECT = EFFECTS.register("my_effect", MyEffect::new); public static final RegistryObject<Potion> MY_POTION = POTIONS.register("my_potion", () -> new Potion(new EffectInstance(MY_EFFECT.get(), 1))); // Method 1 public static void addBrews1() { BrewingRecipeRegistry.addRecipe(Ingredient.of(ModItems.INPUT_ITEM), Ingredient.of(ModItems.INGREDIENT_ITEM), new ItemStack(ModItems.OUTPUT_ITEM)); } // Method 2 (vanilla-style, adds splash, lingering, and arrow variants) private static Method brewing_mixes; private static void addMix(Potion start, Item ingredient, Potion result) { if (brewing_mixes == null) { brewing_mixes = ObfuscationReflectionHelper.findMethod(PotionBrewing.class, "addMix", Potion.class, Item.class, Potion.class); brewing_mixes.setAccessible(true); } try { brewing_mixes.invoke(null, start, ingredient, result); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); } } public static void addBrews2() { addMix(Potions.AWKWARD, ModItems.INGREDIENT_ITEM, MY_POTION.get()); } }
-
Understood, the return for newList.resolve() should be oldModel.getOverrides().resolve(params). It didn't dawn on me that 'proceed as previously' in step 4 referred to the oldModel here as well instead of the method's super, but it makes sense since you specified it should in step 3. In newList.getOverrides, oldImmutableList already derives from oldModel.getOverrides, but I'll inline the variable if it makes a difference (oldModel.getOverrides().getOverrides())
-
-
Welcome to the forum! In ServerPlayerEntity there should be a method to return the stats. In 1.16.5 it's called getStats() and returns the ServerStatisticsManager, but it may be called something different in 1.18.2
-
Yeah I was confused and labeled both as newList. I'm returning: ImmutableList<ItemOverride> oldList = oldModel.getOverrides().getOverrides(); in newList1.getOverride now. I'm not sure what using oldList in newList1.resolve would do though, since the checks for the itemstack already exist, and new model is returned here. Unless it's for another form of check (what vanilla does). I also can't debug resolve as console outputs there don't work (or something's preventing it). I appreciate your help. I've read the forge docs and tried finding similar examples, but this event hack is something else.
-
i wonna to make fluid tank but i dont know how forge 1.18.2
urbanxx001 replied to kamileq_14's topic in Modder Support
I've never created a fluid tank, but doing some research it seems like you'll want to attach an IFluidHandler capability to your block or item. You can find documentation for capabilities here -
Thanks. Sorry for the stupid mistake. The event is firing, but I'm not sure what to do with getOverrides(), unlike resolve() that has constructor parameters to check with. Trying to return or use newList0.getOverrides() here is null. The resource location should be correct.
-
Following the method outlined by diesieben07 here, I'm attempting to override a texture for a custom potion. I (think?) I have the full ModelBakeEvent implemented, but I'm not sure if it's running, as I get no response similar to here. The new model is being added in the ModelRegistryEvent though. Below are my event classes and item model. Thanks!
-
The code in your previous PlayerTeamCapability was fine, but just needs the snippet I mention. You have some of it, but your GetTeam and SetTeam aren't affecting Team. You also shouldn't need: public PlayerTeamImpl(){ this("None"); } And you can implement both interfaces with: public class PlayerTeamCapability implements PlayerTeam, ICapabilitySerializable<INBT> Then as far as I can tell, your code would be the same as what I have when I used capabilities, which was able to register and work in game.
-
It may be because your PlayerTeam interface doesn't need to extend INBTSerializable<CompoundNBT>
-
Not sure if you already got it from the tutorial, but In your PlayerTeamCapability provider class, you should add: public String team; public PlayerTeamCapability() {this.team = ""} @Override public void SetTeam(String string) { this.team = string; } @Override public String GetTeam() { return this.team; } where we're using the methods from your interface PlayerTeam. But for this PlayerTeamCapability needs to implement PlayerTeam right after ICapabilitySerializable<INBT>.
-
First I'd like to thank the forum for the generous 1.16.x grace period. I'm curious how (or if) I could register a RenderType without using Mixin, since a Forge registry for it doesn't exist. The purpose of this is for colorized glint effects, but if there's an easier approach I'm open to it. Thanks!
-
1.16.X Loot Modifiers Only Run in Dev Environment [Solved]
urbanxx001 replied to urbanxx001's topic in Modder Support
For some reason I was under the impression it would only work there, but you're right it works under the mod space. I did some more testing and it seems it's a problem with the modifier itself after changing something last minute. I'll mark the thread as finished for now. Thanks for the advice though. Edit: I'm an idiot the modifier works I completely forgot I added a condition where certain items were required to make the tools function. I'm losing it lol -
As the title says, everything runs perfectly in dev, but after building the mod and running it, my global loot modifiers don't work. No errors show in the log so I'm not sure what the issue is. I'm certain it's not my custom loot conditions (registered under the minecraft namespace), since I use vanilla conditions as well and those don't work. My global_loot_modifier is located in data/forge/loot_modifiers/(file): And the modifiers are in data/mod_id/loot_modifiers/(file): Any help is appreciated.
-
Incompatible LootConditions? (1.16.X) [Solved]
urbanxx001 replied to urbanxx001's topic in Modder Support
Ah ok that makes sense, I should've looked closer at the list of loot conditions. Thanks! -
I have a loot modifier that updates all loot tables to drop specific items when using certain tools. Or at least I thought it did. It works on blocks, but not for entities. However I've tested it with the condition "killed_by_player" and that works for entities, the problem is testing these conditions together fails: So then I tried creating a custom ILootCondition, which registered fine but still failed: If anyone has advice I'd be very appreciative.
-
addScheduledTask in Newer Versions (1.16.x/ 1.17.x) [Solved]
urbanxx001 replied to urbanxx001's topic in Modder Support
Got it will try both of them. Thanks diesieben07 -
As the title says, I was wondering what the updated method/process for addScheduledTask is. I need this for an event similar to: @SubscribeEvent public void onEntityJoin(final EntityJoinWorldEvent event) { Minecraft.getInstance() //(not recognized)--> .addScheduledTask(new Runnable() { @Override public void run() { } }); } For the FML setup event I've used: event.enqueueWork(() -> { } But I'm not sure what's required for a simple event. The context for this is collecting what language the client is using and then sending a packet to sync with the server. But the packet must be delayed or it fails in this event. Edit: Actually I can do the same thing when the player loads a container needing it. So the event's probably unnecessary