-
Posts
12 -
Joined
-
Last visited
Suncurve's Achievements

Tree Puncher (2/8)
0
Reputation
-
Suncurve changed their profile photo
-
I know, but I'm still pretty new with forge. So how do I get the LivingEntity class itself?
-
Ok. Do you know how to get the LivingEntity though? I need it for pathfinding
-
So how would I do this?
-
If it's not clear, what I'm trying to do is detect when the entity spawns, and get the "LivingEntity" from it. Any help? Thanks
-
I'm pretty new to entity modding, and I've written the basic entity code, but for the pathfinding, I need to get the "LivingEntity" entity. How would I go about getting this? public class EntityFarmer extends AgeableMob implements Npc, IAnimatable { private AnimationFactory factory = GeckoLibUtil.createFactory(this); protected long nextPlayerCollisionTime = 0; public static final int TICKS_SECOND = 20; public EntityFarmer(EntityType<? extends AgeableMob> entityType, Level level) { super(entityType, level); } public static AttributeSupplier.Builder setAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.MAX_HEALTH, 20D) .add(Attributes.MOVEMENT_SPEED, 0.6D) .add(Attributes.FOLLOW_RANGE, 100); } public void pathToLocation(BlockPos pos) { } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel p_146743_, AgeableMob p_146744_) { return null; } @NotNull public BlockPos blockPosition() { return new BlockPos(getX(), getY(), getZ()); } @Override public boolean canBeLeashed(Player player) { return false; } } Essentially, in the "pathToLocation" procedure, I need to get the livingEntity entity. Any help? Thanks.
-
Ah yes, I am registering it here: package net.suncurve.truevillagers.entity; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import net.suncurve.truevillagers.TrueVillagers; import net.suncurve.truevillagers.entity.villager.EntityFarmer; public class ModEntityTypes { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, TrueVillagers.MOD_ID); public static final RegistryObject<EntityType<EntityFarmer>> FARMER = ENTITY_TYPES.register("farmer", () -> EntityType.Builder.of(EntityFarmer::new, MobCategory.CREATURE).setShouldReceiveVelocityUpdates(true).setTrackingRange(256).setUpdateInterval(2) .sized(0.6f, 1.8f) .build(new ResourceLocation(TrueVillagers.MOD_ID, "farmer").toString())); public static void register(IEventBus eventBus) { ENTITY_TYPES.register(eventBus); } }
-
I'm trying to create my first entity "Farmer" But minecraft keeps crashing with this: "[Render thread/ERROR] [net.minecraftforge.fml.javafmlmod.FMLModContainer/]: Exception caught during firing event: Registry Object not present: truevillagers:farmer Index: 1 Listeners: 0: NORMAL 1: ASM: class net.suncurve.truevillagers.client.events.ClientEvents entityAttributeEvent(Lnet/minecraftforge/event/entity/EntityAttributeCreationEvent;)V java.lang.NullPointerException: Registry Object not present: truevillagers:farmer at java.base/java.util.Objects.requireNonNull(Objects.java:334) at TRANSFORMER/forge@40.1.0/net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:320) at TRANSFORMER/truevillagers@0.0NONE/net.suncurve.truevillagers.client.events.ClientEvents.entityAttributeEvent(ClientEvents.java:28) " Code in ModEventBusEvents: package net.suncurve.truevillagers.event; import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.suncurve.truevillagers.TrueVillagers; import net.suncurve.truevillagers.entity.ModEntityTypes; import net.suncurve.truevillagers.entity.villager.EntityFarmer; import javax.annotation.Nonnull; @Mod.EventBusSubscriber(modid = TrueVillagers.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class ModEventBusEvents { @SubscribeEvent public static void entityAttributeEvent(EntityAttributeCreationEvent event) { event.put(ModEntityTypes.FARMER.get(), EntityFarmer.setAttributes().build()); } } EntityFarmer Code: package net.suncurve.truevillagers.entity.villager; import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.npc.Npc; import net.minecraft.world.level.Level; import org.jetbrains.annotations.Nullable; import software.bernie.geckolib3.GeckoLib; import software.bernie.geckolib3.core.IAnimatable; import software.bernie.geckolib3.core.PlayState; import software.bernie.geckolib3.core.builder.AnimationBuilder; import software.bernie.geckolib3.core.controller.AnimationController; import software.bernie.geckolib3.core.event.predicate.AnimationEvent; import software.bernie.geckolib3.core.manager.AnimationData; import software.bernie.geckolib3.core.manager.AnimationFactory; import software.bernie.geckolib3.util.GeckoLibUtil; public class EntityFarmer extends AgeableMob implements Npc, IAnimatable { private AnimationFactory factory = GeckoLibUtil.createFactory(this); public EntityFarmer(EntityType<? extends AgeableMob> entityType, Level level) { super(entityType, level); } public static AttributeSupplier.Builder setAttributes() { return LivingEntity.createLivingAttributes() .add(Attributes.MAX_HEALTH, 20D) .add(Attributes.MOVEMENT_SPEED, 0.6D) .add(Attributes.FOLLOW_RANGE, 100); } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel p_146743_, AgeableMob p_146744_) { return null; } private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { if (event.isMoving()) { event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.farmer.walk", true)); return PlayState.CONTINUE; } event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.farmer.idle", true)); return PlayState.CONTINUE; } @Override public void registerControllers(AnimationData data) { data.addAnimationController(new AnimationController(this, "controller", 0, this::predicate)); } @Override public AnimationFactory getFactory() { return this.factory; } protected SoundEvent getHurtSound(DamageSource damageSourceIn) { return SoundEvents.VILLAGER_HURT; } } Init: private void clientSetup(final FMLClientSetupEvent event) { EntityRenderers.register(ModEntityTypes.FARMER.get(), FarmerRenderer::new); TownHallBorderRenderer.INSTANCE = new TownHallBorderRenderer(Minecraft.getInstance()); } I've no idea what's happening here, so some help would be appreciated! Thanks.
-
I started my mod in 1.18.2, I'm not upgrading it. Do you know what's the way to use the iWorldReader then?
-
I'm trying to use the iWorldReader (from "net.minecraft.world.IWorldReader;") in 1.18.2, yet it is somehow non-existent..? Not sure what's happening here. Some help would be appreciated.
-
Hi, I've created a custom block (Called "Town Hall Block") and managed to detect when it's placed (using a setPlacedBy override) I'm still quite new to modding with forge, and essentially, what I'm trying to do is create a region (64 blocks in each direction, with the town hall being the center), and be able to search that region for a specific block. So far, I've got this: (borderDist is an int with a value of 64) @Override public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, @Nullable LivingEntity pPlacer, ItemStack pStack) { if (pLevel.isClientSide()) { System.out.println("Block Placed"); // Calculate Village Borders BlockPos borderNorth = pPos.north(borderDist); BlockPos borderSouth = pPos.south(borderDist); BlockPos borderEast = pPos.east(borderDist); BlockPos borderWest = pPos.west(borderDist); } super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack); } The part I'm struggling with (I've done some research but couldn't find anything) is actually creating that region around the town hall block, and then working out if there's a block of a specific type there, but most importantly, actually working the region out. Does anyone know what's the right way to do this? Thanks.