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


  • Posts

  • Joined

  • Last visited

Posts posted by urbanxx001

  1. 36 minutes ago, ChampionAsh5357 said:

    Don't rely on a tutorial to teach you information you need to know.

    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.

    3 hours ago, Moosemoosetwutwu said:
    Anyone know how?

    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. 10 minutes ago, SonPlaying said:

    It just adds the food that gives the effect separately one by one.

    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. 7 hours ago, SonPlaying said:

    it didn't add anything. Is it an effect? Is it a potion item?

    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.


    7 hours ago, SonPlaying said:

     i want the effect to be given when a player eats a certain food

    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. 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.setItemStackToSlot(EquipmentSlotType.HEAD, ItemStack.EMPTY);
             flag = false;
          if (flag) {

    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.


  6. 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?

  7. 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);
        try {
            brewing_mixes.invoke(null, start, ingredient, result);
        } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {

    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.


  8. The following requires 2 events, changing FOV and the mouse wheel.

    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.

  9. 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) {
        this.SHAPE = shape;
        this.SEEDS = seeds;
        this.MAX_AGE = SHAPE.length - 1;
        this.AGE_PROPERTY = IntegerProperty.create("age", 0, MAX_AGE);
  10. 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.

  11. So I realized that VoxelShape can be passed into the registry like this:

    public static final VoxelShape[] CROP_SHAPE = new VoxelShape[] {
        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: 

    public class ModCropsBlock extends CropsBlock {
        public final VoxelShape[] SHAPE;
        public final Item SEEDS;
        public ModCropsBlock(VoxelShape[] shape, Item seeds, Properties builder) {
            this.SHAPE = shape;
            this.SEEDS = seeds;
        public int getMaxAge() { return SHAPE.length - 1; }
        public IntegerProperty getAgeProperty() {
            return IntegerProperty.create("age", 0, getMaxAge());
        protected IItemProvider getSeedsItem() { return SEEDS; }
        public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
            if (random.nextInt(getMaxAge()) != 0) {
                super.randomTick(state, worldIn, pos, random);
        protected int getBonemealAgeIncrease(World worldIn) {
            return super.getBonemealAgeIncrease(worldIn) / getMaxAge();
        protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
        public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
            return SHAPE[state.get(this.getAgeProperty())];


    However during compilation I get a null pointer error for getMaxAge and getAgeProperty, which means the VoxelShape isn't being retrieved. Is this an easy fix or do I actually need anonymous functions? Sorry if this is a simple Java question.

  12. 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.

  13. 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) {
            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);


    • Thanks 1
  14. 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?

  15. 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!

  16. 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.