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

Davide_24

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Davide_24

  1. So it does always return true! The weird part is that it is inconsisten in when it works. restarting without code changes just makes it randomly work (only rarely)????
  2. So the isValidTarget() Method is firing but nothing else. The cats won't move to the target block. (temporarily set to slab blocks). I found that the tick() method should also fire while doing some research but it doesn't. public class CatLieOnCatnipGoal extends MoveToBlockGoal { private final Cat cat; private static final Logger LOGGER = LogManager.getLogger(); public CatLieOnCatnipGoal(Cat cat, double p_25136_, int p_25137_) { super(cat, p_25136_, p_25137_, 6); this.cat = cat; this.verticalSearchStart = -2; this.setFlags(EnumSet.of(Goal.Flag.JUMP, Goal.Flag.MOVE)); } @Override public boolean canUse() { return !this.cat.isOrderedToSit() && !this.cat.isLying() && super.canUse(); } @Override public void start() { LOGGER.info("CAT LIE ON CATNIP GOAL STARTED"); super.start(); this.cat.setInSittingPose(false); } @Override protected int nextStartTick(PathfinderMob mob) { return 40; } @Override public void stop() { LOGGER.info("STOPPED"); super.stop(); this.cat.setLying(false); } @Override public void tick() { LOGGER.info("CAT LIE ON CATNIP GOAL TICK!"); super.tick(); this.cat.setInSittingPose(false); if (!this.isReachedTarget()) { this.cat.setLying(false); } else if (!this.cat.isLying()) { this.cat.setLying(true); } } @Override protected boolean isValidTarget(LevelReader levelReader, BlockPos pos) { LOGGER.info("CAT LIE ON CATNIP GOAL SETTING TARGET!"); return levelReader.isEmptyBlock(pos.above()) && levelReader.getBlockState(pos).is(BlockTags.SLABS); } }
  3. So I tried this and it won't work. This is the code: public class events { private static final Logger LOGGER = LogManager.getLogger(); @SubscribeEvent public static void EntityJoined(EntityJoinWorldEvent event) { LOGGER.info("Entity Joined World!"); Entity entity = event.getEntity(); if (entity instanceof Cat) { Cat cat = (Cat) entity; ((Cat) event.getEntity()).goalSelector.addGoal(7, new CatLieOnCatnipGoal(cat, 1.1D, 8)); } } } The event does fire which is confirmed by the logger. EDIT: Sorry for the late reply!
  4. So I am making a catnip carpet type block, and I want to make cats go to it and lie on it. I have already made the code for the AI goal itself. Only issue is adding that AI goal to the cat. I couldn't find anything while searching and now I want to ask here. The only way that comes to my mind is changing the registerGoals() method in Cat.java, but that seems like a bad idea.
  5. Thank you so much! Did not realize that I forgot to make the method static! Silly mistake
  6. So I am porting code from 1.17 to 1.18 and there is a problem. When you throw / spawn the projectile entity it crashes the game. The full log can be found here: https://www.toptal.com/developers/hastebin/vifidaxibo.yaml I do not know why this is happening. Here is the class where I register the renderers: @Mod.EventBusSubscriber(modid = Catty.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class ClientEventBusSubscriber { private static final Logger LOGGER = LogManager.getLogger(); //@SubscribeEvent OLD //public static void clientSetup(FMLClientSetupEvent event) { // ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); // // LOGGER.info("Entity renderers registered!"); //} @SubscribeEvent public void RegisterEntityRenderers(EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(EntityInit.PUSHEEN_PROJECTILE.get(), ThrownItemRenderer::new); LOGGER.info("Catty entity renderers registered!"); } } Here is the PusheenEntity Class: public class PusheenEntity extends ThrowableItemProjectile { public PusheenEntity(EntityType<? extends PusheenEntity> type, Level world) { super(type, world); } public PusheenEntity(Level world, LivingEntity entity) { super(EntityInit.PUSHEEN_PROJECTILE.get(), entity, world); } public PusheenEntity(Level world, double x, double y, double z) { super(EntityInit.PUSHEEN_PROJECTILE.get(), x, y, z, world); } @ParametersAreNonnullByDefault @Override protected void onHit(HitResult rtResult) { super.onHit(rtResult); Explosion.BlockInteraction explosion$mode = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.level, this.getOwner()) ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.NONE; this.level.explode(this, this.getX(), this.getY(), this.getZ(), 2.0F, explosion$mode); if (!this.level.isClientSide) { this.discard(); } } @Nonnull @Override protected Item getDefaultItem() { return ItemInit.PUSHEEN.get().asItem(); } @Nonnull @Override public Packet<?> getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } } The entity is registered here: public class EntityInit { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, Catty.MOD_ID); public static final RegistryObject<EntityType<PusheenEntity>> PUSHEEN_PROJECTILE = ENTITY_TYPES.register("pusheen_projectile", () -> EntityType.Builder.<PusheenEntity>of(PusheenEntity::new, MobCategory.MISC).sized(0.25F, 0.25F).clientTrackingRange(4).updateInterval(10).build("pusheen_projectile")); } Any help will be appreciated
  7. I am new at modding and I don't know how to use that. now I am extremely confused
  8. So I have been trying to make a flammable wool like block. Everything works except flammability. I want to make it slightly more flammable than wool but I don't know how I would do that. I did not find anything on the internet. Help will be appreciated!
×
×
  • Create New...

Important Information

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