Everything posted by btuh
-
[1.20.1] How do I modify Minecraft classes when my mod is loading
Okay but I still need AbstractChicken to be my Chicken's superclass
-
[1.20.1] How do I modify Minecraft classes when my mod is loading
Okay, I have one more question. For example, someone plays a world without this mod. Then, this user loads the world with my mod. And when it happens, all vanilla chickens should be automatically replaced with my chickens.
-
[1.20.1] How do I modify Minecraft classes when my mod is loading
Okay I think I'll just use the EntityJoinLevelEvent
-
[1.20.1] How do I modify Minecraft classes when my mod is loading
AbstrcatChicken should be a superclass of the minecraft's Chicken class, my Rooster class, and my Chick class. Here it is (unfinished yet): 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.animal.Animal; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public abstract class AbstractChicken extends Animal { protected AbstractChicken(EntityType<? extends AbstractChicken> entityType, Level world) { super(entityType, world); } protected SoundEvent getAmbientSound() { return SoundEvents.CHICKEN_AMBIENT; } protected SoundEvent getHurtSound(@NotNull DamageSource damageSource) { return SoundEvents.CHICKEN_HURT; } protected SoundEvent getDeathSound() { return SoundEvents.CHICKEN_DEATH; } @Nullable @Override public AgeableMob getBreedOffspring(ServerLevel level, AgeableMob mobBredWith) { // AbstractChicken's subclasses should also return null in this method return null; } @Override public abstract boolean isBaby(); // for Chicken and Rooster it should be false, and for Chick it should be true @Override public abstract boolean canMate(@NotNull Animal other); // Chick will always return false, and Chicken can only mate with Rooster, and vice versa @Override public abstract void setBaby(boolean newBoolean); // should be overriden by Chick to become a chicken or a rooster public abstract boolean isBoy(); // Rooster returns true, Chicken - false, Chick - determines on his NBT public void setBoy(boolean boy) { throw new UnsupportedOperationException(); // Chick shuold override it } } Also I want to add some NBT to both of these classes (Chicken and EggItem), how do I do that?
-
[1.20.1] How do I modify Minecraft classes when my mod is loading
I'm creating a mod that should modify Chicken class and EggItem class. Chicken class should extend my AbstractChicken class and EggItem shouldn't be throwable anymore, and extend the BlockItem class. Is it possible to make? And yeah, I've already tried mixins
-
Detect when player right clicks entity [Solved]
Yes, it is. I found out how to do it. (for Forge 1.20.1) Add this to main class constructor: // ... MinecraftForge.EVENT_BUS.<PlayerInteractEvent.EntityInteract>addListener(e -> { Player playerWhoUsed = e.getEntity(); ItemStack usedItemStack = e.getItemStack(); Entity entityThatWasClicked = e.getTarget(); if (usedItemStack.getItem() instanceof YourItem item) { // your code... e.setCancelled(true); // you can remove this if you want to continue interaction } } // ...
-
Detect when player right clicks entity [Solved]
Is it possible if it's not?
-
[1.20.1] Custom arrow texture isn't rendering correctly
Okay I just made it like in a LivingEntityRenderer, but now the texture is misplaced btuh
-
[1.20.1] Custom arrow texture isn't rendering correctly
Please don't tell that override render() method is the only solution...
-
[1.20.1] Custom arrow texture isn't rendering correctly
Okay, now my arrow uses the correct texture but still doesn't render correctly Arrow code import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import org.jetbrains.annotations.NotNull; import java.util.Objects; public class TntArrow extends AbstractArrow { private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(TntArrow.class, EntityDataSerializers.INT); public TntArrow(EntityType<? extends TntArrow> entityType, Level level) { super(entityType, level); } public int getFuse() { return entityData.get(DATA_FUSE_ID); } public void setFuse(int fuse) { this.entityData.set(DATA_FUSE_ID, fuse); } public TntArrow(Level level, LivingEntity owner) { super(_Entities.TNT_ARROW.get(), owner, level); } @Override protected void onHitEntity(@NotNull EntityHitResult result) { super.onHitEntity(result); if (result.getEntity() instanceof final Player player && player.isCreative()) return; var tnt = Objects.requireNonNull(EntityType.TNT.create(result.getEntity().level())); tnt.setPos(result.getLocation().get(Direction.Axis.X), result.getLocation().get(Direction.Axis.Y), result.getLocation().get(Direction.Axis.Z)); tnt.setFuse(0); tnt.tick(); discard(); } @Override protected @NotNull ItemStack getPickupItem() { return new ItemStack(_Items.TNT_ARROW_ITEM.get()); // actually, can't be reached, cause arrow explodes // when hits the ground } @Override public void addAdditionalSaveData(@NotNull CompoundTag tag) { super.addAdditionalSaveData(tag); tag.putInt("Fuse", getFuse()); } @Override public void readAdditionalSaveData(@NotNull CompoundTag tag) { super.readAdditionalSaveData(tag); if (tag.contains("Fuse")) { setFuse(tag.getInt("Fuse")); } else { setFuse(80); } } @Override public void defineSynchedData() { super.defineSynchedData(); entityData.define(DATA_FUSE_ID, 80); } @Override protected void onHitBlock(@NotNull BlockHitResult result) { super.onHitBlock(result); var tnt = Objects.requireNonNull(EntityType.TNT.create(level())); tnt.setPos(result.getLocation().with(Direction.Axis.Y, result.getLocation().y + 1)); tnt.setFuse(0); tnt.tick(); discard(); } @Override public void tick() { super.tick(); int fuse = getFuse(); setFuse(--fuse); if (fuse <= 0) { discard(); if(!level().isClientSide) { var tnt = Objects.requireNonNull(EntityType.TNT.create(level())); tnt.setPos(getX(), getY(), getZ()); tnt.setFuse(0); tnt.tick(); } } else { updateInWaterStateAndDoFluidPushing(); if (level().isClientSide) { level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D); } } } } Arrow item code import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ArrowItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; import static net.minecraft.world.item.enchantment.Enchantments.INFINITY_ARROWS; public class TntArrowItem extends ArrowItem { public TntArrowItem(Properties properties) { super(properties); } @Override @NotNull public AbstractArrow createArrow(@NotNull Level level, @NotNull ItemStack stack, @NotNull LivingEntity livingEntity) { return new TntArrow(level, livingEntity); } public boolean isInfinite(@NotNull ItemStack stack, @NotNull ItemStack bow, @NotNull Player player) { return EnchantmentHelper.getTagEnchantmentLevel(INFINITY_ARROWS, bow) > 0; } } Arrow renderer code package ru.fokinatorr.moarrows.tnt_arrow.renderer; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ArrowRenderer; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.RenderLayerParent; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import ru.fokinatorr.moarrows.Main; import ru.fokinatorr.moarrows.tnt_arrow.TntArrow; import ru.fokinatorr.moarrows.tnt_arrow.model.TntArrowModel; public class TntArrowRenderer extends ArrowRenderer<TntArrow> implements RenderLayerParent<TntArrow, TntArrowModel> { @NotNull private static final ResourceLocation TEXTURE = new ResourceLocation(Main.MOD_ID, "textures/entity/projectiles/tnt_arrow.png"); @NotNull private final TntArrowModel model; public TntArrowRenderer(@NotNull EntityRendererProvider.Context ctx) { super(ctx); model = new TntArrowModel(ctx.bakeLayer(TntArrowModel.LAYER_LOCATION)); } @Override public @NotNull TntArrowModel getModel() { return model; } @Override @NotNull public ResourceLocation getTextureLocation(@Nullable TntArrow arrow) { return TEXTURE; } } Arrow model code // Made with Blockbench 4.8.3 // Exported for Minecraft version 1.17 or later with Mojang mappings // Paste this class into your mod and generate all required imports import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.geom.*; import net.minecraft.client.model.geom.builders.*; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; public class TntArrowModel extends EntityModel<TntArrow> { // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation( new ResourceLocation(Main.MOD_ID, "tnt_arrow"), "main"); private final ModelPart arrow; private final ModelPart tnt; public TntArrowModel(ModelPart root) { this.arrow = root.getChild("arrow"); this.tnt = root.getChild("bb_main"); } public static LayerDefinition createBodyLayer() { MeshDefinition mesh = new MeshDefinition(); PartDefinition root = mesh.getRoot(); PartDefinition arrow = root.addOrReplaceChild("arrow", CubeListBuilder.create().texOffs(0, 2) .addBox(-6.0F, 0.0F, -1.0F, 12.0F, 0.0F, 2.0F, new CubeDeformation(0.0F)) .texOffs(0, 2) .addBox(5.5F, -1.0F, -1.0F, 0.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 20.0F, 0.0F)); arrow.addOrReplaceChild("cube_r1", CubeListBuilder.create().texOffs(0, 0) .addBox(-6.0F, 0.0F, -1.0F, 12.0F, 0.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, -1.5708F, 0.0F, 0.0F)); root.addOrReplaceChild("bb_main", CubeListBuilder.create().texOffs(0, 4) .addBox(-2.0F, -6.0F, -2.0F, 4.0F, 4.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); return LayerDefinition.create(mesh, 32, 32); } @Override public void setupAnim(@NotNull TntArrow entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { } @Override public void renderToBuffer(@NotNull PoseStack poseStack, @NotNull VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { arrow.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); tnt.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); } } ClientModEvents import com.mojang.logging.LogUtils; import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import org.slf4j.Logger; @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public final class ClientModEvents { private static final Logger LOGGER = LogUtils.getLogger(); @SubscribeEvent public static void registerRenderers(EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(_Entities.TNT_ARROW.get(), TntArrowRenderer::new); } @SubscribeEvent public static void registerLayerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) { event.registerLayerDefinition(TntArrowModel.LAYER_LOCATION, TntArrowModel::createBodyLayer); } @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { LOGGER.info("Client mode setup"); LOGGER.info("Username {}", Minecraft.getInstance().getUser().getName()); } } _Entities import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class _Entities { public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, Main.MOD_ID); public static final RegistryObject<EntityType<TntArrow>> TNT_ARROW = ENTITIES.register("tnt_arrow", () -> EntityType.Builder.<TntArrow>of(TntArrow::new, MobCategory.MISC) .sized(.5f, .5f) .clientTrackingRange(4) .updateInterval(20) .build(new ResourceLocation(Main.MOD_ID, "tnt_arrow").toString())); private _Entities() {} } I think I should use the model someway, but I don't know how (((
-
[1.20.1] How to add your own texture for arrow
Now I have the correct texture, but it doesn't render correctly
-
[1.20.1] How to add your own texture for arrow
hi?
-
[1.20.1] How to add your own texture for arrow
Okay, but I still don't know how to connect the renderer and model
-
[1.20.1] How to add your own texture for arrow
Maybe I should extend AbstractArrow class instead of Arrow class like the SpectralArrow class does?
-
[1.20.1] How to add your own texture for arrow
I made some experiments and I saw that only spectral arrow spawns with id "minecraft:spectral_arrow". Every other arrow, including my, spawns with id "minecraft:arrow". Is it possible to fix it someway?
-
How to add NBT to your entity
Topic closed. I solved it like this: @Override public void addAdditionalSaveData(@NotNull CompoundTag tag) { super.addAdditionalSaveData(tag); tag.putInt("Fuse", getFuse()); } @Override public void readAdditionalSaveData(@NotNull CompoundTag tag) { super.readAdditionalSaveData(tag); if (tag.contains("Fuse")) { setFuse(tag.getInt("Fuse")); } else { setFuse(80); } }
-
[1.20.1] How to add your own texture for arrow
Ok, what exactly should I override?
-
How to add NBT to your entity
I have a TNT arrow, and it should have a "Fuse" NBT-tag. I already tried that: @Override public CompoundTag serializeNBT() CompoundTag tag = super.serializeNBT(); tag.putInt("Fuse", getFuse()); return tag; } @Override public void deserializeNBT(CompoundTag tag) { super.deserializeNBT(tag); setFuse(tag.getInt("Fuse")); } but it didn't help
-
[1.20.1] How to add your own texture for arrow
I'm creating an arrow which, for some reason, uses vanilla texture, not the one that I want it to use. Arrow code import net.minecraft.core.Direction; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.*; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.TraceableEntity; import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import org.jetbrains.annotations.NotNull; import java.util.Objects; public class TntArrow extends Arrow implements TraceableEntity { private static final EntityDataAccessor<Integer> DATA_FUSE_ID = SynchedEntityData.defineId(TntArrow.class, EntityDataSerializers.INT); public TntArrow(EntityType<? extends TntArrow> entityType, Level level) { super(entityType, level); } public int getFuse() { return entityData.get(DATA_FUSE_ID); } public void setFuse(int fuse) { this.entityData.set(DATA_FUSE_ID, fuse); } public TntArrow(Level p_36866_, LivingEntity p_36867_) { super(p_36866_, p_36867_); } @Override protected void onHitEntity(@NotNull EntityHitResult result) { super.onHitEntity(result); var tnt = Objects.requireNonNull(EntityType.TNT.create(result.getEntity().level())); tnt.setPos(result.getLocation().get(Direction.Axis.X), result.getLocation().get(Direction.Axis.Y), result.getLocation().get(Direction.Axis.Z)); tnt.setFuse(0); tnt.tick(); } @Override public CompoundTag serializeNBT() { CompoundTag tag = super.serializeNBT(); tag.putInt("Fuse", getFuse()); return tag; } @Override public void deserializeNBT(CompoundTag tag) { super.deserializeNBT(tag); setFuse(tag.getInt("Fuse")); } @Override public void defineSynchedData() { super.defineSynchedData(); entityData.define(DATA_FUSE_ID, 80); } @Override protected void onHitBlock(@NotNull BlockHitResult result) { super.onHitBlock(result); var tnt = Objects.requireNonNull(EntityType.TNT.create(level())); tnt.setPos(result.getLocation().with(Direction.Axis.Y, result.getLocation().y + 1)); tnt.setFuse(0); tnt.tick(); discard(); } @Override public void tick() { super.tick(); int fuse = getFuse(); setFuse(--fuse); if (fuse <= 0) { discard(); if(!level().isClientSide) { var tnt = Objects.requireNonNull(EntityType.TNT.create(level())); tnt.setPos(getX(), getY(), getZ()); tnt.setFuse(0); tnt.tick(); } } else { updateInWaterStateAndDoFluidPushing(); if (level().isClientSide) { level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D); } } } } Arrow item code import com.mojang.logging.LogUtils; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ArrowItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import static net.minecraft.world.item.enchantment.Enchantments.INFINITY_ARROWS; public class TntArrowItem extends ArrowItem { private static final Logger LOGGER = LogUtils.getLogger(); public TntArrowItem(Properties properties) { super(properties); } @Override @NotNull public AbstractArrow createArrow(@NotNull Level level, @NotNull ItemStack stack, @NotNull LivingEntity livingEntity) { LOGGER.info("TntArrow creation"); TntArrow arrow = new TntArrow(level, livingEntity); arrow.setEffectsFromItem(stack); return arrow; } public boolean isInfinite(@NotNull ItemStack stack, @NotNull ItemStack bow, @NotNull Player player) { int enchant = EnchantmentHelper.getTagEnchantmentLevel(INFINITY_ARROWS, bow); return enchant > 0 && this.getClass() == TntArrowItem.class; } } Arrow renderer code import net.minecraft.client.renderer.entity.ArrowRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class TntArrowRenderer extends ArrowRenderer<TntArrow> { @NotNull private static final ResourceLocation TEXTURE = new ResourceLocation(Main.MOD_ID, "textures/entity/projectiles/tnt_arrow.png"); public TntArrowRenderer(@NotNull EntityRendererProvider.Context ctx) { super(ctx); } @Override @NotNull public ResourceLocation getTextureLocation(@Nullable TntArrow arrow) { return TEXTURE; } } Arrow model code // Made with Blockbench 4.8.3 // Exported for Minecraft version 1.17 or later with Mojang mappings // Paste this class into your mod and generate all required imports import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.model.EntityModel; import net.minecraft.client.model.geom.ModelLayerLocation; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.*; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.NotNull; import ru.fokinatorr.moarrows.Main; import ru.fokinatorr.moarrows.tnt_arrow.TntArrow; public class TntArrowModel extends EntityModel<TntArrow> { // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation(Main.MOD_ID, "tnt_arrow"), "main"); private final ModelPart arrow; private final ModelPart tnt; public TntArrowModel(ModelPart root) { this.arrow = root.getChild("arrow"); this.tnt = root.getChild("tnt"); } public static LayerDefinition createBodyLayer() { MeshDefinition meshDefinition = new MeshDefinition(); PartDefinition partDefinition = meshDefinition.getRoot(); PartDefinition arrow = partDefinition.addOrReplaceChild("arrow", CubeListBuilder.create() .texOffs(-5, 0) .addBox(-9.5F, -2.75F, -1.13F, 19.5F, 0.0F, 5.0F, new CubeDeformation(0.0F)) .texOffs(4, 6) .addBox(-9.0F, -5.2F, -1.0F, 0.0F, 5.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); arrow.addOrReplaceChild("arrow_2_r1", CubeListBuilder.create(). texOffs(-5, 0) .addBox(-15.6F, -1.5F, -0.75F, 19.5F, 0.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(6.1F, -4.25F, 0.0F, -1.5708F, 0.0F, 0.0F)); partDefinition.addOrReplaceChild("tnt", CubeListBuilder.create() .texOffs(0, 18) .addBox(-6.75F, -7.0F, -6.5F, 16.0F, 16.0F, 16.0F, new CubeDeformation(-5.75F)), PartPose.offset(-1.0F, 20.75F, 0.0F)); return LayerDefinition.create(meshDefinition, 64, 64); } @Override public void setupAnim(@NotNull TntArrow arrow, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { } @Override public void renderToBuffer(@NotNull PoseStack poseStack, @NotNull VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { arrow.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); tnt.render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); } } ClientModEvents import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = Main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public final class ClientModEvents { @SubscribeEvent public static void registerRenderers(EntityRenderersEvent.RegisterRenderers event) { event.registerEntityRenderer(_Entities.TNT_ARROW.get(), TntArrowRenderer::new); } @SubscribeEvent public static void registerLayerDefinitions(EntityRenderersEvent.RegisterLayerDefinitions event) { event.registerLayerDefinition(TntArrowModel.LAYER_LOCATION, TntArrowModel::createBodyLayer); } } _Entities import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class _Entities { public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, Main.MOD_ID); public static final RegistryObject<EntityType<TntArrow>> TNT_ARROW = ENTITIES.register("tnt_arrow", () -> EntityType.Builder.<TntArrow>of(TntArrow::new, MobCategory.MISC) .sized(.5f, .5f) .clientTrackingRange(4) .updateInterval(20) .build(new ResourceLocation(Main.MOD_ID, "tnt_arrow").toString())); private _Entities() {} } Any ideas?
-
[1.19.2] Cannot invoke "net.minecraft.network.syncher.SynchedEntityData$DataItem.getValue()" because "dataitem" is null
me too, but in my case, the EntityDataAccessor is null
IPS spam blocked by CleanTalk.