Jump to content

Pickle_Face5

Members
  • Posts

    54
  • Joined

  • Last visited

Posts posted by Pickle_Face5

  1. So, I'm having issues on understanding how to register attributes for my entity.

    Here's the error: https://pastebin.com/8YGzE6L4

    Entity Class:

    Spoiler
    
    package com.pickleface.oceanscompund.entities.passive.fish;
    
    import com.pickleface.oceanscompund.util.ItemsInit;
    import net.minecraft.entity.EntityType;
    import net.minecraft.entity.LivingEntity;
    import net.minecraft.entity.MobEntity;
    import net.minecraft.entity.ai.attributes.AttributeModifierMap;
    import net.minecraft.entity.ai.attributes.Attributes;
    import net.minecraft.entity.passive.fish.AbstractGroupFishEntity;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.SoundEvent;
    import net.minecraft.util.SoundEvents;
    import net.minecraft.world.World;
    
    
    public class PiranhaEntity extends AbstractGroupFishEntity {
        public PiranhaEntity(EntityType<? extends PiranhaEntity> p_i49856_1_, World p_i49856_2_) {
            super(p_i49856_1_, p_i49856_2_);
        }
    
        @Override
        protected ItemStack getBucketItemStack() {
            return new ItemStack(ItemsInit.PIRANHA_BUCKET.get());
        }
    
        @Override
        protected SoundEvent getAmbientSound() {
            return SoundEvents.COD_AMBIENT;
        }
    
        @Override
        protected SoundEvent getDeathSound() {
            return SoundEvents.COD_DEATH;
        }
    
        @Override
        protected SoundEvent getHurtSound(DamageSource p_184601_1_) {
            return SoundEvents.COD_HURT;
        }
    
        @Override
        protected SoundEvent getFlopSound() {
            return SoundEvents.COD_FLOP;
        }
    
        @Override
        public int getMaxSchoolSize() {
            return 3;
        }
    
        @Override
        protected void registerGoals() {
            super.registerGoals();
        }
    
        public static AttributeModifierMap.MutableAttribute setAttributes() {
            return MobEntity.createMobAttributes()
                    .add(Attributes.MAX_HEALTH, 100.0D)
                    .add(Attributes.MOVEMENT_SPEED, 0.25D)
                    .add(Attributes.FOLLOW_RANGE, 16.0D)
                    .add(Attributes.ATTACK_KNOCKBACK);
        }
    
    
        @Override
        public void tick() {
            super.tick();
        }
    }

     

    Registry and EntityAttributeCreationEvent:

    Spoiler
    
    package com.pickleface.oceanscompund.util;
    
    import com.pickleface.oceanscompund.OceansCompound;
    import com.pickleface.oceanscompund.entities.passive.fish.PiranhaEntity;
    import net.minecraft.entity.EntityClassification;
    import net.minecraft.entity.EntityType;
    import net.minecraft.entity.ai.attributes.Attributes;
    import net.minecraft.entity.passive.fish.CodEntity;
    import net.minecraft.util.ResourceLocation;
    import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
    import net.minecraftforge.event.entity.EntityAttributeModificationEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.RegistryObject;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.registries.DeferredRegister;
    import net.minecraftforge.registries.ForgeRegistries;
    
    public class EntitiesInit {
        public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, OceansCompound.MOD_ID);
    
        public static final RegistryObject<EntityType<PiranhaEntity>> PIRANHA = ENTITIES.register("piranha", () ->
                EntityType.Builder.of(PiranhaEntity::new, EntityClassification.MONSTER)
                        .sized(EntityType.COD.getWidth(), EntityType.COD.getHeight())
                        .clientTrackingRange(4)
                .build(new ResourceLocation(OceansCompound.MOD_ID, "piranha").toString())
        );
    
        @Mod.EventBusSubscriber(modid = OceansCompound.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
        public class EntityHandler {
            @SubscribeEvent
            public void entityAddAttributes(final EntityAttributeCreationEvent event) {
                event.put(PIRANHA.get(), PiranhaEntity.setAttributes().add(Attributes.MAX_HEALTH, 5).build());
            }
        }
    }

     

    And heres the model:

    Spoiler
    
    package com.pickleface.oceanscompund.client.renderer.entity.model;
    
    import com.google.common.collect.ImmutableList;
    import com.mojang.blaze3d.matrix.MatrixStack;
    import com.mojang.blaze3d.vertex.IVertexBuilder;
    import net.minecraft.client.renderer.entity.model.SegmentedModel;
    import net.minecraft.client.renderer.model.ModelRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.util.math.MathHelper;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.api.distmarker.OnlyIn;
    
    @OnlyIn(Dist.CLIENT)
    public class PiranhaModel<T extends Entity> extends SegmentedModel<T> {
        private final ModelRenderer head;
        private final ModelRenderer body;
        private final ModelRenderer fin_r1;
        private final ModelRenderer fin_r2;
        private final ModelRenderer backfin_r1;
    
        public PiranhaModel() {
           this.texWidth = 64;
           this.texHeight = 64;
    
            this.head = new ModelRenderer(this);
            this.head.setPos(0.0F, 24.0F, 0.0F);
            this.head.texOffs(0, 9).addBox(-3.0F, -2.0F, -7.0F, 7.0F, 2.0F, 7.0F, 0.0F, false);
            this.head.texOffs(0, 18).addBox(-2.0F, -8.0F, -6.0F, 5.0F, 6.0F, 6.0F, 0.0F, false);
            this.head.texOffs(0, 0).addBox(-3.0F, -4.0F, -7.0F, 7.0F, 2.0F, 7.0F, 0.0F, false);
    
            this.body = new ModelRenderer(this);
            this.body.setPos(0.0F, 24.0F, 0.0F);
            this.body.texOffs(22, 18).addBox(-2.0F, -7.0F, 0.0F, 5.0F, 6.0F, 3.0F, 0.0F, false);
            this.body.texOffs(24, 5).addBox(-1.0F, -6.1F, 2.0F, 3.0F, 5.0F, 4.0F, 0.0F, false);
            this.body.texOffs(8, 30).addBox(0.0F, -5.0F, 5.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
            this.body.texOffs(0, 26).addBox(0.6F, -7.0F, 8.0F, 0.0F, 7.0F, 4.0F, 0.0F, false);
    
            this.backfin_r1 = new ModelRenderer(this);
            this.backfin_r1.setPos(0.6F, -9.5F, 4.5F);
            this.setRotationAngle(backfin_r1, 1.5708F, 0.0F, 0.0F);
            this.backfin_r1.texOffs(22, 23).addBox(0.0F, -4.5F, -4.5F, 0.0F, 7.0F, 4.0F, 0.0F, false);
    
            this.fin_r1 = new ModelRenderer(this);
            this.fin_r1.setPos(3.6616F, -4.303F, 4.4246F);
            this.setRotationAngle(fin_r1, -0.6109F, 0.0F, 1.0472F);
            this.fin_r1.texOffs(21, 0).addBox(-3.1F, -0.4F, -3.1F, 3.0F, 4.0F, 1.0F, 0.0F, false);
    
            this.fin_r2 = new ModelRenderer(this);
            this.fin_r2.setPos(-3.6616F, -4.303F, 4.4246F);
            this.setRotationAngle(fin_r2, -0.6109F, 0.0F, -1.0472F);
            this.fin_r2.texOffs(29, 0).addBox(0.5F, 0.3F, -2.7F, 3.0F, 4.0F, 1.0F, 0.0F, false);
        }
    
        @Override
        public void setupAnim(T p_225597_1_, float p_225597_2_, float p_225597_3_, float p_225597_4_, float p_225597_5_, float p_225597_6_) {
            float f = 1.0F;
            if (!p_225597_1_.isInWater()) {
                f = 1.5F;
            }
    
            this.fin_r1.xRot = -f * 0.45F * MathHelper.sin(0.6F * p_225597_4_);
            this.fin_r2.xRot = f * 0.45F * MathHelper.sin(0.6F * p_225597_4_);
        }
    
        @Override
        public Iterable<ModelRenderer> parts() {
            return ImmutableList.of(this.body, this.head, this.fin_r1, this.fin_r2, this.backfin_r1);
        }
    
        @Override
        public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
            head.render(matrixStack, buffer, packedLight, packedOverlay);
            body.render(matrixStack, buffer, packedLight, packedOverlay);
        }
    
    
        public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
            modelRenderer.xRot = x;
            modelRenderer.yRot = y;
            modelRenderer.zRot = z;
        }
    }

     

    Any help is appreciated, thanks.

  2. You need to Override registerGoals() in your entity. Since you seem to be creating a custom sheep, the code for the normal sheep in minecraft is:

    protected void registerGoals() {
          this.eatBlockGoal = new EatGrassGoal(this);
          this.goalSelector.addGoal(0, new SwimGoal(this));
          this.goalSelector.addGoal(1, new PanicGoal(this, 1.25D));
          this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
          this.goalSelector.addGoal(3, new TemptGoal(this, 1.1D, Ingredient.of(Items.WHEAT), false));
          this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D));
          this.goalSelector.addGoal(5, this.eatBlockGoal);
          this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 1.0D));
          this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 6.0F));
          this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
       }

    What this is doing is telling the sheep what to do, based on priority (the lower the number, the higher the priority.). For example, the Sheep's highest priority goal is to float in water when its in water.

  3. Hi, I was trying to add a piranha entity in the game. Very similar to Cod, and when testing it out, I realised that I was getting a NullPointerException. I guess that I'm forgetting something important like a function thats required or such, so I'm reaching out to see if someone can point me in the right direction.

    Piranha Entity class:

    Spoiler
    
    public class PiranhaEntity extends AbstractGroupFishEntity {
        public PiranhaEntity(EntityType<? extends PiranhaEntity> p_i49856_1_, World p_i49856_2_) {
            super(p_i49856_1_, p_i49856_2_);
        }
    
        @Override
        protected ItemStack getBucketItemStack() {
            return new ItemStack(ItemsInit.PIRANHA_BUCKET.get());
        }
    
        @Override
        protected SoundEvent getAmbientSound() {
            return SoundEvents.COD_AMBIENT;
        }
    
        @Override
        protected SoundEvent getDeathSound() {
            return SoundEvents.COD_DEATH;
        }
    
        @Override
        protected SoundEvent getHurtSound(DamageSource p_184601_1_) {
            return SoundEvents.COD_HURT;
        }
    
        @Override
        protected SoundEvent getFlopSound() {
            return SoundEvents.COD_FLOP;
        }
    
        @Override
        public int getMaxSchoolSize() {
            return 3;
        }
    
        @Override
        protected void registerGoals() {
            super.registerGoals();
        }
    
        @Override
        public void tick() {
            super.tick();
        }

     

    Registering the Entity:

    Spoiler
    
    public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, OceansCompound.MOD_ID);
    
        public static final RegistryObject<EntityType<PiranhaEntity>> PIRANHA = ENTITIES.register("piranha", () ->
                EntityType.Builder.of(PiranhaEntity::new, EntityClassification.MONSTER)
                        .sized(EntityType.COD.getWidth(), EntityType.COD.getHeight())
                .build(new ResourceLocation(OceansCompound.MOD_ID, "piranha").toString())
        );
    
        @Mod.EventBusSubscriber(modid = OceansCompound.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
        public static class EntityHandler {
            @SubscribeEvent
            public void entityAddAttributes(final EntityAttributeCreationEvent event) {
                event.put(PIRANHA.get(), PiranhaEntity.createAttributes()
                        .add(Attributes.MAX_HEALTH, 5).build());
            }
        }

     

    Piranha Rendering:

    Spoiler
    
    private static final ResourceLocation PIRANHA_LOCATION = new ResourceLocation(OceansCompound.MOD_ID, "textures/entity/fish/piranha.png");
    
        public PiranhaRenderer(EntityRendererManager p_i48864_1_) {
            super(p_i48864_1_, new PiranhaModel<>(), 0.3F);
        }
    
        @Override
        public ResourceLocation getTextureLocation(PiranhaEntity p_110775_1_) {
            return PIRANHA_LOCATION;
        }
    
        protected void setupRotations(PiranhaEntity p_225621_1_, MatrixStack p_225621_2_, float p_225621_3_, float p_225621_4_, float p_225621_5_) {
            super.setupRotations(p_225621_1_, p_225621_2_, p_225621_3_, p_225621_4_, p_225621_5_);
            float f = 4.3F * MathHelper.sin(0.6F * p_225621_3_);
            p_225621_2_.mulPose(Vector3f.YP.rotationDegrees(f));
            if (!p_225621_1_.isInWater()) {
                p_225621_2_.translate(0.1F, 0.1F, -0.1F);
                p_225621_2_.mulPose(Vector3f.ZP.rotationDegrees(90.0F));
            }
    
        }

     

    Finally, Piranha Model:

    Spoiler
    
    private final ModelRenderer head;
        private final ModelRenderer body;
    
        public PiranhaModel() {
            texWidth = 64;
            texHeight = 64;
    
            head = new ModelRenderer(this);
            head.setPos(0.0F, 24.0F, 0.0F);
            head.setTexSize(0, 9).addBox(-3.0F, -2.0F, -7.0F, 7.0F, 2.0F, 7.0F, 0.0F, false);
            head.setTexSize(0, 18).addBox(-2.0F, -8.0F, -6.0F, 5.0F, 6.0F, 6.0F, 0.0F, false);
            head.setTexSize(0, 0).addBox(-3.0F, -4.0F, -7.0F, 7.0F, 2.0F, 7.0F, 0.0F, false);
    
            body = new ModelRenderer(this);
            body.setPos(0.0F, 24.0F, 0.0F);
            body.setTexSize(22, 18).addBox(-2.0F, -7.0F, 0.0F, 5.0F, 6.0F, 3.0F, 0.0F, false);
            body.setTexSize(24, 5).addBox(-1.0F, -6.1F, 2.0F, 3.0F, 5.0F, 4.0F, 0.0F, false);
            body.setTexSize(8, 30).addBox(0.0F, -5.0F, 5.0F, 1.0F, 4.0F, 3.0F, 0.0F, false);
            body.setTexSize(0, 26).addBox(0.6F, -7.0F, 8.0F, 0.0F, 7.0F, 4.0F, 0.0F, false);
    
            ModelRenderer backfin_r1 = new ModelRenderer(this);
            backfin_r1.setPos(0.6F, -9.5F, 4.5F);
            body.addChild(backfin_r1);
            setRotationAngle(backfin_r1, 1.5708F, 0.0F, 0.0F);
            backfin_r1.setTexSize(22, 23).addBox(0.0F, -4.5F, -4.5F, 0.0F, 7.0F, 4.0F, 0.0F, false);
    
            ModelRenderer fin_r1 = new ModelRenderer(this);
            fin_r1.setPos(3.6616F, -4.303F, 4.4246F);
            body.addChild(fin_r1);
            setRotationAngle(fin_r1, -0.6109F, 0.0F, 1.0472F);
            fin_r1.setTexSize(21, 0).addBox(-3.1F, -0.4F, -3.1F, 3.0F, 4.0F, 1.0F, 0.0F, false);
    
            ModelRenderer fin_r2 = new ModelRenderer(this);
            fin_r2.setPos(-3.6616F, -4.303F, 4.4246F);
            body.addChild(fin_r2);
            setRotationAngle(fin_r2, -0.6109F, 0.0F, -1.0472F);
            fin_r2.setTexSize(29, 0).addBox(0.5F, 0.3F, -2.7F, 3.0F, 4.0F, 1.0F, 0.0F, false);
        }
    
        @Override
        public void setupAnim(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){
            //previously the render function, render code was moved to a method below
        }
    
        @Override
        public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){
            head.render(matrixStack, buffer, packedLight, packedOverlay);
            body.render(matrixStack, buffer, packedLight, packedOverlay);
        }
    
        @Override
        public Iterable<ModelRenderer> parts() {
            return ImmutableList.of(this.head, this.body);
        }
    
        public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
            modelRenderer.xRot = x;
            modelRenderer.yRot = y;
            modelRenderer.zRot = z;
        }

     

    Any help in the right direction is appreciated, thanks.

  4. Alright, so I decided to add particles to my Rube Ore (basically Redstone Ore but 24 /7) and while testing the particle data, I get these errors (same as title) about it being cast to RedstoneParticleData, even though I don't see it anywhere. It says the errors in the Ore Block itself, so heres the code for that: 

    package com.pickleface.ruby.blocks;
    
    import com.pickleface.ruby.particles.RubyParticleData;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockState;
    import net.minecraft.block.OreBlock;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.material.Material;
    import net.minecraft.util.Direction;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IWorldReader;
    import net.minecraft.world.World;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.api.distmarker.OnlyIn;
    import net.minecraftforge.common.ToolType;
    
    import java.util.Random;
    
    public class RubyOre extends OreBlock {
        public RubyOre() {
            super(Block.Properties.create(Material.ROCK)
                    .hardnessAndResistance(3.0f, 3.5f)
                    .sound(SoundType.STONE)
                    .harvestLevel(2)
                    .harvestTool(ToolType.PICKAXE)
                    .setRequiresTool()
            );
        }
        @Override
        public int getExpDrop(BlockState state, IWorldReader reader, BlockPos pos, int fortune, int silktouch) {
            return 1;
        }
    
        public boolean ticksRandomly(BlockState state) {
            return true;
        }
    
        @OnlyIn(Dist.CLIENT)
        public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) {
                spawnParticles(worldIn, pos);
        }
    
        private static void spawnParticles(World world, BlockPos worldIn) {
            Random random = world.rand;
    
            for(Direction direction : Direction.values()) {
                BlockPos blockpos = worldIn.offset(direction);
                if (!world.getBlockState(blockpos).isOpaqueCube(world, blockpos)) {
                    Direction.Axis direction$axis = direction.getAxis();
    
                    double d1 = direction$axis == Direction.Axis.X ? 0.5D + 0.5625D * (double)direction.getXOffset() : (double)random.nextFloat();
                    double d2 = direction$axis == Direction.Axis.Y ? 0.5D + 0.5625D * (double)direction.getYOffset() : (double)random.nextFloat();
                    double d3 = direction$axis == Direction.Axis.Z ? 0.5D + 0.5625D * (double)direction.getZOffset() : (double)random.nextFloat();
                    world.addParticle(new RubyParticleData(1.0F, 0F, 0F, 1.0F), (double)worldIn.getX() + d1, (double)worldIn.getY() + d2, (double)worldIn.getZ() + d3, 0.0D, 0.0D, 0.0D);
                }
            }
    
        }
    }

    and if its needed, heres the particle data:

    package com.pickleface.ruby.particles;
    
    import com.mojang.brigadier.StringReader;
    import com.mojang.brigadier.exceptions.CommandSyntaxException;
    import com.mojang.serialization.Codec;
    import com.mojang.serialization.codecs.RecordCodecBuilder;
    import java.util.Locale;
    import net.minecraft.network.PacketBuffer;
    import net.minecraft.particles.*;
    import net.minecraft.util.math.MathHelper;
    import net.minecraft.util.registry.Registry;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.api.distmarker.OnlyIn;
    
    public class RubyParticleData implements IParticleData {
        public static final Codec<RubyParticleData> field_239802_b_ = RecordCodecBuilder.create((p_239803_0_) -> {
            return p_239803_0_.group(Codec.FLOAT.fieldOf("r").forGetter((p_239807_0_) -> {
                return p_239807_0_.red;
            }), Codec.FLOAT.fieldOf("g").forGetter((p_239806_0_) -> {
                return p_239806_0_.green;
            }), Codec.FLOAT.fieldOf("b").forGetter((p_239805_0_) -> {
                return p_239805_0_.blue;
            }), Codec.FLOAT.fieldOf("scale").forGetter((p_239804_0_) -> {
                return p_239804_0_.alpha;
            })).apply(p_239803_0_, RubyParticleData::new);
        });
        private final float red;
        private final float green;
        private final float blue;
        private final float alpha;
    
        public RubyParticleData(float red, float green, float blue, float alpha) {
            this.red = red;
            this.green = green;
            this.blue = blue;
            this.alpha = MathHelper.clamp(alpha, 0.01F, 4.0F);
        }
    
        public void write(PacketBuffer buffer) {
            buffer.writeFloat(this.red);
            buffer.writeFloat(this.green);
            buffer.writeFloat(this.blue);
            buffer.writeFloat(this.alpha);
        }
    
        public String getParameters() {
            return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f", Registry.PARTICLE_TYPE.getKey(this.getType()), this.red, this.green, this.blue, this.alpha);
        }
    
        public ParticleType<RedstoneParticleData> getType() {
            return ParticleTypes.DUST;
        }
    }

    Any help is appreciated, thanks.

  5. Idk what this means. heres the latest.log though.

     

    Here's the registry:

    package com.pickleface.ruby.util;
    
    import com.pickleface.ruby.Ruby;
    import com.pickleface.ruby.armor.ModArmorMaterial;
    import com.pickleface.ruby.blocks.*;
    import com.pickleface.ruby.items.*;
    import com.pickleface.ruby.tools.ModItemTier;
    import net.minecraft.block.Block;
    import net.minecraft.block.OreBlock;
    import net.minecraft.inventory.EquipmentSlotType;
    import net.minecraft.item.*;
    import net.minecraft.particles.BasicParticleType;
    import net.minecraft.particles.ParticleType;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.SoundEvent;
    import net.minecraft.util.SoundEvents;
    import net.minecraftforge.eventbus.api.IEventBus;
    import net.minecraftforge.fml.RegistryObject;
    import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
    import net.minecraftforge.registries.DeferredRegister;
    import net.minecraftforge.registries.ForgeRegistries;
    
    public class RegistryHandler {
        public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Ruby.MOD_ID);
        public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, Ruby.MOD_ID);
        public static final DeferredRegister<SoundEvent> SOUNDS = DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, Ruby.MOD_ID);
        public static final DeferredRegister<ParticleType<?>> PARTICLES = DeferredRegister.create(ForgeRegistries.PARTICLE_TYPES, Ruby.MOD_ID);
    
        public static void init() {
            IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
            ITEMS.register(modEventBus);
            BLOCKS.register(modEventBus);
            SOUNDS.register(modEventBus);
            PARTICLES.register(modEventBus);
        }
    
        // Items
        public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", RubyItem::new);
        public static final RegistryObject<RubyApple> RUBY_APPLE = ITEMS.register("ruby_apple", RubyApple::new);
        public static final RegistryObject<MusicDiscItem> MUSIC_DISC_P_A_T = ITEMS.register("music_disc_peace_and_tranquility", RubyMusicDisc::new);
    
        // Tools
        public static final RegistryObject<SwordItem> RUBY_SWORD = ITEMS.register("ruby_sword", () ->
                new SwordItem(ModItemTier.RUBY, 7, -2.4F, new Item.Properties().group(ItemGroup.COMBAT)));
        public static final RegistryObject<AxeItem> RUBY_AXE = ITEMS.register("ruby_axe", () ->
                new AxeItem(ModItemTier.RUBY, 8, -3.0F, new Item.Properties().group(ItemGroup.TOOLS)));
        public static final RegistryObject<PickaxeItem> RUBY_PICKAXE = ITEMS.register("ruby_pickaxe", () ->
                new PickaxeItem(ModItemTier.RUBY, 4, -2.8F, new Item.Properties().group(ItemGroup.TOOLS)));
        public static final RegistryObject<ShovelItem> RUBY_SHOVEL = ITEMS.register("ruby_shovel", () ->
                new ShovelItem(ModItemTier.RUBY, 6, -3.0F, new Item.Properties().group(ItemGroup.TOOLS)));
        public static final RegistryObject<HoeItem> RUBY_HOE = ITEMS.register("ruby_hoe", () ->
                new HoeItem(ModItemTier.RUBY, 0, 0, new Item.Properties().group(ItemGroup.TOOLS)));
    
        // Armor
        public static final RegistryObject<ArmorItem> RUBY_HELMET = ITEMS.register("ruby_helmet", () ->
                new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.HEAD, new Item.Properties().group(ItemGroup.COMBAT)));
        public static final RegistryObject<ArmorItem> RUBY_CHESTPLATE = ITEMS.register("ruby_chestplate", () ->
                new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.CHEST, new Item.Properties().group(ItemGroup.COMBAT)));
        public static final RegistryObject<ArmorItem> RUBY_LEGGINGS = ITEMS.register("ruby_leggings", () ->
                new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.LEGS, new Item.Properties().group(ItemGroup.COMBAT)));
        public static final RegistryObject<ArmorItem> RUBY_BOOTS = ITEMS.register("ruby_boots", () ->
                new ArmorItem(ModArmorMaterial.RUBY, EquipmentSlotType.FEET, new Item.Properties().group(ItemGroup.COMBAT)));
        public static final RegistryObject<HorseArmorItem> RUBY_HORSE_ARMOR = ITEMS.register("ruby_horse_armor", () ->
                new HorseArmorItem(15, new ResourceLocation(Ruby.MOD_ID + ":textures/entity/horse/armor/horse_armor_ruby.png"), new Item.Properties().group(ItemGroup.COMBAT)));
    
        // Blocks
        public static final RegistryObject<Block> BLOCK_OF_RUBY = BLOCKS.register("ruby_block", RubyBlock::new);
        public static final RegistryObject<OreBlock> RUBY_ORE = BLOCKS.register("ruby_ore", RubyOre::new);
    
        // Block Items
        public static final RegistryObject<Item> BLOCK_OF_RUBY_ITEM = ITEMS.register("ruby_block", () -> new BlockItemBase(BLOCK_OF_RUBY.get()));
        public static final RegistryObject<Item> RUBY_ORE_ITEM = ITEMS.register("ruby_ore", () -> new BlockItemBase(RUBY_ORE.get()));
    
        // Sound Events
        public static final RegistryObject<SoundEvent> MUSIC_DISC_PEACE_AND_TRANQUILITY = SOUNDS.register("music_disc.peace_and_tranquility", () -> new SoundEvent(new ResourceLocation("ruby", "music_disc.peace_and_tranquility")));
    
        // Particles
        public static final RegistryObject<ParticleType<BasicParticleType>> RUBY_SHINE = PARTICLES.register("ruby_shine", () -> new BasicParticleType(false));
    }

     

    Any help is appreciated.

    latest.log

  6. I'm trying to make a berry bush that generates in forests and plains (more common in forests), and now it doesn't generate at all.

    Here's the code:

    package com.pickleface.lifecraft.world.gen;
    
    import com.google.common.collect.ImmutableSet;
    import com.pickleface.lifecraft.LifeCraft;
    import com.pickleface.lifecraft.blocks.BlueberryBush;
    import com.pickleface.lifecraft.util.Registry;
    import net.minecraft.block.Blocks;
    import net.minecraft.world.biome.Biome;
    import net.minecraft.world.gen.GenerationStage;
    import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
    import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
    import net.minecraft.world.gen.feature.*;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.event.world.BiomeLoadingEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    
    @Mod.EventBusSubscriber(modid = LifeCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
    public class VeganGen {
    
        @SubscribeEvent
        public static void generateBushes(BiomeLoadingEvent event) {
            BlockClusterFeatureConfig BLUEBERRY_BUSH_PATCH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.PLACER)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getDefaultState().getBlock())).func_227317_b_().build();
    
            ConfiguredFeature<?, ?> PATCH_BLUEBERRY_BUSH = Feature.RANDOM_PATCH.withConfiguration(BLUEBERRY_BUSH_PATCH_CONFIG);
            ConfiguredFeature<?, ?> PATCH_BLUEBERRY_DECORATED = PATCH_BLUEBERRY_BUSH.withPlacement(Features.Placements.PATCH_PLACEMENT).chance(24);
    
            if (event.getCategory().getString().equals("forest")) {
                event.getGeneration().withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, PATCH_BLUEBERRY_DECORATED);
            } else if (event.getCategory().getString().equals("plains")) {
                event.getGeneration().withFeature(GenerationStage.Decoration.VEGETAL_DECORATION, PATCH_BLUEBERRY_BUSH);
            }
        }
    }

    Any help is appreciated.

  7. I'm making a custom particle to ake the game more "alive", but I've never done particles, so this is fun. Anyway, heres the code for the part where I register the factory:

    @Mod.EventBusSubscriber(modid = WildCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
    public class ParticleUtil {
    
        @SubscribeEvent()
        public static void registerParticles(ParticleFactoryRegisterEvent event) {
            Minecraft.getInstance().particles.registerFactory(Registry.SPIDER_PARTICLE.get(), SpiderParticle.Factory::new);
        }
    }

    I'm assuming there something wrong with the particle class itself also, so I'll put its code here also:

    @OnlyIn(Dist.CLIENT)
    public class SpiderParticle extends SpriteTexturedParticle {
        public SpiderParticle(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) {
            super(world, x, y, z, motionX, motionY, motionZ);
    
            float f = this.rand.nextFloat() * 1.0F;
            this.particleRed = f;
            this.particleGreen = f;
            this.particleBlue = f;
    
            this.setSize(0.02F, 0.02F);
            this.particleScale *= this.rand.nextFloat() * 1.1F;
            this.motionX *= (double)0.02F;
            this.motionY *= (double)0.02F;
            this.motionZ *= (double)0.02F;
            this.maxAge = (int)(20.0D / (Math.random() * 1.0D));
        }
    
        @Override
        public IParticleRenderType getRenderType() {
            return IParticleRenderType.PARTICLE_SHEET_OPAQUE;
        }
    
        @Override
        public void tick() {
            this.prevPosX = this.posX;
            this.prevPosY = this.posY;
            this.prevPosZ = this.posZ;
    
            if(this.maxAge-- <= 0) {
                this.setExpired();
            } else {
                this.move(this.motionX, this.motionY, this.motionZ);
                this.motionX *= 1.0D;
                this.motionY *= 1.0D;
                this.motionZ *= 1.0D;
            }
        }
    
        @OnlyIn(Dist.CLIENT)
        public static class Factory implements IParticleFactory<BasicParticleType> {
            private final IAnimatedSprite spriteSet;
            public Factory(IAnimatedSprite sprite) {
                this.spriteSet = sprite;
            }
    
            @Override
            public Particle makeParticle(BasicParticleType typeIn, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
                SpiderParticle spiderParticle = new SpiderParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed);
                spiderParticle.setColor(1.0F, 1.0F, 1.0F);
                spiderParticle.selectSpriteRandomly(spriteSet);
                return spiderParticle;
            }
        }
    }

    Any help is appreciated, thanks.

  8. 1.16.2 ore generation is broken, and is very difficult to do ore generation in that version. In 1.16.3, there's a new event called BiomeLoadingEvent. Use that event, and inside the event make a ConfiguredFeature for your ore you want to generate (to see how to do this, look how Minecraft does it in minecraft\world\gen\feature\Features). Then in your event, do .getGeneration().withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, <Configured Feature Name Here>

    Heres an Example from one of my mods:

    public static void generateOres(BiomeLoadingEvent event) {
            ConfiguredFeature<?, ?> ORE_SAPPHIRE = Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.field_241882_a, Registry.SAPPHIRE_ORE.get().getDefaultState(), 6)).withPlacement(Placement.field_242910_o.configure(new DepthAverageConfig(15, 16))).func_242728_a();
            event.getGeneration().withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ORE_SAPPHIRE);
        }

     

  9. Just now, diesieben07 said:

    You'd have to replace the block with your own version of redstone wire, but one that does not require a power source.

    There is no way to make redstone wire emit a signal without it having a source.

    Oh, okay, I thought there was an override I could do to set it to full power.

  10. Hello.

    I'm making an enchantment that when walking over redstone, It fully powers it, but I can't find anything for powering a wire.

    Here's my code:

    package com.pickleface.redstone.enchants;
    
    import com.pickleface.redstone.Redstone;
    import net.minecraft.block.Blocks;
    import net.minecraft.block.RedstoneWireBlock;
    import net.minecraft.enchantment.Enchantment;
    import net.minecraft.enchantment.EnchantmentType;
    import net.minecraft.entity.player.PlayerEntity;
    import net.minecraft.inventory.EquipmentSlotType;
    import net.minecraftforge.api.distmarker.Dist;
    import net.minecraftforge.event.TickEvent;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    
    public class Energy extends Enchantment {
        protected Energy() {
            super(Rarity.RARE, EnchantmentType.ARMOR_FEET, new EquipmentSlotType[] {EquipmentSlotType.FEET});
        }
    
        @Mod.EventBusSubscriber(modid = Redstone.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
        public static class Event {
            @SubscribeEvent
            public static void onBootsEquipped(TickEvent.PlayerTickEvent event) {
                PlayerEntity player = event.player;
    
                if (player.getBlockState() == Blocks.REDSTONE_WIRE.getDefaultState()) {
                    player.getBlockState().(power redstone wire here, cant find anything)
                }
            }
        }
    }

    Any help is appreciated.

  11. 9 minutes ago, Maxi07 said:

    Tip: you can declare your blockstates: 

    
    final BlockState BLUEBERRY_BUSH = Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3);
    final BlockState RASPBERRY_BUSH = Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3);

    right in front of your for loop (inside the event) as local variables, so you can reuse the blockstates without havining the static initializer problem.

     

     

    And consider using a DeferredWorkQueue:

     

    DeferredWorkQueue example: 

    
    private void commonSetup(final FMLCommonSetupEvent event) {
    	DeferredWorkQueue.runLater(() -> {
    		//Your Code
    	});
    }

    For more see here: https://championash5357.github.io/ChampionAsh5357/tutorial/minecraft/1.16.1/basic/ore_gen

    Thank you! I’ll add this to my code. Also, can I declare the config(commented out right now) as local variables too?

  12. 6 hours ago, diesieben07 said:

    Didn't we already have this in a previous thread? Yes we did.

    Stop initializing everything in static initializers.

    Works now. Here's my code:

    package com.pickleface.survival.world.gen;
    
    import com.google.common.collect.ImmutableSet;
    import com.pickleface.survival.Registry;
    import com.pickleface.survival.Survival;
    import com.pickleface.survival.blocks.BlueberryBush;
    import com.pickleface.survival.blocks.RaspberryBush;
    import net.minecraft.block.Blocks;
    import net.minecraft.world.biome.Biome;
    import net.minecraft.world.biome.Biomes;
    import net.minecraft.world.gen.GenerationStage;
    import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
    import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
    import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
    import net.minecraft.world.gen.feature.Feature;
    import net.minecraft.world.gen.placement.ChanceConfig;
    import net.minecraft.world.gen.placement.FrequencyConfig;
    import net.minecraft.world.gen.placement.Placement;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
    import net.minecraftforge.registries.ForgeRegistries;
    
    @Mod.EventBusSubscriber(modid = Survival.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public class DecorationGen {
        // Get Stuff to Generate
        //private static final BlockState BLUEBERRY_BUSH = Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3);
        //private static final BlockState RASPBERRY_BUSH = Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3);
    
        // Make Config With Stuff
        //public static final BlockClusterFeatureConfig BLUEBERRY_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build();
        //public static final BlockClusterFeatureConfig RASPBERRY_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(RASPBERRY_BUSH), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build();
    
        @SubscribeEvent
        public static void generateDecorations(final FMLCommonSetupEvent event) {
            for (Biome biome : ForgeRegistries.BIOMES) {
                if (biome == Biomes.PLAINS) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.COUNT_HEIGHTMAP_DOUBLE.configure(new FrequencyConfig(1))));
                }
                if (biome == Biomes.SUNFLOWER_PLAINS) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.COUNT_HEIGHTMAP_DOUBLE.configure(new FrequencyConfig(1))));
                }
                if (biome == Biomes.FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.BIRCH_FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.FLOWER_FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.DARK_FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.JUNGLE_EDGE) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.COUNT_HEIGHTMAP_DOUBLE.configure(new FrequencyConfig(1))));
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.JUNGLE) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.COUNT_HEIGHTMAP_DOUBLE.configure(new FrequencyConfig(1))));
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.MODIFIED_JUNGLE) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.COUNT_HEIGHTMAP_DOUBLE.configure(new FrequencyConfig(1))));
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration((new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3)), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build()).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
            }
        }
    }

     

  13. 21 minutes ago, ChampionAsh5357 said:

    You can't really do this. When the class is first called by the event bus loader, it will declare these variables prior to the registry phase. So, it will initialize both of these values to null. Just create the variables locally in the event since you're not using them anywhere else. 

     

    Two more things, if you need to cast the value to BlockState, you're doing BlockStates wrong. Second, everything must be wrapped in a DeferredWorkQueue as everything you're doing is not thread-safe.

    Thanks for the tip! Can you give the updated piece of code though? I'm pretty bad a following tips :P

    Also, that explais the 'null' values. When I go ingame, it says null.

  14. Hello.

    I'm trying to make my Sweet Barry Bushes generate, but now the game crashes on startup.

    Here's the gen code:

    package com.pickleface.survival.world.gen;
    
    import com.google.common.collect.ImmutableSet;
    import com.pickleface.survival.Registry;
    import com.pickleface.survival.Survival;
    import com.pickleface.survival.blocks.BlueberryBush;
    import com.pickleface.survival.blocks.RaspberryBush;
    import net.minecraft.block.BlockState;
    import net.minecraft.block.Blocks;
    import net.minecraft.world.biome.Biome;
    import net.minecraft.world.biome.Biomes;
    import net.minecraft.world.gen.GenerationStage;
    import net.minecraft.world.gen.blockplacer.SimpleBlockPlacer;
    import net.minecraft.world.gen.blockstateprovider.SimpleBlockStateProvider;
    import net.minecraft.world.gen.feature.BlockClusterFeatureConfig;
    import net.minecraft.world.gen.feature.Feature;
    import net.minecraft.world.gen.placement.ChanceConfig;
    import net.minecraft.world.gen.placement.FrequencyConfig;
    import net.minecraft.world.gen.placement.Placement;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
    import net.minecraftforge.registries.ForgeRegistries;
    
    @Mod.EventBusSubscriber(modid = Survival.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
    public class DecorationGen {
        // Get Stuff to Generate
        private static final BlockState BLUEBERRY_BUSH = (BlockState)Registry.BLUEBERRY_BUSH.get().getDefaultState().with(BlueberryBush.AGE, 3);
        private static final BlockState RASPBERRY_BUSH = (BlockState)Registry.RASPBERRY_BUSH.get().getDefaultState().with(RaspberryBush.AGE, 3);
    
        // Make Config With Stuff
        public static final BlockClusterFeatureConfig BLUEBERRY_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(BLUEBERRY_BUSH), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build();
        public static final BlockClusterFeatureConfig RASPBERRY_BUSH_CONFIG = (new BlockClusterFeatureConfig.Builder(new SimpleBlockStateProvider(RASPBERRY_BUSH), SimpleBlockPlacer.field_236447_c_)).tries(64).whitelist(ImmutableSet.of(Blocks.GRASS_BLOCK.getBlock())).func_227317_b_().build();
    
        @SubscribeEvent
        public static void generateDecorations(final FMLCommonSetupEvent event) {
            for (Biome biome : ForgeRegistries.BIOMES) {
                if (biome == Biomes.PLAINS) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(BLUEBERRY_BUSH_CONFIG).withPlacement(Placement.COUNT_HEIGHTMAP_DOUBLE.configure(new FrequencyConfig(1))));
                }
                if (biome == Biomes.SUNFLOWER_PLAINS) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(BLUEBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.BIRCH_FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(12))));
                }
                if (biome == Biomes.FLOWER_FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(6))));
                }
                if (biome == Biomes.DARK_FOREST) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(18))));
                }
                if (biome == Biomes.JUNGLE_EDGE) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(BLUEBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(24))));
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(24))));
                }
                if (biome == Biomes.JUNGLE) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(BLUEBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(24))));
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(24))));
                }
                if (biome == Biomes.MODIFIED_JUNGLE) {
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(BLUEBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(24))));
                    biome.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Feature.RANDOM_PATCH.withConfiguration(RASPBERRY_BUSH_CONFIG).withPlacement(Placement.CHANCE_HEIGHTMAP_DOUBLE.configure(new ChanceConfig(24))));
                }
            }
        }
    }

    Any help is appreciated.

    Thanks.

  15. Hello.

    I have made a sweet berry bush block, and I'm trying to change its drop from Items.SWEET_BERRIES to Registry.BLUEBERRY.get(). For some reason, this isn't working in game.

    Here's my code:

    package com.pickleface.survival.blocks;
    
    import com.pickleface.survival.Registry;
    import net.minecraft.block.*;
    import net.minecraft.block.material.Material;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.IBlockReader;
    
    public class BlueberryBush extends SweetBerryBushBlock {
        public BlueberryBush() {
            super(Block.Properties.create(Material.PLANTS)
                    .tickRandomly()
                    .doesNotBlockMovement()
                    .sound(SoundType.SWEET_BERRY_BUSH)
                    .zeroHardnessAndResistance()
            );
        }
        @Override
        public ItemStack getItem(IBlockReader block, BlockPos pos, BlockState state) {
            return new ItemStack(Registry.BLUEBERRY.get());
        }
    }

    The part that controls its drops is at the Override. Also, I get 2 warnings saying "Not annotated method overrides method annotated with @MethodsReturnNonnullByDefault" and "Not annotated parameters overrides @ParametersNonnullByDefault".

     

    Any help is appreciated. Thanks.

×
×
  • Create New...

Important Information

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