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'
There are several issues in your code:
1. IceArrowItem Class
The issue here is that you're trying to create an IceArrowItem with only one argument (new Item.Properties()), but the IceArrowItem constructor expects two arguments: Properties properties and float damage.
Here's the corrected code:
public static final RegistryObject<Item> ICE_ARROW = ITEMS.register("ice_arrow",
() -> new IceArrowItem(new Item.Properties(), 1.0f)); // Assuming 1.0f as the damage
2. IceArrow Class
The issue here is that you're trying to access the type variable in the second constructor of the IceArrow class, but type is not defined in that scope. Also, you're trying to call the super constructor with type, shooter, level, but the super constructor expects EntityType<? extends AbstractArrow> type, LivingEntity shooter, Level level.
Here's the corrected code:
public IceArrow(LivingEntity shooter, Level level) {
this(ModEntities.ICE_ARROW.get(), shooter, level);
}
public IceArrow(EntityType<? extends AbstractArrow> type, LivingEntity shooter, Level level) {
super(type, shooter, level);
}
3. IceArrow Class - getPickupItem Method
The issue here is that you're returning null from the getPickupItem method, which is not allowed. You should return an ItemStack instead.
Here's the corrected code:
@Override
protected ItemStack getPickupItem() {
return new ItemStack(ModItems.ICE_ARROW.get());
}
4. IceArrow Class - onHitEntity Method
The issue here is that you're not calling the super constructor correctly in the second constructor of the IceArrow class.
Here's the corrected code:
public IceArrow(EntityType<? extends AbstractArrow> type, Level level) {
super(type, level);
}
public IceArrow(LivingEntity shooter, Level level) {
this(ModEntities.ICE_ARROW.get(), shooter, level);
}
public IceArrow(EntityType<? extends AbstractArrow> type, LivingEntity shooter, Level level) {
super(type, shooter, level);
}