Jump to content

LVUM

Members
  • Posts

    16
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

LVUM's Achievements

Tree Puncher

Tree Puncher (2/8)

4

Reputation

  1. My bad. Armor Stand extends LivingEntity, so there is no problem in getNearestLivingEntity.
  2. Still, how could I find the nearest Armor Standing (a non living entity) ?
  3. Wow, thank you soo much!! I ended up managing to create my mob, register it, render it, create its egg etc etc. I was going to open another thread but since we are here (and the topic fits) I would like to ask how could you find non-living entities. I know you can get the nearest living entity like this: this.mob.level.getNearestEntity(this.mob.level.getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (e) -> {return true;}), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ())); But thats only for living creatures. The mob (Animated Armor) should be a "floating armor" that attacks players if they are close and if not, then return to their armor standing. If its armor standing is destroyed, it should find the nearest armor standing. Also... The armor layer should be "bigger" than the skin, but for some reason (maybe the copy paste from piglins code), mine isnt. public class AnimatedArmorRenderer extends HumanoidMobRenderer<AnimatedArmor, AnimatedArmorModel> { private static final ResourceLocation TEXTURE = new ResourceLocation(Rift.MODID, "textures/entity/animated_armor.png"); public AnimatedArmorRenderer (EntityRendererProvider.Context context) { super(context, new AnimatedArmorModel(context.bakeLayer(AnimatedArmorModel.ANIMATED_ARMOR_LAYER)), 0f); this.addLayer(new HumanoidArmorLayer<>(this, new HumanoidModel(context.bakeLayer(AnimatedArmorModel.ANIMATED_ARMOR_LAYER)), new HumanoidModel(context.bakeLayer(AnimatedArmorModel.ANIMATED_ARMOR_LAYER)))); } @Nonnull @Override public ResourceLocation getTextureLocation (AnimatedArmor entity) { return TEXTURE; } } As I said I dont like asking people for code, but god... I have spent maaaaanyy hours looking for documentation, comparing vanilla code, etc... and not much progress was done. One last question, where did you learn all that? Experience I guess (?)
  4. I was looking all day into minecraft vanilla mobs code, so I could make one myself. My idea is: A mob that disguises itself as an Armor Standing with a full set of armor (being it iron, diamond...), and that if the player is close enough or attacks the "Armor Standing", it starts moving and attacking the player. I ended up with a code much like Endermans code, but still not complete. The lack of detailed documentation of the functions and classes leads up to hours of trying to understand what each class do, what they represent, how do you have to use them etc etc. Anyways, here is what I have: ... public class RiftAnimatedArmor extends Monster implements NeutralMob { private static final EntityDataAccessor<Integer> DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(Bee.class, EntityDataSerializers.INT); private static final UniformInt PERSISTENT_ANGER_TIME = TimeUtil.rangeOfSeconds(20, 39); private UUID persistentAngerTarget; private static final boolean DISGUISED = true; protected int xpReward = 200; public RiftAnimatedArmor(EntityType<? extends RiftAnimatedArmor> entityType, Level level) { super(entityType, level); this.setPathfindingMalus(BlockPathTypes.LAVA, 0); } public static AttributeSupplier.Builder createAttributes() { return Monster.createMonsterAttributes() .add(Attributes.MAX_HEALTH, 33.0D) .add(Attributes.MOVEMENT_SPEED, (double)0.1F) .add(Attributes.ATTACK_DAMAGE, 5) .add(Attributes.FOLLOW_RANGE, 20); } protected void registerGoals() { this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); } protected void addBehaviourGoals() { this.targetSelector.addGoal(2, new HurtByTargetGoal(this)); this.goalSelector.addGoal(2, new MeleeAttackGoal(this, 1.0D, false)); this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Endermite.class, true, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0D)); } public void setTarget(@Nullable LivingEntity entity) { super.setTarget(entity); } boolean CloseToPlayer(Player player) { return player.distanceToSqr(this) <= 3; } public void aiStep() { if (!this.level.isClientSide) { this.updatePersistentAnger((ServerLevel)this.level, true); } super.aiStep(); } @Override protected int getExperienceReward(Player player) { return super.getExperienceReward(player); } // TODO getAmbientSound() // TODO getDeathSound() // TODO getHurtSound() // TODO getStepSound() public boolean doHurtTarget(Entity entity) { boolean flag = entity.hurt(DamageSource.mobAttack(this), (float)((int)this.getAttributeValue(Attributes.ATTACK_DAMAGE))); if (flag) { this.doEnchantDamageEffects(this, entity); if (entity instanceof LivingEntity) { ((LivingEntity) entity).addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 2*20, 0)); } } return flag; } public int getRemainingPersistentAngerTime() { return this.entityData.get(DATA_REMAINING_ANGER_TIME); } public void setRemainingPersistentAngerTime(int time) { this.entityData.set(DATA_REMAINING_ANGER_TIME, time); } @Nullable public UUID getPersistentAngerTarget() { return this.persistentAngerTarget; } public void setPersistentAngerTarget(@Nullable UUID uuid) { this.persistentAngerTarget = uuid; } public void startPersistentAngerTimer() { this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random)); } public class AnimatedArmorUndisguiseIfCloseToPlayer extends Goal { private final RiftAnimatedArmor animatedArmor; @Nullable private LivingEntity target; public AnimatedArmorUndisguiseIfCloseToPlayer(RiftAnimatedArmor animatedArmor) { this.animatedArmor = animatedArmor; } public boolean canUse() { this.target = this.animatedArmor.getTarget(); if (!(this.target instanceof Player)) { return false; } else { return CloseToPlayer((Player)this.target); } } // TODO public void start() { this.animatedArmor.getNavigation().stop(); } } How would I implement this mob? And please if someone knows a good source of documentation please tell me.
  5. Just to be clear, my goal here is not to ask for written code. I started "modding" a week ago, I already made some blocks, items, features and placements... (the very basic stuff). I found McJty tutorials really helpfull in understanding minecraft system, forge library, and how to structure my project. I would like to implement a mob in 1.18.1, but I cant seem to find any documentations or good tutorials on how to approach that... I have been using https://nekoyue.github.io/ documentation most of the time. I would really appreciate some sort of guidance to how mobs are registered, how to create their AI, the conventions of creating a mob, etc...
  6. Solved: protected void registerStatesAndModels() { directionalCross(RiftBlocks.JADE_CLUSTER); directionalCross(RiftBlocks.SMALL_JADE_BUD); directionalCross(RiftBlocks.MEDIUM_JADE_BUD); directionalCross(RiftBlocks.LARGE_JADE_BUD); simpleBlock(RiftBlocks.COMPACT_COAL_ORE); simpleBlock(RiftBlocks.JADE_BLOCK); simpleBlock(RiftBlocks.BUDDING_JADE); } private String name(Block block) { return block.getRegistryName().getPath(); } private void directionalCross(RegistryObject<Block> block) { directionalBlock(block.get(), models().cross(name(block.get()), modLoc("block/" + name(block.get())))); } private void simpleBlock(RegistryObject<Block> block) { simpleBlock(block.get()); }
  7. Thanks, its fixed now. Though I am now struggling to make the jade clusters rotate... any solutions? I know it has to be like amethyst clusters blockstates: { "variants": { "facing=down": { "model": "minecraft:block/amethyst_cluster", "x": 180 }, "facing=east": { "model": "minecraft:block/amethyst_cluster", "x": 90, "y": 90 }, "facing=north": { "model": "minecraft:block/amethyst_cluster", "x": 90 }, "facing=south": { "model": "minecraft:block/amethyst_cluster", "x": 90, "y": 180 }, "facing=up": { "model": "minecraft:block/amethyst_cluster" }, "facing=west": { "model": "minecraft:block/amethyst_cluster", "x": 90, "y": 270 } } } But how do I achieve this in code? Also, sorry for being a noob.
  8. Okey so I solved my problem doing this: simpleBlock(RiftBlocks.JADE_CLUSTER.get(), cross(RiftBlocks.JADE_CLUSTER.get())); And adding this functions in my class: public ModelFile cross(Block block) { return models().cross(name(block), blockTexture(block)); } private String name(Block block) { return block.getRegistryName().getPath(); } Now my problem is the transparency not working...
  9. The thing is, I rather do it in code and generate the json data than create the json by hand.
  10. First of all I am new to modding (started a few days ago) tough I know C, C# and the basics of Java (though is very similar to C#). I am trying to make a custom Geode, a jade geode. I managed to create a CaveFeature, CavePlacement for the geode, and it is being correctly generated. At the time all my blocks states and models are registered with simpleBlock() in my BlockStateProvider class. Example: simpleBlock(RiftBlocks.JADE_BLOCK.get()); [Rift being my mods name and RiftBlocks where I store my mods blocks] The problem is, when I use simpleBlock with my jade cluster png, obviously, it doesnt work. How could I make my jade cluster model look as intended?
  11. I figured out where the error was and now its working. Thanks!
  12. I am sure the problem is the upper 'R' but how can I change it to a lower 'r' ?
  13. I solved one problem but another came out: First I was missing the following code in the server side of DataGeneration datagen.addProvider(new TutRecipes(datagen)); now at least TutRecipes tries to generate the recipes but then when I generate the recipes doing runData I get this error: ... How do I solve this?
  14. Okey so I guess i have to call it inside the DataGeneration class: package com.lv.rift.datagen; import com.lv.rift.Rift; import net.minecraft.data.DataGenerator; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.forge.event.lifecycle.GatherDataEvent; // Registered to the bus @Mod.EventBusSubscriber(modid = Rift.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class DataGeneration { // Receives event when application is 'run' @SubscribeEvent public static void gatherData(GatherDataEvent event) { DataGenerator datagen = event.getGenerator(); if (event.includeServer()) { datagen.addProvider(new TutBlockStates(datagen, event.getExistingFileHelper())); TutBlockTags blockTags = new TutBlockTags(datagen, event.getExistingFileHelper()); datagen.addProvider(blockTags); datagen.addProvider(new TutItemTags(datagen, blockTags, event.getExistingFileHelper())); } if (event.includeClient()) { datagen.addProvider(new TutBlockStates(datagen, event.getExistingFileHelper())); datagen.addProvider(new TutItemModels(datagen, event.getExistingFileHelper())); datagen.addProvider(new TutLanguageProvider(datagen, "en_us")); } } } But where?
  15. Weird... it doesnt generate any recipe at all... Do i have to call this class somewhere else in the project? Also, all my other classes names are highlighted but this one isnt...
×
×
  • Create New...

Important Information

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