Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Spring

Members
  • Joined

  • Last visited

Everything posted by Spring

  1. Because I have no problem here, but it does not have a model, how can I add a model?
  2. add this: MinecraftForge.EVENT_BUS.register(this); ModEntityTypes.register(modEventBus); try again?
  3. When I use summon, there is no Bounding boxes,(F3+B)
  4. ..No, I don’t seem to add a model to it, how do I add it?
  5. yes,It executed
  6. .... NO !
  7. Like a snowball but, it has no throwing animation my entity public class FirecrackerEntity extends ProjectileItemEntity { public FirecrackerEntity(EntityType<? extends FirecrackerEntity> entityType, World world) { super(entityType, world); } public FirecrackerEntity(World world, LivingEntity livingEntity) { super(ModEntityTypes.FIRE_CRACKER.get(), livingEntity, world); } @Override protected Item getDefaultItem() { return ModItems.FIRE_CRACKER.get(); } @OnlyIn(Dist.CLIENT) private IParticleData getParticle() { ItemStack itemstack = this.getItemRaw(); return itemstack.isEmpty() ? ParticleTypes.ITEM_SNOWBALL : new ItemParticleData(ParticleTypes.ITEM, itemstack); } @OnlyIn(Dist.CLIENT) @Override public void handleEntityEvent(byte height) { if (height == 3) { IParticleData iparticledata = this.getParticle(); for (int i = 0; i < 8; ++i) { this.level.addParticle(iparticledata, this.getX(), this.getY(), this.getZ(), 0.0D, 0.0D, 0.0D); } } } } my item: public class Firecracker extends Item { public Firecracker() { super(new Properties().tab(GroupDefine.MISC).stacksTo(16)); } @Override public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { ItemStack itemstack = player.getItemInHand(hand); world.playSound(null, player.getX(), player.getY(), player.getZ(), ModSounds.FIRE_CRACKER.get(), SoundCategory.VOICE, 1F, 1F); if (!world.isClientSide) { FirecrackerEntity firecracker = new FirecrackerEntity(world, player); firecracker.setItem(itemstack); firecracker.shootFromRotation(player, player.xRot, player.yRot, 0.0F, 1.5F, 1.0F); world.addFreshEntity(firecracker); } if (!player.abilities.instabuild) { itemstack.shrink(1); } return ActionResult.sidedSuccess(itemstack, world.isClientSide()); } } entity register public static final DeferredRegister<EntityType<?>> ENTITY_TYPE = DeferredRegister.create(ForgeRegistries.ENTITIES, ApplicationConstants.MOD_ID); public static final RegistryObject<EntityType<FirecrackerEntity>> FIRE_CRACKER = ENTITY_TYPE.register( "fire_cracker", () -> EntityType.Builder.<FirecrackerEntity>of(FirecrackerEntity::new, EntityClassification.MISC).sized(0.5f, 0.5f) .build(new ResourceLocation(ApplicationConstants.MOD_ID, "fire_cracker").toString())); public static void register(IEventBus bus) { ENTITY_TYPE.register(bus); } my entity class . It doesn't seem to be working, how can I make it run? look: https://error-1254387167.cos.ap-chengdu.myqcloud.com/20211225/2021-12-25-18-24-35.avi
  8. This is my language file I also have a custom variable, I want to splice it to the back of the language file to make it look like this: Growth progress: 20 "tooltip.chinacraft.silk_worm.schedule": "§aGrowth progress: ", @Override public void appendHoverText(ItemStack itemStack, @Nullable World world, List<ITextComponent> textComponents, ITooltipFlag tipFlag) { if (itemStack.getTag() != null) { textComponents.add(new TranslationTextComponent("tooltip.chinacraft.silk_worm.schedule")); } } I am curious how it is implemented in the code. Or do I need to implement it in the language file? I use translation software, if you don’t understand, I’m sorry
  9. i try: @Override @OnlyIn(Dist.CLIENT) public void appendHoverText(ItemStack itemStack, @Nullable World world, List<ITextComponent> textComponents, ITooltipFlag tipFlag) { if (itemStack.getTag() != null) { textComponents.add(new TranslationTextComponent("tooltip.chinacraft.silk_worm.schedule",10)); } } No effect, he didn't append variables behind mine
  10. Yes i found out, he works fine now
  11. this ? this.goalSelector.addGoal(8, new LookAtGoal(this, PlayerEntity.class, 8.0F)); How can I delete it? I have tried a lot, but there is no way to delete it. I use the removeGoal method This is the source code of removeGoal. When EntityJoinWorldEvent is called, isRunning is false, so I don’t understand how to use it now public void removeGoal(Goal p_85156_1_) { this.availableGoals.stream().filter((p_220882_1_) -> { return p_220882_1_.getGoal() == p_85156_1_; }).filter(PrioritizedGoal::isRunning).forEach(PrioritizedGoal::stop); this.availableGoals.removeIf((p_220884_1_) -> { return p_220884_1_.getGoal() == p_85156_1_; }); } I use it like this: targetSelector.removeGoal(new LookAtGoal(mob, PlayerEntity.class, 8.0F));
  12. { "credit": "Made with Blockbench", "textures": { "0": "chinacraft:models/blocks/lantern_festival_lanterns" }, "elements": [ { "from": [5.5, 0, 5.5], "to": [10.5, 1, 10.5], "faces": { "north": {"uv": [0, 0, 5, 5], "texture": "#0"}, "east": {"uv": [0, 0, 5, 5], "texture": "#0"}, "south": {"uv": [0, 0, 5, 5], "texture": "#0"}, "west": {"uv": [0, 0, 5, 5], "texture": "#0"}, "up": {"uv": [0, 0, 5, 5], "texture": "#0"}, "down": {"uv": [0, 0, 5, 5], "texture": "#0"} } }, { "from": [5.5, 15, 5.5], "to": [10.5, 16, 10.5], "faces": { "north": {"uv": [0, 0, 5, 1], "texture": "#0"}, "east": {"uv": [0, 0, 5, 1], "texture": "#0"}, "south": {"uv": [0, 0, 5, 1], "texture": "#0"}, "west": {"uv": [0, 0, 5, 1], "texture": "#0"}, "up": {"uv": [0, 0, 5, 1], "texture": "#0"}, "down": {"uv": [0, 0, 5, 1], "texture": "#0"} } }, { "from": [4.5, 1, 4.5], "to": [11.5, 1.5, 11.5], "faces": { "north": {"uv": [9, 14, 16, 15], "texture": "#0"}, "east": {"uv": [9, 14, 16, 15], "texture": "#0"}, "south": {"uv": [9, 14, 16, 15], "texture": "#0"}, "west": {"uv": [9, 14, 16, 15], "texture": "#0"}, "up": {"uv": [9, 14, 16, 15], "texture": "#0"}, "down": {"uv": [9, 14, 16, 15], "texture": "#0"} } }, { "from": [4.5, 14.5, 4.5], "to": [11.5, 15, 11.5], "faces": { "north": {"uv": [9, 1, 16, 2.5], "texture": "#0"}, "east": {"uv": [9, 1, 16, 2.5], "texture": "#0"}, "south": {"uv": [9, 1, 16, 2.5], "texture": "#0"}, "west": {"uv": [9, 1, 16, 2.5], "texture": "#0"}, "up": {"uv": [9, 1, 16, 2.5], "texture": "#0"}, "down": {"uv": [9, 1, 16, 2.5], "texture": "#0"} } }, { "from": [4, 1.5, 4], "to": [12, 2, 12], "faces": { "north": {"uv": [9, 14, 16, 15.5], "texture": "#0"}, "east": {"uv": [9, 14, 16, 15.5], "texture": "#0"}, "south": {"uv": [9, 14, 16, 15.5], "texture": "#0"}, "west": {"uv": [9, 14, 16, 15.5], "texture": "#0"}, "up": {"uv": [9, 14, 16, 15.5], "texture": "#0"}, "down": {"uv": [9, 14, 16, 15.5], "texture": "#0"} } }, { "from": [4, 14, 4], "to": [12, 14.5, 12], "faces": { "north": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "east": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "south": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "west": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "up": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "down": {"uv": [9, 2, 16, 3.5], "texture": "#0"} } }, { "from": [3.5, 2, 3.5], "to": [12.5, 2.5, 12.5], "faces": { "north": {"uv": [9, 13, 16, 14.5], "texture": "#0"}, "east": {"uv": [9, 13, 16, 14.5], "texture": "#0"}, "south": {"uv": [9, 13, 16, 14.5], "texture": "#0"}, "west": {"uv": [9, 13, 16, 14.5], "texture": "#0"}, "up": {"uv": [9, 13, 16, 14.5], "texture": "#0"}, "down": {"uv": [9, 13, 16, 14.5], "texture": "#0"} } }, { "from": [3.5, 13.5, 3.5], "to": [12.5, 14, 12.5], "faces": { "north": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "east": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "south": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "west": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "up": {"uv": [9, 2, 16, 3.5], "texture": "#0"}, "down": {"uv": [9, 2, 16, 3.5], "texture": "#0"} } }, { "from": [3, 2.5, 3], "to": [13, 13.5, 13], "faces": { "north": {"uv": [9, 2, 16, 14], "texture": "#0"}, "east": {"uv": [9, 2, 16, 14], "texture": "#0"}, "south": {"uv": [9, 2, 16, 14], "texture": "#0"}, "west": {"uv": [9, 2, 16, 14], "texture": "#0"}, "up": {"uv": [9, 2, 16, 14], "texture": "#0"}, "down": {"uv": [9, 2, 16, 14], "texture": "#0"} } } ], "display": { "thirdperson_righthand": { "rotation": [71, 0, 0], "scale": [0.55, 0.55, 0.55] }, "thirdperson_lefthand": { "rotation": [71, 0, 0], "scale": [0.55, 0.55, 0.55] }, "firstperson_righthand": { "translation": [0, 3.25, 0], "scale": [0.55, 0.55, 0.55] }, "firstperson_lefthand": { "translation": [0, 3.25, 0], "scale": [0.55, 0.55, 0.55] }, "ground": { "rotation": [90, 0, 0], "translation": [0, -2, 0], "scale": [0.49, 0.49, 0.49] }, "gui": { "rotation": [30, 30, 0], "scale": [0.75, 0.75, 0.75] }, "head": { "translation": [0, 14.5, 0] } } }
  13. What I do now is to extend LootAtGoal, then add my custom LootAtGoal to the monster, and then override the tick method, but the parent method is still called. So i don't understand, what to do I'm using translation, if you understand, I'm sorry my custom LookAtGoal class: public class MonsterLookAtGoal extends LookAtGoal { public MonsterLookAtGoal(MobEntity entity, Class<? extends LivingEntity> livingEntity, float lookDistance) { super(entity, livingEntity, lookDistance); } @Override public void tick() { } } caller: @SubscribeEvent public static void onEntityJoinWorldEvent(final EntityJoinWorldEvent event) { Entity entity = event.getEntity(); if (entity.isAlive() && entity instanceof MobEntity) { MobEntity mobEntity = (MobEntity) entity; GoalSelector targetSelector = mobEntity.targetSelector; targetSelector.addGoal(1, new MonsterAttackGoal(mobEntity, false)); targetSelector.addGoal(1, new MonsterLookAtGoal(mobEntity, PlayerEntity.class, 8F)); } }
  14. public class LanternFestivalLanterns extends HorizontalBlock { private final static VoxelShape SHAPES_N = Stream.of( Block.box(3, 2.5, 3, 13, 13.5, 13), Block.box(5.5, 0, 5.5, 10.5, 1, 10.5), Block.box(5.5, 15, 5.5, 10.5, 16, 10.5), Block.box(4.5, 1, 4.5, 11.5, 1.5, 11.5), Block.box(4.5, 14.5, 4.5, 11.5, 15, 11.5), Block.box(4, 1.5, 4, 12, 2, 12), Block.box(4, 14, 4, 12, 14.5, 12), Block.box(3.5, 2, 3.5, 12.5, 2.5, 12.5), Block.box(3.5, 13.5, 3.5, 12.5, 14, 12.5) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); private final static VoxelShape SHAPES_W = Stream.of( Block.box(3, 2.5, 3, 13, 13.5, 13), Block.box(5.5, 0, 5.5, 10.5, 1, 10.5), Block.box(5.5, 15, 5.5, 10.5, 16, 10.5), Block.box(4.5, 1, 4.5, 11.5, 1.5, 11.5), Block.box(4.5, 14.5, 4.5, 11.5, 15, 11.5), Block.box(4, 1.5, 4, 12, 2, 12), Block.box(4, 14, 4, 12, 14.5, 12), Block.box(3.5, 2, 3.5, 12.5, 2.5, 12.5), Block.box(3.5, 13.5, 3.5, 12.5, 14, 12.5) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); private final static VoxelShape SHAPES_S = Stream.of( Block.box(3, 2.5, 3, 13, 13.5, 13), Block.box(5.5, 0, 5.5, 10.5, 1, 10.5), Block.box(5.5, 15, 5.5, 10.5, 16, 10.5), Block.box(4.5, 1, 4.5, 11.5, 1.5, 11.5), Block.box(4.5, 14.5, 4.5, 11.5, 15, 11.5), Block.box(4, 1.5, 4, 12, 2, 12), Block.box(4, 14, 4, 12, 14.5, 12), Block.box(3.5, 2, 3.5, 12.5, 2.5, 12.5), Block.box(3.5, 13.5, 3.5, 12.5, 14, 12.5) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); private final static VoxelShape SHAPES_E = Stream.of( Block.box(3, 2.5, 3, 13, 13.5, 13), Block.box(5.5, 0, 5.5, 10.5, 1, 10.5), Block.box(5.5, 15, 5.5, 10.5, 16, 10.5), Block.box(4.5, 1, 4.5, 11.5, 1.5, 11.5), Block.box(4.5, 14.5, 4.5, 11.5, 15, 11.5), Block.box(4, 1.5, 4, 12, 2, 12), Block.box(4, 14, 4, 12, 14.5, 12), Block.box(3.5, 2, 3.5, 12.5, 2.5, 12.5), Block.box(3.5, 13.5, 3.5, 12.5, 14, 12.5) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); public LanternFestivalLanterns() { super(Properties.copy(Blocks.LANTERN)); } @Override public VoxelShape getShape(BlockState state, IBlockReader reader, BlockPos pos, ISelectionContext context) { Direction direction = state.getValue(FACING); switch (direction) { case NORTH: return SHAPES_N; case SOUTH: return SHAPES_S; case EAST: return SHAPES_E; case WEST: return SHAPES_W; default: return SHAPES_N; } } @Override public BlockState rotate(BlockState blockState, Rotation rotation) { return blockState.setValue(FACING, rotation.rotate(blockState.getValue(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirror) { return state.rotate(mirror.getRotation(state.getValue(FACING))); } @Override protected void createBlockStateDefinition(@Nonnull StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING); } }
  15. no LookAtPlayerGoal class , my forge version : 1.16.5-36.2.2,only LookAtGoal
  16. This is useful, but not complete. I stand in front of the monster and sometimes look at me. Does the MonsterCustomLookGoal method need to be retained, or is it to be deleted?
  17. @SubscribeEvent public static void onEntityJoinWorldEvent(final EntityJoinWorldEvent event) { Entity entity = event.getEntity(); if (entity.isAlive() && entity instanceof MonsterEntity) { MonsterEntity monsterEntity = (MonsterEntity) entity; GoalSelector targetSelector = monsterEntity.targetSelector; GoalSelector goalSelector = monsterEntity.goalSelector; targetSelector.addGoal(1, new MonsterCustomGoal(monsterEntity, false)); goalSelector.addGoal(2, new MonsterCustomGoal.MonsterCustomLookGoal(monsterEntity, PlayerEntity.class, 8.0F, 0)); } } public class MonsterCustomGoal extends TargetGoal { public MonsterCustomGoal(MobEntity entity, boolean mustSee) { super(entity, mustSee); } @Override public boolean canUse() { return true; } @Override public void tick() { LivingEntity target = mob.getTarget(); if (target instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) target; if (SilkNightArmor.invalid(player)) { List<MonsterEntity> monsterEntities = SilkNightArmor.getNearbyEntities(player); for (MonsterEntity monster : monsterEntities) { if (monster.getTarget() != null && monster.getTarget().getUUID().equals(player.getUUID())) { monster.setTarget(null); } } } } } /** * need this class ? */ public static class MonsterCustomLookGoal extends LookAtGoal { public MonsterCustomLookGoal(MobEntity entity, Class<? extends LivingEntity> livingEntity, float lookDistance , float probability) { super(entity, livingEntity, lookDistance, probability); } @Override public void tick() { if (lookAt != null && lookAt.isAlive() && lookAt instanceof PlayerEntity) { PlayerEntity player = (PlayerEntity) lookAt; System.out.println(!SilkNightArmor.invalid(player)); if (SilkNightArmor.invalid(player)) { //dont not look me .... } } } } }
  18. I used a custom goal, he is no longer attacking me, but he still looks at me
  19. hello, I tried to do it like this, but it doesn't work, why? @SubscribeEvent public static void onEntityJoinWorldEvent(final EntityJoinWorldEvent event) { Entity entity = event.getEntity(); if (entity.isAlive() && entity instanceof MonsterEntity) { MonsterEntity monsterEntity = (MonsterEntity) entity; GoalSelector targetSelector = monsterEntity.targetSelector; targetSelector.addGoal(1, new MonsterCustomGoal(monsterEntity)); } } public class MonsterCustomGoal extends Goal { private final MobEntity entity; public MonsterCustomGoal(MobEntity entity) { this.entity = entity; } @Override public boolean canUse() { return false; } @Override public void tick() { LivingEntity target = entity.getTarget(); if (target instanceof PlayerEntity) { entity.setTarget(null); } } } tick not execute
  20. How to replace the target, first removeGoal(), then addGoal()?
  21. i dont have TargetGoals ...
  22. Yes, but the problem has been bothering me for a long time, I really want to know how to solve this

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.