package net.mattias.oceancritteria.item.custom; import…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
package net.mattias.oceancritteria.item.custom;
import net.mattias.oceancritteria.entity.ModEntities; // Import the entity registry import net.mattias.oceancritteria.entity.custom.projectile.IceArrow; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.item.ArrowItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult;
public class IceArrowItem extends ArrowItem { public final float damage;
public IceArrowItem(Properties properties, float damage) {
super(properties);
this.damage = damage;
}
@Override
public AbstractArrow createArrow(Level level, ItemStack stack, LivingEntity shooter) {
return new IceArrow(ModEntities.ICE_ARROW.get(), level);
}
@Override
public boolean isInfinite(ItemStack stack, ItemStack bow, Player player) {
int infinityLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY_ARROWS, bow);
return infinityLevel > 0 && this.getClass() == ArrowItem.class;
}
}
public static final RegistryObject<Item> ICE_ARROW = ITEMS.register("ice_arrow",
() -> new IceArrowItem(new Item.Properties()));
Expected 2 arguments but found 1
package net.mattias.oceancritteria.entity.custom.projectile;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult;
public class IceArrow extends AbstractArrow {
public IceArrow(EntityType<? extends AbstractArrow> type, Level level) {
super(type, level);
}
@Override
protected ItemStack getPickupItem() {
return null;
}
public IceArrow(LivingEntity shooter, Level level) { // Removed referenceitem
super(type, shooter, level);
}
@Override
protected void onHitEntity(EntityHitResult pResult) {
super.onHitEntity(pResult);
Entity target = pResult.getEntity();
if (target instanceof LivingEntity livingTarget) {
int currentFreezeTicks = livingTarget.getTicksFrozen();
int newFreezeTicks = Math.min(currentFreezeTicks + 40, 140);
livingTarget.setTicksFrozen(newFreezeTicks);
livingTarget.addEffect(new MobEffectInstance(
MobEffects.MOVEMENT_SLOWDOWN,
60,
1,
false,
false
));
}
}
} 'type' has private access in 'net.minecraft.world.entity.Entity'
package net.mattias.oceancritteria.entity;
import net.mattias.oceancritteria.OceanCritteria; import net.mattias.oceancritteria.entity.custom.PenguinEntity; import net.mattias.oceancritteria.entity.custom.projectile.IceArrow; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject;
public class ModEntities { public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, OceanCritteria.MOD_ID);
public static final RegistryObject<EntityType<PenguinEntity>> PENGUIN =
ENTITY_TYPES.register("penguin", () -> EntityType.Builder.of(PenguinEntity::new, MobCategory.CREATURE)
.sized(1f, 1f).build("penguin"));
public static final RegistryObject<EntityType<IceArrow>> ICE_ARROW =
ENTITY_TYPES.register("ice_arrow", () -> EntityType.Builder.of(IceArrow::new, MobCategory.MISC)
.sized(0.1f, 0.1f).build("ice_arrow"));
public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus);
}
} Cannot resolve constructor 'IceArrow'
Let's go through your issues one by one and fix them properly.
IceArrowItem constructor error:public static final RegistryObject<Item> ICE_ARROW = ITEMS.register("ice_arrow",
() -> new IceArrowItem(new Item.Properties()));
Error:
Expected 2 arguments but found 1
Cause:
Your IceArrowItem constructor requires 2 arguments: Properties and float damage. You only provided one.
Fix:
Pass a damage value (e.g., 2.0f or whatever you want):
public static final RegistryObject<Item> ICE_ARROW = ITEMS.register("ice_arrow",
() -> new IceArrowItem(new Item.Properties(), 2.0f));
IceArrow class constructor and type access errorYour IceArrow class:
public class IceArrow extends AbstractArrow {
public IceArrow(EntityType<? extends AbstractArrow> type, Level level) {
super(type, level);
}
@Override
protected ItemStack getPickupItem() {
return null;
}
public IceArrow(LivingEntity shooter, Level level) { // Removed referenceitem
super(type, shooter, level); // ERROR: 'type' has private access in 'Entity'
}
// ...
}
Errors:
type is not accessible here because it's a private field in the superclass.type which is undefined in that scope.getPickupItem() returns null — better to return the arrow item stack.You must pass the EntityType to the constructor. You cannot access type directly.
Option A: Remove the second constructor and only use the one with (EntityType<? extends AbstractArrow>, Level).
Option B: Add a static field or pass the EntityType explicitly.
package net.mattias.oceancritteria.entity.custom.projectile;
import net.mattias.oceancritteria.entity.ModEntities;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;
public class IceArrow extends AbstractArrow {
// Constructor used by the EntityType builder and spawn system
public IceArrow(EntityType<? extends AbstractArrow> type, Level level) {
super(type, level);
}
// Convenience constructor for shooting from a LivingEntity
public IceArrow(LivingEntity shooter, Level level) {
// Pass the registered EntityType explicitly
this(ModEntities.ICE_ARROW.get(), level);
this.setOwner(shooter);
this.setPos(shooter.getX(), shooter.getEyeY() - 0.1, shooter.getZ());
}
@Override
protected ItemStack getPickupItem() {
// Return the item stack for the IceArrow item
return new ItemStack(ModItems.ICE_ARROW.get());
}
@Override
protected void onHitEntity(EntityHitResult pResult) {
super.onHitEntity(pResult);
Entity target = pResult.getEntity();
if (target instanceof LivingEntity livingTarget) {
int currentFreezeTicks = livingTarget.getTicksFrozen();
int newFreezeTicks = Math.min(currentFreezeTicks + 40, 140);
livingTarget.setTicksFrozen(newFreezeTicks);
livingTarget.addEffect(new MobEffectInstance(
MobEffects.MOVEMENT_SLOWDOWN,
60,
1,
false,
false
));
}
}
}
ModEntities class: Cannot resolve constructor 'IceArrow'Your ModEntities:
public static final RegistryObject<EntityType<IceArrow>> ICE_ARROW =
ENTITY_TYPES.register("ice_arrow", () -> EntityType.Builder.of(IceArrow::new, MobCategory.MISC)
.sized(0.1f, 0.1f).build("ice_arrow"));
Error: Cannot resolve constructor IceArrow
The EntityType.Builder.of expects a function that takes (EntityType<T>, Level) and returns a new instance of the entity.
Your IceArrow class must have a constructor with signature:
public IceArrow(EntityType<? extends AbstractArrow> type, Level level)
which you have, so this should work.
IceArrow class is not compiled or recognized properly.IceArrow constructor with (EntityType<? extends AbstractArrow>, Level) is public.ModEntities.IceArrowItem registration to pass 2 arguments.IceArrow constructors: remove the one that uses type field directly; instead, use the constructor with (EntityType, Level) and add a convenience constructor that calls it.getPickupItem() to return the correct item stack.ModEntities registers ICE_ARROW with the correct constructor reference.ModItems in IceArrow for getPickupItem().ModEntities.javapackage net.mattias.oceancritteria.entity;
import net.mattias.oceancritteria.OceanCritteria;
import net.mattias.oceancritteria.entity.custom.PenguinEntity;
import net.mattias.oceancritteria.entity.custom.projectile.IceArrow;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModEntities {
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES =
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, OceanCritteria.MOD_ID);
public static final RegistryObject<EntityType<PenguinEntity>> PENGUIN =
ENTITY_TYPES.register("penguin", () -> EntityType.Builder.of(PenguinEntity::new, MobCategory.CREATURE)
.sized(1f, 1f).build("penguin"));
public static final RegistryObject<EntityType<IceArrow>> ICE_ARROW =
ENTITY_TYPES.register("ice_arrow", () -> EntityType.Builder.of(IceArrow::new, MobCategory.MISC)
.sized(0.1f, 0.1f).build("ice_arrow"));
public static void register(IEventBus eventBus) {
ENTITY_TYPES.register(eventBus);
}
}
IceArrow.javapackage net.mattias.oceancritteria.entity.custom.projectile;
import net.mattias.oceancritteria.item.ModItems;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.EntityHitResult;
public class IceArrow extends AbstractArrow {
public IceArrow(EntityType<? extends AbstractArrow> type, Level level) {
super(type, level);
}
public IceArrow(LivingEntity shooter, Level level) {
this(ModEntities.ICE_ARROW.get(), level);
this.setOwner(shooter);
this.setPos(shooter.getX(), shooter.getEyeY() - 0.1, shooter.getZ());
}
@Override
protected ItemStack getPickupItem() {
return new ItemStack(ModItems.ICE_ARROW.get());
}
@Override
protected void onHitEntity(EntityHitResult pResult) {
super.onHitEntity(pResult);
Entity target = pResult.getEntity();
if (target instanceof LivingEntity livingTarget) {
int currentFreezeTicks = livingTarget.getTicksFrozen();
int newFreezeTicks = Math.min(currentFreezeTicks + 40, 140);
livingTarget.setTicksFrozen(newFreezeTicks);
livingTarget.addEffect(new MobEffectInstance(
MobEffects.MOVEMENT_SLOWDOWN,
60,
1,
false,
false
));
}
}
}
IceArrowItem registration snippetpublic static final RegistryObject<Item> ICE_ARROW = ITEMS.register("ice_arrow",
() -> new IceArrowItem(new Item.Properties(), 2.0f));
IceArrowItem.java (createArrow method)@Override
public AbstractArrow createArrow(Level level, ItemStack stack, LivingEntity shooter) {
return new IceArrow(shooter, level);
}
EntityType to the constructor that Minecraft expects.If you follow these steps, your errors should be resolved! If you want, I can help you with the full mod setup or any other part.