First pass on 1.17.1 update. 13 errors left

This commit is contained in:
drcrazy 2021-07-20 03:38:43 +03:00
parent 3edf36e0ef
commit 08a2cdb081
24 changed files with 69 additions and 67 deletions

View file

@ -108,8 +108,8 @@ public class StackToolTipHandler implements ItemTooltipCallback {
if ((block instanceof BaseBlockEntityProvider)) {
BlockEntity blockEntity = ((BlockEntityProvider) block).createBlockEntity(BlockPos.ORIGIN, block.getDefaultState());
boolean hasData = false;
if (itemStack.hasTag() && itemStack.getOrCreateTag().contains("blockEntity_data")) {
NbtCompound blockEntityData = itemStack.getOrCreateTag().getCompound("blockEntity_data");
if (itemStack.hasNbt() && itemStack.getOrCreateNbt().contains("blockEntity_data")) {
NbtCompound blockEntityData = itemStack.getOrCreateNbt().getCompound("blockEntity_data");
if (blockEntity != null) {
blockEntity.readNbt(blockEntityData);
hasData = true;

View file

@ -282,7 +282,7 @@ public class GuiBase<T extends ScreenHandler> extends HandledScreen<T> {
for (Selectable selectable : accessorScreen.getSelectables()) {
if (selectable instanceof ClickableWidget clickable) {
if (clickable.isHovered()) {
clickable.renderToolTip(matrixStack, mouseX, mouseY);
clickable.renderTooltip(matrixStack, mouseX, mouseY);
break;
}
}

View file

@ -52,18 +52,19 @@ public abstract class BaseBlockEntityProvider extends Block implements BlockEnti
ItemStack newStack = stack.copy();
NbtCompound blockEntityData = blockEntity.writeNbt(new NbtCompound());
stripLocationData(blockEntityData);
if (!newStack.hasTag()) {
newStack.setTag(new NbtCompound());
if (!newStack.hasNbt()) {
newStack.setNbt(new NbtCompound());
}
newStack.getTag().put("blockEntity_data", blockEntityData);
newStack.getOrCreateNbt().put("blockEntity_data", blockEntityData);
return Optional.of(newStack);
}
@Override
public void onPlaced(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
if (stack.hasTag() && stack.getTag().contains("blockEntity_data")) {
if (stack.hasNbt() && stack.getOrCreateNbt().contains("blockEntity_data")) {
BlockEntity blockEntity = worldIn.getBlockEntity(pos);
NbtCompound nbt = stack.getTag().getCompound("blockEntity_data");
if (blockEntity == null) { return; }
NbtCompound nbt = stack.getOrCreateNbt().getCompound("blockEntity_data");
injectLocationData(nbt, pos);
blockEntity.readNbt(nbt);
blockEntity.markDirty();

View file

@ -120,8 +120,8 @@ public class RebornRecipe implements Recipe<Inventory>, CustomOutputRecipe {
if (stack.getCount() > 1) {
stackObject.addProperty("count", stack.getCount());
}
if (stack.hasTag()) {
stackObject.add("nbt", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, stack.getTag()));
if (stack.hasNbt()) {
stackObject.add("nbt", Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, stack.getNbt()));
}
resultsArray.add(stackObject);
}

View file

@ -74,7 +74,7 @@ public class RecipeUtils {
ItemStack stack = new ItemStack(item, count);
if (jsonObject.has("nbt")) {
NbtCompound tag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonObject.get("nbt"));
stack.setTag(tag);
stack.setNbt(tag);
}
return stack;
}

View file

@ -102,14 +102,14 @@ public class StackIngredient extends RebornIngredient {
return false;
}
if (tag.isPresent()) {
if (!itemStack.hasTag()) {
if (!itemStack.hasNbt()) {
return false;
}
//Bit of a meme here, as DataFixer likes to use the most basic primative type over using an int.
//So we have to go to json and back on the incoming stack to be sure its using types that match our input.
NbtCompound compoundTag = itemStack.getTag();
NbtCompound compoundTag = itemStack.getNbt();
JsonElement jsonElement = Dynamic.convert(NbtOps.INSTANCE, JsonOps.INSTANCE, compoundTag);
compoundTag = (NbtCompound) Dynamic.convert(JsonOps.INSTANCE, NbtOps.INSTANCE, jsonElement);
@ -117,7 +117,7 @@ public class StackIngredient extends RebornIngredient {
return false;
}
}
return !requireEmptyTag || !itemStack.hasTag();
return !requireEmptyTag || !itemStack.hasNbt();
}
@Override
@ -131,7 +131,7 @@ public class StackIngredient extends RebornIngredient {
stacks.stream()
.map(ItemStack::copy)
.peek(itemStack -> itemStack.setCount(count.orElse(1)))
.peek(itemStack -> itemStack.setTag(tag.orElse(null)))
.peek(itemStack -> itemStack.setNbt(tag.orElse(null)))
.collect(Collectors.toList()));
}

View file

@ -60,13 +60,13 @@ public class InventoryItem extends InventoryBase {
public NbtCompound getInvData() {
Validate.isTrue(!stack.isEmpty());
if (!stack.hasTag()) {
stack.setTag(new NbtCompound());
if (!stack.hasNbt()) {
stack.setNbt(new NbtCompound());
}
if (!stack.getTag().contains("inventory")) {
stack.getTag().put("inventory", new NbtCompound());
if (!stack.getNbt().contains("inventory")) {
stack.getNbt().put("inventory", new NbtCompound());
}
return stack.getTag().getCompound("inventory");
return stack.getNbt().getCompound("inventory");
}
public NbtCompound getSlotData(int slot) {

View file

@ -34,7 +34,7 @@ public class ItemNBTHelper {
* Checks if an ItemStack has a Tag Compound
**/
public static boolean detectNBT(ItemStack stack) {
return stack.hasTag();
return stack.hasNbt();
}
/**
@ -52,7 +52,7 @@ public class ItemNBTHelper {
* previously
**/
public static void injectNBT(ItemStack stack, NbtCompound nbt) {
stack.setTag(nbt);
stack.setNbt(nbt);
}
/**
@ -61,7 +61,7 @@ public class ItemNBTHelper {
**/
public static NbtCompound getNBT(ItemStack stack) {
initNBT(stack);
return stack.getTag();
return stack.getNbt();
}
// SETTERS

View file

@ -49,7 +49,7 @@ public class ItemUtils {
if (a.getItem() != b.getItem()) {
return false;
}
return !matchNBT || ItemStack.areTagsEqual(a, b);
return !matchNBT || ItemStack.areNbtEqual(a, b);
}
public static boolean isItemEqual(ItemStack a, ItemStack b, boolean matchNBT,
@ -121,7 +121,7 @@ public class ItemUtils {
* @return True if powered item is active
*/
public static boolean isActive(ItemStack stack) {
return !stack.isEmpty() && stack.getTag() != null && stack.getTag().getBoolean("isActive");
return !stack.isEmpty() && stack.getNbt() != null && stack.getNbt().getBoolean("isActive");
}
/**
@ -149,7 +149,7 @@ public class ItemUtils {
)
);
}
stack.getOrCreateTag().putBoolean("isActive", false);
stack.getOrCreateNbt().putBoolean("isActive", false);
}
/**
@ -164,7 +164,7 @@ public class ItemUtils {
ItemUtils.checkActive(stack, cost, isClient, messageId);
if (!ItemUtils.isActive(stack)) {
stack.getOrCreateTag().putBoolean("isActive", true);
stack.getOrCreateNbt().putBoolean("isActive", true);
if (isClient) {
@ -178,7 +178,7 @@ public class ItemUtils {
);
}
} else {
stack.getOrCreateTag().putBoolean("isActive", false);
stack.getOrCreateNbt().putBoolean("isActive", false);
if (isClient) {
ChatUtils.sendNoSpamMessages(messageId, new TranslatableText("reborncore.message.setTo")
.formatted(Formatting.GRAY)

View file

@ -68,8 +68,8 @@ public class WorldUtils {
ItemEntity entityItem = new ItemEntity(world, pos.getX() + dX, pos.getY() + dY, pos.getZ() + dZ,
itemStack.copy());
if (itemStack.hasTag()) {
entityItem.getStack().setTag(itemStack.getTag().copy());
if (itemStack.hasNbt()) {
entityItem.getStack().setNbt(itemStack.getNbt().copy());
}
float factor = 0.05F;

View file

@ -70,7 +70,7 @@ public class ItemStackSerializer implements JsonSerializer<ItemStack>, JsonDeser
if (name != null && Registry.ITEM.get(new Identifier(name)) != null) {
ItemStack itemStack = new ItemStack(Registry.ITEM.get(new Identifier(name)), stackSize);
itemStack.setTag(tagCompound);
itemStack.setNbt(tagCompound);
return itemStack;
}
}
@ -92,8 +92,8 @@ public class ItemStackSerializer implements JsonSerializer<ItemStack>, JsonDeser
jsonObject.addProperty(STACK_SIZE, src.getCount());
if (src.getTag() != null) {
jsonObject.addProperty(TAG_COMPOUND, src.getTag().toString());
if (src.getNbt() != null) {
jsonObject.addProperty(TAG_COMPOUND, src.getNbt().toString());
}
return jsonObject;

View file

@ -88,12 +88,12 @@ allprojects {
// Shared deps between TR and RC
dependencies {
minecraft "com.mojang:minecraft:1.17"
mappings "net.fabricmc:yarn:1.17+build.6:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.3"
minecraft "com.mojang:minecraft:1.17.1"
mappings "net.fabricmc:yarn:1.17.1+build.23:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.6"
//Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.34.10+1.17"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.37.0+1.17"
include(modApi('teamreborn:energy:0.1.1'))
}

View file

@ -205,8 +205,9 @@ public class TechRebornClient implements ClientModInitializer {
FrequencyTransmitterItem.class,
new Identifier("techreborn:coords"),
(item, stack, world, entity, seed) -> {
if (!stack.isEmpty() && stack.hasTag() && stack.getTag() != null && stack.getTag().contains("x")
&& stack.getTag().contains("y") && stack.getTag().contains("z") && stack.getTag().contains("dim")) {
if (!stack.isEmpty() && stack.hasNbt() && stack.getOrCreateNbt().contains("x")
&& stack.getOrCreateNbt().contains("y") && stack.getOrCreateNbt().contains("z")
&& stack.getOrCreateNbt().contains("dim")) {
return 1.0F;
}
return 0.0F;

View file

@ -82,8 +82,8 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
NbtCompound blockEntity = new NbtCompound();
ItemStack dropStack = TRContent.Machine.ADJUSTABLE_SU.getStack();
writeNbt(blockEntity);
dropStack.setTag(new NbtCompound());
dropStack.getOrCreateTag().put("blockEntity", blockEntity);
dropStack.setNbt(new NbtCompound());
dropStack.getOrCreateNbt().put("blockEntity", blockEntity);
return dropStack;
}

View file

@ -80,8 +80,8 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
ItemStack dropStack = new ItemStack(getBlockType(), 1);
final NbtCompound blockEntity = new NbtCompound();
this.writeNbt(blockEntity);
dropStack.setTag(new NbtCompound());
dropStack.getOrCreateTag().put("blockEntity", blockEntity);
dropStack.setNbt(new NbtCompound());
dropStack.getOrCreateNbt().put("blockEntity", blockEntity);
return dropStack;
}

View file

@ -411,8 +411,8 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
final NbtCompound blockEntity = new NbtCompound();
this.writeNbt(blockEntity);
dropStack.setTag(new NbtCompound());
dropStack.getOrCreateTag().put("blockEntity", blockEntity);
dropStack.setNbt(new NbtCompound());
dropStack.getOrCreateNbt().put("blockEntity", blockEntity);
return dropStack;
}

View file

@ -64,7 +64,7 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
addSelectableChild(new GuiButtonSimple(getGuiLeft() + 116, getGuiTop() + 57, 18, 18, LiteralText.EMPTY, b -> onClick()) {
@Override
public void renderToolTip(MatrixStack matrixStack, int mouseX, int mouseY) {
public void renderTooltip(MatrixStack matrixStack, int mouseX, int mouseY) {
PlayerEntity player = MinecraftClient.getInstance().player;
String message = "Experience: ";

View file

@ -74,7 +74,7 @@ public class TRDispenserBehavior {
public ItemStack dispenseSilently(BlockPointer pointer, ItemStack stack) {
DynamicCellItem cell = (DynamicCellItem) stack.getItem();
WorldAccess iWorld = pointer.getWorld();
BlockPos blockPos = pointer.getBlockPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
BlockPos blockPos = pointer.getPos().offset(pointer.getBlockState().get(DispenserBlock.FACING));
BlockState blockState = iWorld.getBlockState(blockPos);
Block block = blockState.getBlock();
if (cell.getFluid(stack) == Fluids.EMPTY) {

View file

@ -231,7 +231,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
@Override
public Fluid getFluid(ItemStack itemStack) {
NbtCompound tag = itemStack.getTag();
NbtCompound tag = itemStack.getNbt();
if (tag != null && tag.contains("fluid")) {
return Registry.FLUID.get(new Identifier(tag.getString("fluid")));
}

View file

@ -64,7 +64,7 @@ public class FrequencyTransmitterItem extends Item {
GlobalPos globalPos = GlobalPos.create(ChunkLoaderManager.getDimensionRegistryKey(world), pos);
GlobalPos.CODEC.encodeStart(NbtOps.INSTANCE, globalPos).result()
.ifPresent(tag -> stack.getOrCreateTag().put("pos", tag));
.ifPresent(tag -> stack.getOrCreateNbt().put("pos", tag));
if (!world.isClient) {
@ -84,10 +84,10 @@ public class FrequencyTransmitterItem extends Item {
}
public static Optional<GlobalPos> getPos(ItemStack stack) {
if (!stack.hasTag() || !stack.getOrCreateTag().contains("pos")) {
if (!stack.hasNbt() || !stack.getOrCreateNbt().contains("pos")) {
return Optional.empty();
}
return GlobalPos.CODEC.parse(NbtOps.INSTANCE, stack.getOrCreateTag().getCompound("pos")).result();
return GlobalPos.CODEC.parse(NbtOps.INSTANCE, stack.getOrCreateNbt().getCompound("pos")).result();
}
@Override
@ -95,7 +95,7 @@ public class FrequencyTransmitterItem extends Item {
Hand hand) {
ItemStack stack = player.getStackInHand(hand);
if (player.isSneaking()) {
stack.setTag(null);
stack.setNbt(null);
if (!world.isClient) {
ChatUtils.sendNoSpamMessages(MessageIDs.freqTransmitterID,

View file

@ -64,7 +64,7 @@ public class PaintingToolItem extends Item {
if (player.isSneaking()) {
if (blockState.isOpaqueFullCube(context.getWorld(), context.getBlockPos())
&& blockState.getBlock().getDefaultState().isOpaqueFullCube(context.getWorld(), context.getBlockPos())) {
context.getStack().getOrCreateTag().put("cover", NbtHelper.fromBlockState(blockState));
context.getStack().getOrCreateNbt().put("cover", NbtHelper.fromBlockState(blockState));
return ActionResult.SUCCESS;
}
return ActionResult.FAIL;
@ -90,8 +90,8 @@ public class PaintingToolItem extends Item {
}
public static BlockState getCover(ItemStack stack) {
if (stack.hasTag() && stack.getTag().contains("cover")) {
return NbtHelper.toBlockState(stack.getTag().getCompound("cover"));
if (stack.hasNbt() && stack.getOrCreateNbt().contains("cover")) {
return NbtHelper.toBlockState(stack.getOrCreateNbt().getCompound("cover"));
}
return null;
}

View file

@ -67,16 +67,16 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
ItemUtils.checkActive(stack, cost, isClient, messageId);
if (!ItemUtils.isActive(stack)) {
ItemUtils.switchActive(stack, cost, isClient, messageId);
stack.getOrCreateTag().putBoolean("AOE5", false);
stack.getOrCreateNbt().putBoolean("AOE5", false);
if (isClient) {
ChatUtils.sendNoSpamMessages(messageId, new TranslatableText("techreborn.message.setTo").formatted(Formatting.GRAY).append(" ").append(new LiteralText("3*3").formatted(Formatting.GOLD)));
}
} else {
if (isAOE5(stack)) {
ItemUtils.switchActive(stack, cost, isClient, messageId);
stack.getOrCreateTag().putBoolean("AOE5", false);
stack.getOrCreateNbt().putBoolean("AOE5", false);
} else {
stack.getOrCreateTag().putBoolean("AOE5", true);
stack.getOrCreateNbt().putBoolean("AOE5", true);
if (isClient) {
ChatUtils.sendNoSpamMessages(messageId, new TranslatableText("techreborn.message.setTo").formatted(Formatting.GRAY).append(" ").append(new LiteralText("5*5").formatted(Formatting.GOLD)));
}
@ -98,7 +98,7 @@ public class IndustrialJackhammerItem extends JackhammerItem implements MultiBlo
}
private boolean isAOE5(ItemStack stack) {
return !stack.isEmpty() && stack.getTag() != null && stack.getTag().getBoolean("AOE5");
return !stack.isEmpty() && stack.getOrCreateNbt().getBoolean("AOE5");
}
// JackhammerItem

View file

@ -114,17 +114,17 @@ public class NanosaberItem extends SwordItem implements EnergyHolder, ItemDurabi
return;
}
ItemStack inactiveUncharged = new ItemStack(this);
inactiveUncharged.setTag(new NbtCompound());
inactiveUncharged.getOrCreateTag().putBoolean("isActive", false);
inactiveUncharged.setNbt(new NbtCompound());
inactiveUncharged.getOrCreateNbt().putBoolean("isActive", false);
ItemStack inactiveCharged = new ItemStack(TRContent.NANOSABER);
inactiveCharged.setTag(new NbtCompound());
inactiveCharged.getOrCreateTag().putBoolean("isActive", false);
inactiveCharged.setNbt(new NbtCompound());
inactiveCharged.getOrCreateNbt().putBoolean("isActive", false);
Energy.of(inactiveCharged).set(Energy.of(inactiveCharged).getMaxStored());
ItemStack activeCharged = new ItemStack(TRContent.NANOSABER);
activeCharged.setTag(new NbtCompound());
activeCharged.getOrCreateTag().putBoolean("isActive", true);
activeCharged.setNbt(new NbtCompound());
activeCharged.getOrCreateNbt().putBoolean("isActive", true);
Energy.of(activeCharged).set(Energy.of(activeCharged).getMaxStored());
itemList.add(inactiveUncharged);

View file

@ -33,8 +33,8 @@
]
},
"depends": {
"fabricloader": ">=0.11.3",
"fabric": ">=0.34.10",
"fabricloader": ">=0.11.6",
"fabric": ">=0.37.0",
"reborncore": "*",
"team_reborn_energy": ">=0.1.1",
"fabric-biome-api-v1": ">=3.0.0"