diff --git a/Fabric/src/main/java/vazkii/botania/fabric/block_entity/FabricRedStringContainerBlockEntity.java b/Fabric/src/main/java/vazkii/botania/fabric/block_entity/FabricRedStringContainerBlockEntity.java index 35f5d2dbf9..c8ffb9dfdf 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/block_entity/FabricRedStringContainerBlockEntity.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/block_entity/FabricRedStringContainerBlockEntity.java @@ -4,6 +4,7 @@ import net.fabricmc.fabric.api.transfer.v1.storage.Storage; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.state.BlockState; @@ -42,7 +43,7 @@ public void onBound(BlockPos pos) { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { // We cannot query for the storage api on the client - so we send the binding position. BlockPos binding = getBinding(); if (binding == null) { @@ -56,7 +57,7 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { if (cmp.contains("bindX")) { clientPos = new BlockPos(cmp.getInt("bindX"), cmp.getInt("bindY"), cmp.getInt("bindZ")); } else { diff --git a/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java b/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java index 37152ac047..dd4e94bd63 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/data/FabricDatagenInitializer.java @@ -41,8 +41,8 @@ private static void configureFabricDatagen(FabricDataGenerator.Pack pack) { private static void configureXplatDatagen(FabricDataGenerator.Pack pack) { pack.addProvider((PackOutput output) -> new BlockLootProvider(output)); - pack.addProvider((PackOutput output) -> new LooniumStructureLootProvider(output)); - pack.addProvider((PackOutput output) -> new LooniumStructureConfigurationProvider(output)); + pack.addProvider(LooniumStructureLootProvider::new); + pack.addProvider(LooniumStructureConfigurationProvider::new); pack.addProvider(LooniumEquipmentLootProvider::new); BlockTagProvider blockTagProvider = pack.addProvider(BlockTagProvider::new); pack.addProvider((output, registriesFuture) -> new ItemTagProvider(output, registriesFuture, blockTagProvider.contentsGetter())); diff --git a/Fabric/src/main/java/vazkii/botania/fabric/integration/rei/ElvenTradeREICategory.java b/Fabric/src/main/java/vazkii/botania/fabric/integration/rei/ElvenTradeREICategory.java index 58290c5f21..61baceac3c 100644 --- a/Fabric/src/main/java/vazkii/botania/fabric/integration/rei/ElvenTradeREICategory.java +++ b/Fabric/src/main/java/vazkii/botania/fabric/integration/rei/ElvenTradeREICategory.java @@ -97,10 +97,10 @@ void drawPortal(PoseStack matrices, Point point) { int stopY = startY + 48; Matrix4f mat = matrices.last().pose(); Matrix3f n = matrices.last().normal(); - v.addVertex(mat, startX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV0()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, startX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV1()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, stopX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV1()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, stopX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV0()).uv2(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, startX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV0()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, startX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV1()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, stopX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV1()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, stopX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV0()).setLight(0xF000F0).setNormal(n, 1, 0, 0); immediate.endBatch(); } } diff --git a/Xplat/src/main/java/vazkii/botania/api/BotaniaAPI.java b/Xplat/src/main/java/vazkii/botania/api/BotaniaAPI.java index 1df0559baa..5e381508cb 100644 --- a/Xplat/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/Xplat/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -14,8 +14,9 @@ import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.Container; import net.minecraft.world.SimpleContainer; import net.minecraft.world.entity.Entity; @@ -37,6 +38,7 @@ import vazkii.botania.api.internal.ManaNetwork; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.function.Function; @@ -98,49 +100,7 @@ default void registerPaintableBlock(ResourceLocation blockId, Function Ingredient.EMPTY, List.of(), 0, 0); Tier DUMMY_ITEM_TIER = new Tier() { @Override @@ -159,8 +119,8 @@ public float getAttackDamageBonus() { } @Override - public int getLevel() { - return 0; + public TagKey getIncorrectBlocksForDrops() { + return BlockTags.INCORRECT_FOR_WOODEN_TOOL; } @Override diff --git a/Xplat/src/main/java/vazkii/botania/api/BotaniaRegistries.java b/Xplat/src/main/java/vazkii/botania/api/BotaniaRegistries.java index be9ad96fec..8ccbbad42b 100644 --- a/Xplat/src/main/java/vazkii/botania/api/BotaniaRegistries.java +++ b/Xplat/src/main/java/vazkii/botania/api/BotaniaRegistries.java @@ -12,11 +12,12 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTab; -import static vazkii.botania.api.BotaniaAPI.botaniaRL; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.recipe.StateIngredientType; +import static vazkii.botania.api.BotaniaAPI.botaniaRL; + public class BotaniaRegistries { public static final ResourceKey> BREWS = ResourceKey.createRegistryKey(botaniaRL("brews")); diff --git a/Xplat/src/main/java/vazkii/botania/api/block/HornHarvestable.java b/Xplat/src/main/java/vazkii/botania/api/block/HornHarvestable.java index d5b65f612d..df046cc222 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block/HornHarvestable.java +++ b/Xplat/src/main/java/vazkii/botania/api/block/HornHarvestable.java @@ -13,10 +13,10 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import static vazkii.botania.api.BotaniaAPI.botaniaRL; import org.jetbrains.annotations.Nullable; -import vazkii.botania.api.BotaniaAPI; + +import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** * Blocks with this capability can express custom logic when being diff --git a/Xplat/src/main/java/vazkii/botania/api/block/HourglassTrigger.java b/Xplat/src/main/java/vazkii/botania/api/block/HourglassTrigger.java index 8880479e73..65b4074744 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block/HourglassTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/api/block/HourglassTrigger.java @@ -10,7 +10,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.entity.BlockEntity; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/block/Wandable.java b/Xplat/src/main/java/vazkii/botania/api/block/Wandable.java index 4330eb8b76..7612afae01 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block/Wandable.java +++ b/Xplat/src/main/java/vazkii/botania/api/block/Wandable.java @@ -14,7 +14,7 @@ import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.Nullable; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/block_entity/BindableSpecialFlowerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/api/block_entity/BindableSpecialFlowerBlockEntity.java index 379846296f..4f4ca8b678 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block_entity/BindableSpecialFlowerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/api/block_entity/BindableSpecialFlowerBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; import net.minecraft.world.entity.LivingEntity; @@ -151,8 +152,8 @@ public boolean bindTo(Player player, ItemStack wand, BlockPos pos, Direction sid } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); if (bindingPos != null) { cmp.put(TAG_BINDING, NbtUtils.writeBlockPos(bindingPos)); @@ -160,8 +161,8 @@ public void writeToPacketNBT(CompoundTag cmp) { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); if (cmp.contains(TAG_BINDING)) { bindingPos = NbtUtils.readBlockPos(cmp.getCompound(TAG_BINDING)); diff --git a/Xplat/src/main/java/vazkii/botania/api/block_entity/FunctionalFlowerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/api/block_entity/FunctionalFlowerBlockEntity.java index 95df9f76ab..a2afcc4482 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block_entity/FunctionalFlowerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/api/block_entity/FunctionalFlowerBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -23,6 +24,7 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.ManaNetwork; import vazkii.botania.api.mana.ManaPool; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** @@ -115,14 +117,14 @@ public ItemStack getDefaultHudIcon() { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); mana = cmp.getInt(TAG_MANA); } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_MANA, mana); } } diff --git a/Xplat/src/main/java/vazkii/botania/api/block_entity/GeneratingFlowerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/api/block_entity/GeneratingFlowerBlockEntity.java index ea277046c8..12e9175ef5 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block_entity/GeneratingFlowerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/api/block_entity/GeneratingFlowerBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.api.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -22,6 +23,7 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.internal.ManaNetwork; import vazkii.botania.api.mana.ManaCollector; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** @@ -101,14 +103,14 @@ public ItemStack getDefaultHudIcon() { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); mana = cmp.getInt(TAG_MANA); } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_MANA, getMana()); } } diff --git a/Xplat/src/main/java/vazkii/botania/api/block_entity/RadiusDescriptor.java b/Xplat/src/main/java/vazkii/botania/api/block_entity/RadiusDescriptor.java index 9ff107b6b9..8aa8c07dc1 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block_entity/RadiusDescriptor.java +++ b/Xplat/src/main/java/vazkii/botania/api/block_entity/RadiusDescriptor.java @@ -15,7 +15,7 @@ * This object describes the Radius of a BlockEntity. It can either be * a circle or rectangle. */ -public sealed interface RadiusDescriptor permits RadiusDescriptor.Circle,RadiusDescriptor.Rectangle { +public sealed interface RadiusDescriptor permits RadiusDescriptor.Circle, RadiusDescriptor.Rectangle { record Circle(BlockPos subtileCoords, double radius) implements RadiusDescriptor { } diff --git a/Xplat/src/main/java/vazkii/botania/api/block_entity/SpecialFlowerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/api/block_entity/SpecialFlowerBlockEntity.java index 19ced5b950..b2afd23d4a 100644 --- a/Xplat/src/main/java/vazkii/botania/api/block_entity/SpecialFlowerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/api/block_entity/SpecialFlowerBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.api.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; @@ -58,6 +59,7 @@ public ItemStack getDisplayStack() { public boolean overgrowth = false; /** true if this flower is working on Enchanted Soil and this is the second tick **/ public boolean overgrowthBoost = false; + @Nullable private BlockPos positionOverride; private boolean isFloating; @@ -144,8 +146,8 @@ protected void tickFlower() { } @Override - public final void load(CompoundTag cmp) { - super.load(cmp); + public final void loadAdditional(CompoundTag cmp, HolderLookup.Provider registries) { + super.loadAdditional(cmp, registries); if (cmp.contains(TAG_TICKS_EXISTED)) { ticksExisted = cmp.getInt(TAG_TICKS_EXISTED); } @@ -154,24 +156,24 @@ public final void load(CompoundTag cmp) { } FloatingFlower.IslandType oldType = floatingData.getIslandType(); - readFromPacketNBT(cmp); + readFromPacketNBT(cmp, registries); if (isFloating() && oldType != floatingData.getIslandType() && level != null) { level.sendBlockUpdated(getBlockPos(), getBlockState(), getBlockState(), 0); } } @Override - public final void saveAdditional(CompoundTag cmp) { - super.saveAdditional(cmp); + public final void saveAdditional(CompoundTag cmp, HolderLookup.Provider registries) { + super.saveAdditional(cmp, registries); cmp.putInt(TAG_TICKS_EXISTED, ticksExisted); - writeToPacketNBT(cmp); + writeToPacketNBT(cmp, registries); } @NotNull @Override - public CompoundTag getUpdateTag() { + public CompoundTag getUpdateTag(HolderLookup.Provider registries) { var tag = new CompoundTag(); - writeToPacketNBT(tag); + writeToPacketNBT(tag, registries); return tag; } @@ -180,7 +182,7 @@ public CompoundTag getUpdateTag() { * by readFromPacketNBT on the client that receives the packet. * Note: This method is also used to write to the world NBT. */ - public void writeToPacketNBT(CompoundTag cmp) { + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { if (isFloating()) { cmp.put(TAG_FLOATING_DATA, floatingData.writeNBT()); } @@ -191,7 +193,7 @@ public void writeToPacketNBT(CompoundTag cmp) { * writeToPacketNBT in the server. Note: This method is also used * to read from the world NBT. */ - public void readFromPacketNBT(CompoundTag cmp) { + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { if (cmp.contains(TAG_FLOATING_DATA)) { floatingData.readNBT(cmp.getCompound(TAG_FLOATING_DATA)); } diff --git a/Xplat/src/main/java/vazkii/botania/api/block_entity/package-info.java b/Xplat/src/main/java/vazkii/botania/api/block_entity/package-info.java new file mode 100644 index 0000000000..ee3bf21955 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/api/block_entity/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.api.block_entity; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobAttributeModifier.java b/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobAttributeModifier.java index 51102f9d8c..9d4d0fdf1b 100644 --- a/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobAttributeModifier.java +++ b/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobAttributeModifier.java @@ -1,64 +1,44 @@ package vazkii.botania.api.configdata; -import com.google.gson.JsonSyntaxException; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; public class LooniumMobAttributeModifier { public static final Codec CODEC = RecordCodecBuilder.create( instance -> instance.group( - Codec.STRING.fieldOf("name").forGetter(mam -> mam.name), - BuiltInRegistries.ATTRIBUTE.byNameCodec().fieldOf("attribute").forGetter(mam -> mam.attribute), + ResourceLocation.CODEC.fieldOf("id").forGetter(mam -> mam.id), + BuiltInRegistries.ATTRIBUTE.holderByNameCodec().fieldOf("attribute").forGetter(mam -> mam.attribute), Codec.DOUBLE.fieldOf("amount").forGetter(mam -> mam.amount), - Codec.STRING.xmap(LooniumMobAttributeModifier::operationFromString, - LooniumMobAttributeModifier::operationToString) - .fieldOf("operation").forGetter(mam -> mam.operation) + AttributeModifier.Operation.CODEC.fieldOf("operation").forGetter(mam -> mam.operation) ).apply(instance, LooniumMobAttributeModifier::new) ); - private final String name; - public final Attribute attribute; + private final ResourceLocation id; + public final Holder attribute; private final double amount; private final AttributeModifier.Operation operation; - public LooniumMobAttributeModifier(String name, Attribute attribute, double amount, - AttributeModifier.Operation operation) { - this.name = name; + public LooniumMobAttributeModifier(ResourceLocation id, Holder attribute, double amount, AttributeModifier.Operation operation) { + this.id = id; this.attribute = attribute; this.amount = amount; this.operation = operation; } public AttributeModifier createAttributeModifier() { - return new AttributeModifier(name, amount, operation); - } - - private static String operationToString(AttributeModifier.Operation operation) { - return switch (operation) { - case ADDITION -> "addition"; - case MULTIPLY_BASE -> "multiply_base"; - case MULTIPLY_TOTAL -> "multiply_total"; - default -> throw new IllegalArgumentException("Unknown operation " + operation); - }; - } - - private static AttributeModifier.Operation operationFromString(String operation) { - return switch (operation) { - case "addition" -> AttributeModifier.Operation.ADDITION; - case "multiply_base" -> AttributeModifier.Operation.MULTIPLY_BASE; - case "multiply_total" -> AttributeModifier.Operation.MULTIPLY_TOTAL; - default -> throw new JsonSyntaxException("Unknown attribute modifier operation " + operation); - }; + return new AttributeModifier(id, amount, operation); } @Override public String toString() { return "MobAttributeModifier{" + - "name='" + name + '\'' + + "id='" + id + '\'' + ", attribute=" + attribute + ", amount=" + amount + ", operation=" + operation + diff --git a/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobSpawnData.java b/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobSpawnData.java index 90be93636d..08a3cc83b2 100644 --- a/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobSpawnData.java +++ b/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumMobSpawnData.java @@ -6,10 +6,11 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.ResourceKey; import net.minecraft.util.random.Weight; import net.minecraft.util.random.WeightedEntry; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.storage.loot.LootTable; import org.jetbrains.annotations.Nullable; @@ -23,7 +24,7 @@ public class LooniumMobSpawnData extends WeightedEntry.IntrusiveBase { Weight.CODEC.fieldOf("weight").forGetter(IntrusiveBase::getWeight), Codec.BOOL.optionalFieldOf("spawnAsBaby").forGetter(msd -> Optional.ofNullable(msd.spawnAsBaby)), CompoundTag.CODEC.optionalFieldOf("nbt").forGetter(msd -> Optional.ofNullable(msd.nbt)), - ResourceLocation.CODEC.optionalFieldOf("equipmentTable") + LootTable.CODEC.optionalFieldOf("equipmentTable") .forGetter(msd -> Optional.ofNullable(msd.equipmentTable)), Codec.list(LooniumMobEffectToApply.CODEC) .optionalFieldOf("effectsToApply") @@ -37,12 +38,12 @@ public class LooniumMobSpawnData extends WeightedEntry.IntrusiveBase { public final EntityType type; public final Boolean spawnAsBaby; public final CompoundTag nbt; - public final ResourceLocation equipmentTable; + public final ResourceKey equipmentTable; public final List effectsToApply; public final List attributeModifiers; private LooniumMobSpawnData(EntityType type, Weight weight, Boolean spawnAsBaby, @Nullable CompoundTag nbt, - @Nullable ResourceLocation equipmentTable, + @Nullable ResourceKey equipmentTable, @Nullable List effectsToApply, @Nullable List attributeModifiers) { super(weight); @@ -76,7 +77,7 @@ public String toString() { private static LooniumMobSpawnData create(EntityType type, Weight weight, Optional spawnAsBaby, Optional nbt, - Optional equipmentTable, + Optional> equipmentTable, Optional> effectsToApply, Optional> attributeModifiers) { return new LooniumMobSpawnData(type, weight, @@ -92,7 +93,7 @@ public static class Builder { private final int weight; private @Nullable Boolean spawnAsBaby; private @Nullable CompoundTag nbt; - private @Nullable ResourceLocation equipmentTable; + private @Nullable ResourceKey equipmentTable; private @Nullable List effectsToApply; private @Nullable List attributeModifiers; @@ -130,7 +131,7 @@ public Builder nbt(CompoundTag nbt) { /** * A loot table to define equipment to apply to the mob after it spawned. */ - public Builder equipmentTable(ResourceLocation equipmentTable) { + public Builder equipmentTable(ResourceKey equipmentTable) { this.equipmentTable = equipmentTable; return this; } diff --git a/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumStructureConfiguration.java b/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumStructureConfiguration.java index 24522e98d6..538e1c5aba 100644 --- a/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumStructureConfiguration.java +++ b/Xplat/src/main/java/vazkii/botania/api/configdata/LooniumStructureConfiguration.java @@ -20,26 +20,26 @@ public class LooniumStructureConfiguration { public static final int DEFAULT_COST = 35000; public static final int DEFAULT_MAX_NEARBY_MOBS = 10; public static final Codec CODEC = RecordCodecBuilder.create( - instance -> instance.group( - ResourceLocation.CODEC.optionalFieldOf("parent") - .forGetter(lsc -> Optional.ofNullable(lsc.parent)), - ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("manaCost") - .forGetter(lsc -> Optional.ofNullable(lsc.manaCost)), - ExtraCodecs.POSITIVE_INT.optionalFieldOf("maxNearbyMobs") - .forGetter(lsc -> Optional.ofNullable(lsc.maxNearbyMobs)), - StructureSpawnOverride.BoundingBoxType.CODEC - .optionalFieldOf("boundingBoxType") - .forGetter(lsc -> Optional.ofNullable(lsc.boundingBoxType)), - WeightedRandomList.codec(LooniumMobSpawnData.CODEC) - .optionalFieldOf("spawnedMobs") - .forGetter(lsc -> Optional.ofNullable(lsc.spawnedMobs)), - Codec.list(LooniumMobAttributeModifier.CODEC) - .optionalFieldOf("attributeModifiers") - .forGetter(lsc -> Optional.ofNullable(lsc.attributeModifiers)), - Codec.list(LooniumMobEffectToApply.CODEC) - .optionalFieldOf("effectsToApply") - .forGetter(lsc -> Optional.ofNullable(lsc.effectsToApply)) - ).apply(instance, LooniumStructureConfiguration::create) + instance -> instance.group( + ResourceLocation.CODEC.optionalFieldOf("parent") + .forGetter(lsc -> Optional.ofNullable(lsc.parent)), + ExtraCodecs.NON_NEGATIVE_INT.optionalFieldOf("manaCost") + .forGetter(lsc -> Optional.ofNullable(lsc.manaCost)), + ExtraCodecs.POSITIVE_INT.optionalFieldOf("maxNearbyMobs") + .forGetter(lsc -> Optional.ofNullable(lsc.maxNearbyMobs)), + StructureSpawnOverride.BoundingBoxType.CODEC + .optionalFieldOf("boundingBoxType") + .forGetter(lsc -> Optional.ofNullable(lsc.boundingBoxType)), + WeightedRandomList.codec(LooniumMobSpawnData.CODEC) + .optionalFieldOf("spawnedMobs") + .forGetter(lsc -> Optional.ofNullable(lsc.spawnedMobs)), + Codec.list(LooniumMobAttributeModifier.CODEC) + .optionalFieldOf("attributeModifiers") + .forGetter(lsc -> Optional.ofNullable(lsc.attributeModifiers)), + Codec.list(LooniumMobEffectToApply.CODEC) + .optionalFieldOf("effectsToApply") + .forGetter(lsc -> Optional.ofNullable(lsc.effectsToApply)) + ).apply(instance, LooniumStructureConfiguration::create) ).validate(lsc -> { if (lsc.parent == null && (lsc.manaCost == null || lsc.boundingBoxType == null || lsc.spawnedMobs == null)) { return DataResult.error(() -> "Mana cost, bounding box type, and spawned mobs must be specified if there is no parent configuration"); diff --git a/Xplat/src/main/java/vazkii/botania/api/internal/ManaBurst.java b/Xplat/src/main/java/vazkii/botania/api/internal/ManaBurst.java index f0021f7d08..c2631d1a58 100644 --- a/Xplat/src/main/java/vazkii/botania/api/internal/ManaBurst.java +++ b/Xplat/src/main/java/vazkii/botania/api/internal/ManaBurst.java @@ -53,6 +53,7 @@ public interface ManaBurst { * The block position of the block entity that spawned this burst. * If the burst wasn't fired from a block entity, returns {@link #NO_SOURCE} */ + @Nullable BlockPos getBurstSourceBlockPos(); void setBurstSourceCoords(BlockPos pos); @@ -71,6 +72,7 @@ public interface ManaBurst { void setShooterUUID(UUID uuid); + @Nullable UUID getShooterUUID(); void ping(); diff --git a/Xplat/src/main/java/vazkii/botania/api/item/AvatarWieldable.java b/Xplat/src/main/java/vazkii/botania/api/item/AvatarWieldable.java index 654cc0a9e5..62b33913ee 100644 --- a/Xplat/src/main/java/vazkii/botania/api/item/AvatarWieldable.java +++ b/Xplat/src/main/java/vazkii/botania/api/item/AvatarWieldable.java @@ -10,8 +10,8 @@ import net.minecraft.resources.ResourceLocation; -import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.block.Avatar; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/item/BlockProvider.java b/Xplat/src/main/java/vazkii/botania/api/item/BlockProvider.java index 311378711d..8c4425b10e 100644 --- a/Xplat/src/main/java/vazkii/botania/api/item/BlockProvider.java +++ b/Xplat/src/main/java/vazkii/botania/api/item/BlockProvider.java @@ -12,7 +12,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/item/CoordBoundItem.java b/Xplat/src/main/java/vazkii/botania/api/item/CoordBoundItem.java index 9b1f836ce1..4b2529d813 100644 --- a/Xplat/src/main/java/vazkii/botania/api/item/CoordBoundItem.java +++ b/Xplat/src/main/java/vazkii/botania/api/item/CoordBoundItem.java @@ -14,8 +14,8 @@ import org.jetbrains.annotations.Nullable; -import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.block.Bound; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/item/Relic.java b/Xplat/src/main/java/vazkii/botania/api/item/Relic.java index 26be42e424..a36b185584 100644 --- a/Xplat/src/main/java/vazkii/botania/api/item/Relic.java +++ b/Xplat/src/main/java/vazkii/botania/api/item/Relic.java @@ -12,9 +12,9 @@ import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; -import vazkii.botania.api.BotaniaAPI; import java.util.UUID; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/mana/ManaCollisionGhost.java b/Xplat/src/main/java/vazkii/botania/api/mana/ManaCollisionGhost.java index 35c61bae9b..f5d1f85cc3 100644 --- a/Xplat/src/main/java/vazkii/botania/api/mana/ManaCollisionGhost.java +++ b/Xplat/src/main/java/vazkii/botania/api/mana/ManaCollisionGhost.java @@ -9,7 +9,7 @@ package vazkii.botania.api.mana; import net.minecraft.resources.ResourceLocation; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/mana/ManaItem.java b/Xplat/src/main/java/vazkii/botania/api/mana/ManaItem.java index 198bf5a7fe..a409bd780b 100644 --- a/Xplat/src/main/java/vazkii/botania/api/mana/ManaItem.java +++ b/Xplat/src/main/java/vazkii/botania/api/mana/ManaItem.java @@ -11,7 +11,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.entity.BlockEntity; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/mana/ManaReceiver.java b/Xplat/src/main/java/vazkii/botania/api/mana/ManaReceiver.java index a6d62a6bcd..fe8f1f717d 100644 --- a/Xplat/src/main/java/vazkii/botania/api/mana/ManaReceiver.java +++ b/Xplat/src/main/java/vazkii/botania/api/mana/ManaReceiver.java @@ -11,7 +11,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/mana/ManaTrigger.java b/Xplat/src/main/java/vazkii/botania/api/mana/ManaTrigger.java index e6ba62ca67..c4f64fc6dc 100644 --- a/Xplat/src/main/java/vazkii/botania/api/mana/ManaTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/api/mana/ManaTrigger.java @@ -9,8 +9,9 @@ package vazkii.botania.api.mana; import net.minecraft.resources.ResourceLocation; -import vazkii.botania.api.BotaniaAPI; + import vazkii.botania.api.internal.ManaBurst; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/mana/spark/SparkAttachable.java b/Xplat/src/main/java/vazkii/botania/api/mana/spark/SparkAttachable.java index cdfca366e0..453301e7ec 100644 --- a/Xplat/src/main/java/vazkii/botania/api/mana/spark/SparkAttachable.java +++ b/Xplat/src/main/java/vazkii/botania/api/mana/spark/SparkAttachable.java @@ -10,7 +10,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; -import vazkii.botania.api.BotaniaAPI; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; /** diff --git a/Xplat/src/main/java/vazkii/botania/api/package-info.java b/Xplat/src/main/java/vazkii/botania/api/package-info.java new file mode 100644 index 0000000000..bd5230aa98 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/api/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.api; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/BotanicalBreweryRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/BotanicalBreweryRecipe.java index 6ee9f9fb8f..aa01827109 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/BotanicalBreweryRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/BotanicalBreweryRecipe.java @@ -9,10 +9,8 @@ package vazkii.botania.api.recipe; import net.minecraft.core.HolderLookup; -import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeInput; @@ -20,8 +18,8 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; public interface BotanicalBreweryRecipe extends Recipe { diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/ElvenTradeRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/ElvenTradeRecipe.java index c895705d7b..066ce77e1f 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/ElvenTradeRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/ElvenTradeRecipe.java @@ -10,10 +10,8 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; -import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; @@ -23,10 +21,9 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; - import java.util.List; import java.util.Optional; + import static vazkii.botania.api.BotaniaAPI.botaniaRL; public interface ElvenTradeRecipe extends Recipe { diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/ManaInfusionRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/ManaInfusionRecipe.java index fbe6c07588..b7eb7aa213 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/ManaInfusionRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/ManaInfusionRecipe.java @@ -12,7 +12,6 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeInput; @@ -21,7 +20,6 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; import static vazkii.botania.api.BotaniaAPI.botaniaRL; public interface ManaInfusionRecipe extends Recipe { diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/OrechidRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/OrechidRecipe.java index 37053f7792..ec903473c2 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/OrechidRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/OrechidRecipe.java @@ -11,9 +11,7 @@ import net.minecraft.commands.CacheableFunction; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; -import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeInput; @@ -22,11 +20,10 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; -import static vazkii.botania.api.BotaniaAPI.botaniaRL; - import java.util.Optional; +import static vazkii.botania.api.BotaniaAPI.botaniaRL; + public interface OrechidRecipe extends Recipe { ResourceLocation TYPE_ID = botaniaRL("orechid"); ResourceLocation IGNEM_TYPE_ID = botaniaRL("orechid_ignem"); diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/PetalApothecaryRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/PetalApothecaryRecipe.java index 77958c6c3a..66a7620c01 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/PetalApothecaryRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/PetalApothecaryRecipe.java @@ -14,7 +14,6 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; import static vazkii.botania.api.BotaniaAPI.botaniaRL; public interface PetalApothecaryRecipe extends RecipeWithReagent { diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/PureDaisyRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/PureDaisyRecipe.java index af85ac2ba1..8084ffa0d0 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/PureDaisyRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/PureDaisyRecipe.java @@ -11,10 +11,8 @@ import net.minecraft.commands.CacheableFunction; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup; -import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeInput; @@ -24,11 +22,10 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; -import static vazkii.botania.api.BotaniaAPI.botaniaRL; - import java.util.Optional; +import static vazkii.botania.api.BotaniaAPI.botaniaRL; + public interface PureDaisyRecipe extends Recipe { ResourceLocation TYPE_ID = botaniaRL("pure_daisy"); diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/RunicAltarRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/RunicAltarRecipe.java index d0c1dc9c89..95e553b37f 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/RunicAltarRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/RunicAltarRecipe.java @@ -11,7 +11,6 @@ import net.minecraft.core.NonNullList; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeInput; @@ -19,7 +18,6 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; import static vazkii.botania.api.BotaniaAPI.botaniaRL; public interface RunicAltarRecipe extends RecipeWithReagent { diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/StateIngredientType.java b/Xplat/src/main/java/vazkii/botania/api/recipe/StateIngredientType.java index e25231821b..06de7718bb 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/StateIngredientType.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/StateIngredientType.java @@ -9,7 +9,7 @@ package vazkii.botania.api.recipe; import com.mojang.serialization.MapCodec; -import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; diff --git a/Xplat/src/main/java/vazkii/botania/api/recipe/TerrestrialAgglomerationRecipe.java b/Xplat/src/main/java/vazkii/botania/api/recipe/TerrestrialAgglomerationRecipe.java index 77c786907b..7108810349 100644 --- a/Xplat/src/main/java/vazkii/botania/api/recipe/TerrestrialAgglomerationRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/api/recipe/TerrestrialAgglomerationRecipe.java @@ -10,7 +10,6 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeInput; @@ -18,7 +17,6 @@ import org.jetbrains.annotations.NotNull; -import vazkii.botania.api.BotaniaAPI; import static vazkii.botania.api.BotaniaAPI.botaniaRL; public interface TerrestrialAgglomerationRecipe extends Recipe { diff --git a/Xplat/src/main/java/vazkii/botania/client/BotaniaItemProperties.java b/Xplat/src/main/java/vazkii/botania/client/BotaniaItemProperties.java index 1f596eb2d6..b9ffb85420 100644 --- a/Xplat/src/main/java/vazkii/botania/client/BotaniaItemProperties.java +++ b/Xplat/src/main/java/vazkii/botania/client/BotaniaItemProperties.java @@ -13,7 +13,6 @@ import vazkii.botania.common.helper.ItemNBTHelper; import vazkii.botania.common.item.*; import vazkii.botania.common.item.brew.BaseBrewItem; -import vazkii.botania.common.item.equipment.bauble.RingOfMagnetizationItem; import vazkii.botania.common.item.equipment.tool.bow.LivingwoodBowItem; import vazkii.botania.common.item.equipment.tool.terrasteel.TerraShattererItem; import vazkii.botania.common.item.equipment.tool.terrasteel.TerraTruncatorItem; @@ -119,13 +118,13 @@ public static void init(TriConsumer= 0; i--) { @@ -390,7 +390,7 @@ public static void renderProgressPie(GuiGraphics gui, int x, int y, float progre } buf.addVertex(mat, centerX, centerY, 0).setColor(0F, 1F, 0.5F, a); - Tesselator.getInstance().end(); + Tesselator.getInstance().clear(); RenderSystem.disableBlend(); GL11.glDisable(GL11.GL_STENCIL_TEST); @@ -477,10 +477,10 @@ public static void renderIconFullBright( float green = ((color >> 8) & 0xFF) / 255F; float blue = (color & 0xFF) / 255F; - buffer.addVertex(mat, startX, endY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvStartX), icon.getV(uvEndY)).uv2(light); - buffer.addVertex(mat, endX, endY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvEndX), icon.getV(uvEndY)).uv2(light); - buffer.addVertex(mat, endX, startY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvEndX), icon.getV(uvStartY)).uv2(light); - buffer.addVertex(mat, startX, startY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvStartX), icon.getV(uvStartY)).uv2(light); + buffer.addVertex(mat, startX, endY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvStartX), icon.getV(uvEndY)).setLight(light); + buffer.addVertex(mat, endX, endY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvEndX), icon.getV(uvEndY)).setLight(light); + buffer.addVertex(mat, endX, startY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvEndX), icon.getV(uvStartY)).setLight(light); + buffer.addVertex(mat, startX, startY, 0).setColor(red, green, blue, alpha).setUv(icon.getU(uvStartX), icon.getV(uvStartY)).setLight(light); } /** @@ -568,10 +568,10 @@ public static void renderGuiItemAlpha(ItemStack stack, int x, int y, int alpha, RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - PoseStack modelViewStack = RenderSystem.getModelViewStack(); - modelViewStack.pushPose(); + Matrix4fStack modelViewStack = RenderSystem.getModelViewStack(); + modelViewStack.pushMatrix(); modelViewStack.translate(x, y, 100.0F); - modelViewStack.translate(8.0D, 8.0D, 0.0D); + modelViewStack.translate(8.0F, 8.0F, 0.0F); modelViewStack.scale(1.0F, -1.0F, 1.0F); modelViewStack.scale(16.0F, 16.0F, 16.0F); RenderSystem.applyModelViewMatrix(); @@ -601,7 +601,7 @@ public static void renderGuiItemAlpha(ItemStack stack, int x, int y, int alpha, Lighting.setupFor3DItems(); } - modelViewStack.popPose(); + modelViewStack.popMatrix(); RenderSystem.applyModelViewMatrix(); } @@ -643,6 +643,7 @@ public static int itemWithNameWidth(Minecraft mc, ItemStack itemStack) { } // Borrowed with permission from https://github.com/XFactHD/FramedBlocks/blob/14f468810fc416b39447512810f0aa86e1012335/src/main/java/xfacthd/framedblocks/client/util/GhostVertexConsumer.java + // TODO: is this even still relevant? it doesn't exist anymore where it was borrowed from public record GhostVertexConsumer(VertexConsumer wrapped, int alpha) implements VertexConsumer { @Override public @NotNull VertexConsumer addVertex(float x, float y, float z) { @@ -664,11 +665,6 @@ public record GhostVertexConsumer(VertexConsumer wrapped, int alpha) implements return wrapped.setUv1(u, v); } - @Override - public VertexConsumer overlayCoords(int u, int v) { - return wrapped.overlayCoords(u, v); - } - @Override public @NotNull VertexConsumer setUv2(int u, int v) { return wrapped.setUv2(u, v); @@ -678,20 +674,5 @@ public VertexConsumer overlayCoords(int u, int v) { public @NotNull VertexConsumer setNormal(float x, float y, float z) { return wrapped.setNormal(x, y, z); } - - @Override - public void endVertex() { - wrapped.endVertex(); - } - - @Override - public void defaultColor(int r, int g, int b, int a) { - wrapped.defaultColor(r, g, b, a); - } - - @Override - public void unsetDefaultColor() { - wrapped.unsetDefaultColor(); - } } } diff --git a/Xplat/src/main/java/vazkii/botania/client/integration/emi/ElvenTradeEmiRecipe.java b/Xplat/src/main/java/vazkii/botania/client/integration/emi/ElvenTradeEmiRecipe.java index 81add64a43..227323a156 100644 --- a/Xplat/src/main/java/vazkii/botania/client/integration/emi/ElvenTradeEmiRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/client/integration/emi/ElvenTradeEmiRecipe.java @@ -86,10 +86,10 @@ public void render(GuiGraphics gui, int mouseX, int mouseY, float delta) { int stopY = y + 48; Matrix4f mat = matrices.last().pose(); Matrix3f n = matrices.last().normal(); - v.addVertex(mat, startX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV0()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, startX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV1()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, stopX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV1()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, stopX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV0()).uv2(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, startX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV0()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, startX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV1()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, stopX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV1()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, stopX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV0()).setLight(0xF000F0).setNormal(n, 1, 0, 0); immediate.endBatch(); } diff --git a/Xplat/src/main/java/vazkii/botania/client/integration/jei/ElvenTradeRecipeCategory.java b/Xplat/src/main/java/vazkii/botania/client/integration/jei/ElvenTradeRecipeCategory.java index 9f829adce4..a1f809ca8d 100644 --- a/Xplat/src/main/java/vazkii/botania/client/integration/jei/ElvenTradeRecipeCategory.java +++ b/Xplat/src/main/java/vazkii/botania/client/integration/jei/ElvenTradeRecipeCategory.java @@ -98,10 +98,10 @@ public void draw(@NotNull ElvenTradeRecipe recipe, @NotNull IRecipeSlotsView slo int stopY = 73; Matrix4f mat = matrices.last().pose(); Matrix3f n = matrices.last().normal(); - v.addVertex(mat, startX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV0()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, startX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV1()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, stopX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV1()).uv2(0xF000F0).setNormal(n, 1, 0, 0); - v.addVertex(mat, stopX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV0()).uv2(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, startX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV0()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, startX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU0(), sprite.getV1()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, stopX, stopY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV1()).setLight(0xF000F0).setNormal(n, 1, 0, 0); + v.addVertex(mat, stopX, startY, 0).setColor(1f, 1f, 1f, 1f).setUv(sprite.getU1(), sprite.getV0()).setLight(0xF000F0).setNormal(n, 1, 0, 0); immediate.endBatch(); } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/AvatarModel.java b/Xplat/src/main/java/vazkii/botania/client/model/AvatarModel.java index f3720a1041..9ec2710a77 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/AvatarModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/AvatarModel.java @@ -62,13 +62,13 @@ public static MeshDefinition createMesh() { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { - leftleg.render(ms, buffer, light, overlay, r, g, b, a); - rightarm.render(ms, buffer, light, overlay, r, g, b, a); - leftarm.render(ms, buffer, light, overlay, r, g, b, a); - head.render(ms, buffer, light, overlay, r, g, b, a); - rightleg.render(ms, buffer, light, overlay, r, g, b, a); - body.render(ms, buffer, light, overlay, r, g, b, a); + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { + leftleg.render(ms, buffer, light, overlay, color); + rightarm.render(ms, buffer, light, overlay, color); + leftarm.render(ms, buffer, light, overlay, color); + head.render(ms, buffer, light, overlay, color); + rightleg.render(ms, buffer, light, overlay, color); + body.render(ms, buffer, light, overlay, color); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/BellowsModel.java b/Xplat/src/main/java/vazkii/botania/client/model/BellowsModel.java index 0de9e6496e..f0b973a2c4 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/BellowsModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/BellowsModel.java @@ -55,24 +55,24 @@ public static MeshDefinition createMesh() { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { - render(ms, buffer, light, overlay, r, g, b, a, 1); + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { + render(ms, buffer, light, overlay, color, 1); } - public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float alpha, float fract) { - base.render(ms, buffer, light, overlay, r, g, b, alpha); - pipe.render(ms, buffer, light, overlay, r, g, b, alpha); + public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color, float fract) { + base.render(ms, buffer, light, overlay, color); + pipe.render(ms, buffer, light, overlay, color); float mov = (1F - fract) * 0.5F; ms.translate(0F, mov, 0F); - top.render(ms, buffer, light, overlay, r, g, b, alpha); + top.render(ms, buffer, light, overlay, color); ms.translate(0F, -mov, 0F); ms.mulPose(VecHelper.rotateX(180F)); ms.translate(-0.19F, -1.375F, -0.19F); ms.scale(1F, fract, 1F); - funnel.render(ms, buffer, light, overlay, r, g, b, alpha); + funnel.render(ms, buffer, light, overlay, color); ms.scale(1F, 1F / fract, 1F); } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/BotanicalBreweryModel.java b/Xplat/src/main/java/vazkii/botania/client/model/BotanicalBreweryModel.java index 618cb3a008..29dd6f5fda 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/BotanicalBreweryModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/BotanicalBreweryModel.java @@ -132,7 +132,7 @@ private void renderItemStack(ItemStack stack, PoseStack ms, MultiBufferSource bu } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { throw new UnsupportedOperationException("unimplemented, call using other render method"); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/CloakModel.java b/Xplat/src/main/java/vazkii/botania/client/model/CloakModel.java index a3c54ffc05..7fef88c5e8 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/CloakModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/CloakModel.java @@ -53,9 +53,9 @@ public static MeshDefinition createMesh() { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { - collar.render(ms, buffer, light, overlay, r, g, b, a); - sideL.render(ms, buffer, light, overlay, r, g, b, a); - sideR.render(ms, buffer, light, overlay, r, g, b, a); + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { + collar.render(ms, buffer, light, overlay, color); + sideL.render(ms, buffer, light, overlay, color); + sideR.render(ms, buffer, light, overlay, color); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/GaiaHeadModel.java b/Xplat/src/main/java/vazkii/botania/client/model/GaiaHeadModel.java index 967250b48b..86feb696b3 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/GaiaHeadModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/GaiaHeadModel.java @@ -26,11 +26,11 @@ public void setupAnim(float animationProgress, float yRot, float xRot) { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { var type = GaiaHeadBlockEntityRenderer.getViewType(); var model = GaiaHeadBlockEntityRenderer.models.get(type); if (model != null) { - model.renderToBuffer(ms, buffer, light, overlay, r, g, b, a); + model.renderToBuffer(ms, buffer, light, overlay, color); } } } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/HourglassModel.java b/Xplat/src/main/java/vazkii/botania/client/model/HourglassModel.java index f9b6237737..8d737fc7b1 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/HourglassModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/HourglassModel.java @@ -64,11 +64,11 @@ public static MeshDefinition createMesh() { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { - render(ms, buffer, light, overlay, r, g, b, a, 0, 1, false); + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { + render(ms, buffer, light, overlay, color, 0, 1, false); } - public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a, float fract1, float fract2, boolean flip) { + public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color, float fract1, float fract2, boolean flip) { if (flip) { float tmp = fract1; fract1 = fract2; @@ -76,9 +76,10 @@ public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, } float f = 1F / 16F; - ring.render(ms, buffer, light, overlay, 1, 1, 1, a); - top.render(ms, buffer, light, overlay, 1, 1, 1, a); - bottom.render(ms, buffer, light, overlay, 1, 1, 1, a); + int alphaWhite = color | 0xffffff; + ring.render(ms, buffer, light, overlay, alphaWhite); + top.render(ms, buffer, light, overlay, alphaWhite); + bottom.render(ms, buffer, light, overlay, alphaWhite); if (fract1 > 0) { ms.pushPose(); @@ -89,7 +90,7 @@ public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, ms.translate(-2.0F * f, -5.0F * f, -2.0F * f); } ms.scale(1F, fract1, 1F); - sandT.render(ms, buffer, light, overlay, r, g, b, a); + sandT.render(ms, buffer, light, overlay, color); ms.popPose(); } @@ -102,12 +103,12 @@ public void render(PoseStack ms, VertexConsumer buffer, int light, int overlay, ms.translate(-2.0F * f, 1.0F * f, -2.0F * f); } ms.scale(1F, fract2, 1F); - sandB.render(ms, buffer, light, overlay, r, g, b, a); + sandB.render(ms, buffer, light, overlay, color); ms.popPose(); } - glassT.render(ms, buffer, light, overlay, 1, 1, 1, a); - glassB.render(ms, buffer, light, overlay, 1, 1, 1, a); + glassT.render(ms, buffer, light, overlay, alphaWhite); + glassB.render(ms, buffer, light, overlay, alphaWhite); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/PixieModel.java b/Xplat/src/main/java/vazkii/botania/client/model/PixieModel.java index 5bbeb9a08d..cc89d5339e 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/PixieModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/PixieModel.java @@ -67,7 +67,7 @@ public static MeshDefinition createMesh() { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float red, float green, float blue, float alpha) { + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { body.render(ms, buffer, light, overlay); leftWingT.render(ms, buffer, light, overlay); diff --git a/Xplat/src/main/java/vazkii/botania/client/model/TeruTeruBozuModel.java b/Xplat/src/main/java/vazkii/botania/client/model/TeruTeruBozuModel.java index 180b97bd1a..80f1ef44e7 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/TeruTeruBozuModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/TeruTeruBozuModel.java @@ -53,13 +53,13 @@ public static MeshDefinition createMesh() { } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { if (Minecraft.getInstance().level.isRaining()) { - sadFace.render(ms, buffer, light, overlay, r, g, b, a); + sadFace.render(ms, buffer, light, overlay, color); } else { - happyFace.render(ms, buffer, light, overlay, r, g, b, a); + happyFace.render(ms, buffer, light, overlay, color); } - thread.render(ms, buffer, light, overlay, r, g, b, a); - cloth.render(ms, buffer, light, overlay, r, g, b, a); + thread.render(ms, buffer, light, overlay, color); + cloth.render(ms, buffer, light, overlay, color); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/model/armor/ArmorModel.java b/Xplat/src/main/java/vazkii/botania/client/model/armor/ArmorModel.java index 1b91964e61..436c454aaf 100644 --- a/Xplat/src/main/java/vazkii/botania/client/model/armor/ArmorModel.java +++ b/Xplat/src/main/java/vazkii/botania/client/model/armor/ArmorModel.java @@ -59,9 +59,9 @@ public void setupAnim(LivingEntity entity, float limbSwing, float limbSwingAmoun } @Override - public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, float r, float g, float b, float a) { + public void renderToBuffer(PoseStack ms, VertexConsumer buffer, int light, int overlay, int color) { setPartVisibility(slot); - super.renderToBuffer(ms, buffer, light, overlay, r, g, b, a); + super.renderToBuffer(ms, buffer, light, overlay, color); } // [VanillaCopy] HumanoidArmorLayer diff --git a/Xplat/src/main/java/vazkii/botania/client/model/armor/package-info.java b/Xplat/src/main/java/vazkii/botania/client/model/armor/package-info.java new file mode 100644 index 0000000000..7239411ace --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/client/model/armor/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.client.model.armor; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/client/model/package-info.java b/Xplat/src/main/java/vazkii/botania/client/model/package-info.java new file mode 100644 index 0000000000..45e755a6f7 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/client/model/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.client.model; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java b/Xplat/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java index 8047030898..7aaafd4517 100644 --- a/Xplat/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java +++ b/Xplat/src/main/java/vazkii/botania/client/patchouli/component/RotatingRecipeComponent.java @@ -14,14 +14,15 @@ import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; import vazkii.botania.common.crafting.BotaniaRecipeTypes; import vazkii.patchouli.api.IVariable; import java.util.List; -import java.util.Map; +import java.util.Optional; import java.util.function.UnaryOperator; /** @@ -37,19 +38,19 @@ public class RotatingRecipeComponent extends RotatingItemListComponentBase { @Override protected List makeIngredients() { Level world = Minecraft.getInstance().level; - Map> map; + RecipeType type; if ("runic_altar".equals(recipeType)) { - map = BotaniaRecipeTypes.getRecipes(world, BotaniaRecipeTypes.RUNE_TYPE); + type = BotaniaRecipeTypes.RUNE_TYPE; } else if ("petal_apothecary".equals(recipeType)) { - map = BotaniaRecipeTypes.getRecipes(world, BotaniaRecipeTypes.PETAL_TYPE); + type = BotaniaRecipeTypes.PETAL_TYPE; } else { throw new IllegalArgumentException("Type must be 'runic_altar' or 'petal_apothecary'!"); } - Recipe recipe = map.get(ResourceLocation.parse(recipeName)); - if (recipe == null) { + Optional> recipe = BotaniaRecipeTypes.getRecipe(world, ResourceLocation.parse(recipeName), type); + if (recipe.isEmpty()) { return ImmutableList.of(); } - return recipe.getIngredients(); + return recipe.get().value().getIngredients(); } @Override diff --git a/Xplat/src/main/java/vazkii/botania/client/render/block_entity/AlfheimPortalBlockEntityRenderer.java b/Xplat/src/main/java/vazkii/botania/client/render/block_entity/AlfheimPortalBlockEntityRenderer.java index e052db6d83..f790360ff7 100644 --- a/Xplat/src/main/java/vazkii/botania/client/render/block_entity/AlfheimPortalBlockEntityRenderer.java +++ b/Xplat/src/main/java/vazkii/botania/client/render/block_entity/AlfheimPortalBlockEntityRenderer.java @@ -20,8 +20,6 @@ import net.minecraft.world.inventory.InventoryMenu; import org.jetbrains.annotations.NotNull; -import org.joml.Matrix3f; -import org.joml.Matrix4f; import vazkii.botania.api.state.BotaniaStateProperties; import vazkii.botania.api.state.enums.AlfheimPortalState; @@ -76,12 +74,11 @@ public void render(@NotNull AlfheimPortalBlockEntity portal, float f, PoseStack public void renderIcon(PoseStack ms, MultiBufferSource buffers, TextureAtlasSprite icon, int x, int y, int width, int height, float alpha, int overlay) { VertexConsumer buffer = buffers.getBuffer(Sheets.translucentItemSheet()); - Matrix4f model = ms.last().pose(); - Matrix3f normal = ms.last().normal(); - buffer.addVertex(model, x, y + height, 0).setColor(1, 1, 1, alpha).setUv(icon.getU0(), icon.getV1()).setOverlay(overlay).uv2(0xF000F0).setNormal(normal, 1, 0, 0); - buffer.addVertex(model, x + width, y + height, 0).setColor(1, 1, 1, alpha).setUv(icon.getU1(), icon.getV1()).setOverlay(overlay).uv2(0xF000F0).setNormal(normal, 1, 0, 0); - buffer.addVertex(model, x + width, y, 0).setColor(1, 1, 1, alpha).setUv(icon.getU1(), icon.getV0()).setOverlay(overlay).uv2(0xF000F0).setNormal(normal, 1, 0, 0); - buffer.addVertex(model, x, y, 0).setColor(1, 1, 1, alpha).setUv(icon.getU0(), icon.getV0()).setOverlay(overlay).uv2(0xF000F0).setNormal(normal, 1, 0, 0); + PoseStack.Pose pose = ms.last(); + buffer.addVertex(pose, x, y + height, 0).setColor(1, 1, 1, alpha).setUv(icon.getU0(), icon.getV1()).setOverlay(overlay).setLight(0xF000F0).setNormal(pose, 1, 0, 0); + buffer.addVertex(pose, x + width, y + height, 0).setColor(1, 1, 1, alpha).setUv(icon.getU1(), icon.getV1()).setOverlay(overlay).setLight(0xF000F0).setNormal(pose, 1, 0, 0); + buffer.addVertex(pose, x + width, y, 0).setColor(1, 1, 1, alpha).setUv(icon.getU1(), icon.getV0()).setOverlay(overlay).setLight(0xF000F0).setNormal(pose, 1, 0, 0); + buffer.addVertex(pose, x, y, 0).setColor(1, 1, 1, alpha).setUv(icon.getU0(), icon.getV0()).setOverlay(overlay).setLight(0xF000F0).setNormal(pose, 1, 0, 0); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/render/block_entity/PetalApothecaryBlockEntityRenderer.java b/Xplat/src/main/java/vazkii/botania/client/render/block_entity/PetalApothecaryBlockEntityRenderer.java index 9f1ee45d06..5f9815514f 100644 --- a/Xplat/src/main/java/vazkii/botania/client/render/block_entity/PetalApothecaryBlockEntityRenderer.java +++ b/Xplat/src/main/java/vazkii/botania/client/render/block_entity/PetalApothecaryBlockEntityRenderer.java @@ -129,13 +129,13 @@ private void renderIcon(PoseStack ms, VertexConsumer builder, TextureAtlasSprite int start = 3; int end = 13; builder.addVertex(mat, start, end, 0).setColor(red, green, blue, (int) (alpha * 255F)) - .setUv(sprite.getU(start), sprite.getV(end)).setOverlay(overlay).uv2(light).setNormal(0, 0, 1); + .setUv(sprite.getU(start), sprite.getV(end)).setOverlay(overlay).setLight(light).setNormal(0, 0, 1); builder.addVertex(mat, end, end, 0).setColor(red, green, blue, (int) (alpha * 255F)) - .setUv(sprite.getU(end), sprite.getV(end)).setOverlay(overlay).uv2(light).setNormal(0, 0, 1); + .setUv(sprite.getU(end), sprite.getV(end)).setOverlay(overlay).setLight(light).setNormal(0, 0, 1); builder.addVertex(mat, end, start, 0).setColor(red, green, blue, (int) (alpha * 255F)) - .setUv(sprite.getU(end), sprite.getV(start)).setOverlay(overlay).uv2(light).setNormal(0, 0, 1); + .setUv(sprite.getU(end), sprite.getV(start)).setOverlay(overlay).setLight(light).setNormal(0, 0, 1); builder.addVertex(mat, start, start, 0).setColor(red, green, blue, (int) (alpha * 255F)) - .setUv(sprite.getU(start), sprite.getV(start)).setOverlay(overlay).uv2(light).setNormal(0, 0, 1); + .setUv(sprite.getU(start), sprite.getV(start)).setOverlay(overlay).setLight(light).setNormal(0, 0, 1); } } diff --git a/Xplat/src/main/java/vazkii/botania/client/render/block_entity/package-info.java b/Xplat/src/main/java/vazkii/botania/client/render/block_entity/package-info.java new file mode 100644 index 0000000000..0b9260c518 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/client/render/block_entity/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.client.render.block_entity; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/client/render/entity/BaseSparkRenderer.java b/Xplat/src/main/java/vazkii/botania/client/render/entity/BaseSparkRenderer.java index d398a98b22..dbb18a97a2 100644 --- a/Xplat/src/main/java/vazkii/botania/client/render/entity/BaseSparkRenderer.java +++ b/Xplat/src/main/java/vazkii/botania/client/render/entity/BaseSparkRenderer.java @@ -117,10 +117,10 @@ private void renderIcon(PoseStack ms, VertexConsumer buffer, TextureAtlasSprite int g = (color >> 8) & 0xFF; int b = color & 0xFF; Matrix4f mat = ms.last().pose(); - buffer.addVertex(mat, 0.0F - f5, 0.0F - f6, 0.0F).setColor(r, g, b, a).setUv(f, f3).uv2(fullbright); - buffer.addVertex(mat, f4 - f5, 0.0F - f6, 0.0F).setColor(r, g, b, a).setUv(f1, f3).uv2(fullbright); - buffer.addVertex(mat, f4 - f5, f4 - f6, 0.0F).setColor(r, g, b, a).setUv(f1, f2).uv2(fullbright); - buffer.addVertex(mat, 0.0F - f5, f4 - f6, 0.0F).setColor(r, g, b, a).setUv(f, f2).uv2(fullbright); + buffer.addVertex(mat, 0.0F - f5, 0.0F - f6, 0.0F).setColor(r, g, b, a).setUv(f, f3).setLight(fullbright); + buffer.addVertex(mat, f4 - f5, 0.0F - f6, 0.0F).setColor(r, g, b, a).setUv(f1, f3).setLight(fullbright); + buffer.addVertex(mat, f4 - f5, f4 - f6, 0.0F).setColor(r, g, b, a).setUv(f1, f2).setLight(fullbright); + buffer.addVertex(mat, 0.0F - f5, f4 - f6, 0.0F).setColor(r, g, b, a).setUv(f, f2).setLight(fullbright); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/AlfheimPortalTrigger.java b/Xplat/src/main/java/vazkii/botania/common/advancements/AlfheimPortalTrigger.java index 4fd82f4d65..ad20651420 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/AlfheimPortalTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/AlfheimPortalTrigger.java @@ -54,7 +54,7 @@ public static Criterion activatedPortal() { } boolean test(ServerLevel world, BlockPos pos, ItemStack wand) { - return (this.wand.isEmpty() || this.wand.get().matches(wand)) + return (this.wand.isEmpty() || this.wand.get().test(wand)) && (this.location.isEmpty() || this.location.get().matches(world, pos.getX(), pos.getY(), pos.getZ())); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java b/Xplat/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java index 86731c203e..01f1699e08 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/LokiPlaceTrigger.java @@ -50,7 +50,7 @@ public static Criterion blocksPlaced(MinMaxBounds.Ints blocksPlaced) { } boolean test(ItemStack ring, int blocksPlaced) { - return (this.ring.isEmpty() || this.ring.get().matches(ring)) && this.blocksPlaced.matches(blocksPlaced); + return (this.ring.isEmpty() || this.ring.get().test(ring)) && this.blocksPlaced.matches(blocksPlaced); } } } diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java b/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java index 1c0bf573ff..bc59421aa8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/ManaBlasterTrigger.java @@ -52,7 +52,7 @@ public static Criterion shoot() { } boolean test(ItemStack stack, ServerPlayer entity) { - return (this.item.isEmpty() || this.item.get().matches(stack)) + return (this.item.isEmpty() || this.item.get().test(stack)) && (this.user.isEmpty() || this.user.get().matches(entity, entity)); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/RelicBindTrigger.java b/Xplat/src/main/java/vazkii/botania/common/advancements/RelicBindTrigger.java index df4df9adc9..8c1a6e4faf 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/RelicBindTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/RelicBindTrigger.java @@ -50,7 +50,7 @@ public static Criterion bound(ItemLike relicItem) { } boolean test(ItemStack stack) { - return this.relic.isEmpty() || this.relic.get().matches(stack); + return this.relic.isEmpty() || this.relic.get().test(stack); } } } diff --git a/Xplat/src/main/java/vazkii/botania/common/advancements/UseItemSuccessTrigger.java b/Xplat/src/main/java/vazkii/botania/common/advancements/UseItemSuccessTrigger.java index 619b6265ac..847e1116d9 100644 --- a/Xplat/src/main/java/vazkii/botania/common/advancements/UseItemSuccessTrigger.java +++ b/Xplat/src/main/java/vazkii/botania/common/advancements/UseItemSuccessTrigger.java @@ -55,7 +55,7 @@ public static Criterion used(ItemLike... items) { } boolean test(ItemStack stack, ServerLevel world, double x, double y, double z) { - return (this.item.isEmpty() || this.item.get().matches(stack)) + return (this.item.isEmpty() || this.item.get().test(stack)) && (this.location.isEmpty() || this.location.get().matches(world, x, y, z)); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/AnimatedTorchBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/AnimatedTorchBlock.java index 335d9e442b..5b0e10702e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/AnimatedTorchBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/AnimatedTorchBlock.java @@ -11,7 +11,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; @@ -44,7 +43,7 @@ public AnimatedTorchBlock(Properties builder) { } @Override - public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player playerIn, InteractionHand hand, BlockHitResult hit) { + public InteractionResult useWithoutItem(BlockState state, Level worldIn, BlockPos pos, Player playerIn, BlockHitResult hit) { if (playerIn.isSecondaryUseActive()) { ((AnimatedTorchBlockEntity) worldIn.getBlockEntity(pos)).handRotate(); return InteractionResult.sidedSuccess(worldIn.isClientSide()); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/AvatarBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/AvatarBlock.java index 962f627790..4756bbb80b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/AvatarBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/AvatarBlock.java @@ -13,7 +13,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; @@ -70,20 +70,19 @@ protected void createBlockStateDefinition(StateDefinition.Builder ALL = new ArrayList<>(); + private static final List> ALL = new ArrayList<>(); public static final ResourceKey FLOWER = make("flower"); public static final ResourceKey LEXICON = make("lexicon"); public static final ResourceKey LOGO = make("logo"); @@ -41,14 +39,16 @@ public final class BotaniaBannerPatterns { public static final ResourceKey SWORD = make("sword"); private static ResourceKey make(String hashName) { - BannerPattern pattern = new BannerPattern(LibMisc.MOD_ID + ":" + hashName); - ALL.add(pattern); - return ResourceKey.create(Registries.BANNER_PATTERN, botaniaRL(hashName)); + ResourceKey bannerKey = ResourceKey.create(Registries.BANNER_PATTERN, botaniaRL(hashName)); + ALL.add(bannerKey); + return bannerKey; } public static void submitRegistrations(BiConsumer consumer) { - for (var pattern : ALL) { - consumer.accept(pattern, ResourceLocation.parse(pattern.getHashname())); + for (var resourceKey : ALL) { + BannerPattern pattern = new BannerPattern(resourceKey.location(), + "block.minecraft.banner." + resourceKey.location().toLanguageKey()); + consumer.accept(pattern, resourceKey.location()); } } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/BotaniaBlocks.java b/Xplat/src/main/java/vazkii/botania/common/block/BotaniaBlocks.java index dbe1ed87b4..4a1c9fe8a8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/BotaniaBlocks.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/BotaniaBlocks.java @@ -57,9 +57,9 @@ import java.util.function.Supplier; import java.util.stream.Stream; +import static vazkii.botania.api.BotaniaAPI.botaniaRL; import static vazkii.botania.common.lib.LibBlockNames.*; import static vazkii.botania.common.lib.LibBlockNames.SLAB_SUFFIX; -import static vazkii.botania.api.BotaniaAPI.botaniaRL; public final class BotaniaBlocks { private static final BlockBehaviour.StateArgumentPredicate> NO_SPAWN = (state, world, pos, et) -> false; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/BotaniaFlowerBlocks.java b/Xplat/src/main/java/vazkii/botania/common/block/BotaniaFlowerBlocks.java index 57a1b3e2ea..9c27fb4fa8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/BotaniaFlowerBlocks.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/BotaniaFlowerBlocks.java @@ -315,8 +315,7 @@ private static FlowerBlock createSpecialFlowerBlock( Holder effect, int effectDuration, BlockBehaviour.Properties props, Supplier> beType) { - return new SpecialFlowerBlock( - effect, effectDuration, props, beType); + return createSpecialFlowerBlock(effect, effectDuration, props, beType, false); } private static FlowerBlock createSpecialFlowerBlock( @@ -324,9 +323,7 @@ private static FlowerBlock createSpecialFlowerBlock( BlockBehaviour.Properties props, Supplier> beType, boolean hasComparatorOutput) { - return XplatAbstractions.INSTANCE.createSpecialFlowerBlock( - effect, effectDuration, props, beType, hasComparatorOutput - ); + return new SpecialFlowerBlock(effect, effectDuration, props, beType, hasComparatorOutput); } public static void registerBlocks(BiConsumer r) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/CocoonBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/CocoonBlock.java index 745f55e3ac..0381afc2a4 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/CocoonBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/CocoonBlock.java @@ -12,7 +12,7 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -71,12 +71,11 @@ public void entityInside(BlockState state, Level world, BlockPos pos, Entity e) } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - ItemStack stack = player.getItemInHand(hand); - return addStack(world, pos, stack, player.getAbilities().instabuild); + public ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + return addStack(level, pos, stack, player.getAbilities().instabuild); } - private InteractionResult addStack(Level world, BlockPos pos, ItemStack stack, boolean creative) { + private ItemInteractionResult addStack(Level world, BlockPos pos, ItemStack stack, boolean creative) { CocoonBlockEntity cocoon = (CocoonBlockEntity) world.getBlockEntity(pos); if (cocoon != null && (stack.is(Items.EMERALD) || stack.is(Items.CHORUS_FRUIT) || stack.is(BotaniaItems.lifeEssence))) { @@ -103,10 +102,10 @@ private InteractionResult addStack(Level world, BlockPos pos, ItemStack stack, b } } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(world.isClientSide()); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } @NotNull diff --git a/Xplat/src/main/java/vazkii/botania/common/block/FelPumpkinBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/FelPumpkinBlock.java index 3b3de7a499..c42a76e28f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/FelPumpkinBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/FelPumpkinBlock.java @@ -58,7 +58,7 @@ public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldS blaze.moveTo(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F); blaze.setPersistenceRequired(); ((MobAccessor) blaze).setLootTable(LOOT_TABLE); - blaze.finalizeSpawn((ServerLevelAccessor) world, world.getCurrentDifficultyAt(pos), MobSpawnType.EVENT, null, null); + blaze.finalizeSpawn((ServerLevelAccessor) world, world.getCurrentDifficultyAt(pos), MobSpawnType.EVENT, null); world.addFreshEntity(blaze); for (ServerPlayer player : world.getEntitiesOfClass(ServerPlayer.class, blaze.getBoundingBox().inflate(5.0))) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/ForceRelayBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/ForceRelayBlock.java index af911fe0ed..86c34f984a 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/ForceRelayBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/ForceRelayBlock.java @@ -11,6 +11,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.GlobalPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtOps; @@ -29,6 +30,7 @@ import net.minecraft.world.level.saveddata.SavedData; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.common.handler.BotaniaSounds; @@ -89,7 +91,7 @@ public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull B } } - public boolean onUsedByWand(Player player, ItemStack stack, Level world, BlockPos pos) { + public boolean onUsedByWand(@Nullable Player player, ItemStack stack, Level world, BlockPos pos) { if (world.isClientSide) { return false; } @@ -124,17 +126,20 @@ public boolean onUsedByWand(Player player, ItemStack stack, Level world, BlockPo public static class WorldData extends SavedData { private static final String ID = "PistonRelayPairs"; - public static final Factory FACTORY = new Factory<>(() -> new WorldData(new CompoundTag()), - WorldData::new, DataFixTypes.LEVEL); + public static final Factory FACTORY = new Factory<>(WorldData::new, WorldData::new, DataFixTypes.LEVEL); public final Map mapping = new HashMap<>(); - public WorldData(@NotNull CompoundTag cmp) { + public WorldData() { + // initialize with empty data + } + + public WorldData(CompoundTag cmp, HolderLookup.Provider registries) { ListTag list = cmp.getList("list", Tag.TAG_INT_ARRAY); for (int i = 0; i < list.size(); i += 2) { Tag from = list.get(i); Tag to = list.get(i + 1); - BlockPos fromPos = BlockPos.CODEC.decode(NbtOps.INSTANCE, from).result().get().getFirst(); - BlockPos toPos = BlockPos.CODEC.decode(NbtOps.INSTANCE, to).result().get().getFirst(); + BlockPos fromPos = BlockPos.CODEC.decode(NbtOps.INSTANCE, from).result().orElseThrow().getFirst(); + BlockPos toPos = BlockPos.CODEC.decode(NbtOps.INSTANCE, to).result().orElseThrow().getFirst(); mapping.put(fromPos, toPos); } @@ -142,11 +147,11 @@ public WorldData(@NotNull CompoundTag cmp) { @NotNull @Override - public CompoundTag save(@NotNull CompoundTag cmp) { + public CompoundTag save(CompoundTag cmp, HolderLookup.Provider registries) { ListTag list = new ListTag(); for (Map.Entry e : mapping.entrySet()) { - Tag from = BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, e.getKey()).result().get(); - Tag to = BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, e.getValue()).result().get(); + Tag from = BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, e.getKey()).result().orElseThrow(); + Tag to = BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, e.getValue()).result().orElseThrow(); list.add(from); list.add(to); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/PlatformBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/PlatformBlock.java index fd81f87323..573880566d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/PlatformBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/PlatformBlock.java @@ -12,7 +12,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -136,12 +136,12 @@ public void appendHoverText(ItemStack stack, @Nullable Item.TooltipContext conte @NotNull @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + public ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { BlockEntity tile = world.getBlockEntity(pos); ItemStack currentStack = player.getItemInHand(hand); if (variant.indestructible && !player.isCreative()) { - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } if (!currentStack.isEmpty() && Block.byItem(currentStack.getItem()) != Blocks.AIR @@ -156,7 +156,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player camo.setCamoState(changeState); } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(world.isClientSide()); } } else if (!currentStack.isEmpty() && currentStack.is(BotaniaItems.phantomInk) @@ -165,10 +165,10 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player camo.setCamoState(Blocks.BARRIER.defaultBlockState()); //Barrier block is being used as a sentinel value here } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(world.isClientSide()); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/TeruTeruBozuBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/TeruTeruBozuBlock.java index 720d8c2033..1a87cf08ba 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/TeruTeruBozuBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/TeruTeruBozuBlock.java @@ -10,7 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -60,15 +60,15 @@ public void entityInside(BlockState state, Level world, BlockPos pos, Entity e) } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - ItemStack stack = player.getItemInHand(hand); - if (!stack.isEmpty() && (isSunflower(stack) && removeRain(world) || isBlueOrchid(stack) && startRain(world))) { + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, + Player player, InteractionHand hand, BlockHitResult hitResult) { + if (isSunflower(stack) && removeRain(level) || isBlueOrchid(stack) && startRain(level)) { if (!player.getAbilities().instabuild) { stack.shrink(1); } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } private boolean isSunflower(ItemStack stack) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java index 76e04c4f5c..abd8e8472f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AlfheimPortalBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; @@ -304,39 +305,38 @@ private void spawnItem(ItemStack stack) { } @Override - public void saveAdditional(CompoundTag cmp) { - super.saveAdditional(cmp); + public void saveAdditional(CompoundTag cmp, HolderLookup.Provider registries) { + super.saveAdditional(cmp, registries); cmp.putInt(TAG_STACK_COUNT, stacksIn.size()); int i = 0; for (ItemStack stack : stacksIn) { - CompoundTag stackcmp = stack.save(new CompoundTag()); - cmp.put(TAG_STACK + i, stackcmp); + cmp.put(TAG_STACK + i, stack.save(registries)); i++; } } @Override - public void load(@NotNull CompoundTag cmp) { + public void loadAdditional(@NotNull CompoundTag cmp, HolderLookup.Provider registries) { super.load(cmp); int count = cmp.getInt(TAG_STACK_COUNT); stacksIn.clear(); for (int i = 0; i < count; i++) { CompoundTag stackcmp = cmp.getCompound(TAG_STACK + i); - ItemStack stack = ItemStack.of(stackcmp); + ItemStack stack = ItemStack.parse(registries, stackcmp).orElse(ItemStack.EMPTY); stacksIn.add(stack); } } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_TICKS_OPEN, ticksOpen); cmp.putInt(TAG_TICKS_SINCE_LAST_ITEM, ticksSinceLastItem); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { ticksOpen = cmp.getInt(TAG_TICKS_OPEN); ticksSinceLastItem = cmp.getInt(TAG_TICKS_SINCE_LAST_ITEM); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AnimatedTorchBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AnimatedTorchBlockEntity.java index 35c5c09942..5baa6ddb4a 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AnimatedTorchBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AnimatedTorchBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.DustParticleOptions; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; @@ -202,7 +203,7 @@ private static void updateNeighbors(Level level, BlockPos worldPosition, BlockSt } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_SIDE, side); cmp.putBoolean(TAG_ROTATING, rotating); cmp.putInt(TAG_ROTATION_TICKS, rotationTicks); @@ -212,7 +213,7 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { side = cmp.getInt(TAG_SIDE); rotating = cmp.getBoolean(TAG_ROTATING); if (level != null && !level.isClientSide) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AvatarBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AvatarBlockEntity.java index 2faafe246b..ed2555efb3 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AvatarBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/AvatarBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -63,8 +64,8 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); tag.putBoolean(TAG_ENABLED, enabled); tag.putInt(TAG_TICKS_ELAPSED, ticksElapsed); tag.putInt(TAG_MANA, mana); @@ -79,8 +80,8 @@ public void writePacketNBT(CompoundTag tag) { } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); enabled = tag.getBoolean(TAG_ENABLED); ticksElapsed = tag.getInt(TAG_TICKS_ELAPSED); mana = tag.getInt(TAG_MANA); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BifrostBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BifrostBlockEntity.java index c2f60e08c2..3a33162533 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BifrostBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BifrostBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; @@ -33,14 +34,14 @@ public static void serverTick(Level level, BlockPos worldPosition, BlockState st } @Override - public void saveAdditional(CompoundTag tag) { - super.saveAdditional(tag); + public void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.saveAdditional(tag, registries); tag.putInt(TAG_TICKS, ticks); } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); + public void loadAdditional(@NotNull CompoundTag tag, HolderLookup.Provider registries) { + super.loadAdditional(tag, registries); ticks = tag.getInt(TAG_TICKS); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntities.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntities.java index 1f8008ecb9..ee8d607f2d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntities.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntities.java @@ -30,8 +30,8 @@ import java.util.function.BiFunction; import java.util.function.Function; -import static vazkii.botania.common.block.BotaniaBlocks.*; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import static vazkii.botania.common.block.BotaniaBlocks.*; public class BotaniaBlockEntities { private static final Map> ALL = new HashMap<>(); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntity.java index 00bfd1f5e5..db01b111d6 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BotaniaBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; @@ -26,28 +27,28 @@ public BotaniaBlockEntity(BlockEntityType type, BlockPos pos, BlockState stat } @Override - public void saveAdditional(CompoundTag tag) { - super.saveAdditional(tag); - writePacketNBT(tag); + public void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.saveAdditional(tag, registries); + writePacketNBT(tag, registries); } @NotNull @Override - public final CompoundTag getUpdateTag() { + public final CompoundTag getUpdateTag(HolderLookup.Provider registries) { var tag = new CompoundTag(); - writePacketNBT(tag); + writePacketNBT(tag, registries); return tag; } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); - readPacketNBT(tag); + public void loadAdditional(@NotNull CompoundTag tag, HolderLookup.Provider registries) { + super.loadAdditional(tag, registries); + readPacketNBT(tag, registries); } - public void writePacketNBT(CompoundTag cmp) {} + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) {} - public void readPacketNBT(CompoundTag cmp) {} + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) {} @Nullable @Override diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BreweryBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BreweryBlockEntity.java index 4c77c94eda..cae1487b73 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BreweryBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/BreweryBlockEntity.java @@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; @@ -204,15 +205,15 @@ public int getManaCost() { } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); tag.putInt(TAG_MANA, mana); } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); mana = tag.getInt(TAG_MANA); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java index 8206d4ccc9..09e3f92294 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CacophoniumBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; @@ -38,22 +39,19 @@ public void annoyDirewolf() { } @Override - public void writePacketNBT(CompoundTag cmp) { - super.writePacketNBT(cmp); + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writePacketNBT(cmp, registries); - CompoundTag cmp1 = new CompoundTag(); if (!stack.isEmpty()) { - cmp1 = stack.save(cmp1); + cmp.put(TAG_STACK, stack.save(registries)); } - cmp.put(TAG_STACK, cmp1); } @Override - public void readPacketNBT(CompoundTag cmp) { - super.readPacketNBT(cmp); + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readPacketNBT(cmp, registries); - CompoundTag cmp1 = cmp.getCompound(TAG_STACK); - stack = ItemStack.of(cmp1); + stack = ItemStack.parse(registries, cmp.getCompound(TAG_STACK)).orElse(ItemStack.EMPTY); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CellularBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CellularBlockEntity.java index 7bc298b590..78aa949a8a 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CellularBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CellularBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; @@ -76,7 +77,7 @@ public int getGeneration() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_GENERATION, generation); cmp.putBoolean(TAG_TICKED, ticked); if (ticked) { @@ -90,7 +91,7 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { generation = cmp.getInt(TAG_GENERATION); ticked = cmp.getBoolean(TAG_TICKED); if (ticked) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CocoonBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CocoonBlockEntity.java index 8c2cbd560c..2f178c9fa6 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CocoonBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CocoonBlockEntity.java @@ -12,6 +12,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -119,7 +120,7 @@ private void hatch() { if (entity instanceof AgeableMob ageable) { ageable.setAge(-24000); } - entity.finalizeSpawn((ServerLevelAccessor) level, level.getCurrentDifficultyAt(getBlockPos()), MobSpawnType.EVENT, null, null); + entity.finalizeSpawn((ServerLevelAccessor) level, level.getCurrentDifficultyAt(getBlockPos()), MobSpawnType.EVENT, null); entity.setPersistenceRequired(); level.addFreshEntity(entity); entity.spawnAnim(); @@ -150,7 +151,7 @@ private Mob random(TagKey> tag) { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_TIME_PASSED, timePassed); cmp.putInt(TAG_EMERALDS_GIVEN, emeraldsGiven); cmp.putInt(TAG_CHORUS_FRUIT_GIVEN, chorusFruitGiven); @@ -158,7 +159,7 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { timePassed = cmp.getInt(TAG_TIME_PASSED); emeraldsGiven = cmp.getInt(TAG_EMERALDS_GIVEN); chorusFruitGiven = cmp.getInt(TAG_CHORUS_FRUIT_GIVEN); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CraftyCrateBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CraftyCrateBlockEntity.java index 6ecc1e9d04..92500cc68c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CraftyCrateBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/CraftyCrateBlockEntity.java @@ -12,6 +12,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; @@ -98,14 +99,14 @@ private boolean isLocked(int slot) { } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); craftResult = ItemStack.of(tag.getCompound(TAG_CRAFTING_RESULT)); } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); tag.put(TAG_CRAFTING_RESULT, craftResult.save(new CompoundTag())); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FakeAirBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FakeAirBlockEntity.java index 7934c5793d..684b670535 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FakeAirBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FakeAirBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -39,16 +40,16 @@ public boolean canStay() { } @Override - public void saveAdditional(CompoundTag tag) { - super.saveAdditional(tag); + public void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { + super.saveAdditional(tag, registries); tag.putInt(TAG_FLOWER_X, flowerPos.getX()); tag.putInt(TAG_FLOWER_Y, flowerPos.getY()); tag.putInt(TAG_FLOWER_Z, flowerPos.getZ()); } @Override - public void load(@NotNull CompoundTag tag) { - super.load(tag); + public void loadAdditional(@NotNull CompoundTag tag, HolderLookup.Provider registries) { + super.loadAdditional(tag, registries); flowerPos = new BlockPos( tag.getInt(TAG_FLOWER_X), tag.getInt(TAG_FLOWER_Y), diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FloatingFlowerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FloatingFlowerBlockEntity.java index 35ccea8da0..3f3d230d8d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FloatingFlowerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/FloatingFlowerBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; @@ -45,12 +46,12 @@ public FloatingFlower getFloatingData() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.put(TAG_FLOATING_DATA, floatingData.writeNBT()); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { FloatingFlower.IslandType oldType = floatingData.getIslandType(); floatingData.readNBT(cmp.getCompound(TAG_FLOATING_DATA)); if (oldType != floatingData.getIslandType() && level != null && level.isClientSide) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/HoveringHourglassBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/HoveringHourglassBlockEntity.java index e40f21da81..ba0f202009 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/HoveringHourglassBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/HoveringHourglassBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.StringUtil; import net.minecraft.world.SimpleContainer; @@ -186,8 +187,8 @@ public void setChanged() { } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); tag.putInt(TAG_TIME, time); tag.putFloat(TAG_TIME_FRACTION, timeFraction); tag.putBoolean(TAG_FLIP, flip); @@ -197,8 +198,8 @@ public void writePacketNBT(CompoundTag tag) { } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); time = tag.getInt(TAG_TIME); timeFraction = tag.getFloat(TAG_TIME_FRACTION); flip = tag.getBoolean(TAG_FLIP); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java index 83da0b08f9..63c7717bb7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/IncensePlateBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; @@ -150,15 +151,15 @@ public void ignite() { } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); tag.putInt(TAG_TIME_LEFT, timeLeft); tag.putBoolean(TAG_BURNING, burning); } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); timeLeft = tag.getInt(TAG_TIME_LEFT); burning = tag.getBoolean(TAG_BURNING); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LifeImbuerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LifeImbuerBlockEntity.java index 63376e41ac..185dba2fcd 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LifeImbuerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LifeImbuerBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; @@ -53,12 +54,12 @@ public static void onSpawnerNearPlayer(Level level, BlockPos pos, CallbackInfoRe } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_MANA, mana); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { mana = cmp.getInt(TAG_MANA); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java index 12d4d08beb..12734cf729 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/LuminizerBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; @@ -261,7 +262,7 @@ public boolean bindTo(Player player, ItemStack wand, BlockPos pos, Direction sid } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { bindPos = new BlockPos( cmp.getInt(TAG_BIND_X), cmp.getInt(TAG_BIND_Y), @@ -271,7 +272,7 @@ public void readPacketNBT(CompoundTag cmp) { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_BIND_X, bindPos.getX()); cmp.putInt(TAG_BIND_Y, bindPos.getY()); cmp.putInt(TAG_BIND_Z, bindPos.getZ()); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaEnchanterBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaEnchanterBlockEntity.java index e6985ea521..f9a2a4ae09 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaEnchanterBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaEnchanterBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; @@ -311,7 +312,8 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st } } - default -> {} + default -> { + } } } @@ -390,7 +392,7 @@ public void sync() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_MANA, mana); cmp.putInt(TAG_MANA_REQUIRED, manaRequired); cmp.putInt(TAG_STAGE, stage.ordinal()); @@ -409,7 +411,7 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { mana = cmp.getInt(TAG_MANA); manaRequired = cmp.getInt(TAG_MANA_REQUIRED); stage = State.values()[cmp.getInt(TAG_STAGE)]; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaFlameBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaFlameBlockEntity.java index d65acae71c..6dc02c356e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaFlameBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/ManaFlameBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.block_entity; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.state.BlockState; @@ -30,12 +31,12 @@ public int getColor() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_COLOR, color); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { color = cmp.getInt(TAG_COLOR); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java index 03508d1479..bddda21c2c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PetalApothecaryBlockEntity.java @@ -9,7 +9,6 @@ package vazkii.botania.common.block.block_entity; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; @@ -34,6 +33,7 @@ import net.minecraft.world.phys.AABB; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4fStack; import vazkii.botania.api.block.PetalApothecary; import vazkii.botania.api.internal.VanillaPacketDispatcher; @@ -361,12 +361,12 @@ public static void render(PetalApothecaryBlockEntity altar, GuiGraphics gui, Min for (int i = 0; i < amt; i++) { double xPos = xc + Math.cos(angle * Math.PI / 180D) * radius - 8; double yPos = yc + Math.sin(angle * Math.PI / 180D) * radius - 8; - PoseStack pose = RenderSystem.getModelViewStack(); - pose.pushPose(); - pose.translate(xPos, yPos, 0); + Matrix4fStack pose = RenderSystem.getModelViewStack(); + pose.pushMatrix(); + pose.translate((float) xPos, (float) yPos, 0); RenderSystem.applyModelViewMatrix(); gui.renderFakeItem(altar.getItemHandler().getItem(i), 0, 0); - pose.popPose(); + pose.popMatrix(); RenderSystem.applyModelViewMatrix(); angle += anglePer; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PlatformBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PlatformBlockEntity.java index 8549eca51c..df5437d236 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PlatformBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/PlatformBlockEntity.java @@ -11,6 +11,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.HolderGetter; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; @@ -102,14 +103,14 @@ private void swap(PlatformBlockEntity tile, boolean empty) { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { if (getCamoState() != null) { cmp.put(TAG_CAMO, NbtUtils.writeBlockState(getCamoState())); } } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { HolderGetter holderGetter = this.level != null ? this.level.holderLookup(Registries.BLOCK) : BuiltInRegistries.BLOCK.asLookup(); BlockState state = NbtUtils.readBlockState(holderGetter, cmp.getCompound(TAG_CAMO)); if (state.isAir()) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java index 948f315974..dbe21498a2 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/RunicAltarBlockEntity.java @@ -16,6 +16,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; @@ -326,16 +327,16 @@ public boolean isEmpty() { } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); tag.putInt(TAG_MANA, mana); tag.putInt(TAG_MANA_TO_GET, manaToGet); } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); mana = tag.getInt(TAG_MANA); manaToGet = tag.getInt(TAG_MANA_TO_GET); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/SimpleInventoryBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/SimpleInventoryBlockEntity.java index 2d9771d1fb..06e7e78457 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/SimpleInventoryBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/SimpleInventoryBlockEntity.java @@ -11,6 +11,7 @@ import com.google.common.base.Preconditions; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.Clearable; @@ -46,15 +47,15 @@ private static NonNullList copyFromInv(Container inv) { } @Override - public void readPacketNBT(CompoundTag tag) { + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { NonNullList tmp = NonNullList.withSize(inventorySize(), ItemStack.EMPTY); - ContainerHelper.loadAllItems(tag, tmp); + ContainerHelper.loadAllItems(tag, tmp, registries); copyToInv(tmp, itemHandler); } @Override - public void writePacketNBT(CompoundTag tag) { - ContainerHelper.saveAllItems(tag, copyFromInv(itemHandler)); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + ContainerHelper.saveAllItems(tag, copyFromInv(itemHandler), registries); } // NB: Cannot be named the same as the corresponding method in vanilla's interface -- causes obf issues with MCP diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TerrestrialAgglomerationPlateBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TerrestrialAgglomerationPlateBlockEntity.java index 012221d987..e195a1f498 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TerrestrialAgglomerationPlateBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TerrestrialAgglomerationPlateBlockEntity.java @@ -12,6 +12,7 @@ import com.google.common.base.Suppliers; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -195,12 +196,12 @@ private boolean hasValidPlatform() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_MANA, mana); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { mana = cmp.getInt(TAG_MANA); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TinyPotatoBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TinyPotatoBlockEntity.java index a7621deec9..22b11850ab 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TinyPotatoBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/TinyPotatoBlockEntity.java @@ -12,6 +12,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -267,14 +268,14 @@ public void setChanged() { } @Override - public void writePacketNBT(CompoundTag cmp) { - super.writePacketNBT(cmp); + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writePacketNBT(cmp, registries); cmp.putString(TAG_NAME, Component.Serializer.toJson(name)); } @Override - public void readPacketNBT(CompoundTag cmp) { - super.readPacketNBT(cmp); + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readPacketNBT(cmp, registries); name = Component.Serializer.fromJson(cmp.getString(TAG_NAME)); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaCrystalCubeBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaCrystalCubeBlockEntity.java index dea46dbe24..8750590889 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaCrystalCubeBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaCrystalCubeBlockEntity.java @@ -15,6 +15,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.LivingEntity; @@ -117,22 +118,20 @@ private void setCount(int count) { } @Override - public void writePacketNBT(CompoundTag tag) { - super.writePacketNBT(tag); - CompoundTag cmp = new CompoundTag(); + public void writePacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.writePacketNBT(tag, registries); if (!requestTarget.isEmpty()) { - cmp = requestTarget.save(cmp); + tag.put(TAG_REQUEST_TARGET, requestTarget.save(registries)); } - tag.put(TAG_REQUEST_TARGET, cmp); tag.putInt(TAG_ITEM_COUNT, itemCount); tag.putBoolean(TAG_LOCK, locked); } @Override - public void readPacketNBT(CompoundTag tag) { - super.readPacketNBT(tag); + public void readPacketNBT(CompoundTag tag, HolderLookup.Provider registries) { + super.readPacketNBT(tag, registries); CompoundTag cmp = tag.getCompound(TAG_REQUEST_TARGET); - requestTarget = ItemStack.of(cmp); + requestTarget = ItemStack.parse(registries, cmp).orElse(ItemStack.EMPTY); setCount(tag.getInt(TAG_ITEM_COUNT)); locked = tag.getBoolean(TAG_LOCK); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaRetainerBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaRetainerBlockEntity.java index 9436583f59..9ae0c5976c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaRetainerBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/corporea/CorporeaRetainerBlockEntity.java @@ -14,6 +14,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; @@ -97,8 +98,8 @@ public void fulfilRequest() { } @Override - public void writePacketNBT(CompoundTag cmp) { - super.writePacketNBT(cmp); + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writePacketNBT(cmp, registries); cmp.putInt(TAG_REQUEST_X, requestPos.getX()); cmp.putInt(TAG_REQUEST_Y, requestPos.getY()); @@ -115,8 +116,8 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { - super.readPacketNBT(cmp); + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readPacketNBT(cmp, registries); int x = cmp.getInt(TAG_REQUEST_X); int y = cmp.getInt(TAG_REQUEST_Y); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java index 1c09973f3c..2b04b214d5 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/BellowsBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; @@ -22,6 +23,8 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.gameevent.GameEvent; +import org.jetbrains.annotations.NotNull; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; import vazkii.botania.common.block.block_entity.BotaniaBlockEntity; @@ -125,12 +128,12 @@ public BlockEntity getLinkedTile() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(@NotNull CompoundTag cmp, HolderLookup.Provider registries) { cmp.putBoolean(TAG_ACTIVE, active); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { active = cmp.getBoolean(TAG_ACTIVE); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java index f6d818b081..ef998b0d72 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPoolBlockEntity.java @@ -15,6 +15,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Entity; @@ -349,7 +350,7 @@ public static void serverTick(Level level, BlockPos worldPosition, BlockState st } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(@NotNull CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_MANA, getCurrentMana()); cmp.putBoolean(TAG_OUTPUTTING, outputting); @@ -362,7 +363,7 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { mana = cmp.getInt(TAG_MANA); outputting = cmp.getBoolean(TAG_OUTPUTTING); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPumpBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPumpBlockEntity.java index 49dfc16297..a54939ed49 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPumpBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaPumpBlockEntity.java @@ -9,11 +9,14 @@ package vazkii.botania.common.block.block_entity.mana; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; + import vazkii.botania.api.internal.VanillaPacketDispatcher; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; import vazkii.botania.common.block.block_entity.BotaniaBlockEntity; @@ -82,12 +85,12 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(@NotNull CompoundTag cmp, HolderLookup.Provider registries) { cmp.putBoolean(TAG_ACTIVE, active); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { active = cmp.getBoolean(TAG_ACTIVE); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaSpreaderBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaSpreaderBlockEntity.java index c3134a298e..c2740c8d73 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaSpreaderBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/ManaSpreaderBlockEntity.java @@ -14,6 +14,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; import net.minecraft.world.SimpleContainer; @@ -257,8 +258,8 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st } @Override - public void writePacketNBT(CompoundTag cmp) { - super.writePacketNBT(cmp); + public void writePacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writePacketNBT(cmp, registries); cmp.putUUID(TAG_UUID, getIdentifier()); @@ -293,8 +294,8 @@ public void writePacketNBT(CompoundTag cmp) { } @Override - public void readPacketNBT(CompoundTag cmp) { - super.readPacketNBT(cmp); + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readPacketNBT(cmp, registries); String tagUuidMostDeprecated = "uuidMost"; String tagUuidLeastDeprecated = "uuidLeast"; @@ -696,7 +697,8 @@ public void rotate(Rotation rotation) { case CLOCKWISE_90 -> rotationX += 270F; case CLOCKWISE_180 -> rotationX += 180F; case COUNTERCLOCKWISE_90 -> rotationX += 90F; - case NONE -> {} + case NONE -> { + } } if (rotationX >= 360F) { @@ -708,7 +710,8 @@ public void mirror(Mirror mirror) { switch (mirror) { case LEFT_RIGHT -> rotationX = 360F - rotationX; case FRONT_BACK -> rotationX = 180F - rotationX; - case NONE -> {} + case NONE -> { + } } if (rotationX < 0F) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/PowerGeneratorBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/PowerGeneratorBlockEntity.java index 34d35af0e7..a40c9520d8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/PowerGeneratorBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/PowerGeneratorBlockEntity.java @@ -9,10 +9,13 @@ package vazkii.botania.common.block.block_entity.mana; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; + import vazkii.botania.api.mana.ManaReceiver; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; import vazkii.botania.common.block.block_entity.BotaniaBlockEntity; @@ -69,12 +72,12 @@ public boolean canReceiveManaFromBursts() { } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(@NotNull CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_MANA, energy); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { energy = cmp.getInt(TAG_MANA); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/SpreaderTurntableBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/SpreaderTurntableBlockEntity.java index d941d5ac2d..3e1391bdca 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/SpreaderTurntableBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/mana/SpreaderTurntableBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -20,6 +21,7 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.block.WandHUD; @@ -56,13 +58,13 @@ public static void commonTick(Level level, BlockPos worldPosition, BlockState st } @Override - public void writePacketNBT(CompoundTag cmp) { + public void writePacketNBT(@NotNull CompoundTag cmp, HolderLookup.Provider registries) { cmp.putInt(TAG_SPEED, speed); cmp.putBoolean(TAG_BACKWARDS, backwards); } @Override - public void readPacketNBT(CompoundTag cmp) { + public void readPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { speed = cmp.getInt(TAG_SPEED); backwards = cmp.getBoolean(TAG_BACKWARDS); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/block_entity/package-info.java b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/package-info.java new file mode 100644 index 0000000000..273838f217 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/block/block_entity/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.block.block_entity; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/corporea/CorporeaCrystalCubeBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/corporea/CorporeaCrystalCubeBlock.java index d96f012eda..f2f7d8eb3d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/corporea/CorporeaCrystalCubeBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/corporea/CorporeaCrystalCubeBlock.java @@ -11,7 +11,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; @@ -58,23 +58,20 @@ public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, Co } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - ItemStack stack = player.getItemInHand(hand); - if (!stack.isEmpty()) { - if (stack.getItem() instanceof WandOfTheForestItem && player.isSecondaryUseActive()) { - return InteractionResult.PASS; - } - CorporeaCrystalCubeBlockEntity cube = (CorporeaCrystalCubeBlockEntity) world.getBlockEntity(pos); - if (cube.locked) { - if (!world.isClientSide) { - player.displayClientMessage(Component.translatable("botaniamisc.crystalCubeLocked"), false); - } - } else { - cube.setRequestTarget(stack); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, + Player player, InteractionHand hand, BlockHitResult hitResult) { + if (stack.getItem() instanceof WandOfTheForestItem && player.isSecondaryUseActive()) { + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; + } + CorporeaCrystalCubeBlockEntity cube = (CorporeaCrystalCubeBlockEntity) level.getBlockEntity(pos); + if (cube.locked) { + if (!level.isClientSide) { + player.displayClientMessage(Component.translatable("botaniamisc.crystalCubeLocked"), false); } - return InteractionResult.sidedSuccess(world.isClientSide()); + } else { + cube.setRequestTarget(stack); } - return InteractionResult.PASS; + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } @NotNull diff --git a/Xplat/src/main/java/vazkii/botania/common/block/corporea/package-info.java b/Xplat/src/main/java/vazkii/botania/common/block/corporea/package-info.java new file mode 100644 index 0000000000..8f38940cf9 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/block/corporea/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.block.corporea; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/decor/FloatingFlowerBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/decor/FloatingFlowerBlock.java index fe1df8e5e3..b65d507b78 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/decor/FloatingFlowerBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/decor/FloatingFlowerBlock.java @@ -11,7 +11,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; @@ -80,10 +80,10 @@ public void animateTick(BlockState state, Level world, BlockPos pos, RandomSourc } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - ItemStack stack = player.getItemInHand(hand); - BlockEntity te = world.getBlockEntity(pos); - if (!stack.isEmpty() && te instanceof FloatingFlowerProvider provider && provider.getFloatingData() != null) { + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, + Player player, InteractionHand hand, BlockHitResult hitResult) { + BlockEntity te = level.getBlockEntity(pos); + if (te instanceof FloatingFlowerProvider provider && provider.getFloatingData() != null) { FloatingFlower flower = provider.getFloatingData(); IslandType type = null; if (stack.is(Items.SNOWBALL)) { @@ -96,7 +96,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player } if (type != null && type != flower.getIslandType()) { - if (!world.isClientSide) { + if (!level.isClientSide) { flower.setIslandType(type); VanillaPacketDispatcher.dispatchTEToNearbyPlayers(te); } @@ -104,10 +104,10 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player if (!player.getAbilities().instabuild) { stack.shrink(1); } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } @NotNull diff --git a/Xplat/src/main/java/vazkii/botania/common/block/decor/FlowerMotifBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/decor/FlowerMotifBlock.java index 532083916d..4785bb4fdd 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/decor/FlowerMotifBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/decor/FlowerMotifBlock.java @@ -16,11 +16,8 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.FlowerBlock; -import org.jetbrains.annotations.Nullable; - import vazkii.botania.common.item.CustomCreativeTabContents; import java.util.List; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/decor/ManaFlameBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/decor/ManaFlameBlock.java index 178752a0c8..49937697e7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/decor/ManaFlameBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/decor/ManaFlameBlock.java @@ -12,7 +12,7 @@ import net.minecraft.tags.ItemTags; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; @@ -55,19 +55,17 @@ public RenderShape getRenderShape(BlockState state) { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - if (XplatAbstractions.INSTANCE.gogLoaded()) { - ItemStack stack = player.getItemInHand(hand); - if (!stack.isEmpty() && stack.is(ItemTags.SAPLINGS) && !InventoryHelper.containsType(player.getInventory(), BotaniaItems.lexicon)) { - if (!world.isClientSide) { - stack.shrink(1); - player.getInventory().placeItemBackInInventory(new ItemStack(BotaniaItems.lexicon)); - } - return InteractionResult.sidedSuccess(world.isClientSide()); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, + Player player, InteractionHand hand, BlockHitResult hitResult) { + if (XplatAbstractions.INSTANCE.gogLoaded() && stack.is(ItemTags.SAPLINGS) + && !InventoryHelper.containsType(player.getInventory(), BotaniaItems.lexicon)) { + if (!level.isClientSide) { + stack.shrink(1); + player.getInventory().placeItemBackInInventory(new ItemStack(BotaniaItems.lexicon)); } - + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } @Override diff --git a/Xplat/src/main/java/vazkii/botania/common/block/decor/package-info.java b/Xplat/src/main/java/vazkii/botania/common/block/decor/package-info.java new file mode 100644 index 0000000000..1f075b7875 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/block/decor/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.block.decor; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java index 84a2c139a3..c78b34e83c 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/PureDaisyBlockEntity.java @@ -9,15 +9,16 @@ package vazkii.botania.common.block.flower; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; @@ -142,8 +143,8 @@ public void tickFlower() { private PureDaisyRecipe findRecipe(BlockPos coords) { BlockState state = getLevel().getBlockState(coords); - for (Recipe recipe : BotaniaRecipeTypes.getRecipes(level, BotaniaRecipeTypes.PURE_DAISY_TYPE).values()) { - if (recipe instanceof PureDaisyRecipe daisyRecipe && daisyRecipe.matches(getLevel(), coords, state)) { + for (RecipeHolder recipe : BotaniaRecipeTypes.getRecipes(level, BotaniaRecipeTypes.PURE_DAISY_TYPE)) { + if (recipe.value() instanceof PureDaisyRecipe daisyRecipe && daisyRecipe.matches(getLevel(), coords, state)) { return daisyRecipe; } } @@ -180,8 +181,8 @@ public RadiusDescriptor getRadius() { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); positionAt = cmp.getInt(TAG_POSITION); for (int i = 0; i < ticksRemaining.length; i++) { @@ -190,8 +191,8 @@ public void readFromPacketNBT(CompoundTag cmp) { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_POSITION, positionAt); for (int i = 0; i < ticksRemaining.length; i++) { cmp.putInt(TAG_TICKS_REMAINING + i, ticksRemaining[i]); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/AgricarnationBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/AgricarnationBlockEntity.java index 8bbc8c223a..507748bc9b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/AgricarnationBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/AgricarnationBlockEntity.java @@ -84,7 +84,7 @@ public void tickFlower() { state.randomTick(serverLevel, pos, serverLevel.random); } if (BotaniaConfig.common().blockBreakParticles()) { - serverLevel.levelEvent(LevelEvent.PARTICLES_PLANT_GROWTH, pos, 6 + serverLevel.random.nextInt(4)); + serverLevel.levelEvent(LevelEvent.PARTICLES_BEE_GROWTH, pos, 6 + serverLevel.random.nextInt(4)); } serverLevel.playSound(null, x, y, z, BotaniaSounds.agricarnation, SoundSource.BLOCKS, 1F, 0.5F + (float) Math.random() * 0.5F); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/BubbellBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/BubbellBlockEntity.java index 8295a74ea3..97b465e2aa 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/BubbellBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/BubbellBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.functional; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -81,14 +82,14 @@ public static boolean isValidBubbell(Level world, BlockPos pos) { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_RANGE, range); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); range = cmp.getInt(TAG_RANGE); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/DaffomillBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/DaffomillBlockEntity.java index 0b83a4a803..0d03f9da81 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/DaffomillBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/DaffomillBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; @@ -98,7 +99,8 @@ private AABB aabbForOrientation() { case SOUTH -> axis = new AABB(x - w, y - h, z + 1, x + w + 1, y + h, z + l + 1); case WEST -> axis = new AABB(x - l, y - h, z - w, x, y + h, z + w + 1); case EAST -> axis = new AABB(x + 1, y - h, z - w, x + l + 1, y + h, z + w + 1); - default -> {} + default -> { + } } return axis; } @@ -148,8 +150,8 @@ public int getMaxMana() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_ORIENTATION, orientation.get3DDataValue()); cmp.putInt(TAG_WIND_TICKS, windTicks); @@ -157,8 +159,8 @@ public void writeToPacketNBT(CompoundTag cmp) { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); orientation = Direction.from3DDataValue(cmp.getInt(TAG_ORIENTATION)); windTicks = cmp.getInt(TAG_WIND_TICKS); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java index 1ff076176d..b93197fa43 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HopperhockBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.entity.item.ItemEntity; @@ -230,15 +231,15 @@ public int getRange() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_FILTER_TYPE, filterType); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); filterType = cmp.getInt(TAG_FILTER_TYPE); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HyacidusBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HyacidusBlockEntity.java index 9e81b19635..72a76c1726 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HyacidusBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/HyacidusBlockEntity.java @@ -9,10 +9,10 @@ package vazkii.botania.common.block.flower.functional; import net.minecraft.core.BlockPos; +import net.minecraft.tags.EntityTypeTags; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.entity.MobType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; @@ -41,7 +41,7 @@ public void tickFlower() { List entities = getLevel().getEntitiesOfClass(LivingEntity.class, new AABB(getEffectivePos()).inflate(RANGE)); for (LivingEntity entity : entities) { - if (!(entity instanceof Player) && entity.getEffect(MobEffects.POISON) == null && getMana() >= COST && !entity.level().isClientSide && entity.getMobType() != MobType.UNDEAD) { + if (!(entity instanceof Player) && entity.getEffect(MobEffects.POISON) == null && getMana() >= COST && !entity.level().isClientSide && entity.getType().is(EntityTypeTags.UNDEAD)) { entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60, 0)); addMana(-COST); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/LooniumBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/LooniumBlockEntity.java index 688483f2d0..904b8899e7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/LooniumBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/LooniumBlockEntity.java @@ -19,6 +19,7 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; @@ -228,7 +229,7 @@ private void spawnMob(ServerLevel world, LooniumMobSpawnData pickedMobType, double y = getEffectivePos().getY(); double z = getEffectivePos().getZ() + 0.5 - RANGE + 2 * RANGE * random.nextDouble(); - while (!world.noCollision(pickedMobType.type.getAABB(x, y, z))) { + while (!world.noCollision(pickedMobType.type.getSpawnAABB(x, y, z))) { y += 1.0; if (y >= world.getMaxBuildHeight()) { return; @@ -510,8 +511,8 @@ public RadiusDescriptor getSecondaryRadius() { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); if (cmp.contains(TAG_LOOT_TABLE)) { lootTableOverride = ResourceLocation.parse(cmp.getString(TAG_LOOT_TABLE)); } @@ -543,8 +544,8 @@ public void readFromPacketNBT(CompoundTag cmp) { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); if (lootTableOverride != null) { cmp.putString(TAG_LOOT_TABLE, lootTableOverride.toString()); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java index 552f315058..7dfa634099 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/OrechidBlockEntity.java @@ -81,7 +81,7 @@ private OrechidRecipe findMatchingRecipe(BlockPos coords) { values.add(WeightedEntry.wrap(recipe, recipe.getWeight(getLevel(), coords))); } return WeightedRandom.getRandomItem(getLevel().random, values) - .map(WeightedEntry.Wrapper::getData) + .map(WeightedEntry.Wrapper::data) .orElse(null); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java index 3f4886e387..88b0c0db23 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/PollidisiacBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.tags.ItemTags; @@ -196,14 +197,14 @@ public boolean onUsedByWand(@Nullable Player player, ItemStack stack, Direction } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); this.mode = Mode.forName(cmp.getString(TAG_FEEDING_MODE)); } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putString(TAG_FEEDING_MODE, this.mode.getSerializedName()); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/RannuncarpusBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/RannuncarpusBlockEntity.java index f6a35bd83e..cde09750ed 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/RannuncarpusBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/RannuncarpusBlockEntity.java @@ -15,6 +15,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -195,8 +196,8 @@ public boolean acceptsRedstone() { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); if (cmp.contains(TAG_STATE_SENSITIVE)) { stateSensitive = cmp.getBoolean(TAG_STATE_SENSITIVE); } else { @@ -206,8 +207,8 @@ public void readFromPacketNBT(CompoundTag cmp) { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putBoolean(TAG_STATE_SENSITIVE, stateSensitive); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/SpectranthemumBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/SpectranthemumBlockEntity.java index e920744d37..036164996a 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/SpectranthemumBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/SpectranthemumBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; @@ -94,16 +95,16 @@ public RadiusDescriptor getRadius() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_BIND_X, bindPos.getX()); cmp.putInt(TAG_BIND_Y, bindPos.getY()); cmp.putInt(TAG_BIND_Z, bindPos.getZ()); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); bindPos = new BlockPos( cmp.getInt(TAG_BIND_X), cmp.getInt(TAG_BIND_Y), diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/TangleberrieBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/TangleberrieBlockEntity.java index 6fcd4c8628..b55e1187aa 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/TangleberrieBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/functional/TangleberrieBlockEntity.java @@ -55,7 +55,7 @@ public void tickFlower() { SparkleParticleData data = SparkleParticleData.sparkle(1F, 0.5F, 0.5F, 0.5F, 3); for (LivingEntity entity : entities) { - if (entity instanceof Player || !entity.canChangeDimensions()) { + if (entity instanceof Player || !entity.canUsePortal(false)) { continue; } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/DandelifeonBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/DandelifeonBlockEntity.java index 2a0ea1b3ab..8ec57c7e87 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/DandelifeonBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/DandelifeonBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.generating; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -251,16 +252,16 @@ public int getColor() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); if (radius != RANGE) { cmp.putInt(TAG_RADIUS, radius); } } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); radius = cmp.contains(TAG_RADIUS) ? cmp.getInt(TAG_RADIUS) : RANGE; } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java index cc53054a2b..aeb2192bdd 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/EndoflameBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.generating; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; @@ -122,15 +123,15 @@ public RadiusDescriptor getRadius() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_BURN_TIME, burnTime); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); burnTime = cmp.getInt(TAG_BURN_TIME); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java index 8ad331e5c0..32d8f45183 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/FluidGeneratorBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.FluidTags; import net.minecraft.tags.TagKey; @@ -136,16 +137,16 @@ public int getGenerationDelay() { public abstract void playSound(); @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_BURN_TIME, burnTime); cmp.putInt(TAG_COOLDOWN, cooldown); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); burnTime = cmp.getInt(TAG_BURN_TIME); cooldown = cmp.getInt(TAG_COOLDOWN); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java index 2959484bff..385bfa245f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/GourmaryllisBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.generating; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; @@ -79,7 +80,7 @@ private int processFood(ItemStack food) { for (ListIterator it = lastFoods.listIterator(); it.hasNext();) { int index = it.nextIndex(); ItemStack streakFood = it.next(); - if (ItemStack.isSameItemSameTags(streakFood, food)) { + if (ItemStack.isSameItemSameComponents(streakFood, food)) { it.remove(); lastFoods.add(0, streakFood); return index; @@ -164,8 +165,8 @@ private static int getFoodValue(ItemStack stack) { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_COOLDOWN, cooldown); cmp.putInt(TAG_DIGESTING_MANA, digestingMana); ListTag foodList = new ListTag(); @@ -178,8 +179,8 @@ public void writeToPacketNBT(CompoundTag cmp) { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); cooldown = cmp.getInt(TAG_COOLDOWN); digestingMana = cmp.getInt(TAG_DIGESTING_MANA); lastFoods.clear(); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/HydroangeasBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/HydroangeasBlockEntity.java index 53c245de15..55a0d7e70a 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/HydroangeasBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/HydroangeasBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.generating; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -75,14 +76,14 @@ public int getColor() { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); passiveDecayTicks = cmp.getInt(TAG_PASSIVE_DECAY_TICKS); } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java index 4dd792188c..588c745d98 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/MunchdewBlockEntity.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.tags.BlockTags; import net.minecraft.world.level.block.Block; @@ -117,16 +118,16 @@ public RadiusDescriptor getRadius() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_COOLDOWN, cooldown); cmp.putBoolean(TAG_ATE_ONCE, ateOnce); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); cooldown = cmp.getInt(TAG_COOLDOWN); ateOnce = cmp.getBoolean(TAG_ATE_ONCE); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RafflowsiaBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RafflowsiaBlockEntity.java index 472264e6b1..cbba5f0480 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RafflowsiaBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/RafflowsiaBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.generating; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.*; import net.minecraft.resources.ResourceLocation; @@ -107,8 +108,8 @@ public void tickFlower() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); ListTag flowerList = new ListTag(); for (ResourceLocation flower : lastFlowers) { @@ -120,8 +121,8 @@ public void writeToPacketNBT(CompoundTag cmp) { } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); lastFlowers.clear(); ListTag flowerList = cmp.getList(TAG_LAST_FLOWERS, Tag.TAG_STRING); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/SpectrolusBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/SpectrolusBlockEntity.java index 03133c31ca..126fdf32c8 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/SpectrolusBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/SpectrolusBlockEntity.java @@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.particles.ItemParticleOption; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; @@ -142,14 +143,14 @@ public void renderHUD(GuiGraphics gui, Minecraft mc) { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_NEXT_COLOR, nextColor.ordinal()); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); nextColor = DyeColor.byId(cmp.getInt(TAG_NEXT_COLOR)); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java index d6ab4d86a2..f15ad1c30d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/generating/ThermalilyBlockEntity.java @@ -9,6 +9,7 @@ package vazkii.botania.common.block.flower.generating; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.sounds.SoundSource; import net.minecraft.tags.FluidTags; @@ -84,15 +85,15 @@ public int getMaxMana() { } @Override - public void writeToPacketNBT(CompoundTag cmp) { - super.writeToPacketNBT(cmp); + public void writeToPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.writeToPacketNBT(cmp, registries); cmp.putInt(TAG_COOLDOWN_MAGNITUDE, cooldownStrength); } @Override - public void readFromPacketNBT(CompoundTag cmp) { - super.readFromPacketNBT(cmp); + public void readFromPacketNBT(CompoundTag cmp, HolderLookup.Provider registries) { + super.readFromPacketNBT(cmp, registries); cooldownStrength = cmp.getInt(TAG_COOLDOWN_MAGNITUDE); } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/flower/package-info.java b/Xplat/src/main/java/vazkii/botania/common/block/flower/package-info.java new file mode 100644 index 0000000000..9a2088bb8e --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/block/flower/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.block.flower; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/BellowsBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/BellowsBlock.java index c66154f976..ed2b2dcae1 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/BellowsBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/BellowsBlock.java @@ -10,7 +10,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; @@ -75,7 +74,7 @@ public BlockState rotate(@NotNull BlockState state, Rotation rot) { } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { + public InteractionResult useWithoutItem(BlockState state, Level world, BlockPos pos, Player player, BlockHitResult hit) { if (PlayerHelper.isTruePlayer(player)) { ((BellowsBlockEntity) world.getBlockEntity(pos)).interact(); return InteractionResult.sidedSuccess(world.isClientSide()); diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/BotanicalBreweryBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/BotanicalBreweryBlock.java index bd65b2a6ae..af496d6725 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/BotanicalBreweryBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/BotanicalBreweryBlock.java @@ -12,6 +12,7 @@ import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; @@ -60,23 +61,23 @@ public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, Co } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - BreweryBlockEntity brew = (BreweryBlockEntity) world.getBlockEntity(pos); - - ItemStack stack = player.getItemInHand(hand); - if (stack.isEmpty()) { - if (!state.getValue(BlockStateProperties.POWERED)) { - InventoryHelper.withdrawFromInventory(brew, player); - return InteractionResult.sidedSuccess(world.isClientSide()); - } - } else { - return brew.addItem(player, stack, hand) - ? InteractionResult.sidedSuccess(world.isClientSide()) - : InteractionResult.PASS; + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { + if (!state.getValue(BlockStateProperties.POWERED)) { + BreweryBlockEntity brew = (BreweryBlockEntity) level.getBlockEntity(pos); + InventoryHelper.withdrawFromInventory(brew, player); + return InteractionResult.sidedSuccess(level.isClientSide()); } return InteractionResult.PASS; } + @Override + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + BreweryBlockEntity brew = (BreweryBlockEntity) level.getBlockEntity(pos); + return brew.addItem(player, stack, hand) + ? ItemInteractionResult.sidedSuccess(level.isClientSide()) + : ItemInteractionResult.SKIP_DEFAULT_BLOCK_INTERACTION; + } + @Override public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { if (!state.is(newState.getBlock())) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPoolBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPoolBlock.java index 41cf00986e..f7386c562b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPoolBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPoolBlock.java @@ -12,7 +12,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -136,11 +136,10 @@ public VoxelShape getInteractionShape(BlockState state, BlockGetter level, Block }; } - @NotNull @Override - public InteractionResult use(@NotNull BlockState state, Level world, @NotNull BlockPos pos, Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) { - BlockEntity be = world.getBlockEntity(pos); - ItemStack stack = player.getItemInHand(hand); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, + Player player, InteractionHand hand, BlockHitResult hitResult) { + BlockEntity be = level.getBlockEntity(pos); Optional itemColor = Optional.empty(); if (stack.getItem() instanceof MysticalPetalItem petalItem) { itemColor = Optional.of(petalItem.color); @@ -154,7 +153,7 @@ public InteractionResult use(@NotNull BlockState state, Level world, @NotNull Bl if (!player.getAbilities().instabuild) { stack.shrink(1); } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } } if (stack.is(Items.CLAY_BALL) && be instanceof ManaPoolBlockEntity pool && pool.getColor().isPresent()) { @@ -162,9 +161,9 @@ public InteractionResult use(@NotNull BlockState state, Level world, @NotNull Bl if (!player.getAbilities().instabuild) { stack.shrink(1); } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } - return super.use(state, world, pos, player, hand, hit); + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } @NotNull diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java index 11edc501da..c3fa99da4b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaPrismBlock.java @@ -106,7 +106,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player ItemStack lens = prism.getItemHandler().getItem(0); ItemStack heldItem = player.getItemInHand(hand); boolean playerHasLens = !heldItem.isEmpty() && heldItem.getItem() instanceof BasicLensItem; - boolean lensIsSame = playerHasLens && ItemStack.isSameItemSameTags(heldItem, lens); + boolean lensIsSame = playerHasLens && ItemStack.isSameItemSameComponents(heldItem, lens); boolean mainHandEmpty = player.getMainHandItem().isEmpty(); if (playerHasLens && !lensIsSame) { diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaSpreaderBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaSpreaderBlock.java index 0290392bc4..41af2711d2 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaSpreaderBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/ManaSpreaderBlock.java @@ -157,12 +157,12 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player ItemStack lens = spreader.getItemHandler().getItem(0); boolean playerHasLens = heldItem.getItem() instanceof BasicLensItem; - boolean lensIsSame = playerHasLens && ItemStack.isSameItemSameTags(heldItem, lens); + boolean lensIsSame = playerHasLens && ItemStack.isSameItemSameComponents(heldItem, lens); ItemStack wool = spreader.paddingColor != null ? new ItemStack(ColorHelper.WOOL_MAP.apply(spreader.paddingColor)) : ItemStack.EMPTY; boolean playerHasWool = ColorHelper.isWool(Block.byItem(heldItem.getItem())); - boolean woolIsSame = playerHasWool && ItemStack.isSameItemSameTags(heldItem, wool); + boolean woolIsSame = playerHasWool && ItemStack.isSameItemSameComponents(heldItem, wool); boolean playerHasScaffolding = !heldItem.isEmpty() && heldItem.is(Items.SCAFFOLDING); boolean shouldInsert = (playerHasLens && !lensIsSame) || (playerHasWool && !woolIsSame) diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/TerrestrialAgglomerationPlateBlock.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/TerrestrialAgglomerationPlateBlock.java index 7a15382c22..e85cffcd61 100644 --- a/Xplat/src/main/java/vazkii/botania/common/block/mana/TerrestrialAgglomerationPlateBlock.java +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/TerrestrialAgglomerationPlateBlock.java @@ -10,12 +10,12 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; -import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.EntityBlock; @@ -32,6 +32,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import vazkii.botania.api.recipe.TerrestrialAgglomerationRecipe; import vazkii.botania.common.block.BotaniaWaterloggedBlock; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; import vazkii.botania.common.block.block_entity.TerrestrialAgglomerationPlateBlockEntity; @@ -53,26 +54,26 @@ public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, Co } @Override - public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { - ItemStack stack = player.getItemInHand(hand); - if (!stack.isEmpty() && usesItem(stack, world)) { - if (!world.isClientSide) { + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, + Player player, InteractionHand hand, BlockHitResult hitResult) { + if (usesItem(stack, level)) { + if (!level.isClientSide) { ItemStack target = stack.split(1); - ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, target); + ItemEntity item = new ItemEntity(level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, target); item.setPickUpDelay(40); item.setDeltaMovement(Vec3.ZERO); - world.addFreshEntity(item); + level.addFreshEntity(item); } - return InteractionResult.sidedSuccess(world.isClientSide()); + return ItemInteractionResult.sidedSuccess(level.isClientSide()); } - return InteractionResult.PASS; + return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION; } private static boolean usesItem(ItemStack stack, Level world) { - for (Recipe value : ((RecipeManagerAccessor) world.getRecipeManager()).botania_getAll(BotaniaRecipeTypes.TERRA_PLATE_TYPE).values()) { - for (Ingredient i : value.getIngredients()) { + for (RecipeHolder value : ((RecipeManagerAccessor) world.getRecipeManager()).botania_getAll(BotaniaRecipeTypes.TERRA_PLATE_TYPE)) { + for (Ingredient i : value.value().getIngredients()) { if (i.test(stack)) { return true; } @@ -82,7 +83,7 @@ private static boolean usesItem(ItemStack stack, Level world) { } @Override - public boolean isPathfindable(@NotNull BlockState state, @NotNull BlockGetter world, @NotNull BlockPos pos, PathComputationType type) { + protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { return false; } diff --git a/Xplat/src/main/java/vazkii/botania/common/block/mana/package-info.java b/Xplat/src/main/java/vazkii/botania/common/block/mana/package-info.java new file mode 100644 index 0000000000..b2553e470f --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/block/mana/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.block.mana; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/block/package-info.java b/Xplat/src/main/java/vazkii/botania/common/block/package-info.java new file mode 100644 index 0000000000..ad0eaed479 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/block/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.block; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/brew/effect/AbsolutionMobEffect.java b/Xplat/src/main/java/vazkii/botania/common/brew/effect/AbsolutionMobEffect.java index 8c88c96879..cbfd981104 100644 --- a/Xplat/src/main/java/vazkii/botania/common/brew/effect/AbsolutionMobEffect.java +++ b/Xplat/src/main/java/vazkii/botania/common/brew/effect/AbsolutionMobEffect.java @@ -27,10 +27,11 @@ public void applyInstantenousEffect(Entity e, Entity e1, @NotNull LivingEntity e } @Override - public void applyEffectTick(LivingEntity livingEntity, int t) { + public boolean applyEffectTick(LivingEntity livingEntity, int t) { // SuspiciousStewItem does not support instant effects, so need to implement removal here. // This exits the loop over all potions effects with a ConcurrentModificationException, but It's Fine(tm), // since that loop is specifically guarded against that case. livingEntity.removeAllEffects(); + return true; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/brew/effect/AllureMobEffect.java b/Xplat/src/main/java/vazkii/botania/common/brew/effect/AllureMobEffect.java index b543f5110d..55ab928e20 100644 --- a/Xplat/src/main/java/vazkii/botania/common/brew/effect/AllureMobEffect.java +++ b/Xplat/src/main/java/vazkii/botania/common/brew/effect/AllureMobEffect.java @@ -28,13 +28,14 @@ public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) { } @Override - public void applyEffectTick(@NotNull LivingEntity living, int amplified) { + public boolean applyEffectTick(@NotNull LivingEntity living, int amplified) { if (living instanceof Player player) { FishingHook hook = player.fishing; if (hook != null) { hook.tick(); } } + return true; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/brew/effect/FeatherfeetMobEffect.java b/Xplat/src/main/java/vazkii/botania/common/brew/effect/FeatherfeetMobEffect.java index 5279eea824..c1521d9280 100644 --- a/Xplat/src/main/java/vazkii/botania/common/brew/effect/FeatherfeetMobEffect.java +++ b/Xplat/src/main/java/vazkii/botania/common/brew/effect/FeatherfeetMobEffect.java @@ -26,10 +26,11 @@ public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) { } @Override - public void applyEffectTick(@NotNull LivingEntity living, int amplified) { + public boolean applyEffectTick(@NotNull LivingEntity living, int amplified) { if (living.fallDistance > 2.5F) { living.fallDistance = 2.5F; } + return true; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/component/AdvancedTooltipProvider.java b/Xplat/src/main/java/vazkii/botania/common/component/AdvancedTooltipProvider.java index a69a8b9841..a3faf5823f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/component/AdvancedTooltipProvider.java +++ b/Xplat/src/main/java/vazkii/botania/common/component/AdvancedTooltipProvider.java @@ -12,6 +12,5 @@ void addToTooltip( Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag tooltipFlag, - List fullTooltip - ); + List fullTooltip); } diff --git a/Xplat/src/main/java/vazkii/botania/common/component/TooltipVisibility.java b/Xplat/src/main/java/vazkii/botania/common/component/TooltipVisibility.java index ffcf82afba..641fcd2233 100644 --- a/Xplat/src/main/java/vazkii/botania/common/component/TooltipVisibility.java +++ b/Xplat/src/main/java/vazkii/botania/common/component/TooltipVisibility.java @@ -1,15 +1,18 @@ package vazkii.botania.common.component; import com.mojang.serialization.Codec; -import io.netty.buffer.ByteBuf; + import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.util.ByIdMap; import net.minecraft.util.StringRepresentable; + import org.jetbrains.annotations.NotNull; import java.util.function.IntFunction; +import io.netty.buffer.ByteBuf; + public enum TooltipVisibility implements StringRepresentable { HIDDEN(0, "hidden"), IN_NAME(1, "in_name"), diff --git a/Xplat/src/main/java/vazkii/botania/common/component/WandOfTheForestComponent.java b/Xplat/src/main/java/vazkii/botania/common/component/WandOfTheForestComponent.java index f1dd352702..9e11ca2791 100644 --- a/Xplat/src/main/java/vazkii/botania/common/component/WandOfTheForestComponent.java +++ b/Xplat/src/main/java/vazkii/botania/common/component/WandOfTheForestComponent.java @@ -2,10 +2,9 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import io.netty.buffer.ByteBuf; + import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ComponentUtils; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; import net.minecraft.network.codec.ByteBufCodecs; @@ -14,23 +13,25 @@ import net.minecraft.util.StringRepresentable; import net.minecraft.world.item.Item; import net.minecraft.world.item.TooltipFlag; + import org.jetbrains.annotations.NotNull; import java.util.List; import java.util.function.Consumer; import java.util.function.IntFunction; +import io.netty.buffer.ByteBuf; + public record WandOfTheForestComponent(WandMode wandMode, TooltipVisibility tooltipVisibility) implements AdvancedTooltipProvider { - public static Codec CODEC = RecordCodecBuilder.create(instance -> - instance.group( - WandMode.CODEC.optionalFieldOf("mode", WandMode.BIND).forGetter(WandOfTheForestComponent::wandMode), - TooltipVisibility.CODEC.optionalFieldOf("tooltip_visibility", TooltipVisibility.IN_NAME).forGetter(WandOfTheForestComponent::tooltipVisibility) - ).apply(instance, WandOfTheForestComponent::new) + public static Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + WandMode.CODEC.optionalFieldOf("mode", WandMode.BIND).forGetter(WandOfTheForestComponent::wandMode), + TooltipVisibility.CODEC.optionalFieldOf("tooltip_visibility", TooltipVisibility.IN_NAME).forGetter(WandOfTheForestComponent::tooltipVisibility) + ).apply(instance, WandOfTheForestComponent::new) ); public static StreamCodec STREAM_CODEC = StreamCodec.composite( - WandMode.STREAM_CODEC, WandOfTheForestComponent::wandMode, - TooltipVisibility.STREAM_CODEC, WandOfTheForestComponent::tooltipVisibility, - WandOfTheForestComponent::new + WandMode.STREAM_CODEC, WandOfTheForestComponent::wandMode, + TooltipVisibility.STREAM_CODEC, WandOfTheForestComponent::tooltipVisibility, + WandOfTheForestComponent::new ); @Override diff --git a/Xplat/src/main/java/vazkii/botania/common/config/ConfigDataManagerImpl.java b/Xplat/src/main/java/vazkii/botania/common/config/ConfigDataManagerImpl.java index 7b27cd046b..512b42db57 100644 --- a/Xplat/src/main/java/vazkii/botania/common/config/ConfigDataManagerImpl.java +++ b/Xplat/src/main/java/vazkii/botania/common/config/ConfigDataManagerImpl.java @@ -113,7 +113,7 @@ private CompletableFuture scheduleConfigParse(PreparationBarrier barri .thenAcceptAsync(c -> type.applyFunction.accept(this, c), gameExecutor); } - private record ConfigDataType (Codec codec, String directory, + private record ConfigDataType(Codec codec, String directory, Consumer> validateFunction, BiConsumer> applyFunction) { private static final ConfigDataType LOONUIM = diff --git a/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidRecipe.java b/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidRecipe.java index 92fa814170..07d75a03ab 100644 --- a/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/common/crafting/OrechidRecipe.java @@ -136,8 +136,7 @@ public static class Serializer implements RecipeSerializer { ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC.map( id -> TagKey.create(Registries.BIOME, id), TagKey::location )), OrechidRecipe::getBiomes, - (in, out, weight, weightBonus, biomes) -> - new OrechidRecipe(in, out, weight, null, weightBonus, biomes.orElse(null)) + (in, out, weight, weightBonus, biomes) -> new OrechidRecipe(in, out, weight, null, weightBonus, biomes.orElse(null)) ); @Override diff --git a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java index 74af32d08b..8315edfcf9 100644 --- a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/ArmorUpgradeRecipe.java @@ -60,7 +60,6 @@ private static class Serializer implements WrappingRecipeSerializer STREAM_CODEC = SHAPED_RECIPE.streamCodec() .map(ArmorUpgradeRecipe::new, Function.identity()); - @Override public ArmorUpgradeRecipe wrap(Recipe recipe) { if (!(recipe instanceof ShapedRecipe shapedRecipe)) { diff --git a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/GogAlternationRecipe.java b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/GogAlternationRecipe.java index c46da11ca8..84f3aca540 100644 --- a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/GogAlternationRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/GogAlternationRecipe.java @@ -8,6 +8,7 @@ */ package vazkii.botania.common.crafting.recipe; +import com.google.common.base.Suppliers; import com.mojang.serialization.DataResult; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -22,7 +23,6 @@ import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; -import com.google.common.base.Suppliers; import vazkii.botania.xplat.XplatAbstractions; import java.util.function.Supplier; @@ -84,15 +84,15 @@ public RecipeType getType() { private static class Serializer implements RecipeSerializer> { private static final MapCodec> RAW_CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group( - Recipe.CODEC.fieldOf("base").forGetter(GogAlternationRecipe::getBaseRecipe), - Recipe.CODEC.fieldOf("gog").forGetter(GogAlternationRecipe::getGogRecipe) - ).apply(instance, GogAlternationRecipe::new)); + Recipe.CODEC.fieldOf("base").forGetter(GogAlternationRecipe::getBaseRecipe), + Recipe.CODEC.fieldOf("gog").forGetter(GogAlternationRecipe::getGogRecipe) + ).apply(instance, GogAlternationRecipe::new)); public static final MapCodec> CODEC = RAW_CODEC.validate(recipe -> { - if (recipe.getBaseRecipe().getType() != recipe.getGogRecipe().getType()) { - return DataResult.error(() -> "Subrecipes must have matching types"); - } - return DataResult.success(recipe); - }); + if (recipe.getBaseRecipe().getType() != recipe.getGogRecipe().getType()) { + return DataResult.error(() -> "Subrecipes must have matching types"); + } + return DataResult.success(recipe); + }); public static final StreamCodec> STREAM_CODEC = StreamCodec.composite( Recipe.STREAM_CODEC, GogAlternationRecipe::getBaseRecipe, Recipe.STREAM_CODEC, GogAlternationRecipe::getGogRecipe, diff --git a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java index 2393bf3981..49e16bb1e0 100644 --- a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/LensDyeingRecipe.java @@ -8,6 +8,8 @@ */ package vazkii.botania.common.crafting.recipe; +import com.google.common.base.Suppliers; + import net.minecraft.core.HolderLookup; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -21,7 +23,6 @@ import org.jetbrains.annotations.NotNull; -import com.google.common.base.Suppliers; import vazkii.botania.api.mana.BasicLensItem; import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.common.item.lens.LensItem; diff --git a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/WaterBottleMatchingRecipe.java b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/WaterBottleMatchingRecipe.java index 30152d754d..98c17dc65d 100644 --- a/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/WaterBottleMatchingRecipe.java +++ b/Xplat/src/main/java/vazkii/botania/common/crafting/recipe/WaterBottleMatchingRecipe.java @@ -77,7 +77,6 @@ private static class Serializer implements WrappingRecipeSerializer STREAM_CODEC = SHAPED_RECIPE.streamCodec() .map(WaterBottleMatchingRecipe::new, Function.identity()); - @Override public WaterBottleMatchingRecipe wrap(Recipe recipe) { if (!(recipe instanceof ShapedRecipe shapedRecipe)) { diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/FallingStarEntity.java b/Xplat/src/main/java/vazkii/botania/common/entity/FallingStarEntity.java index 6a14e18e74..36c4814908 100644 --- a/Xplat/src/main/java/vazkii/botania/common/entity/FallingStarEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/entity/FallingStarEntity.java @@ -55,7 +55,7 @@ public void tick() { super.tick(); if (!hasBeenInAir && !level().isClientSide) { - var bs = getFeetBlockState(); + var bs = getBlockStateOn(); hasBeenInAir = bs.isAir() || isInWater() || isInLava(); } diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/GaiaGuardianEntity.java b/Xplat/src/main/java/vazkii/botania/common/entity/GaiaGuardianEntity.java index f5457ddee0..f256a86287 100644 --- a/Xplat/src/main/java/vazkii/botania/common/entity/GaiaGuardianEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/entity/GaiaGuardianEntity.java @@ -94,8 +94,8 @@ import java.util.*; import java.util.function.Supplier; -import static vazkii.botania.common.helper.PlayerHelper.isTruePlayer; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import static vazkii.botania.common.helper.PlayerHelper.isTruePlayer; public class GaiaGuardianEntity extends Mob { public static final float ARENA_RANGE = 12F; diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/ManaBurstEntity.java b/Xplat/src/main/java/vazkii/botania/common/entity/ManaBurstEntity.java index 566fad6209..09aec56ba9 100644 --- a/Xplat/src/main/java/vazkii/botania/common/entity/ManaBurstEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/entity/ManaBurstEntity.java @@ -90,13 +90,16 @@ public class ManaBurstEntity extends ThrowableProjectile implements ManaBurst { private boolean fake = false; private final Set alreadyCollidedAt = new HashSet<>(); private boolean fullManaLastTick = true; + @Nullable private UUID shooterIdentity = null; private int _ticksExisted = 0; private boolean scanBeam = false; + @Nullable private BlockPos lastCollision; private boolean warped = false; private int orbitTime = 0; private boolean tripped = false; + @Nullable private BlockPos magnetizePos = null; public final List propsList = new ArrayList<>(); @@ -196,7 +199,7 @@ public void tick() { if (propsList.isEmpty()) { propsList.add(props); } else { - PositionProperties lastProps = propsList.get(propsList.size() - 1); + PositionProperties lastProps = propsList.getLast(); if (!props.coordsEqual(lastProps)) { propsList.add(props); } @@ -214,9 +217,11 @@ public boolean isInLava() { return false; } + @Nullable private ManaReceiver collidedTile = null; private boolean noParticles = false; + @Nullable public ManaReceiver getCollidedTile(boolean noParticles) { this.noParticles = noParticles; @@ -255,9 +260,9 @@ public void addAdditionalSaveData(CompoundTag tag) { tag.putFloat(TAG_GRAVITY, getBurstGravity()); ItemStack stack = getSourceLens(); - CompoundTag lensCmp = new CompoundTag(); + Tag lensCmp = new CompoundTag(); if (!stack.isEmpty()) { - lensCmp = stack.save(lensCmp); + lensCmp = stack.save(level().registryAccess()); } tag.put(TAG_LENS_STACK, lensCmp); @@ -282,13 +287,13 @@ public void addAdditionalSaveData(CompoundTag tag) { tag.putInt(TAG_ORBIT_TIME, orbitTime); tag.putBoolean(TAG_TRIPPED, tripped); if (magnetizePos != null) { - tag.put(TAG_MAGNETIZE_POS, BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, magnetizePos).get().orThrow()); + tag.put(TAG_MAGNETIZE_POS, BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, magnetizePos).getOrThrow()); } tag.putBoolean(TAG_LEFT_SOURCE, hasLeftSource()); var alreadyCollidedAt = new ListTag(); for (BlockPos pos : this.alreadyCollidedAt) { - alreadyCollidedAt.add(BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, pos).get().orThrow()); + alreadyCollidedAt.add(BlockPos.CODEC.encodeStart(NbtOps.INSTANCE, pos).getOrThrow()); } tag.put(TAG_ALREADY_COLLIDED_AT, alreadyCollidedAt); } @@ -305,7 +310,7 @@ public void readAdditionalSaveData(CompoundTag cmp) { setGravity(cmp.getFloat(TAG_GRAVITY)); CompoundTag lensCmp = cmp.getCompound(TAG_LENS_STACK); - ItemStack stack = ItemStack.of(lensCmp); + ItemStack stack = ItemStack.parse(level().registryAccess(), lensCmp).orElse(ItemStack.EMPTY); if (!stack.isEmpty()) { setSourceLens(stack); } else { @@ -341,7 +346,7 @@ public void readAdditionalSaveData(CompoundTag cmp) { orbitTime = cmp.getInt(TAG_ORBIT_TIME); tripped = cmp.getBoolean(TAG_TRIPPED); if (cmp.contains(TAG_MAGNETIZE_POS)) { - magnetizePos = BlockPos.CODEC.parse(NbtOps.INSTANCE, cmp.get(TAG_MAGNETIZE_POS)).get().orThrow(); + magnetizePos = BlockPos.CODEC.parse(NbtOps.INSTANCE, cmp.get(TAG_MAGNETIZE_POS)).getOrThrow(); } else { magnetizePos = null; } @@ -717,6 +722,7 @@ public void setTicksExisted(int ticks) { _ticksExisted = ticks; } + @Nullable private LensEffectItem getLensInstance() { ItemStack lens = getSourceLens(); if (!lens.isEmpty() && lens.getItem() instanceof LensEffectItem effect) { @@ -744,6 +750,7 @@ public void setShooterUUID(UUID uuid) { } @Override + @Nullable public UUID getShooterUUID() { return shooterIdentity; } @@ -827,7 +834,7 @@ private void setDeathTicksForFakeParticle() { public record PositionProperties(BlockPos coords, BlockState state) { public static PositionProperties fromEntity(Entity entity) { - return new PositionProperties(entity.blockPosition(), entity.getFeetBlockState()); + return new PositionProperties(entity.blockPosition(), entity.getBlockStateOn()); } public boolean coordsEqual(PositionProperties props) { diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/ManaPoolMinecartEntity.java b/Xplat/src/main/java/vazkii/botania/common/entity/ManaPoolMinecartEntity.java index 50779b7eee..fbfa06c0cf 100644 --- a/Xplat/src/main/java/vazkii/botania/common/entity/ManaPoolMinecartEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/entity/ManaPoolMinecartEntity.java @@ -181,7 +181,7 @@ protected void readAdditionalSaveData(CompoundTag cmp) { } @Override - public Item getDropItem() { + protected Item getDropItem() { return BotaniaItems.poolMinecart; } diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/ThornChakramEntity.java b/Xplat/src/main/java/vazkii/botania/common/entity/ThornChakramEntity.java index 26d2aec914..4904572f2e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/entity/ThornChakramEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/entity/ThornChakramEntity.java @@ -180,7 +180,7 @@ protected void onHitEntity(@NotNull EntityHitResult hit) { } @Override - protected float getGravity() { + protected double getDefaultGravity() { return 0F; } @@ -216,7 +216,7 @@ private void setEntityToReturnTo(int entityID) { public void addAdditionalSaveData(CompoundTag compound) { super.addAdditionalSaveData(compound); if (!stack.isEmpty()) { - compound.put("fly_stack", stack.save(new CompoundTag())); + compound.put("fly_stack", stack.save(level().registryAccess())); } compound.putBoolean("flare", isFire()); } @@ -225,7 +225,7 @@ public void addAdditionalSaveData(CompoundTag compound) { public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); if (compound.contains("fly_stack")) { - stack = ItemStack.of(compound.getCompound("fly_stack")); + stack = ItemStack.parse(level().registryAccess(), compound.getCompound("fly_stack")).orElse(ItemStack.EMPTY); } setFire(compound.getBoolean("flare")); } diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/ThrowableCopyEntity.java b/Xplat/src/main/java/vazkii/botania/common/entity/ThrowableCopyEntity.java index 780e108227..5f73a5f0cb 100644 --- a/Xplat/src/main/java/vazkii/botania/common/entity/ThrowableCopyEntity.java +++ b/Xplat/src/main/java/vazkii/botania/common/entity/ThrowableCopyEntity.java @@ -102,7 +102,7 @@ public void tick() { this.setPos(d, e, f); } - protected float getGravity() { - return 0.03F; + protected double getDefaultGravity() { + return 0.03; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/entity/package-info.java b/Xplat/src/main/java/vazkii/botania/common/entity/package-info.java new file mode 100644 index 0000000000..34581b3dcb --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/entity/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.entity; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/handler/ExoflameFurnaceHandler.java b/Xplat/src/main/java/vazkii/botania/common/handler/ExoflameFurnaceHandler.java index 346d020cc2..3560d43aed 100644 --- a/Xplat/src/main/java/vazkii/botania/common/handler/ExoflameFurnaceHandler.java +++ b/Xplat/src/main/java/vazkii/botania/common/handler/ExoflameFurnaceHandler.java @@ -9,7 +9,9 @@ package vazkii.botania.common.handler; import net.minecraft.core.BlockPos; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -26,12 +28,13 @@ public static boolean canSmeltRecipe(AbstractFurnaceBlockEntity furnace, RecipeH } public static boolean canSmelt(AbstractFurnaceBlockEntity furnace) { - if (furnace.getItem(0).isEmpty()) { + ItemStack furnaceItem = furnace.getItem(0); + if (furnaceItem.isEmpty()) { return false; } try { var qc = ((AbstractFurnaceBlockEntityAccessor) furnace).getQuickCheck(); - var currentRecipe = qc.getRecipeFor(furnace, furnace.getLevel()); + var currentRecipe = qc.getRecipeFor(new SingleRecipeInput(furnaceItem), furnace.getLevel()); return currentRecipe.isPresent() && ExoflameFurnaceHandler.canSmeltRecipe(furnace, currentRecipe.get()); } catch (Throwable t) { BotaniaAPI.LOGGER.error("Failed to determine if furnace TE can smelt", t); diff --git a/Xplat/src/main/java/vazkii/botania/common/helper/ColorHelper.java b/Xplat/src/main/java/vazkii/botania/common/helper/ColorHelper.java index 786861ec86..62f90a9e0f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/helper/ColorHelper.java +++ b/Xplat/src/main/java/vazkii/botania/common/helper/ColorHelper.java @@ -45,11 +45,8 @@ public static boolean isWool(Block b) { } public static int getColorValue(DyeColor color) { - float[] colors = color.getTextureDiffuseColors(); - int r = (int) (colors[0] * 255.0F); - int g = (int) (colors[1] * 255.0F); - int b = (int) (colors[2] * 255.0F); - return (r << 16) | (g << 8) | b; + // TODO: verify usage, previous implementation assumed A=0 + return color.getTextureDiffuseColor() & 0xffffff; } public static int getColorLegibleOnGrayBackground(DyeColor color) { diff --git a/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java b/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java index ac8209bacc..f0bd4f790b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java +++ b/Xplat/src/main/java/vazkii/botania/common/helper/InventoryHelper.java @@ -167,7 +167,7 @@ public static boolean tryToSetLastRecipe(Player player, Container inv, @Nullable for (int i = 0; i < player.getInventory().getContainerSize(); i++) { ItemStack pstack = player.getInventory().getItem(i); - if (player.isCreative() || (!pstack.isEmpty() && ItemStack.isSameItemSameTags(stack, pstack))) { + if (player.isCreative() || (!pstack.isEmpty() && ItemStack.isSameItemSameComponents(stack, pstack))) { inv.setItem(index, player.isCreative() ? stack.copy() : pstack.split(1)); didAny = true; index++; diff --git a/Xplat/src/main/java/vazkii/botania/common/helper/ItemNBTHelper.java b/Xplat/src/main/java/vazkii/botania/common/helper/ItemNBTHelper.java index 9687eba939..e85a57d653 100644 --- a/Xplat/src/main/java/vazkii/botania/common/helper/ItemNBTHelper.java +++ b/Xplat/src/main/java/vazkii/botania/common/helper/ItemNBTHelper.java @@ -206,7 +206,7 @@ public static boolean matchTagAndManaFullness(ItemStack stack1, ItemStack stack2 return ItemStack.matches(duplicateAndClearMana(stack1), duplicateAndClearMana(stack2)); } } - return ItemStack.isSameItemSameTags(stack1, stack2); + return ItemStack.isSameItemSameComponents(stack1, stack2); } /** diff --git a/Xplat/src/main/java/vazkii/botania/common/impl/mana/ManaItemHandlerImpl.java b/Xplat/src/main/java/vazkii/botania/common/impl/mana/ManaItemHandlerImpl.java index b23efce123..6541c3f1c6 100644 --- a/Xplat/src/main/java/vazkii/botania/common/impl/mana/ManaItemHandlerImpl.java +++ b/Xplat/src/main/java/vazkii/botania/common/impl/mana/ManaItemHandlerImpl.java @@ -286,7 +286,7 @@ public boolean hasProficiency(Player player, ItemStack manaItem) { boolean proficient = false; for (EquipmentSlot e : EquipmentSlot.values()) { - if (e.getType() != EquipmentSlot.Type.ARMOR) { + if (e.getType() != EquipmentSlot.Type.HUMANOID_ARMOR) { continue; } ItemStack stack = player.getItemBySlot(e); diff --git a/Xplat/src/main/java/vazkii/botania/common/internal_caps/SerializableComponent.java b/Xplat/src/main/java/vazkii/botania/common/internal_caps/SerializableComponent.java index 26e64a3d74..fdf6849825 100644 --- a/Xplat/src/main/java/vazkii/botania/common/internal_caps/SerializableComponent.java +++ b/Xplat/src/main/java/vazkii/botania/common/internal_caps/SerializableComponent.java @@ -3,6 +3,7 @@ import net.minecraft.nbt.CompoundTag; import org.jetbrains.annotations.NotNull; + import vazkii.botania.common.annotations.SoftImplement; public abstract class SerializableComponent { diff --git a/Xplat/src/main/java/vazkii/botania/common/internal_caps/SpectralRailComponent.java b/Xplat/src/main/java/vazkii/botania/common/internal_caps/SpectralRailComponent.java index e548eab3c8..9e8414db24 100644 --- a/Xplat/src/main/java/vazkii/botania/common/internal_caps/SpectralRailComponent.java +++ b/Xplat/src/main/java/vazkii/botania/common/internal_caps/SpectralRailComponent.java @@ -9,8 +9,8 @@ package vazkii.botania.common.internal_caps; import net.minecraft.nbt.CompoundTag; - import net.minecraft.resources.ResourceLocation; + import vazkii.botania.common.block.SpectralRailBlock; import static vazkii.botania.api.BotaniaAPI.botaniaRL; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/AncientWillItem.java b/Xplat/src/main/java/vazkii/botania/common/item/AncientWillItem.java index 764c237195..1a271e2f3e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/AncientWillItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/AncientWillItem.java @@ -13,7 +13,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import vazkii.botania.api.item.AncientWillContainer; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/BaubleBoxItem.java b/Xplat/src/main/java/vazkii/botania/common/item/BaubleBoxItem.java index e5e246d7f9..f1e55e701e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/BaubleBoxItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/BaubleBoxItem.java @@ -78,7 +78,7 @@ public void onDestroyed(@NotNull ItemEntity entity) { var stream = IntStream.range(0, container.getContainerSize()) .mapToObj(container::getItem) .filter(s -> !s.isEmpty()); - ItemUtils.onContainerDestroyed(entity, stream); + ItemUtils.onContainerDestroyed(entity, stream::iterator); container.clearContent(); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/BlackLotusItem.java b/Xplat/src/main/java/vazkii/botania/common/item/BlackLotusItem.java index e5ab85ffc9..2104219be3 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/BlackLotusItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/BlackLotusItem.java @@ -15,7 +15,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import vazkii.botania.api.item.ManaDissolvable; import vazkii.botania.api.mana.ManaPool; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/BotaniaItems.java b/Xplat/src/main/java/vazkii/botania/common/item/BotaniaItems.java index 9f7d3dc100..1237140017 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/BotaniaItems.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/BotaniaItems.java @@ -28,7 +28,6 @@ import vazkii.botania.client.gui.box.BaubleBoxContainer; import vazkii.botania.common.block.BotaniaBlocks; import vazkii.botania.common.crafting.recipe.*; -import vazkii.botania.common.handler.BotaniaSounds; import vazkii.botania.common.item.brew.BaseBrewItem; import vazkii.botania.common.item.brew.IncenseStickItem; import vazkii.botania.common.item.brew.VialItem; @@ -203,7 +202,7 @@ public final class BotaniaItems { public static final Item manasteelAxe = make(botaniaRL(LibItemNames.MANASTEEL_AXE), new ManasteelAxeItem(unstackableCustomDamage())); public static final Item manasteelHoe = make(botaniaRL(LibItemNames.MANASTEEL_HOE), new ManasteelHoeItem(unstackableCustomDamage())); public static final Item manasteelSword = make(botaniaRL(LibItemNames.MANASTEEL_SWORD), new ManasteelSwordItem(unstackableCustomDamage())); - public static final Item manasteelShears = make(botaniaRL(LibItemNames.MANASTEEL_SHEARS), new ManasteelShearsItem(unstackableCustomDamage().defaultDurability(238))); + public static final Item manasteelShears = make(botaniaRL(LibItemNames.MANASTEEL_SHEARS), new ManasteelShearsItem(unstackableCustomDamage().durability(238))); public static final Item elementiumHelm = make(botaniaRL(LibItemNames.ELEMENTIUM_HELM), new ElementiumHelmItem(unstackableCustomDamage())); public static final Item elementiumChest = make(botaniaRL(LibItemNames.ELEMENTIUM_CHEST), new ElementiumChestItem(unstackableCustomDamage())); public static final Item elementiumLegs = make(botaniaRL(LibItemNames.ELEMENTIUM_LEGS), new ElementiumLegsItem(unstackableCustomDamage())); @@ -213,7 +212,7 @@ public final class BotaniaItems { public static final Item elementiumAxe = make(botaniaRL(LibItemNames.ELEMENTIUM_AXE), new ElementiumAxeItem(unstackableCustomDamage())); public static final Item elementiumHoe = make(botaniaRL(LibItemNames.ELEMENTIUM_HOE), new ElementiumHoeItem(unstackableCustomDamage())); public static final Item elementiumSword = make(botaniaRL(LibItemNames.ELEMENTIUM_SWORD), new ElementiumSwordItem(unstackableCustomDamage())); - public static final Item elementiumShears = make(botaniaRL(LibItemNames.ELEMENTIUM_SHEARS), new ElementiumShearsItem(unstackableCustomDamage().defaultDurability(238))); + public static final Item elementiumShears = make(botaniaRL(LibItemNames.ELEMENTIUM_SHEARS), new ElementiumShearsItem(unstackableCustomDamage().durability(238))); public static final Item terrasteelHelm = make(botaniaRL(LibItemNames.TERRASTEEL_HELM), new TerrasteelHelmItem(unstackableCustomDamage().fireResistant().rarity(Rarity.UNCOMMON))); public static final Item terrasteelChest = make(botaniaRL(LibItemNames.TERRASTEEL_CHEST), new TerrasteelArmorItem(ArmorItem.Type.CHESTPLATE, unstackableCustomDamage().fireResistant().rarity(Rarity.UNCOMMON))); public static final Item terrasteelLegs = make(botaniaRL(LibItemNames.TERRASTEEL_LEGS), new TerrasteelArmorItem(ArmorItem.Type.LEGGINGS, unstackableCustomDamage().fireResistant().rarity(Rarity.UNCOMMON))); @@ -227,10 +226,10 @@ public final class BotaniaItems { public static final Item manaweaveChest = make(botaniaRL(LibItemNames.MANAWEAVE_CHEST), new ManaweaveArmorItem(ArmorItem.Type.CHESTPLATE, unstackableCustomDamage())); public static final Item manaweaveLegs = make(botaniaRL(LibItemNames.MANAWEAVE_LEGS), new ManaweaveArmorItem(ArmorItem.Type.LEGGINGS, unstackableCustomDamage())); public static final Item manaweaveBoots = make(botaniaRL(LibItemNames.MANAWEAVE_BOOTS), new ManaweaveArmorItem(ArmorItem.Type.BOOTS, unstackableCustomDamage())); - public static final Item enderDagger = make(botaniaRL(LibItemNames.ENDER_DAGGER), new SoulscribeItem(unstackable().defaultDurability(69))); // What you looking at? + public static final Item enderDagger = make(botaniaRL(LibItemNames.ENDER_DAGGER), new SoulscribeItem(unstackable().durability(69))); // What you looking at? public static final Item glassPick = make(botaniaRL(LibItemNames.GLASS_PICK), new VitreousPickaxeItem(unstackableCustomDamage())); - public static final Item livingwoodBow = make(botaniaRL(LibItemNames.LIVINGWOOD_BOW), new LivingwoodBowItem(defaultBuilderCustomDamage().defaultDurability(500))); - public static final Item crystalBow = make(botaniaRL(LibItemNames.CRYSTAL_BOW), new CrystalBowItem(defaultBuilderCustomDamage().defaultDurability(500))); + public static final Item livingwoodBow = make(botaniaRL(LibItemNames.LIVINGWOOD_BOW), new LivingwoodBowItem(defaultBuilderCustomDamage().durability(500))); + public static final Item crystalBow = make(botaniaRL(LibItemNames.CRYSTAL_BOW), new CrystalBowItem(defaultBuilderCustomDamage().durability(500))); public static final Item thornChakram = make(botaniaRL(LibItemNames.THORN_CHAKRAM), new ThornChakramItem(defaultBuilder().stacksTo(6))); public static final Item flareChakram = make(botaniaRL(LibItemNames.FLARE_CHAKRAM), new ThornChakramItem(defaultBuilder().stacksTo(6))); @@ -249,7 +248,7 @@ public final class BotaniaItems { public static final Item enderHand = make(botaniaRL(LibItemNames.ENDER_HAND), new EnderHandItem(unstackable())); public static final Item craftingHalo = make(botaniaRL(LibItemNames.CRAFTING_HALO), new AssemblyHaloItem(unstackable())); public static final Item autocraftingHalo = make(botaniaRL(LibItemNames.AUTOCRAFTING_HALO), new ManufactoryHaloItem(unstackable())); - public static final Item spellCloth = make(botaniaRL(LibItemNames.SPELL_CLOTH), new SpellbindingClothItem(XplatAbstractions.INSTANCE.noRepairOnForge(unstackable().defaultDurability(35)))); + public static final Item spellCloth = make(botaniaRL(LibItemNames.SPELL_CLOTH), new SpellbindingClothItem(XplatAbstractions.INSTANCE.noRepairOnForge(unstackable().durability(35)))); public static final Item flowerBag = make(botaniaRL(LibItemNames.FLOWER_BAG), new FlowerPouchItem(unstackable())); public static final Item blackHoleTalisman = make(botaniaRL(LibItemNames.BLACK_HOLE_TALISMAN), new BlackHoleTalismanItem(unstackable())); public static final Item temperanceStone = make(botaniaRL(LibItemNames.TEMPERANCE_STONE), new StoneOfTemperanceItem(unstackable())); @@ -295,10 +294,10 @@ public final class BotaniaItems { public static final Item flightTiara = make(botaniaRL(LibItemNames.FLIGHT_TIARA), new FlugelTiaraItem(unstackable().rarity(Rarity.UNCOMMON))); // Misc - public static final Item manaCookie = make(botaniaRL(LibItemNames.MANA_COOKIE), new Item(defaultBuilder().food(new FoodProperties.Builder().nutrition(0).saturationMod(0.1F).effect(new MobEffectInstance(MobEffects.SATURATION, 20, 0), 1).build()))); + public static final Item manaCookie = make(botaniaRL(LibItemNames.MANA_COOKIE), new Item(defaultBuilder().food(new FoodProperties.Builder().nutrition(0).saturationModifier(0.1F).effect(new MobEffectInstance(MobEffects.SATURATION, 20, 0), 1).build()))); public static final Item manaBottle = make(botaniaRL(LibItemNames.MANA_BOTTLE), new BottledManaItem( // Mark as food just to fool foxes into using it - unstackable().food(new FoodProperties.Builder().alwaysEat().build()))); + unstackable().food(new FoodProperties.Builder().alwaysEdible().build()))); public static final Item laputaShard = make(botaniaRL(LibItemNames.LAPUTA_SHARD), new LaputaShardItem(unstackable().rarity(Rarity.UNCOMMON))); public static final Item necroVirus = make(botaniaRL(LibItemNames.NECRO_VIRUS), new EquestrianVirusItem(defaultBuilder())); public static final Item nullVirus = make(botaniaRL(LibItemNames.NULL_VIRUS), new EquestrianVirusItem(defaultBuilder())); diff --git a/Xplat/src/main/java/vazkii/botania/common/item/CorporeaSparkItem.java b/Xplat/src/main/java/vazkii/botania/common/item/CorporeaSparkItem.java index 3606fc95e3..25a79f2a65 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/CorporeaSparkItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/CorporeaSparkItem.java @@ -19,7 +19,6 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import vazkii.botania.api.corporea.CorporeaHelper; import vazkii.botania.common.entity.BotaniaEntities; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/FloralObedienceStickItem.java b/Xplat/src/main/java/vazkii/botania/common/item/FloralObedienceStickItem.java index ec4c9893fc..484c42daa2 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/FloralObedienceStickItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/FloralObedienceStickItem.java @@ -52,7 +52,7 @@ public static boolean applyStick(Level world, BlockPos pos) { } BlockEntity tile = world.getBlockEntity(iterPos); - if (tile instanceof BindableSpecialFlowerBlockEntitybindable && bindable.wouldBeValidBinding(pos)) { + if (tile instanceof BindableSpecialFlowerBlockEntity bindable && bindable.wouldBeValidBinding(pos)) { bindable.setBindingPos(pos); WandOfTheForestItem.doParticleBeamWithOffset(world, iterPos, pos); } @@ -61,7 +61,7 @@ public static boolean applyStick(Level world, BlockPos pos) { return true; } BlockEntity tile = world.getBlockEntity(pos); - if (tile instanceof BindableSpecialFlowerBlockEntitybindableFlower) { + if (tile instanceof BindableSpecialFlowerBlockEntity bindableFlower) { bindableFlower.setBindingPos(null); return true; } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/ManaTabletItem.java b/Xplat/src/main/java/vazkii/botania/common/item/ManaTabletItem.java index 6cc5a5e5fb..f143ee4dc6 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/ManaTabletItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/ManaTabletItem.java @@ -13,7 +13,6 @@ import net.minecraft.util.Mth; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.*; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import org.jetbrains.annotations.NotNull; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/block/SpecialFlowerBlockItem.java b/Xplat/src/main/java/vazkii/botania/common/item/block/SpecialFlowerBlockItem.java index 763f4f6a06..1852ce7c2f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/block/SpecialFlowerBlockItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/block/SpecialFlowerBlockItem.java @@ -18,7 +18,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import org.jetbrains.annotations.NotNull; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/brew/BaseBrewItem.java b/Xplat/src/main/java/vazkii/botania/common/item/brew/BaseBrewItem.java index a14f9bacd8..3f5c2d00b5 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/brew/BaseBrewItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/brew/BaseBrewItem.java @@ -19,7 +19,6 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; -import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/brew/IncenseStickItem.java b/Xplat/src/main/java/vazkii/botania/common/item/brew/IncenseStickItem.java index e6ebe9b1f8..4c39bdcb71 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/brew/IncenseStickItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/brew/IncenseStickItem.java @@ -15,8 +15,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.item.alchemy.PotionUtils; -import net.minecraft.world.level.Level; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/brew/package-info.java b/Xplat/src/main/java/vazkii/botania/common/item/brew/package-info.java new file mode 100644 index 0000000000..ab195914a6 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/item/brew/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.item.brew; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/BaubleItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/BaubleItem.java index 0b8aed13f7..57e79fefae 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/BaubleItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/BaubleItem.java @@ -22,7 +22,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import vazkii.botania.api.item.CosmeticAttachable; import vazkii.botania.api.item.PhantomInkable; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/CosmeticBaubleItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/CosmeticBaubleItem.java index eb744bfb78..b791dad2a2 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/CosmeticBaubleItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/CosmeticBaubleItem.java @@ -20,7 +20,6 @@ import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import vazkii.botania.api.item.CosmeticBauble; import vazkii.botania.client.core.helper.RenderHelper; @@ -218,7 +217,8 @@ public void doRender(HumanoidModel bipedModel, ItemStack stack, LivingEntity ms.scale(0.5F, -0.5F, -0.5F); renderItem(stack, ms, buffers, light); } - default -> {} + default -> { + } } } else { // body cosmetics bipedModel.body.translateAndRotate(ms); @@ -272,7 +272,8 @@ public void doRender(HumanoidModel bipedModel, ItemStack stack, LivingEntity ms.scale(0.6F, -0.6F, -0.6F); renderItem(stack, ms, buffers, light); } - default -> {} + default -> { + } } } } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/FlugelTiaraItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/FlugelTiaraItem.java index f213e2ff58..18ce6899e1 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/FlugelTiaraItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/FlugelTiaraItem.java @@ -28,7 +28,6 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; -import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.Nullable; @@ -519,7 +518,7 @@ public static void renderHUD(GuiGraphics gui, float partialTicks, Player player, } if (player.getAbilities().flying) { - int width = (int)(player.getCooldowns().getCooldownPercent(stack.getItem(), partialTicks) * 80); + int width = (int) (player.getCooldowns().getCooldownPercent(stack.getItem(), partialTicks) * 80); RenderSystem.setShaderColor(1F, 1F, 1F, 1F); if (width > 0) { gui.fill(xo, y - 2, xo + 80, y - 1, 0x88000000); diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/ManaseerMonocleItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/ManaseerMonocleItem.java index 9d8659e357..eddf5f27e0 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/ManaseerMonocleItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/ManaseerMonocleItem.java @@ -21,7 +21,6 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ComparatorBlock; import net.minecraft.world.level.block.RedStoneWireBlock; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfDexterousMotionItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfDexterousMotionItem.java index d45da02b06..5e8de3f759 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfDexterousMotionItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfDexterousMotionItem.java @@ -14,14 +14,12 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.Direction; import net.minecraft.util.Mth; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.common.handler.EquipmentHandler; -import vazkii.botania.common.helper.ItemNBTHelper; import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.network.serverbound.DodgePacket; import vazkii.botania.xplat.ClientXplatAbstractions; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfFarReachItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfFarReachItem.java index ccd233b6eb..3ae568cc36 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfFarReachItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfFarReachItem.java @@ -18,7 +18,6 @@ import net.minecraft.world.item.ItemStack; import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.xplat.XplatAbstractions; public class RingOfFarReachItem extends BaubleItem { diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfMagnetizationItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfMagnetizationItem.java index fb003044b4..af3297f181 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfMagnetizationItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/RingOfMagnetizationItem.java @@ -19,7 +19,6 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.common.handler.EquipmentHandler; -import vazkii.botania.common.helper.ItemNBTHelper; import vazkii.botania.common.helper.MathHelper; import vazkii.botania.common.lib.BotaniaTags; import vazkii.botania.mixin.ItemEntityAccessor; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SnowflakePendantItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SnowflakePendantItem.java index 44d537b5bc..8a8f1480e7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SnowflakePendantItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SnowflakePendantItem.java @@ -24,7 +24,6 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.FrostWalkerEnchantment; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SpectatorItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SpectatorItem.java index a41dd9dbdb..1c96f7395e 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SpectatorItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/SpectatorItem.java @@ -216,8 +216,8 @@ private boolean scanBlock(Player player, BlockPos pos, ItemStack mainHandStack, } private boolean equalStacks(ItemStack testStack, ItemStack referenceStack1, ItemStack referenceStack2) { - return !testStack.isEmpty() && (ItemStack.isSameItemSameTags(testStack, referenceStack1) - || ItemStack.isSameItemSameTags(testStack, referenceStack2)); + return !testStack.isEmpty() && (ItemStack.isSameItemSameComponents(testStack, referenceStack1) + || ItemStack.isSameItemSameComponents(testStack, referenceStack2)); } private boolean scanInventory(Container inv, ItemStack mainHandStack, ItemStack offHandStack) { diff --git a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TaintedBloodPendantItem.java b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TaintedBloodPendantItem.java index 2a62e06118..92609aac5a 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TaintedBloodPendantItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/equipment/bauble/TaintedBloodPendantItem.java @@ -31,7 +31,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; -import net.minecraft.world.level.Level; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/package-info.java b/Xplat/src/main/java/vazkii/botania/common/item/package-info.java new file mode 100644 index 0000000000..462f8d7413 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/item/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.item; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/item/record/BotaniaJukeboxSongs.java b/Xplat/src/main/java/vazkii/botania/common/item/record/BotaniaJukeboxSongs.java index 84a52f8ade..764ec448ba 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/record/BotaniaJukeboxSongs.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/record/BotaniaJukeboxSongs.java @@ -15,6 +15,6 @@ import static vazkii.botania.api.BotaniaAPI.botaniaRL; public class BotaniaJukeboxSongs { - public static final ResourceKey GAIA_MUSIC_1 = ResourceKey.create(Registries.JUKEBOX_SONG, botaniaRL("gaia_1")); - public static final ResourceKey GAIA_MUSIC_2 = ResourceKey.create(Registries.JUKEBOX_SONG, botaniaRL("gaia_2")); + public static final ResourceKey GAIA_MUSIC_1 = ResourceKey.create(Registries.JUKEBOX_SONG, botaniaRL("gaia_1")); + public static final ResourceKey GAIA_MUSIC_2 = ResourceKey.create(Registries.JUKEBOX_SONG, botaniaRL("gaia_2")); } diff --git a/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java b/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java index f3ffc9e9b3..b3491f4339 100644 --- a/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java +++ b/Xplat/src/main/java/vazkii/botania/common/item/rod/BifrostRodItem.java @@ -161,7 +161,8 @@ public void onAvatarUpdate(Avatar tile) { case SOUTH -> axis = AABB.encapsulatingFullBlocks(tePos.offset(-w, -h, 1), tePos.offset(w + 1, h, l + 1)); case WEST -> axis = AABB.encapsulatingFullBlocks(tePos.offset(-l, -h, -w), tePos.offset(0, h, w + 1)); case EAST -> axis = AABB.encapsulatingFullBlocks(tePos.offset(1, -h, -w), tePos.offset(l + 1, h, w + 1)); - default -> {} + default -> { + } } List players = world.getEntitiesOfClass(Player.class, axis); diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/BindUuid.java b/Xplat/src/main/java/vazkii/botania/common/loot/BindUuid.java index 82b56c4556..71b38af77b 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/BindUuid.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/BindUuid.java @@ -8,7 +8,7 @@ */ package vazkii.botania.common.loot; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.world.entity.player.Player; @@ -26,7 +26,7 @@ import java.util.List; public class BindUuid extends LootItemConditionalFunction { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> commonFields(instance).apply(instance, BindUuid::new)); + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> commonFields(instance).apply(instance, BindUuid::new)); public BindUuid(List predicates) { super(predicates); @@ -35,7 +35,7 @@ public BindUuid(List predicates) { @NotNull @Override public ItemStack run(@NotNull ItemStack stack, @NotNull LootContext context) { - if (context.getParamOrNull(LootContextParams.KILLER_ENTITY) instanceof Player player) { + if (context.getParamOrNull(LootContextParams.ATTACKING_ENTITY) instanceof Player player) { var relic = XplatAbstractions.INSTANCE.findRelic(stack); if (relic != null) { relic.bindToUUID(player.getUUID()); @@ -46,7 +46,7 @@ public ItemStack run(@NotNull ItemStack stack, @NotNull LootContext context) { } @Override - public LootItemFunctionType getType() { + public LootItemFunctionType getType() { return BotaniaLootModifiers.BIND_UUID; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootModifiers.java b/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootModifiers.java index 13f3aa5189..88ec772943 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootModifiers.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootModifiers.java @@ -20,7 +20,7 @@ public class BotaniaLootModifiers { public static final LootItemConditionType TRUE_GUARDIAN_KILLER = new LootItemConditionType(TrueGuardianKiller.CODEC); public static final LootItemConditionType ENABLE_RELICS = new LootItemConditionType(EnableRelics.CODEC); public static final LootItemConditionType KILLED_BY_REAL_PLAYER = new LootItemConditionType(RealPlayerCondition.CODEC); - public static final LootItemFunctionType BIND_UUID = new LootItemFunctionType(BindUuid.CODEC); + public static final LootItemFunctionType BIND_UUID = new LootItemFunctionType<>(BindUuid.CODEC); public static void submitLootConditions(BiConsumer consumer) { consumer.accept(TRUE_GUARDIAN_KILLER, botaniaRL("true_guardian_killer")); @@ -28,7 +28,7 @@ public static void submitLootConditions(BiConsumer consumer) { + public static void submitLootFunctions(BiConsumer, ResourceLocation> consumer) { consumer.accept(BIND_UUID, botaniaRL("bind_uuid")); } } diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootTables.java b/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootTables.java index 4cc2902723..219d0b7a3f 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootTables.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/BotaniaLootTables.java @@ -2,7 +2,9 @@ import com.google.common.collect.Sets; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.storage.loot.LootTable; import java.util.Collections; import java.util.Set; @@ -10,136 +12,136 @@ import static vazkii.botania.api.BotaniaAPI.botaniaRL; public class BotaniaLootTables { - private static final Set LOCATIONS = Sets.newHashSet(); - private static final Set IMMUTABLE_LOCATIONS = Collections.unmodifiableSet(LOCATIONS); + private static final Set> LOCATIONS = Sets.newHashSet(); + private static final Set> IMMUTABLE_LOCATIONS = Collections.unmodifiableSet(LOCATIONS); - public static final ResourceLocation LOONIUM_DEFAULT_LOOT = register("loonium/default"); + public static final ResourceKey LOONIUM_DEFAULT_LOOT = register("loonium/default"); // TODO 1.21: embed armor set and weapon equipment tables - public static final ResourceLocation LOONIUM_ARMORSET_COAST_CHAIN = register("equipment/loonium/armorset/coast_chain"); - public static final ResourceLocation LOONIUM_ARMORSET_COAST_IRON = register("equipment/loonium/armorset/coast_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_COAST_DIAMOND = register("equipment/loonium/armorset/coast_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_DUNE_GOLD = register("equipment/loonium/armorset/dune_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_DUNE_IRON = register("equipment/loonium/armorset/dune_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_DUNE_DIAMOND = register("equipment/loonium/armorset/dune_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_EYE_GOLD = register("equipment/loonium/armorset/eye_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_EYE_IRON = register("equipment/loonium/armorset/eye_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_EYE_DIAMOND = register("equipment/loonium/armorset/eye_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_HOST_CHAIN = register("equipment/loonium/armorset/host_chain"); - public static final ResourceLocation LOONIUM_ARMORSET_HOST_IRON = register("equipment/loonium/armorset/host_iron"); - - public static final ResourceLocation LOONIUM_ARMORSET_RAISER_IRON = register("equipment/loonium/armorset/raiser_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_RAISER_GOLD = register("equipment/loonium/armorset/raiser_gold"); - - public static final ResourceLocation LOONIUM_ARMORSET_RIB_IRON = register("equipment/loonium/armorset/rib_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_RIB_GOLD = register("equipment/loonium/armorset/rib_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_RIB_DIAMOND = register("equipment/loonium/armorset/rib_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_SENTRY_CHAIN = register("equipment/loonium/armorset/sentry_chain"); - public static final ResourceLocation LOONIUM_ARMORSET_SENTRY_IRON = register("equipment/loonium/armorset/sentry_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_SENTRY_DIAMOND = register("equipment/loonium/armorset/sentry_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_SHAPER_GOLD = register("equipment/loonium/armorset/shaper_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_SHAPER_DIAMOND = register("equipment/loonium/armorset/shaper_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_SILENCE_GOLD = register("equipment/loonium/armorset/silence_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_SILENCE_DIAMOND = register("equipment/loonium/armorset/silence_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_SNOUT_GOLD = register("equipment/loonium/armorset/snout_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_SNOUT_NETHERITE = register("equipment/loonium/armorset/snout_netherite"); - - public static final ResourceLocation LOONIUM_ARMORSET_SPIRE_IRON = register("equipment/loonium/armorset/spire_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_SPIRE_GOLD = register("equipment/loonium/armorset/spire_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_SPIRE_DIAMOND = register("equipment/loonium/armorset/spire_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_TIDE_LEATHER = register("equipment/loonium/armorset/tide_leather"); - public static final ResourceLocation LOONIUM_ARMORSET_TIDE_GOLD = register("equipment/loonium/armorset/tide_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_TIDE_DIAMOND = register("equipment/loonium/armorset/tide_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_WARD_IRON = register("equipment/loonium/armorset/ward_iron"); - public static final ResourceLocation LOONIUM_ARMORSET_WARD_DIAMOND = register("equipment/loonium/armorset/ward_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_WAYFINDER_CHAIN = register("equipment/loonium/armorset/wayfinder_chain"); - public static final ResourceLocation LOONIUM_ARMORSET_WAYFINDER_DIAMOND = register("equipment/loonium/armorset/wayfinder_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_WILD_CHAIN = register("equipment/loonium/armorset/wild_chain"); - public static final ResourceLocation LOONIUM_ARMORSET_WILD_GOLD = register("equipment/loonium/armorset/wild_gold"); - public static final ResourceLocation LOONIUM_ARMORSET_WILD_DIAMOND = register("equipment/loonium/armorset/wild_diamond"); - - public static final ResourceLocation LOONIUM_ARMORSET_COSTUME_ENDERMAN = register("equipment/loonium/armorset/costume_enderman"); - public static final ResourceLocation LOONIUM_ARMORSET_COSTUME_EVOKER = register("equipment/loonium/armorset/costume_evoker"); - public static final ResourceLocation LOONIUM_ARMORSET_COSTUME_VINDICATOR = register("equipment/loonium/armorset/costume_vindicator"); - public static final ResourceLocation LOONIUM_ARMORSET_COSTUME_ILLUSIONER = register("equipment/loonium/armorset/costume_illusioner"); - public static final ResourceLocation LOONIUM_ARMORSET_COSTUME_VEX = register("equipment/loonium/armorset/costume_vex"); - - public static final ResourceLocation LOONIUM_WEAPON_AXE = register("equipment/loonium/weapon_axe"); - public static final ResourceLocation LOONIUM_WEAPON_AXE_GOLD = register("equipment/loonium/weapon_axe_gold"); - public static final ResourceLocation LOONIUM_WEAPON_BOW = register("equipment/loonium/weapon_bow"); - public static final ResourceLocation LOONIUM_WEAPON_CROSSBOW = register("equipment/loonium/weapon_crossbow"); - public static final ResourceLocation LOONIUM_WEAPON_SWORD = register("equipment/loonium/weapon_sword"); - public static final ResourceLocation LOONIUM_WEAPON_SWORD_GOLD = register("equipment/loonium/weapon_sword_gold"); - public static final ResourceLocation LOONIUM_WEAPON_TRIDENT = register("equipment/loonium/weapon_trident"); - public static final ResourceLocation LOONIUM_WEAPON_BY_PROFESSION = register("equipment/loonium/weapon_by_profession"); - public static final ResourceLocation LOONIUM_WEAPON_FOR_PIGLIN = register("equipment/loonium/weapon_for_piglin"); - public static final ResourceLocation LOONIUM_WEAPON_FOR_WITHER_SKELETON = register("equipment/loonium/weapon_for_wither_skeleton"); - - public static final ResourceLocation LOONIUM_ARMOR_ANCIENT_CITY = register("equipment/loonium/armor_ancient_city"); - public static final ResourceLocation LOONIUM_ARMOR_BASTION_REMNANT = register("equipment/loonium/armor_bastion_remnant"); - public static final ResourceLocation LOONIUM_ARMOR_DESERT_PYRAMID = register("equipment/loonium/armor_desert_pyramid"); - public static final ResourceLocation LOONIUM_ARMOR_END_CITY = register("equipment/loonium/armor_end_city"); - public static final ResourceLocation LOONIUM_ARMOR_FORTRESS = register("equipment/loonium/armor_fortress"); - public static final ResourceLocation LOONIUM_ARMOR_JUNGLE_TEMPLE = register("equipment/loonium/armor_jungle_temple"); - public static final ResourceLocation LOONIUM_ARMOR_MANSION = register("equipment/loonium/armor_mansion"); - public static final ResourceLocation LOONIUM_ARMOR_MONUMENT = register("equipment/loonium/armor_monument"); - public static final ResourceLocation LOONIUM_ARMOR_OUTPOST = register("equipment/loonium/armor_outpost"); - public static final ResourceLocation LOONIUM_ARMOR_PORTAL = register("equipment/loonium/armor_portal"); - public static final ResourceLocation LOONIUM_ARMOR_SHIPWRECK = register("equipment/loonium/armor_shipwreck"); - public static final ResourceLocation LOONIUM_ARMOR_STRONGHOLD = register("equipment/loonium/armor_stronghold"); - public static final ResourceLocation LOONIUM_ARMOR_TRAIL_RUINS = register("equipment/loonium/armor_trail_ruins"); - - public static final ResourceLocation LOONIUM_DROWNED_ANCIENT_CITY = register("equipment/loonium/drowned_ancient_city"); - public static final ResourceLocation LOONIUM_DROWNED_JUNGLE_TEMPLE = register("equipment/loonium/drowned_jungle_temple"); - public static final ResourceLocation LOONIUM_DROWNED_MONUMENT = register("equipment/loonium/drowned_monument"); - public static final ResourceLocation LOONIUM_DROWNED_PORTAL = register("equipment/loonium/drowned_portal"); - public static final ResourceLocation LOONIUM_DROWNED_SHIPWRECK = register("equipment/loonium/drowned_shipwreck"); - public static final ResourceLocation LOONIUM_DROWNED_STRONGHOLD = register("equipment/loonium/drowned_stronghold"); - public static final ResourceLocation LOONIUM_DROWNED_TRAIL_RUINS = register("equipment/loonium/drowned_trail_ruins"); - - public static final ResourceLocation LOONIUM_PIGLIN_BASTION_REMNANT = register("equipment/loonium/piglin_bastion_remnant"); - public static final ResourceLocation LOONIUM_PIGLIN_PORTAL = register("equipment/loonium/piglin_ruined_portal"); - - public static final ResourceLocation LOONIUM_SKELETON_ANCIENT_CITY = register("equipment/loonium/skeleton_ancient_city"); - public static final ResourceLocation LOONIUM_SKELETON_DESERT_PYRAMID = register("equipment/loonium/skeleton_desert_pyramid"); - public static final ResourceLocation LOONIUM_SKELETON_JUNGLE_TEMPLE = register("equipment/loonium/skeleton_jungle_temple"); - public static final ResourceLocation LOONIUM_SKELETON_END_CITY = register("equipment/loonium/skeleton_end_city"); - public static final ResourceLocation LOONIUM_SKELETON_FORTRESS = register("equipment/loonium/skeleton_fortress"); - public static final ResourceLocation LOONIUM_SKELETON_MONUMENT = register("equipment/loonium/skeleton_monument"); - public static final ResourceLocation LOONIUM_SKELETON_OUTPOST = register("equipment/loonium/skeleton_outpost"); - public static final ResourceLocation LOONIUM_SKELETON_PORTAL = register("equipment/loonium/skeleton_portal"); - public static final ResourceLocation LOONIUM_SKELETON_SHIPWRECK = register("equipment/loonium/skeleton_shipwreck"); - public static final ResourceLocation LOONIUM_SKELETON_STRONGHOLD = register("equipment/loonium/skeleton_stronghold"); - public static final ResourceLocation LOONIUM_SKELETON_TRAIL_RUINS = register("equipment/loonium/skeleton_trail_ruins"); - - public static final ResourceLocation LOONIUM_ZOMBIE_ANCIENT_CITY = register("equipment/loonium/zombie_ancient_city"); - public static final ResourceLocation LOONIUM_ZOMBIE_DESERT_PYRAMID = register("equipment/loonium/zombie_desert_pyramid"); - public static final ResourceLocation LOONIUM_ZOMBIE_END_CITY = register("equipment/loonium/zombie_end_city"); - public static final ResourceLocation LOONIUM_ZOMBIE_FORTRESS = register("equipment/loonium/zombie_fortress"); - public static final ResourceLocation LOONIUM_ZOMBIE_JUNGLE_TEMPLE = register("equipment/loonium/zombie_jungle_temple"); - public static final ResourceLocation LOONIUM_ZOMBIE_MONUMENT = register("equipment/loonium/zombie_monument"); - public static final ResourceLocation LOONIUM_ZOMBIE_OUTPOST = register("equipment/loonium/zombie_outpost"); - public static final ResourceLocation LOONIUM_ZOMBIE_PORTAL = register("equipment/loonium/zombie_portal"); - public static final ResourceLocation LOONIUM_ZOMBIE_SHIPWRECK = register("equipment/loonium/zombie_shipwreck"); - public static final ResourceLocation LOONIUM_ZOMBIE_STRONGHOLD = register("equipment/loonium/zombie_stronghold"); - public static final ResourceLocation LOONIUM_ZOMBIE_TRAIL_RUINS = register("equipment/loonium/zombie_trail_ruins"); - - private static ResourceLocation register(String path) { - return register(botaniaRL(path)); + public static final ResourceKey LOONIUM_ARMORSET_COAST_CHAIN = register("equipment/loonium/armorset/coast_chain"); + public static final ResourceKey LOONIUM_ARMORSET_COAST_IRON = register("equipment/loonium/armorset/coast_iron"); + public static final ResourceKey LOONIUM_ARMORSET_COAST_DIAMOND = register("equipment/loonium/armorset/coast_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_DUNE_GOLD = register("equipment/loonium/armorset/dune_gold"); + public static final ResourceKey LOONIUM_ARMORSET_DUNE_IRON = register("equipment/loonium/armorset/dune_iron"); + public static final ResourceKey LOONIUM_ARMORSET_DUNE_DIAMOND = register("equipment/loonium/armorset/dune_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_EYE_GOLD = register("equipment/loonium/armorset/eye_gold"); + public static final ResourceKey LOONIUM_ARMORSET_EYE_IRON = register("equipment/loonium/armorset/eye_iron"); + public static final ResourceKey LOONIUM_ARMORSET_EYE_DIAMOND = register("equipment/loonium/armorset/eye_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_HOST_CHAIN = register("equipment/loonium/armorset/host_chain"); + public static final ResourceKey LOONIUM_ARMORSET_HOST_IRON = register("equipment/loonium/armorset/host_iron"); + + public static final ResourceKey LOONIUM_ARMORSET_RAISER_IRON = register("equipment/loonium/armorset/raiser_iron"); + public static final ResourceKey LOONIUM_ARMORSET_RAISER_GOLD = register("equipment/loonium/armorset/raiser_gold"); + + public static final ResourceKey LOONIUM_ARMORSET_RIB_IRON = register("equipment/loonium/armorset/rib_iron"); + public static final ResourceKey LOONIUM_ARMORSET_RIB_GOLD = register("equipment/loonium/armorset/rib_gold"); + public static final ResourceKey LOONIUM_ARMORSET_RIB_DIAMOND = register("equipment/loonium/armorset/rib_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_SENTRY_CHAIN = register("equipment/loonium/armorset/sentry_chain"); + public static final ResourceKey LOONIUM_ARMORSET_SENTRY_IRON = register("equipment/loonium/armorset/sentry_iron"); + public static final ResourceKey LOONIUM_ARMORSET_SENTRY_DIAMOND = register("equipment/loonium/armorset/sentry_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_SHAPER_GOLD = register("equipment/loonium/armorset/shaper_gold"); + public static final ResourceKey LOONIUM_ARMORSET_SHAPER_DIAMOND = register("equipment/loonium/armorset/shaper_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_SILENCE_GOLD = register("equipment/loonium/armorset/silence_gold"); + public static final ResourceKey LOONIUM_ARMORSET_SILENCE_DIAMOND = register("equipment/loonium/armorset/silence_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_SNOUT_GOLD = register("equipment/loonium/armorset/snout_gold"); + public static final ResourceKey LOONIUM_ARMORSET_SNOUT_NETHERITE = register("equipment/loonium/armorset/snout_netherite"); + + public static final ResourceKey LOONIUM_ARMORSET_SPIRE_IRON = register("equipment/loonium/armorset/spire_iron"); + public static final ResourceKey LOONIUM_ARMORSET_SPIRE_GOLD = register("equipment/loonium/armorset/spire_gold"); + public static final ResourceKey LOONIUM_ARMORSET_SPIRE_DIAMOND = register("equipment/loonium/armorset/spire_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_TIDE_LEATHER = register("equipment/loonium/armorset/tide_leather"); + public static final ResourceKey LOONIUM_ARMORSET_TIDE_GOLD = register("equipment/loonium/armorset/tide_iron"); + public static final ResourceKey LOONIUM_ARMORSET_TIDE_DIAMOND = register("equipment/loonium/armorset/tide_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_WARD_IRON = register("equipment/loonium/armorset/ward_iron"); + public static final ResourceKey LOONIUM_ARMORSET_WARD_DIAMOND = register("equipment/loonium/armorset/ward_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_WAYFINDER_CHAIN = register("equipment/loonium/armorset/wayfinder_chain"); + public static final ResourceKey LOONIUM_ARMORSET_WAYFINDER_DIAMOND = register("equipment/loonium/armorset/wayfinder_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_WILD_CHAIN = register("equipment/loonium/armorset/wild_chain"); + public static final ResourceKey LOONIUM_ARMORSET_WILD_GOLD = register("equipment/loonium/armorset/wild_gold"); + public static final ResourceKey LOONIUM_ARMORSET_WILD_DIAMOND = register("equipment/loonium/armorset/wild_diamond"); + + public static final ResourceKey LOONIUM_ARMORSET_COSTUME_ENDERMAN = register("equipment/loonium/armorset/costume_enderman"); + public static final ResourceKey LOONIUM_ARMORSET_COSTUME_EVOKER = register("equipment/loonium/armorset/costume_evoker"); + public static final ResourceKey LOONIUM_ARMORSET_COSTUME_VINDICATOR = register("equipment/loonium/armorset/costume_vindicator"); + public static final ResourceKey LOONIUM_ARMORSET_COSTUME_ILLUSIONER = register("equipment/loonium/armorset/costume_illusioner"); + public static final ResourceKey LOONIUM_ARMORSET_COSTUME_VEX = register("equipment/loonium/armorset/costume_vex"); + + public static final ResourceKey LOONIUM_WEAPON_AXE = register("equipment/loonium/weapon_axe"); + public static final ResourceKey LOONIUM_WEAPON_AXE_GOLD = register("equipment/loonium/weapon_axe_gold"); + public static final ResourceKey LOONIUM_WEAPON_BOW = register("equipment/loonium/weapon_bow"); + public static final ResourceKey LOONIUM_WEAPON_CROSSBOW = register("equipment/loonium/weapon_crossbow"); + public static final ResourceKey LOONIUM_WEAPON_SWORD = register("equipment/loonium/weapon_sword"); + public static final ResourceKey LOONIUM_WEAPON_SWORD_GOLD = register("equipment/loonium/weapon_sword_gold"); + public static final ResourceKey LOONIUM_WEAPON_TRIDENT = register("equipment/loonium/weapon_trident"); + public static final ResourceKey LOONIUM_WEAPON_BY_PROFESSION = register("equipment/loonium/weapon_by_profession"); + public static final ResourceKey LOONIUM_WEAPON_FOR_PIGLIN = register("equipment/loonium/weapon_for_piglin"); + public static final ResourceKey LOONIUM_WEAPON_FOR_WITHER_SKELETON = register("equipment/loonium/weapon_for_wither_skeleton"); + + public static final ResourceKey LOONIUM_ARMOR_ANCIENT_CITY = register("equipment/loonium/armor_ancient_city"); + public static final ResourceKey LOONIUM_ARMOR_BASTION_REMNANT = register("equipment/loonium/armor_bastion_remnant"); + public static final ResourceKey LOONIUM_ARMOR_DESERT_PYRAMID = register("equipment/loonium/armor_desert_pyramid"); + public static final ResourceKey LOONIUM_ARMOR_END_CITY = register("equipment/loonium/armor_end_city"); + public static final ResourceKey LOONIUM_ARMOR_FORTRESS = register("equipment/loonium/armor_fortress"); + public static final ResourceKey LOONIUM_ARMOR_JUNGLE_TEMPLE = register("equipment/loonium/armor_jungle_temple"); + public static final ResourceKey LOONIUM_ARMOR_MANSION = register("equipment/loonium/armor_mansion"); + public static final ResourceKey LOONIUM_ARMOR_MONUMENT = register("equipment/loonium/armor_monument"); + public static final ResourceKey LOONIUM_ARMOR_OUTPOST = register("equipment/loonium/armor_outpost"); + public static final ResourceKey LOONIUM_ARMOR_PORTAL = register("equipment/loonium/armor_portal"); + public static final ResourceKey LOONIUM_ARMOR_SHIPWRECK = register("equipment/loonium/armor_shipwreck"); + public static final ResourceKey LOONIUM_ARMOR_STRONGHOLD = register("equipment/loonium/armor_stronghold"); + public static final ResourceKey LOONIUM_ARMOR_TRAIL_RUINS = register("equipment/loonium/armor_trail_ruins"); + + public static final ResourceKey LOONIUM_DROWNED_ANCIENT_CITY = register("equipment/loonium/drowned_ancient_city"); + public static final ResourceKey LOONIUM_DROWNED_JUNGLE_TEMPLE = register("equipment/loonium/drowned_jungle_temple"); + public static final ResourceKey LOONIUM_DROWNED_MONUMENT = register("equipment/loonium/drowned_monument"); + public static final ResourceKey LOONIUM_DROWNED_PORTAL = register("equipment/loonium/drowned_portal"); + public static final ResourceKey LOONIUM_DROWNED_SHIPWRECK = register("equipment/loonium/drowned_shipwreck"); + public static final ResourceKey LOONIUM_DROWNED_STRONGHOLD = register("equipment/loonium/drowned_stronghold"); + public static final ResourceKey LOONIUM_DROWNED_TRAIL_RUINS = register("equipment/loonium/drowned_trail_ruins"); + + public static final ResourceKey LOONIUM_PIGLIN_BASTION_REMNANT = register("equipment/loonium/piglin_bastion_remnant"); + public static final ResourceKey LOONIUM_PIGLIN_PORTAL = register("equipment/loonium/piglin_ruined_portal"); + + public static final ResourceKey LOONIUM_SKELETON_ANCIENT_CITY = register("equipment/loonium/skeleton_ancient_city"); + public static final ResourceKey LOONIUM_SKELETON_DESERT_PYRAMID = register("equipment/loonium/skeleton_desert_pyramid"); + public static final ResourceKey LOONIUM_SKELETON_JUNGLE_TEMPLE = register("equipment/loonium/skeleton_jungle_temple"); + public static final ResourceKey LOONIUM_SKELETON_END_CITY = register("equipment/loonium/skeleton_end_city"); + public static final ResourceKey LOONIUM_SKELETON_FORTRESS = register("equipment/loonium/skeleton_fortress"); + public static final ResourceKey LOONIUM_SKELETON_MONUMENT = register("equipment/loonium/skeleton_monument"); + public static final ResourceKey LOONIUM_SKELETON_OUTPOST = register("equipment/loonium/skeleton_outpost"); + public static final ResourceKey LOONIUM_SKELETON_PORTAL = register("equipment/loonium/skeleton_portal"); + public static final ResourceKey LOONIUM_SKELETON_SHIPWRECK = register("equipment/loonium/skeleton_shipwreck"); + public static final ResourceKey LOONIUM_SKELETON_STRONGHOLD = register("equipment/loonium/skeleton_stronghold"); + public static final ResourceKey LOONIUM_SKELETON_TRAIL_RUINS = register("equipment/loonium/skeleton_trail_ruins"); + + public static final ResourceKey LOONIUM_ZOMBIE_ANCIENT_CITY = register("equipment/loonium/zombie_ancient_city"); + public static final ResourceKey LOONIUM_ZOMBIE_DESERT_PYRAMID = register("equipment/loonium/zombie_desert_pyramid"); + public static final ResourceKey LOONIUM_ZOMBIE_END_CITY = register("equipment/loonium/zombie_end_city"); + public static final ResourceKey LOONIUM_ZOMBIE_FORTRESS = register("equipment/loonium/zombie_fortress"); + public static final ResourceKey LOONIUM_ZOMBIE_JUNGLE_TEMPLE = register("equipment/loonium/zombie_jungle_temple"); + public static final ResourceKey LOONIUM_ZOMBIE_MONUMENT = register("equipment/loonium/zombie_monument"); + public static final ResourceKey LOONIUM_ZOMBIE_OUTPOST = register("equipment/loonium/zombie_outpost"); + public static final ResourceKey LOONIUM_ZOMBIE_PORTAL = register("equipment/loonium/zombie_portal"); + public static final ResourceKey LOONIUM_ZOMBIE_SHIPWRECK = register("equipment/loonium/zombie_shipwreck"); + public static final ResourceKey LOONIUM_ZOMBIE_STRONGHOLD = register("equipment/loonium/zombie_stronghold"); + public static final ResourceKey LOONIUM_ZOMBIE_TRAIL_RUINS = register("equipment/loonium/zombie_trail_ruins"); + + private static ResourceKey register(String path) { + return register(ResourceKey.create(Registries.LOOT_TABLE, botaniaRL(path))); } - private static ResourceLocation register(ResourceLocation location) { + private static ResourceKey register(ResourceKey location) { if (LOCATIONS.add(location)) { return location; } else { @@ -147,7 +149,7 @@ private static ResourceLocation register(ResourceLocation location) { } } - public static Set all() { + public static Set> all() { return IMMUTABLE_LOCATIONS; } } diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/EnableRelics.java b/Xplat/src/main/java/vazkii/botania/common/loot/EnableRelics.java index d0a545b87f..f8024ffad7 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/EnableRelics.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/EnableRelics.java @@ -8,7 +8,7 @@ */ package vazkii.botania.common.loot; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; @@ -20,7 +20,7 @@ public class EnableRelics implements LootItemCondition { public static final EnableRelics INSTANCE = new EnableRelics(); - public static final Codec CODEC = Codec.unit(INSTANCE); + public static final MapCodec CODEC = MapCodec.unit(INSTANCE); private EnableRelics() {} diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/LootHandler.java b/Xplat/src/main/java/vazkii/botania/common/loot/LootHandler.java index 8b4b7477af..4a66226852 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/LootHandler.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/LootHandler.java @@ -12,7 +12,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; -import net.minecraft.world.level.storage.loot.entries.LootTableReference; +import net.minecraft.world.level.storage.loot.entries.NestedLootTable; import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator; import vazkii.botania.api.BotaniaAPI; @@ -50,7 +50,7 @@ public static void lootLoad(ResourceLocation id, Consumer addP } } else if (XplatAbstractions.INSTANCE.gogLoaded() && (Blocks.SHORT_GRASS.getLootTable().equals(id) || Blocks.TALL_GRASS.getLootTable().equals(id))) { - addPool.accept(LootPool.lootPool().add(LootTableReference.lootTableReference(GOG_SEEDS_TABLE))); + addPool.accept(LootPool.lootPool().add(NestedLootTable.lootTableReference(GOG_SEEDS_TABLE))); } } @@ -62,7 +62,7 @@ private static LootPool.Builder getInjectPool(String entryName) { private static LootPoolEntryContainer.Builder getInjectEntry(String name, int weight) { ResourceLocation table = botaniaRL("inject/" + name); - return LootTableReference.lootTableReference(table) + return NestedLootTable.lootTableReference(table) .setWeight(weight); } diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/RealPlayerCondition.java b/Xplat/src/main/java/vazkii/botania/common/loot/RealPlayerCondition.java index a47bb424a3..c46ee78119 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/RealPlayerCondition.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/RealPlayerCondition.java @@ -9,7 +9,7 @@ package vazkii.botania.common.loot; import com.google.common.collect.ImmutableSet; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.storage.loot.LootContext; @@ -26,7 +26,7 @@ public class RealPlayerCondition implements LootItemCondition { public static final RealPlayerCondition INSTANCE = new RealPlayerCondition(); - public static final Codec CODEC = Codec.unit(INSTANCE); + public static final MapCodec CODEC = MapCodec.unit(INSTANCE); private RealPlayerCondition() {} diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/TrueGuardianKiller.java b/Xplat/src/main/java/vazkii/botania/common/loot/TrueGuardianKiller.java index 162d6726aa..5d73dbfd85 100644 --- a/Xplat/src/main/java/vazkii/botania/common/loot/TrueGuardianKiller.java +++ b/Xplat/src/main/java/vazkii/botania/common/loot/TrueGuardianKiller.java @@ -8,7 +8,7 @@ */ package vazkii.botania.common.loot; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.storage.loot.LootContext; @@ -22,7 +22,7 @@ public class TrueGuardianKiller implements LootItemCondition { public static final TrueGuardianKiller INSTANCE = new TrueGuardianKiller(); - public static final Codec CODEC = Codec.unit(INSTANCE); + public static final MapCodec CODEC = MapCodec.unit(INSTANCE); private TrueGuardianKiller() {} @@ -30,7 +30,7 @@ private TrueGuardianKiller() {} public boolean test(@NotNull LootContext context) { Entity victim = context.getParamOrNull(LootContextParams.THIS_ENTITY); return victim instanceof GaiaGuardianEntity gg - && context.getParamOrNull(LootContextParams.KILLER_ENTITY) == gg.trueKiller; + && context.getParamOrNull(LootContextParams.ATTACKING_ENTITY) == gg.trueKiller; } @Override diff --git a/Xplat/src/main/java/vazkii/botania/common/loot/package-info.java b/Xplat/src/main/java/vazkii/botania/common/loot/package-info.java new file mode 100644 index 0000000000..08ac400322 --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/common/loot/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.common.loot; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java b/Xplat/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java index 8bdc82a299..f24b822dea 100644 --- a/Xplat/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java +++ b/Xplat/src/main/java/vazkii/botania/common/world/SkyblockChunkGenerator.java @@ -8,7 +8,7 @@ */ package vazkii.botania.common.world; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.*; @@ -25,20 +25,19 @@ import org.jetbrains.annotations.NotNull; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; import java.util.function.BiConsumer; import static vazkii.botania.api.BotaniaAPI.botaniaRL; public class SkyblockChunkGenerator extends NoiseBasedChunkGenerator { // [VanillaCopy] NoiseBasedChunkGenerator's codec, but calls our constructor - public static final Codec CODEC = RecordCodecBuilder.create( + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( (instance) -> instance.group( BiomeSource.CODEC.fieldOf("biome_source").forGetter((gen) -> gen.biomeSource), NoiseGeneratorSettings.CODEC.fieldOf("settings").forGetter(NoiseBasedChunkGenerator::generatorSettings)) .apply(instance, instance.stable(SkyblockChunkGenerator::new))); - public static void submitRegistration(BiConsumer, ResourceLocation> consumer) { + public static void submitRegistration(BiConsumer, ResourceLocation> consumer) { consumer.accept(SkyblockChunkGenerator.CODEC, botaniaRL("skyblock")); } @@ -52,7 +51,7 @@ private SkyblockChunkGenerator(BiomeSource biomeSource, Holder codec() { + protected MapCodec codec() { return CODEC; } @@ -67,7 +66,7 @@ public void applyCarvers(@NotNull WorldGenRegion worldGenRegion, long seed, @Not @NotNull ChunkAccess chunkAccess, GenerationStep.@NotNull Carving carving) {} @Override - public @NotNull CompletableFuture fillFromNoise(@NotNull Executor executor, @NotNull Blender blender, + public @NotNull CompletableFuture fillFromNoise(@NotNull Blender blender, @NotNull RandomState randomState, @NotNull StructureManager structureManager, @NotNull ChunkAccess chunk) { return CompletableFuture.completedFuture(chunk); } diff --git a/Xplat/src/main/java/vazkii/botania/common/world/SkyblockSavedData.java b/Xplat/src/main/java/vazkii/botania/common/world/SkyblockSavedData.java index d8798994d2..d3b0198440 100644 --- a/Xplat/src/main/java/vazkii/botania/common/world/SkyblockSavedData.java +++ b/Xplat/src/main/java/vazkii/botania/common/world/SkyblockSavedData.java @@ -12,6 +12,7 @@ import com.google.common.collect.HashBiMap; import net.minecraft.Util; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -29,7 +30,7 @@ public class SkyblockSavedData extends SavedData { private static final String NAME = "gog_skyblock_islands"; public static final Factory FACTORY = - new Factory<>(() -> new SkyblockSavedData(new CompoundTag()), SkyblockSavedData::new, DataFixTypes.LEVEL); + new Factory<>(SkyblockSavedData::new, SkyblockSavedData::new, DataFixTypes.LEVEL); /** The offset is chosen to put islands under default settings in the center of a chunk region. */ private static final int OFFSET = 1; @@ -37,7 +38,12 @@ public class SkyblockSavedData extends SavedData { public final BiMap skyblocks; private final Spiral spiral; - public SkyblockSavedData(CompoundTag nbt) { + public SkyblockSavedData() { + this.skyblocks = HashBiMap.create(); + this.spiral = new Spiral(); + } + + public SkyblockSavedData(CompoundTag nbt, HolderLookup.Provider registries) { HashBiMap map = HashBiMap.create(); for (Tag inbt : nbt.getList("Islands", Tag.TAG_COMPOUND)) { CompoundTag tag = (CompoundTag) inbt; @@ -80,7 +86,7 @@ public IslandPos create(UUID playerId) { @NotNull @Override - public CompoundTag save(@NotNull CompoundTag nbt) { + public CompoundTag save(@NotNull CompoundTag nbt, @NotNull HolderLookup.Provider registries) { ListTag list = new ListTag(); for (Map.Entry entry : skyblocks.entrySet()) { CompoundTag entryTag = entry.getKey().toTag(); diff --git a/Xplat/src/main/java/vazkii/botania/data/BlockLootProvider.java b/Xplat/src/main/java/vazkii/botania/data/BlockLootProvider.java index 2933bad04c..2ca536148d 100644 --- a/Xplat/src/main/java/vazkii/botania/data/BlockLootProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/BlockLootProvider.java @@ -27,7 +27,7 @@ import net.minecraft.world.level.storage.loot.entries.AlternativesEntry; import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer; -import net.minecraft.world.level.storage.loot.entries.LootTableReference; +import net.minecraft.world.level.storage.loot.entries.NestedLootTable; import net.minecraft.world.level.storage.loot.functions.ApplyExplosionDecay; import net.minecraft.world.level.storage.loot.functions.CopyNameFunction; import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction; @@ -202,7 +202,7 @@ protected static LootTable.Builder genSilkDrop(ItemLike silkDrop, ItemLike norma } protected static LootTable.Builder genSolidVine(Block b) { - LootPoolEntryContainer.Builder entry = LootTableReference.lootTableReference(ResourceLocation.withDefaultNamespace("blocks/vine")); + LootPoolEntryContainer.Builder entry = NestedLootTable.lootTableReference(ResourceLocation.withDefaultNamespace("blocks/vine")); return LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(entry)); } diff --git a/Xplat/src/main/java/vazkii/botania/data/BlockTagProvider.java b/Xplat/src/main/java/vazkii/botania/data/BlockTagProvider.java index 20f8681f58..820cfb166b 100644 --- a/Xplat/src/main/java/vazkii/botania/data/BlockTagProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/BlockTagProvider.java @@ -35,7 +35,6 @@ import vazkii.botania.common.lib.BotaniaTags; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; -import vazkii.botania.xplat.XplatAbstractions; import java.util.Comparator; import java.util.Set; @@ -214,7 +213,7 @@ protected void addTags(HolderLookup.Provider provider) { tag(BotaniaTags.Blocks.PASTURE_SEED_REPLACEABLE).add(Blocks.DIRT, Blocks.GRASS_BLOCK, Blocks.MYCELIUM); - tag(BotaniaTags.Blocks.UNETHICAL_TNT_CHECK).addOptional(new ResourceLocation("ae2:tiny_tnt")); + tag(BotaniaTags.Blocks.UNETHICAL_TNT_CHECK).addOptional(ResourceLocation.fromNamespaceAndPath("ae2", "tiny_tnt")); tag(BlockTags.FLOWER_POTS) .add(ColorHelper.supportedColors() diff --git a/Xplat/src/main/java/vazkii/botania/data/BlockstateProvider.java b/Xplat/src/main/java/vazkii/botania/data/BlockstateProvider.java index 33eec3a181..262227497f 100644 --- a/Xplat/src/main/java/vazkii/botania/data/BlockstateProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/BlockstateProvider.java @@ -53,8 +53,8 @@ import static net.minecraft.data.models.model.ModelLocationUtils.getModelLocation; import static net.minecraft.data.models.model.TextureMapping.getBlockTexture; -import static vazkii.botania.common.block.BotaniaBlocks.*; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import static vazkii.botania.common.block.BotaniaBlocks.*; public class BlockstateProvider implements DataProvider { protected final PackOutput packOutput; diff --git a/Xplat/src/main/java/vazkii/botania/data/ItemModelProvider.java b/Xplat/src/main/java/vazkii/botania/data/ItemModelProvider.java index 0dd765e184..ffbc55c013 100644 --- a/Xplat/src/main/java/vazkii/botania/data/ItemModelProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/ItemModelProvider.java @@ -58,8 +58,8 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static vazkii.botania.common.item.BotaniaItems.*; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import static vazkii.botania.common.item.BotaniaItems.*; public class ItemModelProvider implements DataProvider { private static final TextureSlot LAYER1 = TextureSlotAccessor.make("layer1"); @@ -469,7 +469,7 @@ private void registerItemBlocks(Set itemBlocks, BiConsumer builtinEntity(i, consumer)); + .forEach(i -> builtinEntity(i, consumer)); takeAll(itemBlocks, BotaniaBlocks.teruTeruBozu.asItem()) .forEach(i -> builtinEntity(i, consumer, 2.5)); diff --git a/Xplat/src/main/java/vazkii/botania/data/LooniumEquipmentLootProvider.java b/Xplat/src/main/java/vazkii/botania/data/LooniumEquipmentLootProvider.java index 119ac65a22..7bf97a9bb9 100644 --- a/Xplat/src/main/java/vazkii/botania/data/LooniumEquipmentLootProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/LooniumEquipmentLootProvider.java @@ -3,32 +3,28 @@ import net.minecraft.advancements.critereon.*; import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtOps; -import net.minecraft.resources.RegistryOps; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.effect.MobEffect; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.npc.VillagerProfession; import net.minecraft.world.item.*; -import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.armortrim.*; +import net.minecraft.world.item.component.DyedItemColor; import net.minecraft.world.level.storage.loot.LootContext; import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.entries.LootItem; -import net.minecraft.world.level.storage.loot.entries.LootTableReference; +import net.minecraft.world.level.storage.loot.entries.LootPoolSingletonContainer; +import net.minecraft.world.level.storage.loot.entries.NestedLootTable; import net.minecraft.world.level.storage.loot.functions.EnchantRandomlyFunction; -import net.minecraft.world.level.storage.loot.functions.SetNbtFunction; +import net.minecraft.world.level.storage.loot.functions.LootItemConditionalFunction; +import net.minecraft.world.level.storage.loot.functions.SetComponentsFunction; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.minecraft.world.level.storage.loot.predicates.AnyOfCondition; import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition; @@ -47,9 +43,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; -import java.util.function.BiConsumer; import java.util.function.BiFunction; -import java.util.function.Consumer; +import java.util.function.UnaryOperator; public class LooniumEquipmentLootProvider implements DataProvider { public static final int COLOR_ENDERMAN_BODY = 0x1d1d21; // (black) @@ -64,7 +59,7 @@ public class LooniumEquipmentLootProvider implements DataProvider { private final CompletableFuture registryLookupFuture; public LooniumEquipmentLootProvider(PackOutput packOutput, CompletableFuture registryLookupFuture) { - // NOTE: equipment loot tables become a vanilla feature in future versions + // TODO: refactor to use vanilla equipment table functionality this.pathProvider = packOutput.createPathProvider(PackOutput.Target.DATA_PACK, "loot_tables"); this.registryLookupFuture = registryLookupFuture; } @@ -80,17 +75,14 @@ private CompletableFuture run(@NotNull CachedOutput cache, HolderLookup.Provi HolderLookup.RegistryLookup materialRegistry = registryLookup.lookupOrThrow(Registries.TRIM_MATERIAL); BiFunction, ResourceKey, ArmorTrim> trimFactory = (pattern, material) -> getTrim(patternRegistry, materialRegistry, pattern, material); - BiConsumer trimSetter = (trim, tag) -> addTrimToTag(registryLookup, trim).accept(tag); BiFunction randomizedSetFactory = - (trim, armorItems) -> createArmorSet(addTrimToTag(registryLookup, trim), true, armorItems); + (trim, armorItems) -> createArmorSet(addTrim(trim), true, armorItems); TriFunction randomizedDyedSetFactory = - (trim, color, armorItems) -> createArmorSet(addTrimToTag(registryLookup, trim) - .andThen(addDyedColorToTag(color)), true, armorItems); + (trim, color, armorItems) -> createArmorSet(addTrimAndDye(trim, color), true, armorItems); TriFunction fixedDyedSetFactory = - (trim, color, armorItems) -> createArmorSet(addTrimToTag(registryLookup, trim) - .andThen(addDyedColorToTag(color)), false, armorItems); + (trim, color, armorItems) -> createArmorSet(addTrimAndDye(trim, color), false, armorItems); - Map armorItems = Map.of( + Map, Item[]> armorItems = Map.of( ArmorMaterials.LEATHER, new Item[] { Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS }, @@ -111,39 +103,41 @@ private CompletableFuture run(@NotNull CachedOutput cache, HolderLookup.Provi } ); - Map tables = new HashMap<>(); + Map, LootTable.Builder> tables = new HashMap<>(); - defineWeaponEquipmentTables(tables); + // TODO: weapon and armor tables should probably be embedded now instead of being separate references + defineWeaponEquipmentTables(tables, registryLookup); defineAncientCityEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); defineBastionRemnantEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); defineDesertPyramidEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); - defineEndCityEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); + defineEndCityEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory, registryLookup); defineJungleTempleEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); defineFortressEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); defineOceanMonumentEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory, randomizedDyedSetFactory); definePillagerOutpostEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); defineRuinedPortalEquipmentTables(tables); defineShipwreckEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); - defineStrongholdEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory, trimSetter); + defineStrongholdEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); defineTrailRuinsEquipmentTables(tables, armorItems, trimFactory, randomizedSetFactory); - defineWoodlandMansionEquipmentTables(tables, trimFactory, fixedDyedSetFactory, trimSetter); + // TODO add trial chamber equipment + defineWoodlandMansionEquipmentTables(tables, trimFactory, fixedDyedSetFactory, registryLookup); // TODO: we should be using LootTableSubProvider implementations instead of three individual loot providers var output = new ArrayList>(tables.size()); - for (Map.Entry e : tables.entrySet()) { - Path path = pathProvider.json(e.getKey()); + for (Map.Entry, LootTable.Builder> e : tables.entrySet()) { + Path path = pathProvider.json(e.getKey().location()); LootTable.Builder builder = e.getValue(); - // TODO 1.21: use LootContextParamSets.EQUIPMENT instead - LootTable lootTable = builder.setParamSet(LootContextParamSets.SELECTOR).build(); - output.add(DataProvider.saveStable(cache, LootTable.CODEC, lootTable, path)); + LootTable lootTable = builder.setParamSet(LootContextParamSets.EQUIPMENT).build(); + output.add(DataProvider.saveStable(cache, registryLookup, LootTable.DIRECT_CODEC, lootTable, path)); } return CompletableFuture.allOf(output.toArray(CompletableFuture[]::new)); } - private void defineWeaponEquipmentTables(Map tables) { + private void defineWeaponEquipmentTables(Map, LootTable.Builder> tables, + HolderLookup.Provider registries) { tables.put(BotaniaLootTables.LOONIUM_WEAPON_AXE, LootTable.lootTable().withPool(LootPool.lootPool() - .apply(EnchantRandomlyFunction.randomApplicableEnchantment() + .apply(EnchantRandomlyFunction.randomApplicableEnchantment(registries) .when(LootItemRandomChanceCondition.randomChance(0.3f))) .add(LootItem.lootTableItem(Items.IRON_AXE)) // no need to add diamond axe, it's the same base damage, but actually less enchantable @@ -151,27 +145,27 @@ private void defineWeaponEquipmentTables(Map tables, - Map armorItems, + private void defineAncientCityEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -260,41 +254,43 @@ private void defineAncientCityEquipmentTables(Map tables, - Map armorItems, + private void defineBastionRemnantEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -307,19 +303,19 @@ private void defineBastionRemnantEquipmentTables(Map tables, - Map armorItems, + private void defineDesertPyramidEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -333,27 +329,28 @@ private void defineDesertPyramidEquipmentTables(Map tables, - Map armorItems, + private void defineEndCityEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, - BiFunction randomizedSetFactory) { + BiFunction randomizedSetFactory, + HolderLookup.Provider registries) { ArmorTrim trimSpireAmethyst = trimFactory.apply(TrimPatterns.SPIRE, TrimMaterials.AMETHYST); tables.put(BotaniaLootTables.LOONIUM_ARMORSET_SPIRE_IRON, @@ -363,49 +360,52 @@ private void defineEndCityEquipmentTables(Map tables, - Map armorItems, + // TODO: was used for arbitrary tipped arrow effects +// private static CompoundTag getPotionEffectTag(MobEffect mobEffect, int duration) { +// // [VanillaCopy] based on PotionUtils::setCustomEffects +// ListTag effects = new ListTag(); +// effects.add(new MobEffectInstance(mobEffect, duration).save(new CompoundTag())); +// +// CompoundTag effectTag = new CompoundTag(); +// effectTag.put(PotionUtils.TAG_CUSTOM_POTION_EFFECTS, effects); +// effectTag.putInt(PotionUtils.TAG_CUSTOM_POTION_COLOR, mobEffect.getColor()); +// +// return effectTag; +// } + + private void defineFortressEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -419,25 +419,25 @@ private void defineFortressEquipmentTables(Map tables, - Map armorItems, + private void defineJungleTempleEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -451,30 +451,30 @@ private void defineJungleTempleEquipmentTables(Map tables, - Map armorItems, + private void defineOceanMonumentEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory, TriFunction randomizedDyedSetFactory) { @@ -488,30 +488,30 @@ private void defineOceanMonumentEquipmentTables(Map tables, - Map armorItems, + private void definePillagerOutpostEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -525,24 +525,24 @@ private void definePillagerOutpostEquipmentTables(Map tables) { + private void defineRuinedPortalEquipmentTables(Map, LootTable.Builder> tables) { tables.put(BotaniaLootTables.LOONIUM_ARMOR_PORTAL, LootTable.lootTable() @@ -559,35 +559,35 @@ private void defineRuinedPortalEquipmentTables(Map tables, - Map armorItems, + private void defineShipwreckEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -601,33 +601,32 @@ private void defineShipwreckEquipmentTables(Map tables, - Map armorItems, + private void defineStrongholdEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, - BiFunction randomizedSetFactory, - BiConsumer trimSetter) { + BiFunction randomizedSetFactory) { ArmorTrim trimEyeRedstone = trimFactory.apply(TrimPatterns.EYE, TrimMaterials.REDSTONE); ArmorTrim trimEyeLapis = trimFactory.apply(TrimPatterns.EYE, TrimMaterials.LAPIS); @@ -639,49 +638,45 @@ private void defineStrongholdEquipmentTables(Map tables, - Map armorItems, + private void defineTrailRuinsEquipmentTables(Map, LootTable.Builder> tables, + Map, Item[]> armorItems, BiFunction, ResourceKey, ArmorTrim> trimFactory, BiFunction randomizedSetFactory) { @@ -711,37 +706,37 @@ private void defineTrailRuinsEquipmentTables(Map tables, + private void defineWoodlandMansionEquipmentTables(Map, LootTable.Builder> tables, BiFunction, ResourceKey, ArmorTrim> trimFactory, TriFunction fixedDyedSetFactory, - BiConsumer trimSetter) { + HolderLookup.Provider registries) { // Evoker cosplay, with higher likelihood of holding a totem tables.put(BotaniaLootTables.LOONIUM_ARMORSET_COSTUME_EVOKER, fixedDyedSetFactory.apply( @@ -754,68 +749,63 @@ private void defineWoodlandMansionEquipmentTables(Map patter return new ArmorTrim(goldMaterial, tidePattern); } - private static Consumer addTrimToTag(HolderLookup.Provider registryLookup, ArmorTrim trim) { - // [VanillaCopy] from ArmorTrim::setTrim, because no access to item tags here - return tag -> tag.put(ArmorTrim.TAG_TRIM_ID, - ArmorTrim.CODEC.encodeStart(RegistryOps.create(NbtOps.INSTANCE, registryLookup), trim) - .result().orElseThrow()); + private static UnaryOperator> addTrim(ArmorTrim trim) { + return builder -> builder.apply(setTrim(trim)); + } + + private static UnaryOperator> addTrimAndDye(ArmorTrim trim, int color) { + return builder -> builder.apply(setTrim(trim)).apply(setDyedColor(color)); + } + + private static LootItemConditionalFunction.Builder setTrim(ArmorTrim trim) { + return SetComponentsFunction.setComponent(DataComponents.TRIM, trim); } - private static Consumer addDyedColorToTag(int color) { - // [VanillaCopy] implementation based on DyeableLeatherItem::setColor - CompoundTag displayTag = new CompoundTag(); - displayTag.putInt("color", color); - return tag -> tag.put("display", displayTag); + private static LootItemConditionalFunction.Builder setDyedColor(int color) { + return SetComponentsFunction.setComponent(DataComponents.DYED_COLOR, new DyedItemColor(color, true)); } - private LootTable.Builder createArmorSet(Consumer tagModifier, boolean randomized, Item... armorItems) { - CompoundTag tag = new CompoundTag(); - tagModifier.accept(tag); + private LootTable.Builder createArmorSet(UnaryOperator> armorModifier, boolean randomized, Item... armorItems) { LootTable.Builder lootTable = LootTable.lootTable(); for (Item armorItem : armorItems) { lootTable.withPool(LootPool.lootPool() .setRolls(randomized ? UniformGenerator.between(0, 1) : ConstantValue.exactly(1)) - .add(LootItem.lootTableItem(armorItem).apply(SetNbtFunction.setTag(tag)))); + .add(armorModifier.apply(LootItem.lootTableItem(armorItem)))); } return lootTable; } diff --git a/Xplat/src/main/java/vazkii/botania/data/LooniumStructureConfigurationProvider.java b/Xplat/src/main/java/vazkii/botania/data/LooniumStructureConfigurationProvider.java index 57ee7999e7..9d509499f3 100644 --- a/Xplat/src/main/java/vazkii/botania/data/LooniumStructureConfigurationProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/LooniumStructureConfigurationProvider.java @@ -5,12 +5,14 @@ import com.mojang.serialization.Dynamic; import com.mojang.serialization.JsonOps; +import net.minecraft.core.HolderLookup; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.Tag; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.EntityType; @@ -21,6 +23,7 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; import net.minecraft.world.level.levelgen.structure.StructureSpawnOverride; +import net.minecraft.world.level.storage.loot.LootTable; import org.jetbrains.annotations.NotNull; @@ -42,17 +45,23 @@ public class LooniumStructureConfigurationProvider implements DataProvider { - public static final String LOONIUM_MODIFIER_DAMAGE = "Loonium Modifier Damage"; - public static final String LOONIUM_MODIFIER_HEALTH = "Loonium Modifier Health"; + public static final ResourceLocation LOONIUM_MODIFIER_DAMAGE = botaniaRL("loonium_modifier_damage"); + public static final ResourceLocation LOONIUM_MODIFIER_HEALTH = botaniaRL("loonium_modifier_health"); private final PackOutput.PathProvider pathProvider; + private final CompletableFuture registryLookupFuture; - public LooniumStructureConfigurationProvider(PackOutput packOutput) { + public LooniumStructureConfigurationProvider(PackOutput packOutput, CompletableFuture registryLookupFuture) { pathProvider = packOutput.createPathProvider(PackOutput.Target.DATA_PACK, "loonium_config"); + this.registryLookupFuture = registryLookupFuture; } @NotNull @Override public CompletableFuture run(@NotNull CachedOutput cache) { + return registryLookupFuture.thenCompose(registryLookup -> this.run(cache, registryLookup)); + } + + private CompletableFuture run(@NotNull CachedOutput cache, HolderLookup.Provider registries) { Map configs = new HashMap<>(); addConfigs(configs); @@ -61,7 +70,7 @@ public CompletableFuture run(@NotNull CachedOutput cache) { Path path = pathProvider.json(e.getKey()); LooniumStructureConfiguration config = e.getValue(); JsonElement jsonTree = LooniumStructureConfiguration.CODEC.encodeStart(JsonOps.INSTANCE, config) - .getOrThrow(false, BotaniaAPI.LOGGER::error); + .getOrThrow(); output.add(DataProvider.saveStable(cache, jsonTree, path)); } return CompletableFuture.allOf(output.toArray(CompletableFuture[]::new)); @@ -141,9 +150,9 @@ public static LooniumStructureConfiguration getDefaultConfig() { ) .attributeModifiers( new LooniumMobAttributeModifier(LOONIUM_MODIFIER_HEALTH, - Attributes.MAX_HEALTH, 2, AttributeModifier.Operation.MULTIPLY_BASE), + Attributes.MAX_HEALTH, 2, AttributeModifier.Operation.ADD_MULTIPLIED_BASE), new LooniumMobAttributeModifier(LOONIUM_MODIFIER_DAMAGE, - Attributes.ATTACK_DAMAGE, 1.5, AttributeModifier.Operation.MULTIPLY_BASE) + Attributes.ATTACK_DAMAGE, 1.5, AttributeModifier.Operation.ADD_MULTIPLIED_BASE) ) .effectsToApply(getStandardEffects(false, true)) .build(); @@ -179,9 +188,9 @@ public static LooniumStructureConfiguration getConfigBastionRemnant(ResourceLoca .equipmentTable(BotaniaLootTables.LOONIUM_WEAPON_AXE_GOLD) .attributeModifiers( new LooniumMobAttributeModifier(LOONIUM_MODIFIER_HEALTH, - Attributes.MAX_HEALTH, 1.5, AttributeModifier.Operation.MULTIPLY_BASE), + Attributes.MAX_HEALTH, 1.5, AttributeModifier.Operation.ADD_MULTIPLIED_BASE), new LooniumMobAttributeModifier(LOONIUM_MODIFIER_DAMAGE, - Attributes.ATTACK_DAMAGE, 1.5, AttributeModifier.Operation.MULTIPLY_BASE) + Attributes.ATTACK_DAMAGE, 1.5, AttributeModifier.Operation.ADD_MULTIPLIED_BASE) ) .build(), LooniumMobSpawnData.entityWeight(EntityType.HOGLIN, 300).spawnAsAdult().build() @@ -719,7 +728,7 @@ public static LooniumMobSpawnData getCreeperSpawnData(int weight, boolean charge .build(); } - public static LooniumMobSpawnData getPiglinSpawnData(int weight, ResourceLocation equipmentTable, + public static LooniumMobSpawnData getPiglinSpawnData(int weight, ResourceKey equipmentTable, boolean needWaterBreathing, boolean zombificationImmune) { CompoundTag piglinNbt = new CompoundTag(); if (zombificationImmune) { diff --git a/Xplat/src/main/java/vazkii/botania/data/LooniumStructureLootProvider.java b/Xplat/src/main/java/vazkii/botania/data/LooniumStructureLootProvider.java index 9059fe2b33..b4170692f3 100644 --- a/Xplat/src/main/java/vazkii/botania/data/LooniumStructureLootProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/LooniumStructureLootProvider.java @@ -1,5 +1,7 @@ package vazkii.botania.data; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.registries.Registries; import net.minecraft.data.CachedOutput; import net.minecraft.data.DataProvider; import net.minecraft.data.PackOutput; @@ -13,7 +15,7 @@ import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.level.storage.loot.entries.LootItem; -import net.minecraft.world.level.storage.loot.entries.LootTableReference; +import net.minecraft.world.level.storage.loot.entries.NestedLootTable; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import org.jetbrains.annotations.NotNull; @@ -38,40 +40,46 @@ public class LooniumStructureLootProvider implements DataProvider { .of(VillageLoot.CARTOGRAPHER, VillageLoot.FLETCHER, VillageLoot.TANNERY, VillageLoot.TOOLSMITH, VillageLoot.WEAPONSMITH); private final PackOutput.PathProvider pathProvider; + private final CompletableFuture registryLookupFuture; - public LooniumStructureLootProvider(PackOutput packOutput) { + public LooniumStructureLootProvider(PackOutput packOutput, CompletableFuture registryLookupFuture) { this.pathProvider = packOutput.createPathProvider(PackOutput.Target.DATA_PACK, "loot_tables/loonium"); + this.registryLookupFuture = registryLookupFuture; } - public static ResourceLocation getStructureId(ResourceKey structureKey) { + public static ResourceKey getStructureId(ResourceKey structureKey) { return getStructureId(structureKey.location()); } - public static ResourceLocation getStructureId(ResourceLocation structureId) { - return botaniaRL("%s/%s".formatted(structureId.getNamespace(), structureId.getPath())); + public static ResourceKey getStructureId(ResourceLocation structureId) { + return ResourceKey.create(Registries.LOOT_TABLE, botaniaRL("%s/%s".formatted(structureId.getNamespace(), structureId.getPath()))); } @NotNull @Override public CompletableFuture run(@NotNull CachedOutput cache) { - Map tables = new HashMap<>(); + return registryLookupFuture.thenCompose(registryLookup -> this.run(cache, registryLookup)); + } + + private CompletableFuture run(@NotNull CachedOutput cache, HolderLookup.Provider registries) { + Map, LootTable.Builder> tables = new HashMap<>(); addLootTables(tables); var output = new ArrayList>(tables.size()); - for (Map.Entry e : tables.entrySet()) { - Path path = pathProvider.json(e.getKey()); + for (Map.Entry, LootTable.Builder> e : tables.entrySet()) { + Path path = pathProvider.json(e.getKey().location()); LootTable.Builder builder = e.getValue(); LootTable lootTable = builder.setParamSet(LootContextParamSets.ALL_PARAMS).build(); - JsonElement jsonTree = Deserializers.createLootTableSerializer().create().toJsonTree(lootTable); - output.add(DataProvider.saveStable(cache, LootTable.CODEC, lootTable, path)); + output.add(DataProvider.saveStable(cache, registries, LootTable.DIRECT_CODEC, lootTable, path)); } return CompletableFuture.allOf(output.toArray(CompletableFuture[]::new)); } - private void addLootTables(Map tables) { + private void addLootTables(Map, LootTable.Builder> tables) { // Note: As far as world generating is concerned, dungeons are "features" (i.e. like trees or geodes), // not "structures" (like everything else the Loonium might care about). - tables.put(botaniaRL("default"), buildDelegateLootTable(BuiltInLootTables.SIMPLE_DUNGEON)); + tables.put(ResourceKey.create(Registries.LOOT_TABLE, botaniaRL("default")), + buildDelegateLootTable(BuiltInLootTables.SIMPLE_DUNGEON)); /* Note: Be careful about adding individual items instead of loot table references. @@ -83,30 +91,30 @@ private void addLootTables(Map tables) { tables.put(getStructureId(BuiltinStructures.ANCIENT_CITY), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.ANCIENT_CITY).setWeight(9)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.ANCIENT_CITY_ICE_BOX).setWeight(1)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.ANCIENT_CITY).setWeight(9)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.ANCIENT_CITY_ICE_BOX).setWeight(1)) ) ); tables.put(getStructureId(BuiltinStructures.BASTION_REMNANT), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.BASTION_BRIDGE).setWeight(1)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.BASTION_HOGLIN_STABLE).setWeight(1)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.BASTION_TREASURE).setWeight(1)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.BASTION_OTHER).setWeight(7)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.BASTION_BRIDGE).setWeight(1)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.BASTION_HOGLIN_STABLE).setWeight(1)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.BASTION_TREASURE).setWeight(1)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.BASTION_OTHER).setWeight(7)) ) ); tables.put(getStructureId(BuiltinStructures.BURIED_TREASURE), buildDelegateLootTable(BuiltInLootTables.BURIED_TREASURE)); tables.put(getStructureId(BuiltinStructures.DESERT_PYRAMID), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.DESERT_PYRAMID).setWeight(37)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY).setWeight(2)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.DESERT_PYRAMID).setWeight(37)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY).setWeight(2)) // desert wells are features, so not detectable by the Loonium - .add(LootTableReference.lootTableReference(BuiltInLootTables.DESERT_WELL_ARCHAEOLOGY)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.DESERT_WELL_ARCHAEOLOGY)) ) ); tables.put(getStructureId(BuiltinStructures.END_CITY), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.END_CITY_TREASURE).setWeight(49)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.END_CITY_TREASURE).setWeight(49)) .add(LootItem.lootTableItem(Items.ELYTRA)) ) ); @@ -114,15 +122,15 @@ private void addLootTables(Map tables) { // skipping igloo, because the laboratory piece, which is the only part that has loot, can't be detected reliably tables.put(getStructureId(BuiltinStructures.JUNGLE_TEMPLE), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.JUNGLE_TEMPLE).setWeight(9)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.JUNGLE_TEMPLE_DISPENSER)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.JUNGLE_TEMPLE).setWeight(9)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.JUNGLE_TEMPLE_DISPENSER)) ) ); tables.put(getStructureId(BuiltinStructures.MINESHAFT), buildDelegateLootTable(BuiltInLootTables.ABANDONED_MINESHAFT)); tables.put(getStructureId(BuiltinStructures.MINESHAFT_MESA), buildDelegateLootTable(BuiltInLootTables.ABANDONED_MINESHAFT)); tables.put(getStructureId(BuiltinStructures.OCEAN_MONUMENT), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(EntityType.ELDER_GUARDIAN.getDefaultLootTable()).setWeight(5)) + .add(NestedLootTable.lootTableReference(EntityType.ELDER_GUARDIAN.getDefaultLootTable()).setWeight(5)) // sponge is a player-kill drop and won't be rolled for the elder guardian table by the Loonium .add(LootItem.lootTableItem(Items.WET_SPONGE)) @@ -147,9 +155,9 @@ private void addLootTables(Map tables) { tables.put(getStructureId(BuiltinStructures.STRONGHOLD), // Strongholds generate up to 4 corridor chests, up to 6 crossings, and up to 2 libraries with 1 or 2 chests LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.STRONGHOLD_CORRIDOR).setWeight(4)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.STRONGHOLD_CROSSING).setWeight(6)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.STRONGHOLD_LIBRARY).setWeight(3)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.STRONGHOLD_CORRIDOR).setWeight(4)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.STRONGHOLD_CROSSING).setWeight(6)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.STRONGHOLD_LIBRARY).setWeight(3)) ) ); // skipping swamp hut, because it doesn't contain unique loot (could merge witch/cat tables, I guess) @@ -157,8 +165,8 @@ private void addLootTables(Map tables) { // Trail ruins have 2 common suspicious gravel for the tower top and each road section, // and 6 common plus 3 rare suspicious gravel per building and for the tower bottom. LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.TRAIL_RUINS_ARCHAEOLOGY_COMMON).setWeight(9)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.TRAIL_RUINS_ARCHAEOLOGY_RARE)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.TRAIL_RUINS_ARCHAEOLOGY_COMMON).setWeight(9)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.TRAIL_RUINS_ARCHAEOLOGY_RARE)) ) ); tables.put(getStructureId(BuiltinStructures.VILLAGE_PLAINS), @@ -178,16 +186,16 @@ private void addLootTables(Map tables) { ); tables.put(getStructureId(BuiltinStructures.WOODLAND_MANSION), LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.WOODLAND_MANSION).setWeight(99)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.WOODLAND_MANSION).setWeight(99)) .add(LootItem.lootTableItem(Items.TOTEM_OF_UNDYING).setWeight(1)) ) ); } - public static LootTable.Builder buildVillageLootTable(ResourceLocation house, Set villageLootSet) { - LootPool.Builder lootPool = LootPool.lootPool().add(LootTableReference.lootTableReference(house).setWeight(3)); + public static LootTable.Builder buildVillageLootTable(ResourceKey house, Set villageLootSet) { + LootPool.Builder lootPool = LootPool.lootPool().add(NestedLootTable.lootTableReference(house).setWeight(3)); for (VillageLoot loot : villageLootSet) { - lootPool.add(LootTableReference.lootTableReference(loot.lootTable)); + lootPool.add(NestedLootTable.lootTableReference(loot.lootTable)); } return LootTable.lootTable().withPool(lootPool); } @@ -195,28 +203,28 @@ public static LootTable.Builder buildVillageLootTable(ResourceLocation house, Se @NotNull public static LootTable.Builder buildShipwreckLootTable() { return LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(BuiltInLootTables.SHIPWRECK_MAP)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.SHIPWRECK_SUPPLY)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.SHIPWRECK_TREASURE)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.SHIPWRECK_MAP)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.SHIPWRECK_SUPPLY)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.SHIPWRECK_TREASURE)) ); } @NotNull - public static LootTable.Builder buildDelegateLootTable(ResourceLocation reference) { + public static LootTable.Builder buildDelegateLootTable(ResourceKey reference) { return LootTable.lootTable().withPool(LootPool.lootPool() - .add(LootTableReference.lootTableReference(reference)) + .add(NestedLootTable.lootTableReference(reference)) ); } @NotNull - public static LootTable.Builder buildOceanRuinLootTable(ResourceLocation archaeology) { + public static LootTable.Builder buildOceanRuinLootTable(ResourceKey archaeology) { // Note: since the Loonium does not supply a location, treasure maps will roll as empty maps return LootTable.lootTable().withPool(LootPool.lootPool() // 30% of ocean ruin sites generate with a big ruin instead of a small one, // but 90% of those big ruin sites additionally generate 4-8 small ruins around the big one. - .add(LootTableReference.lootTableReference(BuiltInLootTables.UNDERWATER_RUIN_BIG)) - .add(LootTableReference.lootTableReference(BuiltInLootTables.UNDERWATER_RUIN_SMALL).setWeight(8)) - .add(LootTableReference.lootTableReference(archaeology)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.UNDERWATER_RUIN_BIG)) + .add(NestedLootTable.lootTableReference(BuiltInLootTables.UNDERWATER_RUIN_SMALL).setWeight(8)) + .add(NestedLootTable.lootTableReference(archaeology)) ); } @@ -239,9 +247,9 @@ public enum VillageLoot { TANNERY(BuiltInLootTables.VILLAGE_TANNERY), TEMPLE(BuiltInLootTables.VILLAGE_TEMPLE); - public final ResourceLocation lootTable; + public final ResourceKey lootTable; - VillageLoot(ResourceLocation lootTable) { + VillageLoot(ResourceKey lootTable) { this.lootTable = lootTable; } } diff --git a/Xplat/src/main/java/vazkii/botania/data/package-info.java b/Xplat/src/main/java/vazkii/botania/data/package-info.java new file mode 100644 index 0000000000..3d914df0cb --- /dev/null +++ b/Xplat/src/main/java/vazkii/botania/data/package-info.java @@ -0,0 +1,19 @@ +/* + * This class is distributed as part of the Botania Mod. + * Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + * + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package vazkii.botania.data; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java b/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java index 8ea79b32ce..7898f06963 100644 --- a/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java +++ b/Xplat/src/main/java/vazkii/botania/data/recipes/ManaInfusionProvider.java @@ -29,9 +29,6 @@ import vazkii.botania.common.helper.ColorHelper; import vazkii.botania.common.item.BotaniaItems; -import java.util.Arrays; -import java.util.function.Consumer; - import static vazkii.botania.api.BotaniaAPI.botaniaRL; public class ManaInfusionProvider extends BotaniaRecipeProvider { diff --git a/Xplat/src/main/java/vazkii/botania/mixin/AbstractFurnaceBlockEntityAccessor.java b/Xplat/src/main/java/vazkii/botania/mixin/AbstractFurnaceBlockEntityAccessor.java index dc729f0ba0..43caf99c88 100644 --- a/Xplat/src/main/java/vazkii/botania/mixin/AbstractFurnaceBlockEntityAccessor.java +++ b/Xplat/src/main/java/vazkii/botania/mixin/AbstractFurnaceBlockEntityAccessor.java @@ -9,10 +9,10 @@ package vazkii.botania.mixin; import net.minecraft.core.NonNullList; -import net.minecraft.world.Container; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeManager; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import org.spongepowered.asm.mixin.Mixin; @@ -24,7 +24,7 @@ public interface AbstractFurnaceBlockEntityAccessor { NonNullList getItems(); @Accessor("quickCheck") - RecipeManager.CachedCheck getQuickCheck(); + RecipeManager.CachedCheck getQuickCheck(); @Accessor int getLitTime(); diff --git a/Xplat/src/main/java/vazkii/botania/mixin/MushroomCowAccessor.java b/Xplat/src/main/java/vazkii/botania/mixin/MushroomCowAccessor.java index b786b7f219..e485f31a74 100644 --- a/Xplat/src/main/java/vazkii/botania/mixin/MushroomCowAccessor.java +++ b/Xplat/src/main/java/vazkii/botania/mixin/MushroomCowAccessor.java @@ -1,20 +1,18 @@ package vazkii.botania.mixin; import net.minecraft.world.entity.animal.MushroomCow; -import net.minecraft.world.level.block.SuspiciousEffectHolder; +import net.minecraft.world.item.component.SuspiciousStewEffects; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.List; - @Mixin(MushroomCow.class) public interface MushroomCowAccessor { @Accessor @Nullable - List getStewEffects(); + SuspiciousStewEffects getStewEffects(); @Accessor - void setStewEffects(@Nullable List stewEffects); + void setStewEffects(@Nullable SuspiciousStewEffects stewEffects); } diff --git a/Xplat/src/main/java/vazkii/botania/mixin/RecipeProviderAccessor.java b/Xplat/src/main/java/vazkii/botania/mixin/RecipeProviderAccessor.java index 015fcf9ebe..e76099d50f 100644 --- a/Xplat/src/main/java/vazkii/botania/mixin/RecipeProviderAccessor.java +++ b/Xplat/src/main/java/vazkii/botania/mixin/RecipeProviderAccessor.java @@ -12,9 +12,6 @@ import net.minecraft.advancements.critereon.InventoryChangeTrigger; import net.minecraft.advancements.critereon.ItemPredicate; import net.minecraft.data.recipes.RecipeProvider; -import net.minecraft.tags.TagKey; -import net.minecraft.world.item.Item; -import net.minecraft.world.level.ItemLike; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; diff --git a/Xplat/src/main/java/vazkii/botania/network/clientbound/AvatarSkiesRodPacket.java b/Xplat/src/main/java/vazkii/botania/network/clientbound/AvatarSkiesRodPacket.java index c6c30f79f0..f4b937cbb8 100644 --- a/Xplat/src/main/java/vazkii/botania/network/clientbound/AvatarSkiesRodPacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/clientbound/AvatarSkiesRodPacket.java @@ -11,13 +11,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; - -import io.netty.buffer.ByteBuf; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; + import vazkii.botania.common.item.rod.SkiesRodItem; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public record AvatarSkiesRodPacket(boolean elytra) implements CustomPacketPayload { public static final Type ID = new Type<>(botaniaRL("atr")); public static final StreamCodec STREAM_CODEC = ByteBufCodecs.BOOL diff --git a/Xplat/src/main/java/vazkii/botania/network/clientbound/BotaniaEffectPacket.java b/Xplat/src/main/java/vazkii/botania/network/clientbound/BotaniaEffectPacket.java index 85bb945fe3..b226cc4dbf 100644 --- a/Xplat/src/main/java/vazkii/botania/network/clientbound/BotaniaEffectPacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/clientbound/BotaniaEffectPacket.java @@ -24,7 +24,6 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.phys.Vec3; -import io.netty.buffer.ByteBuf; import vazkii.botania.client.fx.SparkleParticleData; import vazkii.botania.client.fx.WispParticleData; import vazkii.botania.common.block.block_entity.TerrestrialAgglomerationPlateBlockEntity; @@ -36,10 +35,10 @@ import vazkii.botania.common.proxy.Proxy; import vazkii.botania.network.EffectType; -import java.util.ArrayList; - import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + // Prefer using World.addBlockEvent/Block.eventReceived/TileEntity.receiveClientEvent where possible // as those use less network bandwidth (~14 bytes), vs 26+ bytes here public record BotaniaEffectPacket(EffectType effectType, double x, double y, double z, int... args) implements CustomPacketPayload { @@ -51,8 +50,8 @@ public record BotaniaEffectPacket(EffectType effectType, double x, double y, dou ByteBufCodecs.DOUBLE, BotaniaEffectPacket::x, ByteBufCodecs.DOUBLE, BotaniaEffectPacket::y, ByteBufCodecs.DOUBLE, BotaniaEffectPacket::z, - ByteBufCodecs.VAR_INT.apply(ByteBufCodecs.list()).map(Ints::toArray, is -> Ints.asList((int[])is)), BotaniaEffectPacket::args, - (type, x, y, z, args) -> new BotaniaEffectPacket(type, x, y, z, (int[])args) + ByteBufCodecs.VAR_INT.apply(ByteBufCodecs.list()).map(Ints::toArray, is -> Ints.asList((int[]) is)), BotaniaEffectPacket::args, + (type, x, y, z, args) -> new BotaniaEffectPacket(type, x, y, z, (int[]) args) ); @Override diff --git a/Xplat/src/main/java/vazkii/botania/network/clientbound/GogWorldPacket.java b/Xplat/src/main/java/vazkii/botania/network/clientbound/GogWorldPacket.java index 07c096a098..273cc60552 100644 --- a/Xplat/src/main/java/vazkii/botania/network/clientbound/GogWorldPacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/clientbound/GogWorldPacket.java @@ -10,13 +10,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.network.codec.StreamCodec; - -import io.netty.buffer.ByteBuf; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; + import vazkii.botania.client.core.SkyblockWorldInfo; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public class GogWorldPacket implements CustomPacketPayload { public static final GogWorldPacket INSTANCE = new GogWorldPacket(); public static final Type ID = new Type<>(botaniaRL("gog")); diff --git a/Xplat/src/main/java/vazkii/botania/network/clientbound/ItemAgePacket.java b/Xplat/src/main/java/vazkii/botania/network/clientbound/ItemAgePacket.java index 0fd86345aa..356be38da8 100644 --- a/Xplat/src/main/java/vazkii/botania/network/clientbound/ItemAgePacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/clientbound/ItemAgePacket.java @@ -15,11 +15,12 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; -import io.netty.buffer.ByteBuf; import vazkii.botania.xplat.XplatAbstractions; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public record ItemAgePacket(int entityId, int timeCounter) implements CustomPacketPayload { public static final Type ID = new Type<>(botaniaRL("ia")); diff --git a/Xplat/src/main/java/vazkii/botania/network/serverbound/DodgePacket.java b/Xplat/src/main/java/vazkii/botania/network/serverbound/DodgePacket.java index 9241223ba6..e556df1e53 100644 --- a/Xplat/src/main/java/vazkii/botania/network/serverbound/DodgePacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/serverbound/DodgePacket.java @@ -16,15 +16,15 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.world.item.ItemStack; -import io.netty.buffer.ByteBuf; import vazkii.botania.common.handler.BotaniaSounds; import vazkii.botania.common.handler.EquipmentHandler; -import vazkii.botania.common.helper.ItemNBTHelper; import vazkii.botania.common.item.BotaniaItems; import vazkii.botania.common.item.equipment.bauble.RingOfDexterousMotionItem; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public class DodgePacket implements CustomPacketPayload { public static final DodgePacket INSTANCE = new DodgePacket(); public static final Type ID = new Type<>(botaniaRL("do")); diff --git a/Xplat/src/main/java/vazkii/botania/network/serverbound/IndexStringRequestPacket.java b/Xplat/src/main/java/vazkii/botania/network/serverbound/IndexStringRequestPacket.java index 3c90565e68..20dc2bc9e2 100644 --- a/Xplat/src/main/java/vazkii/botania/network/serverbound/IndexStringRequestPacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/serverbound/IndexStringRequestPacket.java @@ -6,11 +6,12 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; -import io.netty.buffer.ByteBuf; import vazkii.botania.common.block.block_entity.corporea.CorporeaIndexBlockEntity; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public record IndexStringRequestPacket(String message) implements CustomPacketPayload { public static final Type ID = new Type<>(botaniaRL("idxs")); public static final StreamCodec STREAM_CODEC = ByteBufCodecs.STRING_UTF8 diff --git a/Xplat/src/main/java/vazkii/botania/network/serverbound/JumpPacket.java b/Xplat/src/main/java/vazkii/botania/network/serverbound/JumpPacket.java index a39379c82f..fbc2b814fb 100644 --- a/Xplat/src/main/java/vazkii/botania/network/serverbound/JumpPacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/serverbound/JumpPacket.java @@ -14,12 +14,13 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; -import io.netty.buffer.ByteBuf; import vazkii.botania.common.handler.EquipmentHandler; import vazkii.botania.common.item.equipment.bauble.CirrusAmuletItem; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public class JumpPacket implements CustomPacketPayload { public static final JumpPacket INSTANCE = new JumpPacket(); public static final Type ID = new Type<>(botaniaRL("jmp")); diff --git a/Xplat/src/main/java/vazkii/botania/network/serverbound/LeftClickPacket.java b/Xplat/src/main/java/vazkii/botania/network/serverbound/LeftClickPacket.java index 763d4d27cb..e654a6077b 100644 --- a/Xplat/src/main/java/vazkii/botania/network/serverbound/LeftClickPacket.java +++ b/Xplat/src/main/java/vazkii/botania/network/serverbound/LeftClickPacket.java @@ -13,11 +13,12 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; -import io.netty.buffer.ByteBuf; import vazkii.botania.common.item.equipment.tool.terrasteel.TerraBladeItem; import static vazkii.botania.api.BotaniaAPI.botaniaRL; +import io.netty.buffer.ByteBuf; + public class LeftClickPacket implements CustomPacketPayload { public static final LeftClickPacket INSTANCE = new LeftClickPacket(); public static final Type ID = new Type<>(botaniaRL("lc")); diff --git a/Xplat/src/main/java/vazkii/botania/test/TestingUtil.java b/Xplat/src/main/java/vazkii/botania/test/TestingUtil.java index 9aba0dee7a..ded276dd6b 100644 --- a/Xplat/src/main/java/vazkii/botania/test/TestingUtil.java +++ b/Xplat/src/main/java/vazkii/botania/test/TestingUtil.java @@ -19,6 +19,7 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.phys.BlockHitResult; @@ -115,7 +116,7 @@ public static void useItemOn(GameTestHelper helper, Player player, InteractionHa public static void bindWithWandOfTheForest(GameTestHelper helper, BlockPos first, BlockPos second) { //Conjure a player with Wand of the Forest - Player player = helper.makeMockPlayer(); + Player player = helper.makeMockPlayer(GameType.CREATIVE); player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(BotaniaItems.twigWand)); player.setShiftKeyDown(true); diff --git a/Xplat/src/main/java/vazkii/botania/test/block/BindingTest.java b/Xplat/src/main/java/vazkii/botania/test/block/BindingTest.java index dd490be440..ae1609180a 100644 --- a/Xplat/src/main/java/vazkii/botania/test/block/BindingTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/block/BindingTest.java @@ -15,6 +15,7 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -112,7 +113,7 @@ private void obedienceStickTest(GameTestHelper helper, Block bindTargetBlock, Bl BlockPos absoluteBindTarget = TestingUtil.assertAnyBlockEntity(helper, middle).getBlockPos(); //Use a Floral Obedience Stick on the pool - Player player = helper.makeMockPlayer(); + Player player = helper.makeMockPlayer(GameType.CREATIVE); player.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(BotaniaItems.obedienceStick)); TestingUtil.useItemOn(helper, player, InteractionHand.MAIN_HAND, middle); diff --git a/Xplat/src/main/java/vazkii/botania/test/block/DrumBlockTest.java b/Xplat/src/main/java/vazkii/botania/test/block/DrumBlockTest.java index ddafddc93e..2a8f8f90fe 100644 --- a/Xplat/src/main/java/vazkii/botania/test/block/DrumBlockTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/block/DrumBlockTest.java @@ -11,6 +11,8 @@ import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.animal.MushroomCow; import net.minecraft.world.item.*; +import net.minecraft.world.item.component.SuspiciousStewEffects; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.SuspiciousEffectHolder; import net.minecraft.world.phys.Vec3; @@ -35,7 +37,7 @@ public class DrumBlockTest { private static final Vec3 VECTOR_MOB = POSITION_MOB.getCenter(); private static T setup(GameTestHelper helper, EntityType entityType, @Nullable Item item) { - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); var spreader = TestingUtil.assertBlockEntity(helper, POSITION_SPREADER, BotaniaBlockEntities.SPREADER); TestingUtil.assertThat(spreader.bindTo(player, new ItemStack(BotaniaItems.twigWand), helper.absolutePos(POSITION_DRUM), Direction.UP), @@ -79,7 +81,7 @@ public void testMilkingBrownMooshroomSuspiciousStew(GameTestHelper helper) { var cow = setup(helper, EntityType.MOOSHROOM, Items.BOWL); cow.setVariant(MushroomCow.MushroomType.BROWN); var cowAccessor = (MushroomCowAccessor) cow; - cowAccessor.setStewEffects(List.of(new SuspiciousEffectHolder.EffectEntry(MobEffects.BLINDNESS, 15))); + cowAccessor.setStewEffects(new SuspiciousStewEffects(List.of(new SuspiciousStewEffects.Entry(MobEffects.BLINDNESS, 15)))); helper.startSequence() .thenExecute(() -> helper.pressButton(POSITION_BUTTON)) .thenWaitUntil(() -> helper.assertItemEntityPresent(Items.SUSPICIOUS_STEW, POSITION_MOB, 1.0)) diff --git a/Xplat/src/main/java/vazkii/botania/test/block/EntropinnyumUnethicalTntDetectionTest.java b/Xplat/src/main/java/vazkii/botania/test/block/EntropinnyumUnethicalTntDetectionTest.java index 1dd3188bbe..5ea652920f 100644 --- a/Xplat/src/main/java/vazkii/botania/test/block/EntropinnyumUnethicalTntDetectionTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/block/EntropinnyumUnethicalTntDetectionTest.java @@ -7,6 +7,7 @@ import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; import vazkii.botania.common.block.BotaniaBlocks; @@ -54,7 +55,7 @@ private static Runnable checkEntropinnyumForUnethicalManaAmount(GameTestHelper h public void testForceLensDuper(GameTestHelper helper) { helper.startSequence() .thenExecute(() -> { - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); var spreader = TestingUtil.assertBlockEntity(helper, POSITION_FORCE_LENS_MANA_SPREADER, BotaniaBlockEntities.SPREADER); TestingUtil.assertThat(spreader.bindTo(player, new ItemStack(BotaniaItems.twigWand), helper.absolutePos(POSITION_FORCE_LENS_PUSHED_SLIME_BLOCK), Direction.UP), diff --git a/Xplat/src/main/java/vazkii/botania/test/block/ManaSpreaderTest.java b/Xplat/src/main/java/vazkii/botania/test/block/ManaSpreaderTest.java index ff529fe7b0..ca11140692 100644 --- a/Xplat/src/main/java/vazkii/botania/test/block/ManaSpreaderTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/block/ManaSpreaderTest.java @@ -5,6 +5,7 @@ import net.minecraft.gametest.framework.GameTest; import net.minecraft.gametest.framework.GameTestHelper; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; import vazkii.botania.common.item.BotaniaItems; @@ -20,7 +21,7 @@ public class ManaSpreaderTest { @GameTest(template = "botania:block/spreader_pool_default_aim") public void testSpreaderDefaultAimHittingPool(GameTestHelper helper) { - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); // point the spreaders at their corresponding sink block to aim them exactly horizontally for (int i = 0; i < NUM_SPREADERS; i++) { diff --git a/Xplat/src/main/java/vazkii/botania/test/block/TargetBlockTest.java b/Xplat/src/main/java/vazkii/botania/test/block/TargetBlockTest.java index fcee1a7c5a..7d5d8b1391 100644 --- a/Xplat/src/main/java/vazkii/botania/test/block/TargetBlockTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/block/TargetBlockTest.java @@ -4,6 +4,7 @@ import net.minecraft.core.Direction; import net.minecraft.gametest.framework.*; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.RedstoneLampBlock; import vazkii.botania.common.block.block_entity.BotaniaBlockEntities; @@ -18,7 +19,7 @@ public void testFakeBurstNoShooty(GameTestHelper helper) { var spreaderPos = new BlockPos(5, 2, 5); var lampPos = new BlockPos(3, 3, 5); var bindPos = new BlockPos(3, 2, 5); - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); // Because Mojang removed the block entity rotation methods, we need to ensure // that the spreader is pointed at the mana void properly, in case the test diff --git a/Xplat/src/main/java/vazkii/botania/test/item/AstrolabeTest.java b/Xplat/src/main/java/vazkii/botania/test/item/AstrolabeTest.java index a18bce421c..cca4d28139 100644 --- a/Xplat/src/main/java/vazkii/botania/test/item/AstrolabeTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/item/AstrolabeTest.java @@ -10,6 +10,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.CandleBlock; @@ -379,7 +380,7 @@ private void checkRemainingMana(Player player, int expectedMana) { @NotNull private Player mockPlayerWithAstrolabe(final GameTestHelper helper, Vec3 posPlayer, final Vec3 lookTarget, int mana) { - final Player player = helper.makeMockPlayer(); + final Player player = helper.makeMockPlayer(GameType.CREATIVE); player.setItemInHand(InteractionHand.MAIN_HAND, new ItemStack(BotaniaItems.astrolabe)); final ItemStack tablet = new ItemStack(BotaniaItems.manaTablet); Objects.requireNonNull(XplatAbstractions.INSTANCE.findManaItem(tablet)).addMana(mana); diff --git a/Xplat/src/main/java/vazkii/botania/test/item/CacophoniumTest.java b/Xplat/src/main/java/vazkii/botania/test/item/CacophoniumTest.java index 140d1b53d5..1712b84334 100644 --- a/Xplat/src/main/java/vazkii/botania/test/item/CacophoniumTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/item/CacophoniumTest.java @@ -18,6 +18,7 @@ import net.minecraft.world.entity.animal.Cow; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.properties.BlockStateProperties; @@ -36,7 +37,7 @@ public void testCacophonium(GameTestHelper helper) { BlockPos noteBlockPos = new BlockPos(1, 2, 3); helper.assertBlockPresent(Blocks.NOTE_BLOCK, noteBlockPos); - Player player = helper.makeMockPlayer(); + Player player = helper.makeMockPlayer(GameType.CREATIVE); Cow cow = helper.spawnWithNoFreeWill(EntityType.COW, cowPos); //Give a cacophonium to the player. diff --git a/Xplat/src/main/java/vazkii/botania/test/item/FlowerPouchTest.java b/Xplat/src/main/java/vazkii/botania/test/item/FlowerPouchTest.java index cda95a1ec2..9be0268856 100644 --- a/Xplat/src/main/java/vazkii/botania/test/item/FlowerPouchTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/item/FlowerPouchTest.java @@ -5,6 +5,7 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.GameType; import vazkii.botania.common.block.BotaniaBlocks; import vazkii.botania.common.item.BotaniaItems; @@ -14,7 +15,7 @@ public class FlowerPouchTest { @GameTest(template = TestingUtil.EMPTY_STRUCTURE) public void testNoShinyFlowers(GameTestHelper helper) { - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); var bag = new ItemStack(BotaniaItems.flowerBag); player.getInventory().setItem(1, bag); @@ -33,7 +34,7 @@ public void testNoShinyFlowers(GameTestHelper helper) { @GameTest(template = TestingUtil.EMPTY_STRUCTURE) public void testPickupBasic(GameTestHelper helper) { - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); var bag = new ItemStack(BotaniaItems.flowerBag); player.getInventory().setItem(1, bag); diff --git a/Xplat/src/main/java/vazkii/botania/test/item/LifeAggregatorTest.java b/Xplat/src/main/java/vazkii/botania/test/item/LifeAggregatorTest.java index 0329e3216b..3fc1d43ed3 100644 --- a/Xplat/src/main/java/vazkii/botania/test/item/LifeAggregatorTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/item/LifeAggregatorTest.java @@ -10,6 +10,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.SpawnerBlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -24,7 +25,7 @@ public class LifeAggregatorTest { @GameTest(template = TestingUtil.EMPTY_STRUCTURE) public void testSpawnerMover(GameTestHelper helper) { var spawnerPos = BlockPos.ZERO; - var player = helper.makeMockPlayer(); + var player = helper.makeMockPlayer(GameType.CREATIVE); var stack = new ItemStack(BotaniaItems.spawnerMover); helper.setBlock(spawnerPos, Blocks.SPAWNER); diff --git a/Xplat/src/main/java/vazkii/botania/test/item/SpectatorScanTest.java b/Xplat/src/main/java/vazkii/botania/test/item/SpectatorScanTest.java index 692f2c5753..845c880b2a 100644 --- a/Xplat/src/main/java/vazkii/botania/test/item/SpectatorScanTest.java +++ b/Xplat/src/main/java/vazkii/botania/test/item/SpectatorScanTest.java @@ -13,6 +13,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.phys.Vec3; @@ -97,7 +98,7 @@ private static void performTest(GameTestHelper helper, BiConsumer(Lnet/minecr public net.minecraft.world.item.crafting.Ingredient$TagValue (Lnet/minecraft/tags/TagKey;)V public net.minecraft.client.renderer.RenderType$CompositeRenderType public net.minecraft.client.renderer.RenderType$CompositeState -# TODO probably not needed anymore, since AbstractMinecart declares it as protected -#public net.minecraft.world.entity.vehicle.VehicleEntity getDropItem()Lnet/minecraft/world/item/Item; -public net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator +protected net.minecraft.world.entity.vehicle.VehicleEntity getDropItem()Lnet/minecraft/world/item/Item; +public-f net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator