From 75b31d1b1ee57a84d5fcef6c25cdfdc244801d05 Mon Sep 17 00:00:00 2001 From: Jenny Date: Mon, 10 Feb 2025 16:12:19 +0100 Subject: [PATCH] 1.20.3 working, yay --- build.gradle | 7 +- gradle.properties | 12 +- .../datagen/DataGenerators.java | 5 - .../datagen/ModItemModelProvider.java | 3 +- .../advancedarrows/entities/baseArrow.java | 196 ++---------------- .../entities/breachingArrow.java | 12 +- .../advancedarrows/entities/enderArrow.java | 25 +-- .../advancedarrows/entities/homingArrow.java | 13 +- .../entities/incendiaryArrow.java | 18 +- .../advancedarrows/entities/kineticArrow.java | 13 +- .../entities/ricochetArrow.java | 15 +- .../entities/sharpenedArrow.java | 14 +- .../advancedarrows/entities/switchArrow.java | 19 +- 13 files changed, 68 insertions(+), 284 deletions(-) diff --git a/build.gradle b/build.gradle index cda893c..deb6589 100644 --- a/build.gradle +++ b/build.gradle @@ -31,7 +31,7 @@ minecraft { // // Use non-default mappings at your own risk. They may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'parchment', version: '2023.09.03-1.20.1' + mappings channel: 'parchment', version: '2024.04.14-1.20.4' // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. // In most cases, it is not necessary to enable. @@ -186,3 +186,8 @@ tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation } +sourceSets.each { + def dir = layout.buildDirectory.dir("sourcesSets/$it.name") + it.output.resourcesDir = dir + it.java.destinationDirectory = dir +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2e68374..4908766 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # The Minecraft version must agree with the Forge version to get a valid artifact -minecraft_version=1.20.1 +minecraft_version=1.20.3 # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. -minecraft_version_range=[1.20.1,1.20.2] +minecraft_version_range=[1.20.3, 1.20.4] # The Forge version must agree with the Minecraft version to get a valid artifact -forge_version=47.3.0 +forge_version=49.0.2 # The Forge version range can use any version of Forge as bounds or match the loader version range -forge_version_range=[47,) +forge_version_range=[49,) # The loader version range can only use the major version of Forge/FML as bounds -loader_version_range=[47,) +loader_version_range=[49,) # The mapping channel to use for mappings. # The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. # Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. @@ -29,7 +29,7 @@ loader_version_range=[47,) mapping_channel=official # The mapping version to query from the mapping channel. # This must match the format required by the mapping channel. -mapping_version=1.20.1 +mapping_version=1.20.3 # The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} # Must match the String constant located in the main mod class annotated with @Mod. mod_id=advancedarrows diff --git a/src/main/java/com/jenny/advancedarrows/datagen/DataGenerators.java b/src/main/java/com/jenny/advancedarrows/datagen/DataGenerators.java index da3dede..dd2e8a0 100644 --- a/src/main/java/com/jenny/advancedarrows/datagen/DataGenerators.java +++ b/src/main/java/com/jenny/advancedarrows/datagen/DataGenerators.java @@ -1,6 +1,5 @@ package com.jenny.advancedarrows.datagen; -import net.minecraft.core.HolderLookup; import net.minecraft.data.DataGenerator; import net.minecraft.data.PackOutput; import net.minecraftforge.common.data.ExistingFileHelper; @@ -9,8 +8,6 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import org.jetbrains.annotations.NotNull; -import java.util.concurrent.CompletableFuture; - import static com.jenny.advancedarrows.advancedArrows.MODID; @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD) @@ -20,8 +17,6 @@ public class DataGenerators { DataGenerator generator = event.getGenerator(); PackOutput packOutput = generator.getPackOutput(); ExistingFileHelper existingFileHelper = event.getExistingFileHelper(); - CompletableFuture lookupProvider = event.getLookupProvider(); - generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper)); } } \ No newline at end of file diff --git a/src/main/java/com/jenny/advancedarrows/datagen/ModItemModelProvider.java b/src/main/java/com/jenny/advancedarrows/datagen/ModItemModelProvider.java index 0b2f156..4c8474b 100644 --- a/src/main/java/com/jenny/advancedarrows/datagen/ModItemModelProvider.java +++ b/src/main/java/com/jenny/advancedarrows/datagen/ModItemModelProvider.java @@ -8,6 +8,7 @@ import net.minecraftforge.client.model.generators.ItemModelBuilder; import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.RegistryObject; +import org.jetbrains.annotations.NotNull; import static com.jenny.advancedarrows.advancedArrows.MODID; @@ -23,7 +24,7 @@ public class ModItemModelProvider extends ItemModelProvider { } } - private ItemModelBuilder simpleItem(RegistryObject item) { + private ItemModelBuilder simpleItem(@NotNull RegistryObject item) { return withExistingParent(item.getId().getPath(), new ResourceLocation("item/generated")).texture("layer0", new ResourceLocation(MODID,"item/" + item.getId().getPath())); diff --git a/src/main/java/com/jenny/advancedarrows/entities/baseArrow.java b/src/main/java/com/jenny/advancedarrows/entities/baseArrow.java index 74d7287..3d53cb5 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/baseArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/baseArrow.java @@ -1,220 +1,51 @@ package com.jenny.advancedarrows.entities; -import com.google.common.collect.Sets; import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; -import net.minecraft.network.syncher.EntityDataAccessor; -import net.minecraft.network.syncher.EntityDataSerializers; -import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.world.effect.MobEffectInstance; 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.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.alchemy.Potion; -import net.minecraft.world.item.alchemy.PotionUtils; -import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; -import java.util.Collection; -import java.util.Set; - public class baseArrow extends AbstractArrow { - private static final int EXPOSED_POTION_DECAY_TIME = 600; - private static final int NO_EFFECT_COLOR = -1; - private static final EntityDataAccessor ID_EFFECT_COLOR = SynchedEntityData.defineId(baseArrow.class, EntityDataSerializers.INT); - private static final byte EVENT_POTION_PUFF = 0; - private Potion potion = Potions.EMPTY; - private final Set effects = Sets.newHashSet(); - private boolean fixedColor; + private final Item itemPickup; private int tick = 0; - public baseArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + public baseArrow(EntityType pEntityType, Level pLevel, Item item) { + super(pEntityType, pLevel, item.getDefaultInstance()); + this.itemPickup = item; } - public baseArrow(Level pLevel, double pX, double pY, double pZ, EntityType pEntityType) { - super(pEntityType, pX, pY, pZ, pLevel); - } - - public baseArrow(Level pLevel, LivingEntity pShooter, EntityType pEntityType) { - super(pEntityType, pShooter, pLevel); - } - - public void setEffectsFromItem(ItemStack pStack) { - if (pStack.is(Items.TIPPED_ARROW)) { - this.potion = PotionUtils.getPotion(pStack); - Collection collection = PotionUtils.getCustomEffects(pStack); - if (!collection.isEmpty()) { - for(MobEffectInstance mobeffectinstance : collection) { - this.effects.add(new MobEffectInstance(mobeffectinstance)); - } - } - - int i = getCustomColor(pStack); - if (i == -1) { - this.updateColor(); - } else { - this.setFixedColor(i); - } - } else if (pStack.is(Items.ARROW)) { - this.potion = Potions.EMPTY; - this.effects.clear(); - this.entityData.set(ID_EFFECT_COLOR, -1); - } - - } - - public static int getCustomColor(ItemStack pStack) { - CompoundTag compoundtag = pStack.getTag(); - return compoundtag != null && compoundtag.contains("CustomPotionColor", 99) ? compoundtag.getInt("CustomPotionColor") : -1; - } - - private void updateColor() { - this.fixedColor = false; - if (this.potion == Potions.EMPTY && this.effects.isEmpty()) { - this.entityData.set(ID_EFFECT_COLOR, -1); - } else { - this.entityData.set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects))); - } - - } - - public void addEffect(MobEffectInstance pEffectInstance) { - this.effects.add(pEffectInstance); - this.getEntityData().set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects))); - } - - protected void defineSynchedData() { - super.defineSynchedData(); - this.entityData.define(ID_EFFECT_COLOR, -1); + public baseArrow(Level pLevel, LivingEntity pShooter, EntityType pEntityType, Item item) { + super(pEntityType, pShooter, pLevel, item.getDefaultInstance()); + this.itemPickup = item; } public void tick() { super.tick(); if (this.level().isClientSide) { - if (this.inGround) { - if (this.inGroundTime % 5 == 0) { - this.makeParticle(1); - } - } else { + if (!this.inGround) { spawnParticles(); } this.tick++; - } else if (this.inGround && this.inGroundTime != 0 && !this.effects.isEmpty() && this.inGroundTime >= 600) { + } else if (this.inGround && this.inGroundTime != 0 && this.inGroundTime >= 600) { this.level().broadcastEntityEvent(this, (byte)0); - this.potion = Potions.EMPTY; - this.effects.clear(); - this.entityData.set(ID_EFFECT_COLOR, -1); } } - private void makeParticle(int pParticleAmount) { - int i = this.getColor(); - if (i != -1 && pParticleAmount > 0) { - double d0 = (double)(i >> 16 & 255) / 255.0D; - double d1 = (double)(i >> 8 & 255) / 255.0D; - double d2 = (double)(i >> 0 & 255) / 255.0D; - - for(int j = 0; j < pParticleAmount; ++j) { - this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5D), this.getRandomY(), this.getRandomZ(0.5D), d0, d1, d2); - } - - } - } - - public int getColor() { - return this.entityData.get(ID_EFFECT_COLOR); - } - - private void setFixedColor(int pFixedColor) { - this.fixedColor = true; - this.entityData.set(ID_EFFECT_COLOR, pFixedColor); - } - - public void addAdditionalSaveData(@NotNull CompoundTag pCompound) { - super.addAdditionalSaveData(pCompound); - if (this.potion != Potions.EMPTY) { - pCompound.putString("Potion", BuiltInRegistries.POTION.getKey(this.potion).toString()); - } - - if (this.fixedColor) { - pCompound.putInt("Color", this.getColor()); - } - - if (!this.effects.isEmpty()) { - ListTag listtag = new ListTag(); - - for(MobEffectInstance mobeffectinstance : this.effects) { - listtag.add(mobeffectinstance.save(new CompoundTag())); - } - - pCompound.put("CustomPotionEffects", listtag); - } - - } - - public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { - super.readAdditionalSaveData(pCompound); - if (pCompound.contains("Potion", 8)) { - this.potion = PotionUtils.getPotion(pCompound); - } - - for(MobEffectInstance mobeffectinstance : PotionUtils.getCustomEffects(pCompound)) { - this.addEffect(mobeffectinstance); - } - - if (pCompound.contains("Color", 99)) { - this.setFixedColor(pCompound.getInt("Color")); - } else { - this.updateColor(); - } - - } - - protected void doPostHurtEffects(@NotNull LivingEntity pLiving) { - super.doPostHurtEffects(pLiving); - Entity entity = this.getEffectSource(); - - for(MobEffectInstance mobeffectinstance : this.potion.getEffects()) { - pLiving.addEffect(new MobEffectInstance(mobeffectinstance.getEffect(), Math.max(mobeffectinstance.mapDuration((p_268168_) -> { - return p_268168_ / 8; - }), 1), mobeffectinstance.getAmplifier(), mobeffectinstance.isAmbient(), mobeffectinstance.isVisible()), entity); - } - - if (!this.effects.isEmpty()) { - for(MobEffectInstance mobeffectinstance1 : this.effects) { - pLiving.addEffect(mobeffectinstance1, entity); - } - } - - } - @NotNull protected ItemStack getPickupItem() { - if (this.effects.isEmpty() && this.potion == Potions.EMPTY) { - return new ItemStack(Items.ARROW); - } else { - ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW); - PotionUtils.setPotion(itemstack, this.potion); - PotionUtils.setCustomEffects(itemstack, this.effects); - if (this.fixedColor) { - itemstack.getOrCreateTag().putInt("CustomPotionColor", this.getColor()); - } - - return itemstack; - } + System.out.println(itemPickup.toString()); + return itemPickup.getDefaultInstance(); } public void handleEntityEvent(byte pId) { if (pId == 0) { - int i = this.getColor(); + int i = -1; if (i != -1) { double d0 = (double)(i >> 16 & 255) / 255.0D; double d1 = (double)(i >> 8 & 255) / 255.0D; @@ -247,7 +78,6 @@ public class baseArrow extends AbstractArrow { } public void spawnParticles() { - } public int getTick() { diff --git a/src/main/java/com/jenny/advancedarrows/entities/breachingArrow.java b/src/main/java/com/jenny/advancedarrows/entities/breachingArrow.java index c07d49f..2ff9ccd 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/breachingArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/breachingArrow.java @@ -6,7 +6,7 @@ import com.jenny.advancedarrows.particles.particles; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.EntityHitResult; @@ -19,13 +19,14 @@ import java.util.List; public class breachingArrow extends baseArrow{ static final int range = 4; + static final Item item = items.ARROW_BREACHING.get(); public breachingArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public breachingArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_BREACHING.get()); + super(pLevel, pShooter, entities.ARROW_BREACHING.get(), item); } @Override @@ -73,9 +74,4 @@ public class breachingArrow extends baseArrow{ level().addParticle(particles.PARTICLE_BREACHING_ARROW.get(), pos.x, pos.y, pos.z, 0, 0, 0); } } - - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_BREACHING.get()); - } } diff --git a/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java b/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java index e5e4d8d..420f00e 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/enderArrow.java @@ -1,37 +1,25 @@ package com.jenny.advancedarrows.entities; import com.jenny.advancedarrows.config.ConfigClient; -import com.jenny.advancedarrows.items.items; import net.minecraft.core.particles.ParticleTypes; -import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; public class enderArrow extends baseArrow { + static final Item item = Items.AIR; + public enderArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public enderArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_ENDER.get()); - } - - @Override - protected void onHitEntity(@NotNull EntityHitResult pTarget) { - super.onHitEntity(pTarget); - Entity target = pTarget.getEntity(); - target.addDeltaMovement(getDeltaMovement().multiply(1.5, 0.2, 1.5)); - } - - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_ENDER.get()); + super(pLevel, pShooter, entities.ARROW_ENDER.get(), item); } @Override @@ -41,6 +29,7 @@ public class enderArrow extends baseArrow { Vec3 pos = pResult.getLocation(); level().getPlayerByUUID(getOwner().getUUID()).teleportTo(pos.x, pos.y, pos.z); } + discard(); } @Override diff --git a/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java b/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java index cd2478c..6388caf 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/homingArrow.java @@ -6,32 +6,27 @@ import com.jenny.advancedarrows.items.items; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; public class homingArrow extends baseArrow { LivingEntity target; + static final Item item = items.ARROW_HOMING.get(); public homingArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public homingArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_HOMING.get()); + super(pLevel, pShooter, entities.ARROW_HOMING.get(), item); setBaseDamage(1); } - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_HOMING.get()); - } - @Override public void tick() { if (!level().isClientSide) { diff --git a/src/main/java/com/jenny/advancedarrows/entities/incendiaryArrow.java b/src/main/java/com/jenny/advancedarrows/entities/incendiaryArrow.java index c6cfc34..3acea3e 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/incendiaryArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/incendiaryArrow.java @@ -5,23 +5,20 @@ import com.jenny.advancedarrows.items.items; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; public class incendiaryArrow extends baseArrow{ + static final Item item = items.ARROW_INCENDIARY.get(); + public incendiaryArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public incendiaryArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_INCENDIARY.get()); - } - - public incendiaryArrow(Level pLevel, double x, double y, double z) { - super(entities.ARROW_INCENDIARY.get(), pLevel); - setPos(x, y, z); + super(pLevel, pShooter, entities.ARROW_INCENDIARY.get(), item); } @Override @@ -29,11 +26,6 @@ public class incendiaryArrow extends baseArrow{ pTarget.setSecondsOnFire(5); } - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_INCENDIARY.get()); - } - @Override public void spawnParticles() { for (int i = 1; i <= ConfigClient.calcPCount(5); i++) { diff --git a/src/main/java/com/jenny/advancedarrows/entities/kineticArrow.java b/src/main/java/com/jenny/advancedarrows/entities/kineticArrow.java index 3e82ec4..9d97833 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/kineticArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/kineticArrow.java @@ -6,19 +6,21 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; public class kineticArrow extends baseArrow{ + static final Item item = items.ARROW_KINETIC.get(); + public kineticArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public kineticArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_KINETIC.get()); + super(pLevel, pShooter, entities.ARROW_KINETIC.get(), item); } @Override @@ -28,11 +30,6 @@ public class kineticArrow extends baseArrow{ target.addDeltaMovement(getDeltaMovement().multiply(1.5, 0.2, 1.5)); } - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_KINETIC.get()); - } - @Override public void spawnParticles() { for (int i = 1; i <= ConfigClient.calcPCount(5); i++) { diff --git a/src/main/java/com/jenny/advancedarrows/entities/ricochetArrow.java b/src/main/java/com/jenny/advancedarrows/entities/ricochetArrow.java index f835812..c75e75a 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/ricochetArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/ricochetArrow.java @@ -3,18 +3,19 @@ package com.jenny.advancedarrows.entities; import com.jenny.advancedarrows.items.items; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; public class ricochetArrow extends baseArrow{ + static final Item item = items.ARROW_RICOCHET.get(); + public ricochetArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public ricochetArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_RICOCHET.get()); + super(pLevel, pShooter, entities.ARROW_RICOCHET.get(), item); } @Override @@ -33,10 +34,4 @@ public class ricochetArrow extends baseArrow{ } } } - - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_RICOCHET.get()); - } - } diff --git a/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java b/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java index e8085e4..e31e427 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/sharpenedArrow.java @@ -5,26 +5,22 @@ import com.jenny.advancedarrows.items.items; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; public class sharpenedArrow extends baseArrow{ + static final Item item = items.ARROW_SHARPENED.get(); + public sharpenedArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public sharpenedArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_SHARPENED.get()); + super(pLevel, pShooter, entities.ARROW_SHARPENED.get(), item); setBaseDamage(3); } - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_SHARPENED.get()); - } - @Override public void spawnParticles() { for (int i = 1; i <= ConfigClient.calcPCount(5); i++) { diff --git a/src/main/java/com/jenny/advancedarrows/entities/switchArrow.java b/src/main/java/com/jenny/advancedarrows/entities/switchArrow.java index e526de8..250ee7a 100644 --- a/src/main/java/com/jenny/advancedarrows/entities/switchArrow.java +++ b/src/main/java/com/jenny/advancedarrows/entities/switchArrow.java @@ -6,24 +6,21 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; public class switchArrow extends baseArrow{ + static final Item item = items.ARROW_SWITCH.get(); + public switchArrow(EntityType pEntityType, Level pLevel) { - super(pEntityType, pLevel); + super(pEntityType, pLevel, item); } public switchArrow(Level pLevel, LivingEntity pShooter) { - super(pLevel, pShooter, entities.ARROW_SWITCH.get()); - } - - public switchArrow(Level pLevel, double x, double y, double z) { - super(entities.ARROW_SWITCH.get(), pLevel); - setPos(x, y, z); + super(pLevel, pShooter, entities.ARROW_SWITCH.get(), item); } @Override @@ -37,11 +34,7 @@ public class switchArrow extends baseArrow{ //owner.setPos(ownerPos) doesn't work somehow, idk why level().getPlayerByUUID(owner.getUUID()).teleportTo(ownerPos.x, ownerPos.y, ownerPos.z); } - } - - @NotNull - protected ItemStack getPickupItem() { - return new ItemStack(items.ARROW_SWITCH.get()); + discard(); } @Override