From 1cdc71b9a6acca1dc7d8e1422aa2fa1389de5a34 Mon Sep 17 00:00:00 2001 From: Partonetrain Date: Sun, 5 Jan 2025 14:53:40 -0600 Subject: [PATCH 1/3] some mobs and attributes lots of defineSyncedData and finalizeSpawn signature changes getDefaultAttributeModifiers converted into static createAttributes --- .../addons/oddities/item/BackpackItem.java | 9 ++--- .../quark/base/item/boat/QuarkBoat.java | 6 ++-- .../building/entity/GlassItemFrame.java | 16 +++++---- .../client/module/AutoWalkKeybindModule.java | 21 +++++++----- .../mobs/ai/DeliverFetchedItemGoal.java | 4 +-- .../quark/content/mobs/entity/Crab.java | 29 +++++++--------- .../quark/content/mobs/entity/Forgotten.java | 25 +++++++------- .../quark/content/mobs/entity/Foxhound.java | 34 +++++++++---------- .../quark/content/mobs/entity/Shiba.java | 16 ++++----- .../quark/content/mobs/entity/SoulBead.java | 6 ++-- .../quark/content/mobs/entity/Stoneling.java | 26 ++++++-------- .../quark/content/mobs/entity/Toretoise.java | 18 ++++------ .../quark/content/mobs/entity/Wraith.java | 14 ++++---- .../content/mobs/item/DiamondHeartItem.java | 8 +---- .../content/mobs/item/ForgottenHatItem.java | 26 ++++++-------- .../content/mobs/module/ForgottenModule.java | 2 +- .../content/mobs/module/StonelingsModule.java | 3 +- .../content/tools/item/PickarangItem.java | 17 ++++------ .../content/tools/module/PickarangModule.java | 2 ++ .../tweaks/module/PigLittersModule.java | 3 +- .../entity_type/can_breathe_under_water.json | 7 ++++ 21 files changed, 142 insertions(+), 150 deletions(-) create mode 100644 src/main/resources/data/minecraft/tags/entity_type/can_breathe_under_water.json diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java b/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java index ad3161d4ba..4a51838175 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/item/BackpackItem.java @@ -16,6 +16,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.*; +import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; @@ -53,7 +54,8 @@ public BackpackItem(@Nullable ZetaModule module) { new Item.Properties() .stacksTo(1) .durability(0) - .rarity(Rarity.RARE)); + .rarity(Rarity.RARE) + .attributes(createAttributes())); this.module = module; @@ -224,9 +226,8 @@ public ICapabilityProvider initCapabilities(ItemStack stack, CompoundTag oldCapN return handler; } - @Override - public Multimap getDefaultAttributeModifiers(EquipmentSlot p_40390_) { - return ImmutableMultimap.of(); + public static ItemAttributeModifiers createAttributes(){ + return ItemAttributeModifiers.builder().build(); } @Override diff --git a/src/main/java/org/violetmoon/quark/base/item/boat/QuarkBoat.java b/src/main/java/org/violetmoon/quark/base/item/boat/QuarkBoat.java index 01d8c51a26..7c193df144 100644 --- a/src/main/java/org/violetmoon/quark/base/item/boat/QuarkBoat.java +++ b/src/main/java/org/violetmoon/quark/base/item/boat/QuarkBoat.java @@ -34,9 +34,9 @@ public QuarkBoat(Level world, double x, double y, double z) { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - entityData.define(DATA_QUARK_TYPE, "blossom"); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(DATA_QUARK_TYPE, "blossom"); } public String getQuarkBoatType() { diff --git a/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java b/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java index 5430a48d14..95995b5b5d 100755 --- a/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java +++ b/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java @@ -6,6 +6,7 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; @@ -35,6 +36,7 @@ import net.minecraftforge.entity.IEntityAdditionalSpawnData; import net.minecraftforge.network.NetworkHooks; +import net.neoforged.neoforge.entity.IEntityWithComplexSpawn; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -42,7 +44,7 @@ import java.util.UUID; -public class GlassItemFrame extends ItemFrame implements IEntityAdditionalSpawnData { +public class GlassItemFrame extends ItemFrame implements IEntityWithComplexSpawn { public static final EntityDataAccessor IS_SHINY = SynchedEntityData.defineId(GlassItemFrame.class, EntityDataSerializers.BOOLEAN); @@ -246,14 +248,14 @@ public Packet getAddEntityPacket() { } @Override - public void writeSpawnData(FriendlyByteBuf buffer) { - buffer.writeBlockPos(this.pos); - buffer.writeVarInt(this.direction.get3DDataValue()); + public void writeSpawnData(RegistryFriendlyByteBuf registryFriendlyByteBuf) { + registryFriendlyByteBuf.writeBlockPos(this.pos); + registryFriendlyByteBuf.writeVarInt(this.direction.get3DDataValue()); } @Override - public void readSpawnData(FriendlyByteBuf buffer) { - this.pos = buffer.readBlockPos(); - this.setDirection(Direction.from3DDataValue(buffer.readVarInt())); + public void readSpawnData(RegistryFriendlyByteBuf registryFriendlyByteBuf) { + this.pos = registryFriendlyByteBuf.readBlockPos(); + this.setDirection(Direction.from3DDataValue(registryFriendlyByteBuf.readVarInt())); } } diff --git a/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java b/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java index e075a695c7..f50cffc4f3 100644 --- a/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java +++ b/src/main/java/org/violetmoon/quark/content/client/module/AutoWalkKeybindModule.java @@ -9,6 +9,8 @@ import net.minecraft.client.player.Input; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.resources.language.I18n; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; import org.violetmoon.quark.base.QuarkClient; @@ -93,17 +95,20 @@ private void acceptInput() { if(shouldAccept) { shouldAccept = false; Player player = mc.player; - float height = player.getStepHeight(); + AttributeInstance stepHeight = player.getAttribute(Attributes.STEP_HEIGHT); + if(stepHeight != null){ + double height = stepHeight.getValue(); - autorunning = !autorunning; + autorunning = !autorunning; - if(autorunning) { - hadAutoJump = opt.get(); + if(autorunning) { + hadAutoJump = opt.get(); - if(height < 1) - opt.set(true); - } else - opt.set(hadAutoJump); + if(height < 1) + opt.set(true); + } else + opt.set(hadAutoJump); + } } } else shouldAccept = true; diff --git a/src/main/java/org/violetmoon/quark/content/mobs/ai/DeliverFetchedItemGoal.java b/src/main/java/org/violetmoon/quark/content/mobs/ai/DeliverFetchedItemGoal.java index 16facec4cc..d56b44f070 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/ai/DeliverFetchedItemGoal.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/ai/DeliverFetchedItemGoal.java @@ -9,8 +9,8 @@ public class DeliverFetchedItemGoal extends FollowOwnerGoal { private final Shiba shiba; private int timeTilNextJump = 20; - public DeliverFetchedItemGoal(Shiba shiba, double speed, float minDist, float maxDist, boolean teleportToLeaves) { - super(shiba, speed, minDist, maxDist, teleportToLeaves); + public DeliverFetchedItemGoal(Shiba shiba, double speed, float minDist, float maxDist) { + super(shiba, speed, minDist, maxDist); this.shiba = shiba; } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java index 2dd186ba17..1e4a23c707 100755 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java @@ -15,6 +15,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; @@ -64,6 +65,7 @@ import net.minecraftforge.fluids.FluidType; import net.minecraftforge.network.NetworkHooks; +import net.neoforged.neoforge.entity.IEntityWithComplexSpawn; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -74,7 +76,7 @@ import java.util.function.BiConsumer; -public class Crab extends Animal implements IEntityAdditionalSpawnData, Bucketable { +public class Crab extends Animal implements IEntityWithComplexSpawn, Bucketable { public static final int COLORS = 3; public static final ResourceKey CRAB_LOOT_TABLE = Quark.asResourceKey(Registries.LOOT_TABLE, "entities/crab"); @@ -169,11 +171,6 @@ public float getWalkTargetValue(BlockPos pos, LevelReader world) { return world.getBlockState(pos.below()).is(CrabsModule.crabSpawnableTag) ? 10.0F : world.getRawBrightness(pos, 0) - 0.5F; } - @Override - public boolean canBreatheUnderwater() { - return true; - } - @NotNull @Override public MobType getMobType() { @@ -181,13 +178,13 @@ public MobType getMobType() { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); - entityData.define(SIZE_MODIFIER, 1f); - entityData.define(VARIANT, -1); - entityData.define(RAVING, false); - entityData.define(FROM_BUCKET, false); + builder.define(SIZE_MODIFIER, 1f); + builder.define(VARIANT, -1); + builder.define(RAVING, false); + builder.define(FROM_BUCKET, false); } @NotNull @@ -478,13 +475,13 @@ public Packet getAddEntityPacket() { } @Override - public void writeSpawnData(FriendlyByteBuf buffer) { - buffer.writeFloat(getSizeModifier()); + public void writeSpawnData(RegistryFriendlyByteBuf registryFriendlyByteBuf) { + registryFriendlyByteBuf.writeFloat(getSizeModifier()); } @Override - public void readSpawnData(FriendlyByteBuf buffer) { - entityData.set(SIZE_MODIFIER, buffer.readFloat()); + public void readSpawnData(RegistryFriendlyByteBuf registryFriendlyByteBuf) { + entityData.set(SIZE_MODIFIER, registryFriendlyByteBuf.readFloat()); } @Override diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Forgotten.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Forgotten.java index 4a314ddc99..f1729f1c17 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Forgotten.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Forgotten.java @@ -34,6 +34,7 @@ import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.providers.VanillaEnchantmentProviders; import net.minecraft.world.level.Level; import net.minecraft.world.level.ServerLevelAccessor; import net.minecraft.world.level.storage.loot.LootTable; @@ -58,9 +59,9 @@ public Forgotten(EntityType type, Level world) { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - entityData.define(SHEATHED_ITEM, ItemStack.EMPTY); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(SHEATHED_ITEM, ItemStack.EMPTY); } public static AttributeSupplier.Builder registerAttributes() { @@ -72,8 +73,8 @@ public static AttributeSupplier.Builder registerAttributes() { @Override @Nullable - public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn, @Nullable CompoundTag dataTag) { - SpawnGroupData ilivingentitydata = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); + public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, @Nullable SpawnGroupData spawnDataIn) { + SpawnGroupData ilivingentitydata = super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn); reassessWeaponGoal(); return ilivingentitydata; @@ -160,12 +161,12 @@ protected void populateDefaultEquipmentSlots(@NotNull RandomSource rand, @NotNul prepareEquipment(); } - public void prepareEquipment() { + public void prepareEquipment(ServerLevelAccessor serverLevelAccessor, DifficultyInstance difficultyInstance) { ItemStack bow = new ItemStack(Items.BOW); ItemStack sheathed = new ItemStack(Items.IRON_SWORD); - EnchantmentHelper.enchantItem(random, bow, 20, false); - EnchantmentHelper.enchantItem(random, sheathed, 20, false); + EnchantmentHelper.enchantItemFromProvider(bow, serverLevelAccessor.registryAccess(), VanillaEnchantmentProviders.MOB_SPAWN_EQUIPMENT, difficultyInstance, random); + EnchantmentHelper.enchantItemFromProvider(sheathed, serverLevelAccessor.registryAccess(), VanillaEnchantmentProviders.MOB_SPAWN_EQUIPMENT, difficultyInstance, random); if(Quark.ZETA.modules.isEnabled(ColorRunesModule.class) && random.nextBoolean()) { DyeColor color = DyeColor.values()[random.nextInt(DyeColor.values().length)]; @@ -185,12 +186,10 @@ public void prepareEquipment() { @NotNull @Override - protected AbstractArrow getArrow(@NotNull ItemStack arrowStack, float distanceFactor) { - AbstractArrow arrow = super.getArrow(arrowStack, distanceFactor); + protected AbstractArrow getArrow(@NotNull ItemStack arrowStack, float distanceFactor, @Nullable ItemStack itemStack) { + AbstractArrow arrow = super.getArrow(arrowStack, distanceFactor, itemStack); if(arrow instanceof Arrow arrowInstance) { - ItemStack stack = new ItemStack(Items.TIPPED_ARROW); - PotionUtils.setCustomEffects(stack, ImmutableSet.of(new MobEffectInstance(MobEffects.BLINDNESS, 100, 0))); - arrowInstance.setEffectsFromItem(stack); + arrowInstance.addEffect(new MobEffectInstance(MobEffects.BLINDNESS, 100, 0)); } return arrow; diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Foxhound.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Foxhound.java index e450c82110..1587d2ad53 100755 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Foxhound.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Foxhound.java @@ -39,10 +39,7 @@ import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal; import net.minecraft.world.entity.ai.goal.target.NonTameRandomTargetGoal; import net.minecraft.world.entity.ai.goal.target.OwnerHurtTargetGoal; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Rabbit; -import net.minecraft.world.entity.animal.Sheep; -import net.minecraft.world.entity.animal.Wolf; +import net.minecraft.world.entity.animal.*; import net.minecraft.world.entity.monster.Enemy; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; @@ -56,6 +53,7 @@ import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -82,7 +80,6 @@ public class Foxhound extends Wolf implements Enemy { public static final ResourceKey FOXHOUND_LOOT_TABLE = Quark.asResourceKey(Registries.LOOT_TABLE, "entities/foxhound"); - private static final EntityDataAccessor TEMPTATION = SynchedEntityData.defineId(Foxhound.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor IS_BLUE = SynchedEntityData.defineId(Foxhound.class, EntityDataSerializers.BOOLEAN); private static final EntityDataAccessor TATERING = SynchedEntityData.defineId(Foxhound.class, EntityDataSerializers.BOOLEAN); @@ -91,19 +88,19 @@ public class Foxhound extends Wolf implements Enemy { public Foxhound(EntityType type, Level worldIn) { super(type, worldIn); - this.setPathfindingMalus(BlockPathTypes.WATER, -1.0F); - this.setPathfindingMalus(BlockPathTypes.LAVA, 1.0F); - this.setPathfindingMalus(BlockPathTypes.DANGER_FIRE, 1.0F); - this.setPathfindingMalus(BlockPathTypes.DAMAGE_FIRE, 1.0F); + this.setPathfindingMalus(PathType.WATER, -1.0F); + this.setPathfindingMalus(PathType.LAVA, 1.0F); + this.setPathfindingMalus(PathType.DANGER_FIRE, 1.0F); + this.setPathfindingMalus(PathType.DAMAGE_FIRE, 1.0F); //TODO is there a reason this is here twice? } @Override - protected void defineSynchedData() { - super.defineSynchedData(); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); setCollarColor(DyeColor.ORANGE); - entityData.define(TEMPTATION, false); - entityData.define(IS_BLUE, false); - entityData.define(TATERING, false); + builder.define(TEMPTATION, false); + builder.define(IS_BLUE, false); + builder.define(TATERING, false); } @Override @@ -127,12 +124,12 @@ public boolean removeWhenFarAway(double distanceToClosestPlayer) { } @Override - public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, SpawnGroupData spawnDataIn, CompoundTag dataTag) { + public SpawnGroupData finalizeSpawn(ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, SpawnGroupData spawnDataIn) { Holder biome = worldIn.getBiome(BlockPos.containing(position())); if(biome.is(Biomes.SOUL_SAND_VALLEY.location())) setBlue(true); - return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); + return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn); } @Override @@ -158,6 +155,7 @@ public void tick() { setTatering(false); ItemStack stack = new ItemStack(TinyPotatoModule.tiny_potato); ItemNBTHelper.setBoolean(stack, TinyPotatoBlock.ANGRY, true); + spawnAtLocation(stack); playSound(QuarkSounds.BLOCK_POTATO_HURT, 1f, 1f); } else if(!isTatering()) @@ -180,7 +178,7 @@ public void tick() { if(WantLoveGoal.needsPets(this)) { Entity owner = getOwner(); if(owner != null && owner.distanceToSqr(this) < 1 && !owner.isInWater() && !owner.fireImmune() && (!(owner instanceof Player player) || !player.getAbilities().invulnerable)) - owner.setSecondsOnFire(5); + owner.igniteForSeconds(5); } Vec3 pos = position(); @@ -279,7 +277,7 @@ public boolean doHurtTarget(Entity entityIn) { ((int) this.getAttributeValue(Attributes.ATTACK_DAMAGE))); if(flag) { - entityIn.setSecondsOnFire(5); + entityIn.igniteForSeconds(5); this.doEnchantDamageEffects(this, entityIn); } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Shiba.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Shiba.java index 7780883fa4..865bb5fd63 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Shiba.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Shiba.java @@ -63,8 +63,8 @@ protected void registerGoals() { goalSelector.addGoal(2, new SitWhenOrderedToGoal(this)); goalSelector.addGoal(3, new BarkAtDarknessGoal(this)); goalSelector.addGoal(4, new FetchArrowGoal(this)); - goalSelector.addGoal(5, new DeliverFetchedItemGoal(this, 1.1D, -1F, 32.0F, false)); - goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F, false)); + goalSelector.addGoal(5, new DeliverFetchedItemGoal(this, 1.1D, -1F, 32.0F)); + goalSelector.addGoal(6, new FollowOwnerGoal(this, 1.0D, 10.0F, 2.0F)); goalSelector.addGoal(7, new TemptGoal(this, 1, Ingredient.of(Items.BONE), false)); goalSelector.addGoal(8, new BreedGoal(this, 1.0D)); goalSelector.addGoal(9, new NuzzleGoal(this, 0.5F, 16, 2, QuarkSounds.ENTITY_SHIBA_WHINE)); @@ -179,11 +179,11 @@ public boolean isFood(ItemStack stack) { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - entityData.define(COLLAR_COLOR, DyeColor.RED.getId()); - entityData.define(MOUTH_ITEM, ItemStack.EMPTY); - entityData.define(FETCHING, -1); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(COLLAR_COLOR, DyeColor.RED.getId()); + builder.define(MOUTH_ITEM, ItemStack.EMPTY); + builder.define(FETCHING, -1); } public DyeColor getCollarColor() { @@ -246,7 +246,7 @@ public void readAdditionalSaveData(@NotNull CompoundTag compound) { if(compound.contains("MouthItem")) { CompoundTag itemcmp = compound.getCompound("MouthItem"); - setMouthItem(ItemStack.of(itemcmp)); + setMouthItem(ItemStack.parseOptional(level().registryAccess(), itemcmp)); } } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/SoulBead.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/SoulBead.java index 1e10136c49..4ea67d82d7 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/SoulBead.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/SoulBead.java @@ -41,9 +41,9 @@ public void setTarget(int x, int z) { } @Override - protected void defineSynchedData() { - entityData.define(TARGET_X, 0); - entityData.define(TARGET_Z, 0); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + builder.define(TARGET_X, 0); + builder.define(TARGET_Z, 0); } @Override diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Stoneling.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Stoneling.java index ef3bab8b9d..9bc1cda8e9 100755 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Stoneling.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Stoneling.java @@ -40,6 +40,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; @@ -89,18 +90,18 @@ public class Stoneling extends PathfinderMob { public Stoneling(EntityType type, Level worldIn) { super(type, worldIn); - this.setPathfindingMalus(BlockPathTypes.DAMAGE_OTHER, 1.0F); - this.setPathfindingMalus(BlockPathTypes.DANGER_OTHER, 1.0F); + this.setPathfindingMalus(PathType.DAMAGE_OTHER, 1.0F); + this.setPathfindingMalus(PathType.DANGER_OTHER, 1.0F); } @Override - protected void defineSynchedData() { - super.defineSynchedData(); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); - entityData.define(CARRYING_ITEM, ItemStack.EMPTY); - entityData.define(VARIANT, (byte) 0); - entityData.define(HOLD_ANGLE, 0F); - entityData.define(HAS_LICHEN, false); + builder.define(CARRYING_ITEM, ItemStack.EMPTY); + builder.define(VARIANT, (byte) 0); + builder.define(HOLD_ANGLE, 0F); + builder.define(HAS_LICHEN, false); } @Override @@ -253,7 +254,7 @@ public InteractionResult interactAt(@NotNull Player player, @NotNull Vec3 vec, @ @Nullable @Override - public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, @NotNull DifficultyInstance difficulty, @NotNull MobSpawnType spawnReason, @Nullable SpawnGroupData data, @Nullable CompoundTag compound) { + public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, @NotNull DifficultyInstance difficulty, @NotNull MobSpawnType spawnReason, @Nullable SpawnGroupData data) { RandomSource rand = world.getRandom(); byte variant; if(data instanceof StonelingVariant stonelingVariant) @@ -274,7 +275,7 @@ public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, @NotNull Difficul entityData.set(CARRYING_ITEM, items.get(0)); } - return super.finalizeSpawn(world, difficulty, spawnReason, data, compound); + return super.finalizeSpawn(world, difficulty, spawnReason, data); } @Override @@ -297,11 +298,6 @@ else if(sourceEntity instanceof AbstractArrow arrow) return true; } - @Override - public boolean canBreatheUnderwater() { - return true; - } - @Override public boolean checkSpawnObstruction(LevelReader worldReader) { return worldReader.isUnobstructed(this, Shapes.create(getBoundingBox())); diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java index 80b86c0faf..9d4060594f 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Toretoise.java @@ -38,6 +38,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.pathfinder.BlockPathTypes; +import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.AABB; @@ -76,14 +77,14 @@ public class Toretoise extends Animal { public Toretoise(EntityType type, Level world) { super(type, world); setMaxUpStep(1.0F); - setPathfindingMalus(BlockPathTypes.WATER, 1.0F); + setPathfindingMalus(PathType.WATER, 1.0F); } @Override - protected void defineSynchedData() { - super.defineSynchedData(); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); - entityData.define(ORE_TYPE, 0); + builder.define(ORE_TYPE, 0); } @Override @@ -111,16 +112,11 @@ private void computeGoodFood() { } @Override - public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor world, @NotNull DifficultyInstance difficulty, @NotNull MobSpawnType spawnType, SpawnGroupData spawnData, CompoundTag additionalData) { + public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor world, @NotNull DifficultyInstance difficulty, @NotNull MobSpawnType spawnType, SpawnGroupData spawnData) { popOre(true); return spawnData; } - @Override - public boolean canBreatheUnderwater() { - return true; - } - @Override public boolean isPushedByFluid() { return false; @@ -360,7 +356,7 @@ public boolean checkSpawnRules(@NotNull LevelAccessor world, @NotNull MobSpawnTy } @Override - protected void jumpFromGround() { + public void jumpFromGround() { // NO-OP } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Wraith.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Wraith.java index a1587ad83f..52f0ee4158 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Wraith.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Wraith.java @@ -58,12 +58,12 @@ public Wraith(EntityType type, Level worldIn) { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); - entityData.define(IDLE_SOUND, ""); - entityData.define(HURT_SOUND, ""); - entityData.define(DEATH_SOUND, ""); + builder.define(IDLE_SOUND, ""); + builder.define(HURT_SOUND, ""); + builder.define(DEATH_SOUND, ""); } public static AttributeSupplier.Builder registerAttributes() { @@ -142,7 +142,7 @@ public boolean doHurtTarget(@NotNull Entity entityIn) { } @Override - public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, SpawnGroupData spawnDataIn, CompoundTag dataTag) { + public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNull DifficultyInstance difficultyIn, @NotNull MobSpawnType reason, SpawnGroupData spawnDataIn) { int idx = random.nextInt(WraithModule.validWraithSounds.size()); String sound = WraithModule.validWraithSounds.get(idx); String[] split = sound.split("\\|"); @@ -151,7 +151,7 @@ public SpawnGroupData finalizeSpawn(@NotNull ServerLevelAccessor worldIn, @NotNu entityData.set(HURT_SOUND, split[1]); entityData.set(DEATH_SOUND, split[2]); - return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn, dataTag); + return super.finalizeSpawn(worldIn, difficultyIn, reason, spawnDataIn); } @Override diff --git a/src/main/java/org/violetmoon/quark/content/mobs/item/DiamondHeartItem.java b/src/main/java/org/violetmoon/quark/content/mobs/item/DiamondHeartItem.java index 644dcc7c06..8e35de7021 100755 --- a/src/main/java/org/violetmoon/quark/content/mobs/item/DiamondHeartItem.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/item/DiamondHeartItem.java @@ -66,7 +66,7 @@ public InteractionResult useOn(UseOnContext context) { stoneling.setPos(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); stoneling.setPlayerMade(true); stoneling.setYRot(player.getYRot() + 180F); - stoneling.finalizeSpawn(serverLevel, world.getCurrentDifficultyAt(pos), MobSpawnType.STRUCTURE, variant, null); + stoneling.finalizeSpawn(serverLevel, world.getCurrentDifficultyAt(pos), MobSpawnType.STRUCTURE, variant); world.addFreshEntity(stoneling); if(player instanceof ServerPlayer serverPlayer) { @@ -86,12 +86,6 @@ public InteractionResult useOn(UseOnContext context) { return InteractionResult.PASS; } - @NotNull - @Override - public Rarity getRarity(@NotNull ItemStack stack) { - return Rarity.UNCOMMON; - } - @Override public boolean isFoil(@NotNull ItemStack stack) { return true; diff --git a/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java b/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java index 6c9ebc565a..d61d58ccb7 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/item/ForgottenHatItem.java @@ -6,10 +6,12 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.item.*; +import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraftforge.common.ForgeMod; import org.jetbrains.annotations.NotNull; @@ -35,7 +37,8 @@ public ForgottenHatItem(ZetaModule module) { new Item.Properties() .stacksTo(1) .durability(0) - .rarity(Rarity.RARE)); + .rarity(Rarity.RARE) + .attributes(createAttributes())); Quark.ZETA.registry.registerItem(this, "forgotten_hat"); this.module = module; @@ -72,22 +75,15 @@ public boolean isEnchantable(@NotNull ItemStack stack) { return false; } - @Override - public Multimap getDefaultAttributeModifiers(EquipmentSlot slot) { - if(attributes == null) { - Builder builder = ImmutableMultimap.builder(); - UUID uuid = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150"); - builder.put(Attributes.ARMOR, new AttributeModifier(uuid, "Armor modifier", 1, AttributeModifier.Operation.ADDITION)); - builder.put(Attributes.LUCK, new AttributeModifier(uuid, "Armor luck modifier", 1, AttributeModifier.Operation.ADDITION)); - - //TODO: Forge extension attributes (but these are on the way out, i guess) - builder.put(ForgeMod.ENTITY_REACH.get(), new AttributeModifier(uuid, "Armor entity reach modifier", 2, AttributeModifier.Operation.ADDITION)); - builder.put(ForgeMod.BLOCK_REACH.get(), new AttributeModifier(uuid, "Armor block reach modifier", 2, AttributeModifier.Operation.ADDITION)); + public static ItemAttributeModifiers createAttributes() { + ItemAttributeModifiers.Builder builder = ItemAttributeModifiers.builder(); + builder.add(Attributes.ARMOR, new AttributeModifier(Quark.asResource("forgotten_hat_armor"), 1, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.HEAD); + builder.add(Attributes.LUCK, new AttributeModifier(Quark.asResource("forgotten_hat_luck"), 1, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.HEAD); - attributes = builder.build(); - } + builder.add(Attributes.ENTITY_INTERACTION_RANGE, new AttributeModifier(Quark.asResource("forgotten_hat_entity_interaction_range"), 2, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.HEAD); + builder.add(Attributes.BLOCK_INTERACTION_RANGE, new AttributeModifier(Quark.asResource("forgotten_hat_block_interaction_range"), 2, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.HEAD); - return slot == this.getEquipmentSlot() ? attributes : super.getDefaultAttributeModifiers(slot); + return builder.build(); } } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/module/ForgottenModule.java b/src/main/java/org/violetmoon/quark/content/mobs/module/ForgottenModule.java index 708f5d8535..8ac21ddc96 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/module/ForgottenModule.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/module/ForgottenModule.java @@ -88,7 +88,7 @@ public void onSkeletonSpawn(ZMobSpawnEvent.CheckSpawn.Lowest event) { Vec3 epos = entity.position(); forgotten.absMoveTo(epos.x, epos.y, epos.z, entity.getYRot(), entity.getXRot()); - forgotten.prepareEquipment(); + forgotten.prepareEquipment(event.getLevel(), event.getLevel().getCurrentDifficultyAt(entity.getOnPos())); BlockPos pos = BlockPos.containing(event.getX(), event.getY(), event.getZ()); diff --git a/src/main/java/org/violetmoon/quark/content/mobs/module/StonelingsModule.java b/src/main/java/org/violetmoon/quark/content/mobs/module/StonelingsModule.java index c945648ebb..53f699a101 100755 --- a/src/main/java/org/violetmoon/quark/content/mobs/module/StonelingsModule.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/module/StonelingsModule.java @@ -7,6 +7,7 @@ import net.minecraft.world.entity.MobCategory; import net.minecraft.world.entity.SpawnPlacements.Type; import net.minecraft.world.item.Item; +import net.minecraft.world.item.Rarity; import net.minecraft.world.level.levelgen.Heightmap.Types; import net.minecraftforge.common.Tags; import org.violetmoon.quark.base.Quark; @@ -57,7 +58,7 @@ public class StonelingsModule extends ZetaModule { @LoadEvent public final void register(ZRegister event) { this.registered = true; - diamondHeart = new DiamondHeartItem("diamond_heart", this, new Item.Properties()); + diamondHeart = new DiamondHeartItem("diamond_heart", this, new Item.Properties().rarity(Rarity.UNCOMMON)); stonelingType = EntityType.Builder.of(Stoneling::new, MobCategory.CREATURE) .sized(0.5F, 0.9F) diff --git a/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java b/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java index baccc2bef5..d2dd7ed95a 100755 --- a/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java +++ b/src/main/java/org/violetmoon/quark/content/tools/item/PickarangItem.java @@ -12,6 +12,7 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; @@ -21,6 +22,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.TridentItem; +import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; @@ -127,18 +129,13 @@ public InteractionResultHolder use(Level worldIn, Player playerIn, @N return InteractionResultHolder.sidedSuccess( itemstack, worldIn.isClientSide); } - @SuppressWarnings("deprecation") //Avoiding FOrge extension - @NotNull - @Override - public Multimap getDefaultAttributeModifiers(@NotNull EquipmentSlot slot) { - Multimap multimap = Multimaps.newSetMultimap(new HashMap<>(), HashSet::new); + public static ItemAttributeModifiers createAttributes() { + ItemAttributeModifiers.Builder builder = ItemAttributeModifiers.builder(); - if(slot == EquipmentSlot.MAINHAND) { - multimap.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", type.attackDamage, AttributeModifier.Operation.ADDITION)); - multimap.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", -2.8, AttributeModifier.Operation.ADDITION)); - } + builder.add(Attributes.ATTACK_DAMAGE, new AttributeModifier(Quark.asResource("pickarang_attack_damage"), type.attackDamage, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND); + builder.add(Attributes.ATTACK_SPEED, new AttributeModifier(Quark.asResource("pickarang_attack_speed"), -2.8, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND); - return multimap; + return builder.build(); } @Override diff --git a/src/main/java/org/violetmoon/quark/content/tools/module/PickarangModule.java b/src/main/java/org/violetmoon/quark/content/tools/module/PickarangModule.java index 519cae3715..e3813c8e39 100755 --- a/src/main/java/org/violetmoon/quark/content/tools/module/PickarangModule.java +++ b/src/main/java/org/violetmoon/quark/content/tools/module/PickarangModule.java @@ -109,6 +109,8 @@ private Item.Properties propertiesFor(int durability, boolean fireResist) { if (fireResist) properties.fireResistant(); + properties.attributes(PickarangItem.createAttributes()); + return properties; } diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/module/PigLittersModule.java b/src/main/java/org/violetmoon/quark/content/tweaks/module/PigLittersModule.java index edeeebc9b5..5f879e1210 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/module/PigLittersModule.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/module/PigLittersModule.java @@ -1,5 +1,6 @@ package org.violetmoon.quark.content.tweaks.module; +import net.minecraft.world.entity.Entity; import org.violetmoon.quark.base.Quark; import org.violetmoon.zeta.config.Config; import org.violetmoon.zeta.event.bus.PlayEvent; @@ -87,7 +88,7 @@ public void onPigAppear(ZEntityJoinLevel event) { @PlayEvent public void onEntityUpdate(ZLivingTick event) { - LivingEntity entity = event.getEntity(); + Entity entity = event.getEntity(); if(entity instanceof Animal animal && !animal.isInLove()) animal.getPersistentData().remove(GOLDEN_CARROT_TAG); } diff --git a/src/main/resources/data/minecraft/tags/entity_type/can_breathe_under_water.json b/src/main/resources/data/minecraft/tags/entity_type/can_breathe_under_water.json new file mode 100644 index 0000000000..8c1bc9265b --- /dev/null +++ b/src/main/resources/data/minecraft/tags/entity_type/can_breathe_under_water.json @@ -0,0 +1,7 @@ +{ + "values": [ + "quark:crab", + "quark:stoneling", + "quark:toretoise" + ] +} \ No newline at end of file From 26d8069bbd43bd7a77a6a20151eb5abcf829cf49 Mon Sep 17 00:00:00 2001 From: Partonetrain Date: Sun, 5 Jan 2025 15:29:50 -0600 Subject: [PATCH 2/3] more of the last commit --- .../oddities/magnetsystem/DefaultMoveActions.java | 4 ++-- .../org/violetmoon/quark/api/ITransferManager.java | 2 +- .../quark/base/item/boat/QuarkChestBoat.java | 6 +++--- .../quark/content/automation/entity/Gravisand.java | 7 +++---- .../content/building/entity/GlassItemFrame.java | 6 +++--- .../quark/content/building/entity/Stool.java | 3 ++- .../building/module/GlassItemFrameModule.java | 2 +- .../content/client/tooltip/AttributeTooltips.java | 6 +++--- .../quark/content/mobs/module/CrabsModule.java | 2 +- .../quark/content/tools/entity/ParrotEgg.java | 6 +++--- .../quark/content/tools/entity/SkullPike.java | 3 ++- .../quark/content/tools/entity/TorchArrow.java | 9 +++++++-- .../content/tools/entity/rang/AbstractPickarang.java | 6 +++--- .../quark/content/tweaks/entity/DyedItemFrame.java | 12 ++++++------ 14 files changed, 40 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/magnetsystem/DefaultMoveActions.java b/src/main/java/org/violetmoon/quark/addons/oddities/magnetsystem/DefaultMoveActions.java index 6df82d2bc9..c1b326bfe8 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/magnetsystem/DefaultMoveActions.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/magnetsystem/DefaultMoveActions.java @@ -14,8 +14,8 @@ import net.minecraft.world.level.block.*; import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidState; -import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.common.util.FakePlayerFactory; +import net.neoforged.neoforge.common.util.FakePlayer; +import net.neoforged.neoforge.common.util.FakePlayerFactory; import org.violetmoon.quark.addons.oddities.module.MagnetsModule; import org.violetmoon.quark.api.IMagnetMoveAction; diff --git a/src/main/java/org/violetmoon/quark/api/ITransferManager.java b/src/main/java/org/violetmoon/quark/api/ITransferManager.java index da9c52c7c1..f8a02db78c 100644 --- a/src/main/java/org/violetmoon/quark/api/ITransferManager.java +++ b/src/main/java/org/violetmoon/quark/api/ITransferManager.java @@ -11,7 +11,7 @@ package org.violetmoon.quark.api; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.items.IItemHandler; +import net.neoforged.neoforge.items.IItemHandler; import java.util.function.Supplier; diff --git a/src/main/java/org/violetmoon/quark/base/item/boat/QuarkChestBoat.java b/src/main/java/org/violetmoon/quark/base/item/boat/QuarkChestBoat.java index 1c63b89564..15aa93a08e 100644 --- a/src/main/java/org/violetmoon/quark/base/item/boat/QuarkChestBoat.java +++ b/src/main/java/org/violetmoon/quark/base/item/boat/QuarkChestBoat.java @@ -35,9 +35,9 @@ public QuarkChestBoat(Level world, double x, double y, double z) { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - entityData.define(DATA_QUARK_TYPE, "blossom"); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(DATA_QUARK_TYPE, "blossom"); } public String getQuarkBoatType() { diff --git a/src/main/java/org/violetmoon/quark/content/automation/entity/Gravisand.java b/src/main/java/org/violetmoon/quark/content/automation/entity/Gravisand.java index b66397d80b..649e54f153 100755 --- a/src/main/java/org/violetmoon/quark/content/automation/entity/Gravisand.java +++ b/src/main/java/org/violetmoon/quark/content/automation/entity/Gravisand.java @@ -88,10 +88,9 @@ public void tick() { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - - entityData.define(DIRECTION, 0F); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(DIRECTION, 0F); } @Override diff --git a/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java b/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java index 95995b5b5d..f4c7a97262 100755 --- a/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java +++ b/src/main/java/org/violetmoon/quark/content/building/entity/GlassItemFrame.java @@ -175,10 +175,10 @@ else if(absDiff >= 135 && absDiff < 225) } @Override - protected void defineSynchedData() { - super.defineSynchedData(); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); - entityData.define(IS_SHINY, false); + builder.define(IS_SHINY, false); } @Override diff --git a/src/main/java/org/violetmoon/quark/content/building/entity/Stool.java b/src/main/java/org/violetmoon/quark/content/building/entity/Stool.java index 220b371189..39832314fa 100644 --- a/src/main/java/org/violetmoon/quark/content/building/entity/Stool.java +++ b/src/main/java/org/violetmoon/quark/content/building/entity/Stool.java @@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MoverType; @@ -81,7 +82,7 @@ public double getPassengersRidingOffset() { } @Override - protected void defineSynchedData() { + protected void defineSynchedData(SynchedEntityData.Builder builder) { // NO-OP } diff --git a/src/main/java/org/violetmoon/quark/content/building/module/GlassItemFrameModule.java b/src/main/java/org/violetmoon/quark/content/building/module/GlassItemFrameModule.java index fb087be6ae..91137917c9 100644 --- a/src/main/java/org/violetmoon/quark/content/building/module/GlassItemFrameModule.java +++ b/src/main/java/org/violetmoon/quark/content/building/module/GlassItemFrameModule.java @@ -76,7 +76,7 @@ public final void clientSetup(ZClientSetup event) { @LoadEvent public void registerAdditionalModels(ZAddModels event) { - event.register(new ModelResourceLocation(Quark.MOD_ID, "extra/glass_item_frame", "inventory")); + event.register(new ModelResourceLocation(Quark.asResource("extra/glass_item_frame"), "inventory")); } } diff --git a/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java b/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java index 7fba3a15b0..ca7465bef1 100644 --- a/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java +++ b/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java @@ -299,19 +299,19 @@ private static double getAttribute(Player player, AttributeSlot slot, ItemStack } for(AttributeModifier modifier : collection) { - if(modifier.getOperation() == AttributeModifier.Operation.ADDITION) + if(modifier.getOperation() == AttributeModifier.Operation.ADD_VALUE) value += modifier.getAmount(); } double rawValue = value; for(AttributeModifier modifier : collection) { - if(modifier.getOperation() == AttributeModifier.Operation.MULTIPLY_BASE) + if(modifier.getOperation() == AttributeModifier.Operation.ADD_MULTIPLIED_BASE) value += rawValue * modifier.getAmount(); } for(AttributeModifier modifier : collection) { - if(modifier.getOperation() == AttributeModifier.Operation.MULTIPLY_TOTAL) + if(modifier.getOperation() == AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL) value += value * modifier.getAmount(); } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/module/CrabsModule.java b/src/main/java/org/violetmoon/quark/content/mobs/module/CrabsModule.java index b9779114f2..b8f0d24edb 100644 --- a/src/main/java/org/violetmoon/quark/content/mobs/module/CrabsModule.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/module/CrabsModule.java @@ -115,7 +115,7 @@ public final void register(ZRegister event) { crab_bucket = new ZetaMobBucketItem(() -> crabType, () -> Fluids.WATER, () -> QuarkSounds.BUCKET_EMPTY_CRAB, "crab_bucket", this); resilience = new ZetaEffect(Quark.ZETA, "resilience", MobEffectCategory.BENEFICIAL, 0x5b1a04); - resilience.addAttributeModifier(Attributes.KNOCKBACK_RESISTANCE, "2ddf3f0a-f386-47b6-aeb0-6bd32851f215", 0.5, AttributeModifier.Operation.ADDITION); + resilience.addAttributeModifier(Attributes.KNOCKBACK_RESISTANCE, Quark.asResource("resilience_knockback_resistance"), 0.5, AttributeModifier.Operation.ADD_VALUE); event.getBrewingRegistry().addPotionMix("crab_brewing", () -> Ingredient.of(crab_shell), resilience); diff --git a/src/main/java/org/violetmoon/quark/content/tools/entity/ParrotEgg.java b/src/main/java/org/violetmoon/quark/content/tools/entity/ParrotEgg.java index 4b3c95fd88..a10d567584 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/entity/ParrotEgg.java +++ b/src/main/java/org/violetmoon/quark/content/tools/entity/ParrotEgg.java @@ -38,9 +38,9 @@ public ParrotEgg(Level world, LivingEntity owner) { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - getEntityData().define(VARIANT, 0); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(VARIANT, 0); } public Parrot.Variant getVariant() { diff --git a/src/main/java/org/violetmoon/quark/content/tools/entity/SkullPike.java b/src/main/java/org/violetmoon/quark/content/tools/entity/SkullPike.java index d91f2c4981..0b761d271d 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/entity/SkullPike.java +++ b/src/main/java/org/violetmoon/quark/content/tools/entity/SkullPike.java @@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BlockTags; import net.minecraft.world.entity.Entity; @@ -58,7 +59,7 @@ public boolean isVisible(Entity entityIn) { } @Override - protected void defineSynchedData() { + protected void defineSynchedData(SynchedEntityData.Builder builder) { // NO-OP } diff --git a/src/main/java/org/violetmoon/quark/content/tools/entity/TorchArrow.java b/src/main/java/org/violetmoon/quark/content/tools/entity/TorchArrow.java index 8a683dddca..e4365ea84b 100644 --- a/src/main/java/org/violetmoon/quark/content/tools/entity/TorchArrow.java +++ b/src/main/java/org/violetmoon/quark/content/tools/entity/TorchArrow.java @@ -95,9 +95,9 @@ protected void onHitBlock(BlockHitResult result) { @Override protected void onHitEntity(EntityHitResult result) { // incredible hack to ensure we still set entities on fire without rendering the fire texture - setSecondsOnFire(1); + igniteForSeconds(1); super.onHitEntity(result); - setSecondsOnFire(0); + extinguishFire(); } @Override @@ -105,4 +105,9 @@ protected void onHitEntity(EntityHitResult result) { return new ItemStack(TorchArrowModule.extinguishOnMiss ? Items.ARROW : TorchArrowModule.torch_arrow); } + @Override + protected ItemStack getDefaultPickupItem() { + return new ItemStack(TorchArrowModule.torch_arrow); + } + } diff --git a/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java b/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java index dfdc64592d..377b419025 100755 --- a/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java +++ b/src/main/java/org/violetmoon/quark/content/tools/entity/rang/AbstractPickarang.java @@ -136,9 +136,9 @@ public void setThrowData(int slot, ItemStack stack) { } @Override - protected void defineSynchedData() { - entityData.define(STACK, new ItemStack(PickarangModule.pickarang)); - entityData.define(RETURNING, false); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + builder.define(STACK, new ItemStack(PickarangModule.pickarang)); + builder.define(RETURNING, false); } protected void checkImpact() { diff --git a/src/main/java/org/violetmoon/quark/content/tweaks/entity/DyedItemFrame.java b/src/main/java/org/violetmoon/quark/content/tweaks/entity/DyedItemFrame.java index 83c63e9c6b..0c6f575dbe 100644 --- a/src/main/java/org/violetmoon/quark/content/tweaks/entity/DyedItemFrame.java +++ b/src/main/java/org/violetmoon/quark/content/tweaks/entity/DyedItemFrame.java @@ -12,8 +12,8 @@ import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.DyedItemColor; import net.minecraft.world.level.Level; - import org.violetmoon.quark.base.Quark; import org.violetmoon.quark.content.tweaks.module.DyeableItemFramesModule; @@ -37,10 +37,10 @@ public DyedItemFrame(Level level, BlockPos pos, Direction direction, int color, } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - getEntityData().define(DATA_COLOR, 0); - getEntityData().define(DATA_GLOW, false); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(DATA_COLOR, 0); + builder.define(DATA_GLOW, false); } @Override @@ -59,7 +59,7 @@ public void readAdditionalSaveData(CompoundTag cmp) { getEntityData().set(DATA_GLOW, cmp.getBoolean(TAG_GLOW)); } - public int getColor() { + public DyedItemColor getColor() { return getEntityData().get(DATA_COLOR); } From 1966598b0c353640b973656b5885dc81e12d0f19 Mon Sep 17 00:00:00 2001 From: Partonetrain Date: Sun, 5 Jan 2025 15:46:53 -0600 Subject: [PATCH 3/3] step height attribute stuff --- .../content/building/block/GrateBlock.java | 20 +++++++++++-------- .../client/tooltip/AttributeTooltips.java | 6 +++--- .../quark/content/mobs/entity/Crab.java | 6 +++--- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/violetmoon/quark/content/building/block/GrateBlock.java b/src/main/java/org/violetmoon/quark/content/building/block/GrateBlock.java index 3d4e34b105..0b5b504d5d 100755 --- a/src/main/java/org/violetmoon/quark/content/building/block/GrateBlock.java +++ b/src/main/java/org/violetmoon/quark/content/building/block/GrateBlock.java @@ -1,13 +1,15 @@ package org.violetmoon.quark.content.building.block; -import it.unimi.dsi.fastutil.floats.Float2ObjectArrayMap; - +import it.unimi.dsi.fastutil.doubles.Double2ObjectArrayMap; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerPlayer; import net.minecraft.tags.FluidTags; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ExperienceOrb; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.ai.attributes.AttributeInstance; +import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.WaterAnimal; import net.minecraft.world.entity.item.ItemEntity; @@ -33,10 +35,8 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.event.ForgeEventFactory; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - import org.violetmoon.quark.api.ICrawlSpaceBlock; import org.violetmoon.zeta.block.SimpleFluidloggedBlock; import org.violetmoon.zeta.block.ZetaBlock; @@ -45,7 +45,7 @@ public class GrateBlock extends ZetaBlock implements SimpleFluidloggedBlock, ICrawlSpaceBlock { private static final VoxelShape TRUE_SHAPE = box(0, 15, 0, 16, 16, 16); - private static final Float2ObjectArrayMap WALK_BLOCK_CACHE = new Float2ObjectArrayMap<>(); + private static final Double2ObjectArrayMap WALK_BLOCK_CACHE = new Double2ObjectArrayMap<>(); public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; public static final BooleanProperty LAVALOGGED = BooleanProperty.create("lavalogged"); @@ -97,7 +97,7 @@ public VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter world return TRUE_SHAPE; } - private static VoxelShape getCachedShape(float stepHeight) { + private static VoxelShape getCachedShape(double stepHeight) { return WALK_BLOCK_CACHE.computeIfAbsent(stepHeight, GrateBlock::createNewBox); } @@ -125,8 +125,12 @@ public VoxelShape getCollisionShape(@NotNull BlockState state, @NotNull BlockGet boolean onGrate = world.getBlockState(entity.blockPosition().offset(0, -1, 0)).getBlock() instanceof GrateBlock; if(preventedType && !leashed && !onGrate) { - return getCachedShape(entity.getStepHeight()); - } + LivingEntity livingEntity = (LivingEntity) entity; + AttributeInstance stepHeight = livingEntity.getAttribute(Attributes.STEP_HEIGHT); + if (stepHeight != null) { + return getCachedShape(stepHeight.getValue()); + } + } return TRUE_SHAPE; } diff --git a/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java b/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java index ca7465bef1..f6f513da76 100644 --- a/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java +++ b/src/main/java/org/violetmoon/quark/content/client/tooltip/AttributeTooltips.java @@ -172,13 +172,13 @@ private static Multimap getModifiers(ItemStack sta var map = capturedModifiers.get(slot); if(slot == AttributeSlot.MAINHAND) { if(!map.containsKey(Attributes.ATTACK_DAMAGE) && (map.containsKey(Attributes.ATTACK_SPEED) || EnchantmentHelper.getDamageBonus(stack, MobType.UNDEFINED) > 0)) - map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(Util.NIL_UUID, "-", 0, AttributeModifier.Operation.ADDITION)); + map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(Util.NIL_UUID, "-", 0, AttributeModifier.Operation.ADD_VALUE)); if(!map.containsKey(Attributes.ATTACK_SPEED) && map.containsKey(Attributes.ATTACK_DAMAGE)) - map.put(Attributes.ATTACK_SPEED, new AttributeModifier(Util.NIL_UUID, "-", 0, AttributeModifier.Operation.ADDITION)); + map.put(Attributes.ATTACK_SPEED, new AttributeModifier(Util.NIL_UUID, "-", 0, AttributeModifier.Operation.ADD_VALUE)); if(!map.containsKey(Attributes.ATTACK_KNOCKBACK) && Quark.ZETA.itemExtensions.get(stack).getEnchantmentLevelZeta(stack, Enchantments.KNOCKBACK) > 0) - map.put(Attributes.ATTACK_KNOCKBACK, new AttributeModifier(Util.NIL_UUID, "-", 0, AttributeModifier.Operation.ADDITION)); + map.put(Attributes.ATTACK_KNOCKBACK, new AttributeModifier(Util.NIL_UUID, "-", 0, AttributeModifier.Operation.ADD_VALUE)); } return map; } diff --git a/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java b/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java index 1e4a23c707..0304cbc1f5 100755 --- a/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java +++ b/src/main/java/org/violetmoon/quark/content/mobs/entity/Crab.java @@ -323,9 +323,9 @@ public void tick() { } @Override - public float getStepHeight() { - float baseStep = wasTouchingWater ? 1F : 0.6F; - AttributeInstance stepHeightAttribute = getAttribute(ForgeMod.STEP_HEIGHT_ADDITION.get()); + public float getStepHeight() { //TODO figure out when to recalculate attribute -Partonetrain + float baseStep = isInWater() ? 1F : 0.6F; + AttributeInstance stepHeightAttribute = getAttribute(Attributes.STEP_HEIGHT); if(stepHeightAttribute != null) return (float) Math.max(0, baseStep + stepHeightAttribute.getValue()); return baseStep;