Everything posted by Spring
-
custom Throw Item
Because I have no problem here, but it does not have a model, how can I add a model?
-
custom Throw Item
add this: MinecraftForge.EVENT_BUS.register(this); ModEntityTypes.register(modEventBus); try again?
- custom Throw Item
-
custom Throw Item
When I use summon, there is no Bounding boxes,(F3+B)
- custom Throw Item
-
custom Throw Item
..No, I don’t seem to add a model to it, how do I add it?
- custom Throw Item
- custom Throw Item
-
custom Throw Item
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
-
on TranslationTextComponent append variable
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
-
on TranslationTextComponent append variable
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
-
block break particle has a problem
Yes i found out, he works fine now
-
Unable to cancel event
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));
-
block break particle has a problem
{ "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] } } }
-
Unable to cancel event
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)); } }
-
block break particle has a problem
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); } }
-
Unable to cancel event
no LookAtPlayerGoal class , my forge version : 1.16.5-36.2.2,only LookAtGoal
- Unable to cancel event
-
Unable to cancel event
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?
-
Unable to cancel event
@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 .... } } } } }
-
Unable to cancel event
I used a custom goal, he is no longer attacking me, but he still looks at me
-
Unable to cancel event
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
-
Unable to cancel event
How to replace the target, first removeGoal(), then addGoal()?
-
Unable to cancel event
i dont have TargetGoals ...
-
Unable to cancel event
Yes, but the problem has been bothering me for a long time, I really want to know how to solve this
IPS spam blocked by CleanTalk.