Skip to content

Commit

Permalink
Fixing various Xplat errors not related to item components
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealWormbo committed Jan 19, 2025
1 parent bd7d8ee commit 156b62b
Show file tree
Hide file tree
Showing 241 changed files with 1,516 additions and 1,264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
52 changes: 6 additions & 46 deletions Xplat/src/main/java/vazkii/botania/api/BotaniaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -98,49 +100,7 @@ default void registerPaintableBlock(ResourceLocation blockId, Function<DyeColor,

}

ArmorMaterial DUMMY_ARMOR_MATERIAL = new ArmorMaterial() {
@Override
public int getDurabilityForType(@NotNull ArmorItem.Type type) {
return 0;
}

@Override
public int getDefenseForType(@NotNull ArmorItem.Type type) {
return 0;
}

@Override
public int getEnchantmentValue() {
return 0;
}

@NotNull
@Override
public SoundEvent getEquipSound() {
return SoundEvents.ARMOR_EQUIP_LEATHER;
}

@NotNull
@Override
public Ingredient getRepairIngredient() {
return Ingredient.EMPTY;
}

@Override
public String getName() {
return "missingno";
}

@Override
public float getToughness() {
return 0;
}

@Override
public float getKnockbackResistance() {
return 0;
}
};
ArmorMaterial DUMMY_ARMOR_MATERIAL = new ArmorMaterial(Map.of(), 0, SoundEvents.ARMOR_EQUIP_LEATHER, () -> Ingredient.EMPTY, List.of(), 0, 0);

Tier DUMMY_ITEM_TIER = new Tier() {
@Override
Expand All @@ -159,8 +119,8 @@ public float getAttackDamageBonus() {
}

@Override
public int getLevel() {
return 0;
public TagKey<Block> getIncorrectBlocksForDrops() {
return BlockTags.INCORRECT_FOR_WOODEN_TOOL;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Registry<Brew>> BREWS =
ResourceKey.createRegistryKey(botaniaRL("brews"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion Xplat/src/main/java/vazkii/botania/api/block/Wandable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -151,17 +152,17 @@ 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));
}
}

@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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand All @@ -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());
}
Expand All @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Loading

0 comments on commit 156b62b

Please sign in to comment.