Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

urbanxx001

Members
  • Posts

    181
  • Joined

  • Last visited

Everything posted by urbanxx001

  1. I'd have to disagree a little. That's like saying go read a textbook without attending class. The point of tutorials is to teach it in a way that's more streamlined. But if tutorials don't exist for something, then yest it's good to look at the source or another mod. In the link below I go over a custom potion effect. If you have questions after that, ask them here though, not in that post. Invulnerability Effect help
  2. Ohh I gotcha, sorry. In that case, register the effect like a potion in my first reply, and then access it in the food properties like: public static final Food ITEM_NAME = new Food.Builder().hunger(1).saturation(0.8f).effect(new EffectInstance(ModEffects.EFFECT_NAME, 1200, 3), 1.0F).build(); Where ModEffects is the class you registered the effect in. Edit: fixed the line from being cut-off.
  3. It should give you them all at the same time. I tested it myself and it works. Have you done anything else related to effects, like a custom item class, that's affecting it?
  4. When you register it as a potion without a brewing recipe, it's technically just an effect, because there's no way to access it in-game.So normally when you want to register an effect on it's own, you do it as a potion. In that case, we can register items with effects attached. To do so, we add the effects as part of the item's food properties. First the item: public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Reference.MOD_ID); public static final RegistryObject<Item> ITEM_NAME = ITEMS.register("item_name", () -> new Item(new Item.Properties().food(ModFood.ITEM_NAME).group(ItemGroup.FOOD))); And now we add the food properties in a separate class, ModFood: public static final Food ITEM_NAME = new Food.Builder().hunger(1).saturation(2.0f).effect(new EffectInstance(Effects.RESISTANCE, 1200, 3), 1.0F).effect(new EffectInstance(Effects.REGENERATION, 300, 2), 1.0F).effect(new EffectInstance(Effects.FIRE_RESISTANCE, 300, 1), 1.0F).build(); When modifying the effects, (we'll look at resistance as an example), the first value is the duration, the second is the amplifier (Resistance I, Resistance II, etc.), and the last is the probability it will occur upon eating (a value between 0 and 1).
  5. Ah ok I'll look into the stack, thank you so much!
  6. That makes sense. I asked about 2 handlers at the bottom of the first post lol. Wasn't sure how to use one with the other though.
  7. I implemented it that way by referring to another mod that did it like that.
  8. If mouse event is removed, the FOV change does work in-game, if I set the scaling value scroll to a static value like 4. Was just trying to extend this behavior.
  9. If we take a look at a class like AbstractSkeletonEntity, this snippet determines if they should burn: public void livingTick() { boolean flag = this.isInDaylight(); if (flag) { ItemStack itemstack = this.getItemStackFromSlot(EquipmentSlotType.HEAD); if (!itemstack.isEmpty()) { if (itemstack.isDamageable()) { itemstack.setDamage(itemstack.getDamage() + this.rand.nextInt(2)); if (itemstack.getDamage() >= itemstack.getMaxDamage()) { this.sendBreakAnimation(EquipmentSlotType.HEAD); this.setItemStackToSlot(EquipmentSlotType.HEAD, ItemStack.EMPTY); } } flag = false; } if (flag) { this.setFire(8); } } super.livingTick(); } However this also requires we look at isInDaylight() in MobEntity: protected boolean isInDaylight() { if (this.world.isDaytime() && !this.world.isRemote) { float f = this.getBrightness(); BlockPos blockpos = this.getRidingEntity() instanceof BoatEntity ? (new BlockPos(this.getPosX(), (double)Math.round(this.getPosY()), this.getPosZ())).up() : new BlockPos(this.getPosX(), (double)Math.round(this.getPosY()), this.getPosZ()); if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.canSeeSky(blockpos)) { return true; } } return false; } And finally, isDaytime() in World: public boolean isDaytime() { return !this.func_230315_m_().func_241514_p_() && this.skylightSubtracted < 4; } And there's the light level. So altogether you'll need to add code like these three for your entity.
  10. The intended behavior is detect if an item is equiped, and if so, then allow scrolling to change FOV. Is there a different way other than events? Alternatively there's Mouse.getWheel(), which doesn't require mouse event, but it's non-static. Also, this is unrelated, but is there a reason we're asking people to update Forge when they ask questions regarding older versions, rather than redirecting them somewhere that will accept those questions?
  11. For the deferred registry method, you can do: public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTION_TYPES, Main.MOD_ID); public static final RegistryObject<Potion> EFFECT_NAME = POTIONS.register("effect_name", () -> new Potion(new EffectInstance[] {new EffectInstance(Effects.RESISTANCE, 9600), new EffectInstance(Effects.REGENERATION, 9600), new EffectInstance(Effects.FIRE_RESISTANCE, 9600)})); Where 9600 is the duration, and can be different values for each one. To create a brewing recipe for this, you have 2 options: using an access transformer, or reflection. These are required because we can't directly access the registry method Minecraft uses for brewing. Reflection is less buggy, but requires more code. To do this, copy: 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(); } } And then your recipe: public static void addBrewingRecipes() { addMix(Potions.AWKWARD, ModItems.ITEM_NAME, EFFECT_NAME.get()); } Where the first entry is the input potion, second is the brewing item, and third is the output.
  12. Funnily enough, I also just asked a question involving a helmet lol. There I used: ItemStack helmet = yourEvent.getEntity().getItemStackFromSlot(EquipmentSlotType.HEAD); if (!helmet.isEmpty() && helmet.getItem() == ModItems.ITEM_NAME) { }
  13. The following requires 2 events, changing FOV and the mouse wheel. @SubscribeEvent public void onFOVChange(FOVUpdateEvent fovUpdateEvent, MouseWheelEvent mouseWheelEvent) { if (fovUpdateEvent.getEntity() != null) { ItemStack helmet = fovUpdateEvent.getEntity().getItemStackFromSlot(EquipmentSlotType.HEAD); if (!helmet.isEmpty() && helmet.getItem() == ModItems.LENSES) { int scroll = Integer.signum(mouseWheelEvent.getScrollAmount()); if (scroll < 0) { scroll = -1 / scroll; } fovUpdateEvent.setNewfov((float) (fovUpdateEvent.getFov() / scroll)); } } } However event handlers only manage 1 event. Is there a workaround? I considered using 2 separate handlers, but that would still require both to work together somehow.
  14. Ah it's the scope.I made those changes and it resolved the max age, but there's still a null error with the age property, saying it's invalid: public final VoxelShape[] SHAPE; public final Item SEEDS; public final int MAX_AGE; public final IntegerProperty AGE_PROPERTY; public ModCropsBlock(VoxelShape[] shape, Item seeds, Properties builder) { super(builder); this.SHAPE = shape; this.SEEDS = seeds; this.MAX_AGE = SHAPE.length - 1; this.AGE_PROPERTY = IntegerProperty.create("age", 0, MAX_AGE); }
  15. True creating a new property each time might be affecting it. The reason I think it's an issue with getting the shape is that getMaxAge returns an error separately, which is only dependent on that. I'm actually just overriding the current methods that are in place so that both properties generate automatically based on the shape array. In CropsBlock, these fields are defined outside the methods, but when I try to do it that way with something like Max_Age = Shapes.length - 1 then it says that Shapes isn't initialized.
  16. So I realized that VoxelShape can be passed into the registry like this: public static final VoxelShape[] CROP_SHAPE = new VoxelShape[] { Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,2.0D,16.0D), Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,4.0D,16.0D), Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,6.0D,16.0D), Block.makeCuboidShape(0.0D,0.0D,0.0D,16.0D,8.0D,16.0D) }; public static final Block PEANUTS = register(Reference.MOD_ID + ":peanut", new ModCropsBlock(CROP_SHAPE, ModItems.PEANUT_ITEM, Block.Properties.create(Material.PLANTS).doesNotBlockMovement().tickRandomly().zeroHardnessAndResistance().sound(SoundType.CROP))); With the class:
  17. Ah ok I'll tinker with an anyonymous class. Thanks!
  18. Right now I have block classes that are all identical except for their voxel shape, defined inside each class. I'd like to somehow pass this in during registry so that I can boil it down to one reusable class. Is this possible? I know it can't be passed into the super since the parent class "Block" doesn't work that way; I could extend AbstractBlock instead and add code for that, but that seems like more work.
  19. Luckily there's a vanilla block that has this functionality already: the daylight detector. The blockstate for that looks like: { "variants": { "inverted=false": { "model": "minecraft:block/daylight_detector" }, "inverted=true": { "model": "minecraft:block/daylight_detector_inverted" } } } So you can adapt your blockstate to use true/false flags like that. Now we need to look at the class file for the daylight detector to see how the tags are implemented. I've added the relevant parts here. public static final BooleanProperty INVERTED = BlockStateProperties.INVERTED; public DaylightDetectorBlock(AbstractBlock.Properties properties) { super(properties); this.setDefaultState(this.stateContainer.getBaseState().with(INVERTED, Boolean.FALSE)); } public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (player.isAllowEdit()) { if (worldIn.isRemote) { return ActionResultType.SUCCESS; } else { BlockState blockstate = state.func_235896_a_(INVERTED); worldIn.setBlockState(pos, blockstate, 4); return ActionResultType.CONSUME; } } else { return super.onBlockActivated(state, worldIn, pos, player, handIn, hit); } }
  20. Hmm the TeleportCommand and SpawnpointCommand classes located in net/minecraft/command/impl might be a good place to start. I'm new to modding as well though.
  21. In the future I'd suggest copying the error log into a pastebin or in spoiler tags, to keep it compact. I'd like to bet my money on Optifine, it's missing 2 classes (Launch and Loader) as well as a config file. Preview versions of Optifine are known to be buggy. Unfortunately that's the only one for 1.15.2. Try loading it without that and report if it works?
  22. Ah didn't know only certain AT's were viable. Yeah I tried to make the protected field Block_Stripping_Map, public. I assumed it was possible, as I'm just copying over some code from a mod developed by someone else, and they somehow got it to work. Will work out an alternative though. Thanks!
  23. I'm running a few commands in Intellij in order to update the AT config file into the project (This is suggested by YouTube modding tutorials, but lmk if there's a better method). This consists of: 1. gradlew --refresh-dependencies 2. gradlew clean 3. gradlew genIntellijRuns 4. Opening Intellij and waiting for dependencies to install/indices refresh Now randomly, after running the first three and opening Intellij, step 4 never occurs and the net.minecraftforge:forge library remains missing. Is this a bug, and is there a way to force it to install when this happens?
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.